summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-26 23:47:17 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-26 23:47:17 -0800
commit3bf82c833b15c2a2e0078b156f5ea48e171a463a (patch)
treef9bd6ff3482e9653f4a6c3d42b03355fb971a881
parentcc4781d9af3cb57c39a4ac26283f6428ad2aaa60 (diff)
downloadhands-on-scala-js-3bf82c833b15c2a2e0078b156f5ea48e171a463a.tar.gz
hands-on-scala-js-3bf82c833b15c2a2e0078b156f5ea48e171a463a.tar.bz2
hands-on-scala-js-3bf82c833b15c2a2e0078b156f5ea48e171a463a.zip
client-server example works
-rw-r--r--book/src/main/scala/book/BookData.scala1
-rw-r--r--book/src/main/scalatex/book/handson/ClientServer.scalatex2
-rw-r--r--examples/crossBuilds/clientserver/Procfile1
-rw-r--r--examples/crossBuilds/clientserver/build.sbt2
-rw-r--r--examples/crossBuilds/clientserver/project/build.sbt1
-rw-r--r--examples/crossBuilds/clientserver/server/src/main/scala/simple/Page.scala2
-rw-r--r--examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala5
-rw-r--r--project/build.sbt2
8 files changed, 14 insertions, 2 deletions
diff --git a/book/src/main/scala/book/BookData.scala b/book/src/main/scala/book/BookData.scala
index f448521..c306475 100644
--- a/book/src/main/scala/book/BookData.scala
+++ b/book/src/main/scala/book/BookData.scala
@@ -43,6 +43,7 @@ object BookData {
script(s"$main(document.getElementById('$tagId'))")
)
}
+
def split = div(cls:="pure-g")
def more = div(cls:="pure-u-1 pure-u-md-13-24")
def less = div(cls:="pure-u-1 pure-u-md-11-24")
diff --git a/book/src/main/scalatex/book/handson/ClientServer.scalatex b/book/src/main/scalatex/book/handson/ClientServer.scalatex
index 3a952dc..3fcf016 100644
--- a/book/src/main/scalatex/book/handson/ClientServer.scalatex
+++ b/book/src/main/scalatex/book/handson/ClientServer.scalatex
@@ -74,6 +74,8 @@
@p
Now, if we go to the browser at @code{localhost:8080}, we should see our web-page!
+ @iframe(src:="https://hands-on-scala-js.herokuapp.com/", width:="100%", height:="300px", "frameBorder".attr:="0")
+
@sect{Client-Server Reflections}
@p
By now you've already set up your first client-server application. However, it might not be immediately clear what we've done and why it's interesting! Here are some points to consider.
diff --git a/examples/crossBuilds/clientserver/Procfile b/examples/crossBuilds/clientserver/Procfile
new file mode 100644
index 0000000..59ff8a8
--- /dev/null
+++ b/examples/crossBuilds/clientserver/Procfile
@@ -0,0 +1 @@
+web: server/target/universal/stage/bin/server
diff --git a/examples/crossBuilds/clientserver/build.sbt b/examples/crossBuilds/clientserver/build.sbt
index e5b70ff..3bba3af 100644
--- a/examples/crossBuilds/clientserver/build.sbt
+++ b/examples/crossBuilds/clientserver/build.sbt
@@ -1,3 +1,4 @@
+import NativePackagerKeys._
import utest.jsrunner.JsCrossBuild
import scala.scalajs.sbtplugin.ScalaJSPlugin._
import ScalaJSKeys._
@@ -22,6 +23,7 @@ lazy val client = project.in(file("client"))
lazy val server = project.in(file("server"))
.settings(sharedSettings:_*)
+ .settings(packageArchetype.java_application:_*)
.settings(
libraryDependencies ++= Seq(
"io.spray" %% "spray-can" % "1.3.2",
diff --git a/examples/crossBuilds/clientserver/project/build.sbt b/examples/crossBuilds/clientserver/project/build.sbt
index 7c60a91..c24e2b0 100644
--- a/examples/crossBuilds/clientserver/project/build.sbt
+++ b/examples/crossBuilds/clientserver/project/build.sbt
@@ -3,3 +3,4 @@ addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.5")
addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.4")
+addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.4")
diff --git a/examples/crossBuilds/clientserver/server/src/main/scala/simple/Page.scala b/examples/crossBuilds/clientserver/server/src/main/scala/simple/Page.scala
index ce6617c..d657290 100644
--- a/examples/crossBuilds/clientserver/server/src/main/scala/simple/Page.scala
+++ b/examples/crossBuilds/clientserver/server/src/main/scala/simple/Page.scala
@@ -10,7 +10,7 @@ object Page{
script(src:="/client-fastopt.js"),
link(
rel:="stylesheet",
- href:="http://yui.yahooapis.com/pure/0.5.0/pure-min.css"
+ href:="https://cdnjs.cloudflare.com/ajax/libs/pure/0.5.0/pure-min.css"
)
),
body(
diff --git a/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala b/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala
index 4d1ece2..e9038b5 100644
--- a/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala
+++ b/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala
@@ -4,10 +4,13 @@ import akka.actor.ActorSystem
import spray.http.{HttpEntity, MediaTypes}
import spray.routing.SimpleRoutingApp
+import scala.util.Properties
+
object Server extends SimpleRoutingApp{
def main(args: Array[String]): Unit = {
implicit val system = ActorSystem()
- startServer("localhost", port = 8080){
+ val port = Properties.envOrElse("PORT", "8080").toInt
+ startServer("0.0.0.0", port = port){
get{
pathSingleSlash{
complete{
diff --git a/project/build.sbt b/project/build.sbt
index 02ad299..e04b021 100644
--- a/project/build.sbt
+++ b/project/build.sbt
@@ -2,4 +2,6 @@ addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.5")
addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.4")
+addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.4")
+
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "3.5.1.201410131835-r" \ No newline at end of file