mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-03 03:55:58 +01:00
(refs #464)Switch to play-twirl
This commit is contained in:
@@ -1 +1 @@
|
|||||||
sbt.version=0.13.1
|
sbt.version=0.13.5
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
import org.scalatra.sbt._
|
import org.scalatra.sbt._
|
||||||
import twirl.sbt.TwirlPlugin._
|
|
||||||
import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
|
import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
|
||||||
|
import play.twirl.sbt.SbtTwirl
|
||||||
|
import play.twirl.sbt.Import.TwirlKeys._
|
||||||
|
|
||||||
object MyBuild extends Build {
|
object MyBuild extends Build {
|
||||||
val Organization = "jp.sf.amateras"
|
val Organization = "jp.sf.amateras"
|
||||||
@@ -13,8 +14,10 @@ object MyBuild extends Build {
|
|||||||
|
|
||||||
lazy val project = Project (
|
lazy val project = Project (
|
||||||
"gitbucket",
|
"gitbucket",
|
||||||
file("."),
|
file(".")
|
||||||
settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ Seq(
|
)
|
||||||
|
.settings(ScalatraPlugin.scalatraWithJRebel: _*)
|
||||||
|
.settings(
|
||||||
sourcesInBase := false,
|
sourcesInBase := false,
|
||||||
organization := Organization,
|
organization := Organization,
|
||||||
name := Name,
|
name := Name,
|
||||||
@@ -46,12 +49,12 @@ object MyBuild extends Build {
|
|||||||
"ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime",
|
"ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime",
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container;provided",
|
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container;provided",
|
||||||
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts Artifact("javax.servlet", "jar", "jar"),
|
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts Artifact("javax.servlet", "jar", "jar"),
|
||||||
"junit" % "junit" % "4.11" % "test"
|
"junit" % "junit" % "4.11" % "test",
|
||||||
|
"com.typesafe.play" %% "twirl-compiler" % "1.0.2"
|
||||||
),
|
),
|
||||||
EclipseKeys.withSource := true,
|
EclipseKeys.withSource := true,
|
||||||
javacOptions in compile ++= Seq("-target", "6", "-source", "6"),
|
javacOptions in compile ++= Seq("-target", "6", "-source", "6"),
|
||||||
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "junitxml", "console"),
|
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "junitxml", "console"),
|
||||||
packageOptions += Package.MainClass("JettyLauncher")
|
packageOptions += Package.MainClass("JettyLauncher")
|
||||||
) ++ seq(Twirl.settings: _*)
|
).enablePlugins(SbtTwirl)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
|
|||||||
|
|
||||||
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.5")
|
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.5")
|
||||||
|
|
||||||
resolvers += "spray repo" at "http://repo.spray.io"
|
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.2")
|
||||||
|
|
||||||
addSbtPlugin("io.spray" % "sbt-twirl" % "0.7.0")
|
|
||||||
|
|
||||||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.4")
|
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.4")
|
||||||
|
|||||||
Binary file not shown.
2
sbt.bat
2
sbt.bat
@@ -1,2 +1,2 @@
|
|||||||
set SCRIPT_DIR=%~dp0
|
set SCRIPT_DIR=%~dp0
|
||||||
java -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar "%SCRIPT_DIR%\sbt-launch-0.13.1.jar" %*
|
java -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar "%SCRIPT_DIR%\sbt-launch-0.13.5.jar" %*
|
||||||
|
|||||||
2
sbt.sh
2
sbt.sh
@@ -1 +1 @@
|
|||||||
java -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar `dirname $0`/sbt-launch-0.13.1.jar "$@"
|
java -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar `dirname $0`/sbt-launch-0.13.5.jar "$@"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import plugin.Security._
|
|||||||
import service.RepositoryService.RepositoryInfo
|
import service.RepositoryService.RepositoryInfo
|
||||||
import scala.reflect.runtime.currentMirror
|
import scala.reflect.runtime.currentMirror
|
||||||
import scala.tools.reflect.ToolBox
|
import scala.tools.reflect.ToolBox
|
||||||
|
import play.twirl.compiler.TwirlCompiler
|
||||||
|
|
||||||
// TODO This is a sample implementation for Scala based plug-ins.
|
// TODO This is a sample implementation for Scala based plug-ins.
|
||||||
class ScalaPlugin(val id: String, val version: String,
|
class ScalaPlugin(val id: String, val version: String,
|
||||||
@@ -49,7 +50,7 @@ class ScalaPlugin(val id: String, val version: String,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object ScalaPlugin {
|
object ScalaPlugin extends App {
|
||||||
|
|
||||||
def define(id: String, version: String, author: String, url: String, description: String)
|
def define(id: String, version: String, author: String, url: String, description: String)
|
||||||
= new ScalaPlugin(id, version, author, url, description)
|
= new ScalaPlugin(id, version, author, url, description)
|
||||||
@@ -60,4 +61,23 @@ object ScalaPlugin {
|
|||||||
toolbox.eval(tree)
|
toolbox.eval(tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def compileTemplate(source: String) = {
|
||||||
|
val result = TwirlCompiler.compileVirtual(source,
|
||||||
|
new java.io.File("./sample.scala.html"),
|
||||||
|
new java.io.File("."),
|
||||||
|
"twirl.api.HtmlFormat.Appendable",
|
||||||
|
"twirl.api.HtmlFormat")
|
||||||
|
|
||||||
|
println(result.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileTemplate(
|
||||||
|
"""@(value: String)
|
||||||
|
| <html>@value</html>
|
||||||
|
| """.stripMargin)
|
||||||
|
|
||||||
|
compileTemplate(
|
||||||
|
"""@(value: String)
|
||||||
|
| <b>@value</b>
|
||||||
|
| """.stripMargin)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package servlet
|
|||||||
import javax.servlet._
|
import javax.servlet._
|
||||||
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import twirl.api.Html
|
import play.twirl.api.Html
|
||||||
import service.{AccountService, RepositoryService, SystemSettingsService}
|
import service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
import model.{Account, Session}
|
import model.{Account, Session}
|
||||||
import util.{JGitUtil, Keys}
|
import util.{JGitUtil, Keys}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import service.RequestCache
|
import service.RequestCache
|
||||||
import twirl.api.Html
|
import play.twirl.api.Html
|
||||||
import util.StringUtil
|
import util.StringUtil
|
||||||
|
|
||||||
trait AvatarImageProvider { self: RequestCache =>
|
trait AvatarImageProvider { self: RequestCache =>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import twirl.api.Html
|
import play.twirl.api.Html
|
||||||
import util.StringUtil
|
import util.StringUtil
|
||||||
import service.RequestCache
|
import service.RequestCache
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@(listparts: twirl.api.Html,
|
@(listparts: play.twirl.api.Html,
|
||||||
allCount: Int,
|
allCount: Int,
|
||||||
assignedCount: Int,
|
assignedCount: Int,
|
||||||
createdByCount: Int,
|
createdByCount: Int,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@(listparts: twirl.api.Html,
|
@(listparts: play.twirl.api.Html,
|
||||||
counts: List[service.PullRequestService.PullRequestCount],
|
counts: List[service.PullRequestService.PullRequestCount],
|
||||||
repositories: List[(String, String, Int)],
|
repositories: List[(String, String, Int)],
|
||||||
condition: service.IssuesService.IssueSearchCondition,
|
condition: service.IssuesService.IssueSearchCondition,
|
||||||
|
|||||||
Reference in New Issue
Block a user