Permalink
Browse files

Fixed dependencies and made views location configurable.

  • Loading branch information...
mraible committed Feb 9, 2012
1 parent c90b41f commit af390f1d8029ebf9e406feb886507c98823dbe92
Showing with 11 additions and 13 deletions.
  1. +1 −4 conf/dependencies.yml
  2. +10 −9 src/play/modules/scalate/ScalateTemplate.scala
View
@@ -1,4 +1,4 @@
-self: play -> scalate 0.2.5
+self: play -> scalate 0.2.1
require:
- play
@@ -8,7 +8,4 @@ require:
- javax.servlet -> *
- com.sun.jersey -> *
- org.osgi -> *
- - org.scala-lang -> *
- org.fusesource.scalate -> scalate-util 1.5.3-scala_2.8.2:
- exclude:
- - org.scala-lang -> *
@@ -14,17 +14,18 @@ object ScalateTemplate {
import org.fusesource.scalate.util._
import org.fusesource.scalate.layout._
- val scalateType = "." + Play.configuration.get("scalate")
-
+ val scalateFormat = "." + Play.configuration.get("scalate.format")
+ val viewsPath = "." + Play.configuration.get("scalate.path")
+
lazy val scalateEngine = {
val engine = new TemplateEngine
- engine.resourceLoader = new FileResourceLoader(Some(Play.getFile("/app/pages")))
+ engine.resourceLoader = new FileResourceLoader(Some(Play.getFile(viewsPath)))
engine.classpath = Play.getFile("/tmp/classes").getAbsolutePath
engine.workingDirectory = Play.getFile("tmp")
engine.combinedClassPath = true
engine.classLoader = Play.classloader
engine.layoutStrategy = new DefaultLayoutStrategy(engine,
- Play.getFile("/app/pages/layouts/default" + scalateType).getAbsolutePath)
+ Play.getFile(viewsPath + "/layouts/default" + scalateFormat).getAbsolutePath)
engine.bindings = List(
Binding("context", SourceCodeHelper.name(classOf[DefaultRenderContext]), true)
@@ -43,9 +44,9 @@ object ScalateTemplate {
try {
val baseName = name.replaceAll(".html","") // for when Template() is used instead of render
- val templatePath = new File(Play.applicationPath+"/app/pages","/"+baseName).toString
- .replace(new File(Play.applicationPath+"/app/pages").toString,"")
- scalateEngine.layout(templatePath + scalateType, argsMap)
+ val templatePath = new File(Play.applicationPath + viewsPath,"/"+baseName).toString
+ .replace(new File(Play.applicationPath + viewsPath).toString,"")
+ scalateEngine.layout(templatePath + scalateFormat, argsMap)
} catch {
case ex:TemplateNotFoundException => {
if(ex.isSourceAvailable) {
@@ -107,8 +108,8 @@ object ScalateTemplate {
}
private def errorTemplate:String = {
- val fullPath = new File(Play.applicationPath,"/app/pages/errors/500.scaml").toString
- fullPath.replace(new File(Play.applicationPath+"/app/pages").toString,"")
+ val fullPath = new File(Play.applicationPath, viewsPath + "/errors/500.scaml").toString
+ fullPath.replace(new File(Play.applicationPath + viewsPath).toString,"")
}
// --- ROUTERS
def action(action: => Any) = {

0 comments on commit af390f1

Please sign in to comment.