Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #18 from UdashFramework/udash-0.4
Browse files Browse the repository at this point in the history
Upgrade  to Udash 0.4
  • Loading branch information
Starzu authored Sep 16, 2016
2 parents caca46e + 2120292 commit b16ba5d
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 49 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lazy val generator = project.in(file("."))
.settings(publishArtifact := false)

lazy val core = project.in(file("core"))
.settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0-M15" % Test)
.settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % Test)

lazy val cmd = project.in(file("cmd"))
.dependsOn(core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ case class GeneratorSettings(rootDirectory: File,
def stylesSubPackage: Seq[String] = Seq("styles")

def scalaVersion: String = "2.11.8"
def sbtVersion: String = "0.13.11"
def scalaJSVersion: String = "0.6.11"
def scalaCSSVersion: String = "0.4.1"
def udashVersion: String = "0.3.1"
def sbtVersion: String = "0.13.12"
def scalaJSVersion: String = "0.6.12"
def scalaCSSVersion: String = "0.5.0"
def udashVersion: String = "0.4.0"
def udashJQueryVersion: String = "1.0.0"
def jettyVersion: String = "9.3.11.v20160721"
def logbackVersion: String = "1.1.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ object CoreDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fronten
| p("You typed: ", bind(model)),
| h3("Read more"),
| a$FrontendStylesLinkBlackPlaceholder(href := "${settings.udashDevGuide}#/frontend/bindings", target := "_blank")("Read more in Udash Guide.")
| ).render
| )
|
| override def getTemplate: Element = content
| override def getTemplate: Modifier = content
|
| override def renderChild(view: View): Unit = {}
|}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath
| import ${settings.rootPackage.mkPackage()}.Context._
| import scalatags.JsDom.all._
|
| private var child: Element = div().render
| private val child: Element = div().render
|
| private val content = div(
| $FrontendStyledHeaderPlaceholder
Expand All @@ -173,15 +173,14 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath
| child
| )
| )$FrontendStyledFooterPlaceholder
| ).render
| )
|
| override def getTemplate: Element = content
| override def getTemplate: Modifier = content
|
| override def renderChild(view: View): Unit = {
| import io.udash.wrappers.jquery._
| val newChild = view.getTemplate
| jQ(child).replaceWith(newChild)
| child = newChild
| jQ(child).children().remove()
| view.getTemplate.applyTo(child)
| }
|}
|""".stripMargin
Expand Down Expand Up @@ -223,9 +222,9 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath
| a(${FrontendStylesLinkBlackPlaceholder}href := "http://www.lihaoyi.com/scalatags/", target := "_blank")("Read more about ScalaTags")
| )
| )
| ).render
| )
|
| override def getTemplate: Element = content
| override def getTemplate: Modifier = content
|
| override def renderChild(view: View): Unit = {}
|}
Expand All @@ -246,9 +245,9 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath
|
| private val content = h3(
| "URL not found!"
| ).render
| )
|
| override def getTemplate: Element = content
| override def getTemplate: Modifier = content
|
| override def renderChild(view: View): Unit = {}
|}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ object JettyLauncherPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
}

private def createJettyServer(rootPackage: File, settings: GeneratorSettings, backendModuleName: String): Unit = {
val resourcesDir = resources(settings.rootDirectory.subFile(backendModuleName))
val logbackXml = resourcesDir.subFile("logback.xml")

val jettyDir = "jetty"
val jettyPackage = rootPackage.subFile(jettyDir)
val appServerScala = jettyPackage.subFile("ApplicationServer.scala")
val launcherScala = rootPackage.subFile("Launcher.scala")

requireFilesExist(Seq(rootPackage))
createDirs(Seq(jettyPackage))
createFiles(Seq(appServerScala, launcherScala))
createDirs(Seq(jettyPackage, resourcesDir))
createFiles(Seq(appServerScala, launcherScala, logbackXml))

writeFile(appServerScala)(
s"""package ${settings.rootPackage.mkPackage()}.$jettyDir
Expand Down Expand Up @@ -109,6 +112,30 @@ object JettyLauncherPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
""".stripMargin
)

writeFile(logbackXml)(
"""<configuration>
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
| <encoder>
| <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
| </encoder>
| </appender>
|
| <timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
|
| <appender name="FILE" class="ch.qos.logback.core.FileAppender">
| <file>logs/udash-guide-${bySecond}.log</file>
| <append>true</append>
| <encoder>
| <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
| </encoder>
| </appender>
|
| <root level="info">
| <appender-ref ref="STDOUT" />
| <appender-ref ref="FILE" />
| </root>
|</configuration>""".stripMargin)

writeFile(launcherScala)(
s"""package ${settings.rootPackage.mkPackage()}
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ object RPCDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Frontend
| p("Server response: ", bind(serverResponse)),
| h3("Read more"),
| a$FrontendStylesLinkBlackPlaceholder(href := "${settings.udashDevGuide}#/rpc", target := "_blank")("Read more in Udash Guide.")
| ).render
| )
|
| override def getTemplate: Element = content
| override def getTemplate: Modifier = content
|
| override def renderChild(view: View): Unit = {}
|}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles {
val addJsWorkbenchPlugin = if (settings.shouldEnableJsWorkbench) s"""addSbtPlugin("com.lihaoyi" % "workbench" % "0.2.3")""" else ""

writeFile(buildSbt(settings))(
s"""${importJsWorkbench}
s"""$importJsWorkbench
|import UdashBuild._
|import Dependencies._
|
|name := "${settings.projectName}"
|
Expand Down Expand Up @@ -52,7 +54,7 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles {
s"""logLevel := Level.Warn
|addSbtPlugin("org.scala-js" % "sbt-scalajs" % "${settings.scalaJSVersion}")
|
|${addJsWorkbenchPlugin}
|$addJsWorkbenchPlugin
|
|""".stripMargin)

Expand All @@ -61,15 +63,15 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles {
|import sbt.Keys._
|import sbt._
|
|object UdashBuild extends Build {$UdashBuildPlaceholder}
|object UdashBuild {$UdashBuildPlaceholder}
|
|""".stripMargin)

writeFile(dependenciesScala(settings))(
s"""import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
|import sbt._
|
|object Dependencies extends Build {$DependenciesPlaceholder}
|object Dependencies {$DependenciesPlaceholder}
|
|""".stripMargin)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object SBTModulesPlugin extends GeneratorPlugin with SBTProjectFiles with Fronte
| compileStatics := {
| IO.copyDirectory(sourceDirectory.value / "main/assets/fonts", crossTarget.value / StaticFilesDir / WebContent / "assets/fonts")
| IO.copyDirectory(sourceDirectory.value / "main/assets/images", crossTarget.value / StaticFilesDir / WebContent / "assets/images")
| compileStaticsForRelease.value
| val statics = compileStaticsForRelease.value
| (crossTarget.value / StaticFilesDir).***.get
| },
|
Expand Down Expand Up @@ -185,14 +185,13 @@ object SBTModulesPlugin extends GeneratorPlugin with SBTProjectFiles with Fronte
| jsDependencies ++= $frontendJSDepsName.value,
| persistLauncher in Compile := true,
|
| compile <<= (compile in Compile),
| compile <<= (compile in Compile).dependsOn(compileStatics),
| compileStatics := {
| IO.copyDirectory(sourceDirectory.value / "main/assets/fonts", crossTarget.value / StaticFilesDir / WebContent / "assets/fonts")
| IO.copyDirectory(sourceDirectory.value / "main/assets/images", crossTarget.value / StaticFilesDir / WebContent / "assets/images")
| compileStaticsForRelease.value
| val statics = compileStaticsForRelease.value
| (crossTarget.value / StaticFilesDir).***.get
| },
| compileStatics <<= compileStatics.dependsOn(compile in Compile),
|
| artifactPath in(Compile, fastOptJS) :=
| (crossTarget in(Compile, fastOptJS)).value / StaticFilesDir / WebContent / "scripts" / "${settings.frontendImplFastJs}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
| a(DemoStyles.underlineLinkBlack)(href := "https://japgolly.github.io/scalacss/book/", target := "_blank")("Read more in ScalaCSS docs.")
| )
| )
| ).render
| )
|
| override def getTemplate: Element = content
| override def getTemplate: Modifier = content
|
| override def renderChild(view: View): Unit = {}
|
Expand Down Expand Up @@ -279,13 +279,60 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
|import ${settings.rootPackage.mkPackage()}.${settings.stylesSubPackage.mkPackage()}.${stylesUtilsPackage.getName}.{MediaQueries, StyleUtils}
|
|import scala.language.postfixOps
|import scalacss.Attr
|import scalacss.internal.{Attr, Literal}
|import scalacss.Defaults._
|
|object GlobalStyles extends StyleSheet.Inline {
| import dsl._
|
| val reset = style(scalacss.ext.CssReset.meyer)
| val reset = style(
| unsafeRoot(\"\"\"html, body, div, span, applet, object, iframe,
| | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
| | a, abbr, acronym, address, big, cite, code,
| | del, dfn, em, img, ins, kbd, q, s, samp,
| | small, strike, strong, sub, sup, tt, var,
| | b, u, i, center,
| | dl, dt, dd, ol, ul, li,
| | fieldset, form, label, legend,
| | table, caption, tbody, tfoot, thead, tr, th, td,
| | article, aside, canvas, details, embed,
| | figure, figcaption, footer, header, hgroup,
| | menu, nav, output, ruby, section, summary,
| | time, mark, audio, video\"\"\".stripMargin.replaceAll("\\\\s+", ""))(
| margin.`0`,
| padding.`0`,
| border.`0`,
| fontSize(100 %%),
| font := Literal.inherit,
| verticalAlign.baseline
| ),
|
| unsafeRoot("article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section")(
| display.block
| ),
|
| unsafeRoot("body")(
| lineHeight(1)
| ),
|
| unsafeRoot("ol,ul")(
| listStyle := none // TODO
| ),
|
| unsafeRoot ("blockquote, q")(
| quotes.none
| ),
|
| unsafeRoot("blockquote:before, blockquote:after, q:before, q:after")(
| content := "''",
| content := none
| ),
|
| unsafeRoot("table")(
| borderCollapse.collapse,
| borderSpacing.`0`
| )
| )
|
| val global = style(
| unsafeRoot("#application") (
Expand Down Expand Up @@ -579,7 +626,7 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
|
|import scala.concurrent.duration.FiniteDuration
|import scala.language.postfixOps
|import scalacss.Compose
|import scalacss.internal.Compose
|import scalacss.Defaults._
|
|object DemoStyles extends StyleSheet.Inline {
Expand Down Expand Up @@ -773,7 +820,7 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
writeFile(stylesFontsScala)(
s"""package ${settings.rootPackage.mkPackage()}.${settings.stylesSubPackage.mkPackage()}.${stylesFontsPackage.getName}
|import scala.language.postfixOps
|import scalacss.AV
|import scalacss.internal.AV
|import scalacss.Defaults._
|
|object UdashFonts extends StyleSheet.Inline {
Expand Down Expand Up @@ -1131,7 +1178,7 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro
|
|import scala.concurrent.duration.FiniteDuration
|import scala.language.postfixOps
|import scalacss.{AV, Attr, Length, ValueT}
|import scalacss.internal.{AV, Attr, Length, ValueT}
|import scalacss.Defaults._
|
|object StyleUtils extends StyleSheet.Inline {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import io.udash.generator.GeneratorSettings
import io.udash.generator.utils._

trait UtilPaths {
def resources(module: File): File =
module.subFile(resourcesPathPart)
def src(module: File): File =
module.subFile(srcPathPart)
def testSrc(module: File): File =
Expand All @@ -15,6 +17,7 @@ trait UtilPaths {
def rootPackageInTestSrc(module: File, settings: GeneratorSettings): File =
module.subFile(Seq(testSrcPathPart, packagePathPart(settings)).mkString(File.separator))

private val resourcesPathPart = Seq("src", "main", "resources").mkString(File.separator)
private val srcPathPart = Seq("src", "main", "scala").mkString(File.separator)
private val testSrcPathPart = Seq("src", "test", "scala").mkString(File.separator)
private def packagePathPart(settings: GeneratorSettings) = settings.rootPackage.mkString(File.separator)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.11
sbt.version = 0.13.12
12 changes: 0 additions & 12 deletions test/empty.cnf

This file was deleted.

0 comments on commit b16ba5d

Please sign in to comment.