summaryrefslogtreecommitdiff
path: root/book
diff options
context:
space:
mode:
authorlihaoyi <haoyi.sg@gmail.com>2014-11-23 22:21:44 -0800
committerlihaoyi <haoyi.sg@gmail.com>2014-11-23 22:21:44 -0800
commit85d381c1201ff8aa798321ea9237b57464b40de9 (patch)
tree26dac3719558b66a549a7236b4c46bb5119a3cf0 /book
parent7924069976b15ee0c535221673d89200ce3d5570 (diff)
downloadhands-on-scala-js-85d381c1201ff8aa798321ea9237b57464b40de9.tar.gz
hands-on-scala-js-85d381c1201ff8aa798321ea9237b57464b40de9.tar.bz2
hands-on-scala-js-85d381c1201ff8aa798321ea9237b57464b40de9.zip
gh links work
Diffstat (limited to 'book')
-rwxr-xr-xbook/src/main/resources/css/side-menu.css2
-rw-r--r--book/src/main/scala/book/Utils.scala18
-rw-r--r--book/src/main/scalatex/book/Intro.scalatex2
3 files changed, 19 insertions, 3 deletions
diff --git a/book/src/main/resources/css/side-menu.css b/book/src/main/resources/css/side-menu.css
index 81f1ee7..b8e36c6 100755
--- a/book/src/main/resources/css/side-menu.css
+++ b/book/src/main/resources/css/side-menu.css
@@ -333,6 +333,6 @@ code{
}
/*Workaround for bug in highlight.js IDEA theme*/
-.hljs-tag, .hljs-symbol{
+span.hljs-tag, span.hljs-symbol{
background: none;
}
diff --git a/book/src/main/scala/book/Utils.scala b/book/src/main/scala/book/Utils.scala
index 91d76a7..8c5c920 100644
--- a/book/src/main/scala/book/Utils.scala
+++ b/book/src/main/scala/book/Utils.scala
@@ -147,6 +147,11 @@ object hl{
def diff(code: String*) = highlight(code, "diff")
def html(code: String*) = highlight(code, "xml")
+ val mappings = Seq(
+ "output/scala-js" -> "https://github.com/scala-js/scala-js",
+ "output/workbench-example-app" -> "https://github.com/lihaoyi/workbench-example-app",
+ "" -> "https://github.com/lihaoyi/hands-on-scala-js"
+ )
def ref(filepath: String, start: String = "", end: String = "\n") = {
val lang = filepath.split('.').last match {
@@ -179,7 +184,17 @@ object hl{
val blob = sliced.map(_.drop(whitespace)).mkString("\n")
+ val (prefix, url) =
+ mappings.iterator
+ .find{case (prefix, path) => filepath.startsWith(prefix)}
+ .get
+
+ val hash =
+ if (endLine == -1) ""
+ else s"#L$startLine-L$endLine"
+ val linkUrl =
+ s"$url/tree/master/${filepath.drop(prefix.length)}$hash"
pre(
code(cls:=lang + " highlight-me hljs", blob),
a(
@@ -190,7 +205,8 @@ object hl{
bottom:="0.5em",
display.block,
fontSize:="24px",
- href:="#"
+ href:=linkUrl,
+ target:="_blank"
)
)
}
diff --git a/book/src/main/scalatex/book/Intro.scalatex b/book/src/main/scalatex/book/Intro.scalatex
index 10a2638..87c8895 100644
--- a/book/src/main/scalatex/book/Intro.scalatex
+++ b/book/src/main/scalatex/book/Intro.scalatex
@@ -101,7 +101,7 @@
@p
Despite the problems with Javascript (and other tools like HTML an CSS, which have their own problems) the Web platform got a lot of things right, and the Desktop and Mobile platforms have a lot of catching up to do. If only we could improve upon the parts that aren't so great. This is where Scala.js comes in.
-@sect{The Promise}
+@sect{About Scala.js}
@p
With Scala.js, you can cross compile your Scala code to a Javascript executable that can run on all major web browsers. You get all the benefits of the web platform in terms of deployability, security, and hyperlinking, with none of the problems of writing your software in Javascript. Scala.js provides a @sect.ref("The Language", "better language") to do your work in, but also provides some other goodies that have in-so-far never been seen in mainstream web development: @sect.ref("Sharing Code", "shared-code") and @sect.ref("Client-Server Integration", "client-server integration").