scala-news-reader
rss/atom news reader in scala
git clone https://9o.is/git/scala-news-reader.git
commit d7d1030a6dc9cfe7bb880b9d7c2f09beae264c97 parent 42d6570915ea5253b4c9658795254e1722b74bfe Author: Jul <jul@9o.is> Date: Sun, 4 Aug 2013 09:19:22 -0400 replaced google analytics with the module Diffstat:
| M | project/Build.scala | | | 3 | ++- |
| M | src/main/scala/bootstrap/liftweb/Boot.scala | | | 20 | ++++++++++++-------- |
| D | src/main/scala/com/joereader/config/GoogleAnalytics.scala | | | 26 | -------------------------- |
3 files changed, 14 insertions(+), 35 deletions(-)
diff --git a/project/Build.scala b/project/Build.scala @@ -22,7 +22,8 @@ object LiftProjectBuild extends Build { "org.jsoup" % "jsoup" % "1.7.2", "rome" % "rome" % "1.0", "org.rometools" % "rome-modules" % "1.0", - "com.typesafe.akka" %% "akka-actor" % "2.1.4" + "com.typesafe.akka" %% "akka-actor" % "2.1.4", + "net.liftmodules" %% "google-analytics" % (Ver.lift+"-1.0") ) ) } diff --git a/src/main/scala/bootstrap/liftweb/Boot.scala b/src/main/scala/bootstrap/liftweb/Boot.scala @@ -1,6 +1,6 @@ package bootstrap.liftweb -import scala.xml.{Null, UnprefixedAttribute} +import scala.xml.{ Null, UnprefixedAttribute } import javax.mail.internet.MimeMessage import net.liftweb._ @@ -10,9 +10,11 @@ import util._ import util.Helpers._ import com.joereader.config._ -import com.joereader.model.{SystemUser, User} +import com.joereader.model.{ SystemUser, User } -import net.liftmodules.extras.{Gravatar, LiftExtras} +import bootstrap.liftmodules._ +import GoogleAnalytics.dsl._ +import net.liftmodules.extras.{ Gravatar, LiftExtras } import net.liftmodules.mongoauth.MongoAuth import net.liftweb.http.SHtml.ChoiceHolder import net.liftweb.sitemap.SiteMap @@ -24,7 +26,7 @@ import net.liftweb.http.js.jquery.JqJsCmds.FadeIn */ class Boot extends Loggable { def boot() { - logger.info("Run Mode: "+Props.mode.toString) + logger.info("Run Mode: " + Props.mode.toString) // init mongodb MongoConfig.init() @@ -49,7 +51,9 @@ class Boot extends Loggable { LiftRules.addToPackages("com.joereader") // Google analytics - if(Props.productionMode) GoogleAnalytics.init + GoogleAnalytics.init { + only when Props.productionMode + } // set the default htmlProperties LiftRules.htmlProperties.default.set((r: Req) => @@ -87,11 +91,11 @@ class Boot extends Loggable { (session: LiftSession) => false) // Twitter Bootstrap css fix radio inputs by surrounding with label - ChoiceHolder.htmlize = ci => evalElemWithId((id,e) => - <label for={id}>{e} {ci.key.toString}</label>)(ci.xhtml) + ChoiceHolder.htmlize = ci => evalElemWithId((id, e) => + <label for={ id }>{ e } { ci.key.toString }</label>)(ci.xhtml) // API LiftRules.dispatch.append(com.joereader.lib.ImageUpload) LiftRules.statelessDispatch.append(com.joereader.snippet.Sitemap) -} + } } diff --git a/src/main/scala/com/joereader/config/GoogleAnalytics.scala b/src/main/scala/com/joereader/config/GoogleAnalytics.scala @@ -1,26 +0,0 @@ -package com.joereader.config - -import scala.xml.Unparsed -import net.liftweb.util.Props -import net.liftweb.http._ - -object GoogleAnalytics { - - def init: Unit = Props.get("google.analytics.id") map headJs foreach { js => - def addTracking(s: LiftSession, r: Req): Unit = S.putInHead(js) - LiftSession.onBeginServicing = addTracking _ :: LiftSession.onBeginServicing - } - - def headJs(id: String) = <script type="text/javascript"> - var _gaq = _gaq || []; - _gaq.push(['_setAccount', '{Unparsed(id)}']); - _gaq.push(['_trackPageview']); - (function() {{ - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(ga, s); - }})(); - </script> - -}