Permalink
Browse files

Major code cleanup for v0.5.

Bumped Liftweb to 2.4.
Bumped sbt 0.11.2.
Removed useless code.
Fixed some ajaxCalls (code cleanup).
Updated License in Headers for vim code-folding. (i hated to scroll)
Removed the "/admin/<slug>" nonsense.
Publish-buttons in admin are now fixed. (only publishAt will change it)
PublishAt will be replied parsed from the server. (no mistakes there anymore)
  • Loading branch information...
1 parent e954748 commit a61b36d0f388c27e09afae5cce46e499c3268965 @fbettag committed Jan 21, 2012
View
@@ -1,16 +1,26 @@
name := "println"
-
+
+organization := "ag.bett.lift"
+
+version := "0.5"
+
scalaVersion := "2.9.1"
seq(webSettings: _*)
+port in container.Configuration := 8081
+
+//scalacOptions ++= Seq("-deprecation")
+scalacOptions ++= Seq("-unchecked", "-deprecation")
+
// If using JRebel with 0.1.0 of the sbt web plugin
//jettyScanDirs := Nil
// using 0.2.4+ of the sbt web plugin
scanDirectories in Compile := Nil
resolvers ++= Seq(
"Repo Maven" at "http://repo1.maven.org/maven2/",
+ "Repo Maven" at "http://repo2.maven.org/maven2/",
"Scala Tools Snapshot" at "http://scala-tools.org/repo-releases/",
"Scala Tools Snapshot" at "http://scala-tools.org/repo-snapshots/",
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/",
@@ -21,7 +31,7 @@ resolvers ++= Seq(
//checksums := Nil
libraryDependencies ++= {
- val liftVersion = "2.4-M4"
+ val liftVersion = "2.4"
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
@@ -31,8 +41,8 @@ libraryDependencies ++= {
}
libraryDependencies ++= Seq(
- "org.postgresql" % "postgresql" % "9.1-901.jdbc4",
- "com.foursquare" %% "rogue" % "1.0.27" intransitive(),
+ "postgresql" % "postgresql" % "9.1-901-1.jdbc4",
+ "com.foursquare" %% "rogue" % "1.1.0" intransitive(),
"com.github.scala-incubator.io" %% "scala-io-core" % "0.2.0",
"com.github.scala-incubator.io" %% "scala-io-file" % "0.2.0"
)
View
@@ -1,3 +1,3 @@
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
-libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.8"))
+libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))
View
@@ -1,7 +1,8 @@
#!/bin/sh
# Internal options, always specified
-INTERNAL_OPTS="-Dfile.encoding=UTF-8 -Xss8M -Xmx1G -XX:MaxPermSize=768M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -noverify -javaagent:/usr/jrebel/jrebel.jar -Drebel.lift_plugin=true"
+INTERNAL_OPTS="-Dfile.encoding=UTF-8 -Xss8M -Xmx1G -XX:MaxPermSize=768M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -noverify"
+#INTERNAL_OPTS="-Dfile.encoding=UTF-8 -Xss8M -Xmx1G -XX:MaxPermSize=768M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -noverify -javaagent:/usr/jrebel/jrebel.jar -Drebel.lift_plugin=true"
# Default options, if nothing is specified
DEFAULT_OPTS="-Dsbt.intransitive=true"
View
Binary file not shown.
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package bootstrap.liftweb
@@ -131,7 +131,7 @@ class Boot {
def renderTemplate(what: String) =
- S.render(<lift:embed what={what} />, S.request.get.request).first
+ S.render(<lift:embed what={what} />, S.request.get.request).head
def normalizeURI(a: String) = a.replaceAll("(\\.[xht]+ml)?(\\?.*)?$", "")
@@ -152,7 +152,6 @@ class Boot {
LiftRules.statelessTest.append {
case "users" :: "login" :: Nil => false
- case "admin" :: _ => false
}
LiftRules.passNotFoundToChain = false
@@ -171,9 +170,6 @@ class Boot {
case _ if (req.uri.matches("/sitemap(\\.xml)?")) =>
NotFoundAsResponse(cacheResponse(req, XmlResponse(renderTemplate("sitemap"), 200, "application/xml; charset=utf-8")))
- case _ if (req.uri.matches("^(/admin)?/tag/.+$") && Tag.findAll(By(Tag.slug, req.uri.replaceFirst("^(/admin)?/tag/", ""))).length != 0) =>
- NotFoundAsResponse(cacheResponse(req, XhtmlTemplateResponse(ParsePath("tag" :: Nil, "html", false, false), 200)))
-
case _ if (Post.one(req.uri) != Empty) =>
NotFoundAsResponse(cacheResponse(req, XhtmlTemplateResponse(ParsePath("post" :: Nil, "html", false, false), 200)))
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.comet
@@ -43,7 +43,7 @@ import code.model._
case class GetResponse(req: Req, uri: String)
case class StoreResponse(req: Req, uri: String, resp: LiftResponse)
-case class CleanupCache
+case object CleanupCache
case class CachedReply(resp: LiftResponse, updated: DateTime)
@@ -52,7 +52,7 @@ object CacheActor extends LiftActor {
var responses: Map[String, CachedReply] = Map()
- ActorPing.schedule(this, CleanupCache, 1 minute)
+ Schedule.schedule(this, CleanupCache, 1 minute)
protected def messageHandler = {
case StoreResponse(req: Req, uri: String, resp: LiftResponse) =>
@@ -69,7 +69,7 @@ object CacheActor extends LiftActor {
val cleanDate = (new DateTime).minusMinutes(1)
responses = responses.filter(_._2.updated.isAfter(cleanDate))
- ActorPing.schedule(this, CleanupCache, 1 minute)
+ Schedule.schedule(this, CleanupCache, 1 minute)
}
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.lib
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.lib
@@ -101,7 +101,7 @@ object DateTimeHelpers {
if (p.publishDate.is.before(new Date))
<xml:group>Published on <time datetime={pubDateISO} pubdate="pubdate">{pubDate}</time></xml:group>
else
- <xml:group>>Will be published on <time datetime={pubDateISO} pubdate="pubdate">{pubDate}</time></xml:group>
+ <xml:group>Will be published on <time datetime={pubDateISO} pubdate="pubdate">{pubDate}</time></xml:group>
}
else <xml:group>This Post is not published yet.</xml:group>
@@ -185,11 +185,8 @@ trait JsEffects[A <: Mapper[A]] {
if (this.delete_!) RedirectTo("/") //JsFx.remove(selector)
else JsFx.failed(selector)
- private def deleteJs(selector: String): JsCmd = {
- val handler = (SHtml.ajaxButton("delete", () => this.delete_!!(selector)) \\ "@onclick").toString.replaceAll("&quot;", "'").replaceAll("return false;+$", "")
- println("-----------------------\n%s\n%s\n-------------------".format(handler, JsRaw(handler).cmd))
- JsRaw(handler).cmd
- }
+ private def deleteJs(selector: String): JsCmd =
+ SHtml.ajaxInvoke(() => this.delete_!!(selector))._2
def deleteWithJsFeedback(selector: String, name: String): JsCmd =
Confirm("Permanently delete '%s'?".format(name), deleteJs(selector))
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.model
@@ -70,12 +70,14 @@ class Tag extends LongKeyedMapper[Tag] with IdPK with ManyToMany {
def userPosts = {
val allposts = posts.all
- var unpublished = allposts.filter(f => f.publishDate.is == null)
- var published = allposts.filter(f => f.publishDate.is != null).sort((e1, e2) => (e1.publishDate.is compareTo e2.publishDate.is) > 0)
+ var published = allposts.filter(f => f.publishDate.is != null).sortWith((e1, e2) => (e1.publishDate.is compareTo e2.publishDate.is) > 0)
User.currentUser match {
- case Full(u: User) => unpublished ++ published
- case _ => published
+ case Full(u: User) =>
+ var unpublished = allposts.filter(f => f.publishDate.is == null)
+ unpublished ++ published
+ case _ =>
+ published
}
}
def publicPosts = userPosts.filter(p => ! (p.published && (p.publishDate compareTo new Date) > 0))
@@ -165,24 +167,23 @@ class Post extends LongKeyedMapper[Post] with IdPK with ManyToMany with JsEffect
object tags extends MappedManyToMany(PostTags, PostTags.post, PostTags.tag, Tag)
- def link = (if (User.loggedIn_?) "/admin" else "") + "/%s".format(slug)
+ def link = "/%s".format(slug)
def publish(a: Boolean) = {
- val d = if (!a) null else DateTimeHelpers.getDate.toDate
- this.published(a).publishDate(d).save
+ this.published(a).save
this
}
- def publishAt(d: String): Boolean = {
- try {
- val fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")
- val dt = fmt.parseDateTime(d)
- this.published(true).publishDate(dt.toDate).save
- this.saved_?
- }
- catch {
- case _ => false
- }
+ def publishAt(d: String): DateTime = try {
+ val fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")
+ val dt = fmt.parseDateTime(d)
+ this.published(true).publishDate(dt.toDate).save
+ dt
+ } catch {
+ case _ =>
+ val res = DateTimeHelpers.getDate
+ this.published(true).publishDate(res.toDate).save
+ res
}
def teaserText: NodeSeq =
@@ -241,7 +242,7 @@ object Post extends Post with LongKeyedMetaMapper[Post] {
}
def one(gNameOrId: String) = {
- val nameOrId = gNameOrId.replaceAll("^(/admin)?/", "")
+ val nameOrId = gNameOrId.replaceAll("^/", "")
User.currentUser match {
case Full(u: User) =>
Post.find(By(Post.slug, nameOrId)) match {
@@ -263,8 +264,8 @@ object Post extends Post with LongKeyedMetaMapper[Post] {
class PostTags extends LongKeyedMapper[PostTags] with IdPK {
def getSingleton = PostTags
- object post extends LongMappedMapper(this, Post)
- object tag extends LongMappedMapper(this, Tag)
+ object post extends MappedLongForeignKey(this, Post)
+ object tag extends MappedLongForeignKey(this, Tag)
}
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.model
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.model
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.snippet
@@ -1,4 +1,4 @@
-/*
+/** {{{
* Copyright (c) 2011, Franz Bettag <franz@bett.ag>
* All rights reserved.
*
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ */// }}}
package code.snippet
@@ -58,6 +58,7 @@ import code.model._
import code.lib._
+/* This will sort out of Stuff which slows pageloading for dynamic reasons (e.g. js). */
object SpeedTestAgent {
def apply(): Boolean = {
try {
Oops, something went wrong.

0 comments on commit a61b36d

Please sign in to comment.