Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update lift-scalate to use scalate 1.4.1. Closes #894

  • Loading branch information...
commit af1ede558ba9142a20e27942f85fd0b31b5385af 1 parent 3aba5c4
@indrajitr indrajitr authored
View
47 scalate/src/main/scala/net/liftweb/scalate/LiftTemplateEngine.scala
@@ -1,22 +1,39 @@
-package net.liftweb.scalate
+/*
+ * Copyright 2010-2011 WorldWide Conferencing, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.liftweb
+package scalate
import java.io.File
+
import tools.nsc.Global
+
import org.fusesource.scalate.layout.DefaultLayoutStrategy
-import org.fusesource.scalate.util.ClassPathBuilder
-import org.fusesource.scalate.support.FileResourceLoader
-import net.liftweb.http.LiftRules
+import org.fusesource.scalate.util.{ClassPathBuilder, FileResourceLoader}
import org.fusesource.scalate.{DefaultRenderContext, ResourceNotFoundException, Binding, TemplateEngine}
-import net.liftweb.http.provider.servlet.HTTPServletContext
-import net.liftweb.common.Logger
+
+import common._
+import http.LiftRules
+import http.provider.servlet.HTTPServletContext
+
/**
- * A TemplateEngine using the Lift web abstractions
- *
- * @version $Revision : 1.1 $
+ * A TemplateEngine using the Lift web abstractions.
*/
-
-class LiftTemplateEngine extends TemplateEngine {
+class LiftTemplateEngine extends TemplateEngine with Loggable {
bindings = List(Binding("context", classOf[DefaultRenderContext].getName, true, isImplicit = true))
if (useWebInfWorkingDirectory) {
@@ -56,7 +73,7 @@ class LiftTemplateEngine extends TemplateEngine {
def realPath(uri: String): String = {
LiftRules.context match {
case http: HTTPServletContext => http.ctx.getRealPath(uri)
- case c => warn("Do not know how to get the real path of: " + uri + " for context: " + c); uri
+ case c => logger.warn("Do not know how to get the real path of: " + uri + " for context: " + c); uri
}
}
@@ -65,7 +82,7 @@ class LiftTemplateEngine extends TemplateEngine {
realFile(uri)
}
- override protected def toFileOrFail(uri: String): File = {
+ protected def toFileOrFail(uri: String): File = {
val file = realFile(uri)
if (file == null) {
throw new ResourceNotFoundException(resource = uri, root = context.realPath("/"))
@@ -96,12 +113,12 @@ class LiftTemplateEngine extends TemplateEngine {
}
*/
val path = context.realPath(uri)
- debug("realPath for: " + uri + " is: " + path)
+ logger.debug("realPath for: " + uri + " is: " + path)
var answer: File = null
if (path != null) {
val file = new File(path)
- debug("file from realPath for: " + uri + " is: " + file)
+ logger.debug("file from realPath for: " + uri + " is: " + file)
if (file.canRead) {answer = file}
}
answer
View
37 scalate/src/main/scala/net/liftweb/scalate/ScalateView.scala
@@ -1,15 +1,32 @@
-package net.liftweb.scalate
+/*
+ * Copyright 2010-2011 WorldWide Conferencing, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.liftweb
+package scalate
-import _root_.net.liftweb.common._
-import _root_.net.liftweb.util._
-import _root_.net.liftweb.http._
import xml.NodeSeq
+import common._
+import util._
+import http._
+
+
/**
* A {@link LiftView} which uses a <a href="http://scalate.fusesource.org/">Scalate</a>
* template engine to resolve a URI and render it as markup
- *
- * @version $Revision : 1.1 $
*/
class ScalateView(engine: LiftTemplateEngine = new LiftTemplateEngine()) extends LiftView with Logger {
@@ -37,10 +54,7 @@ class ScalateView(engine: LiftTemplateEngine = new LiftTemplateEngine()) extends
def dispatch: PartialFunction[String, () => Box[NodeSeq]] = {
case v if (canLoad(v)) =>
- () => {
- val template = engine.load(v)
- Full(engine.layoutAsNodes(template))
- }
+ () => Full(engine.layoutAsNodes(v))
}
@@ -64,8 +78,7 @@ class ScalateView(engine: LiftTemplateEngine = new LiftTemplateEngine()) extends
val uri: String = if (ext != "") createUri(path, ext) else {
List("scaml", "ssp").map(createUri(path, _)).find(engine.canLoad(_)).get
}
- val template = engine.load(uri)
- Full(TextResponse(engine.layout(template)))
+ Full(TextResponse(engine.layout(uri)))
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.