diff options
Diffstat (limited to 'book/src/main/scala/book')
-rw-r--r-- | book/src/main/scala/book/Book.scala | 54 | ||||
-rw-r--r-- | book/src/main/scala/book/Main.scala | 62 | ||||
-rw-r--r-- | book/src/main/scala/book/Utils.scala | 2 |
3 files changed, 57 insertions, 61 deletions
diff --git a/book/src/main/scala/book/Book.scala b/book/src/main/scala/book/Book.scala index 785e6ab..e11c512 100644 --- a/book/src/main/scala/book/Book.scala +++ b/book/src/main/scala/book/Book.scala @@ -1,5 +1,5 @@ package book - +import acyclic.file import scalatex._ import scalatags.Text.tags2 @@ -11,7 +11,6 @@ import scalatags.Text.all._ */ object Book { import Utils.sect - val myTable = Seq( ("Most of java.lang.*", "j.l.Thread, j.l.Runtime, ..."), ("Almost all of scala.*", "s.c.parallel, s.tools.nsc"), @@ -23,58 +22,7 @@ object Book { ("JavaScript libraries: chipmunk.js, hand.js, react.js, jquery", "Java ecosystem: guice, junit, apache-commons, log4j"), ("IntelliJ, Eclipse, SBT, Chrome console, firebug", "Scala REPL, Yourkit, VisualVM, JProfiler") ) - val txt = Index.template - val contentBar = { - def rec(current: Node, depth: Int): Seq[Frag] = { - println("\t"*depth + current.name) - Seq( - li( - a( - current.name, - href:="#"+Utils.munge(current.name), - paddingLeft := s"${depth * 10 + 10}px", - cls := "menu-item" + (if (depth == 1) " menu-item-divided " else "") - ) - ) - ) ++ current.children.flatMap(rec(_, depth + 1)) - } - - println("TABLE OF CONTENTS") - rec(Utils.structure, 0) - } - val site = Seq( - raw("<!doctype html>"), - html( - head( - meta(charset:="utf-8"), - meta(name:="viewport", content:="width=device-width, initial-scale=1.0"), - tags2.title("Hands-on Scala.js"), - Utils.includes - ), - - div(id:="layout")( - a(href:="#menu", id:="menuLink", cls:="menu-link")( - span - ), - div(id:="menu")( - div(cls:="pure-menu pure-menu-open")( - a(cls:="pure-menu-heading", href:="#")( - "Contents" - ), - ul(cls:="menu-item-list")( - contentBar - ) - ) - ) - ), - div(id:="main", - div(id:="main-box")( - txt - ) - ) - ) - ).render object hl{ def highlight(snippet: Seq[String], lang: String) = { diff --git a/book/src/main/scala/book/Main.scala b/book/src/main/scala/book/Main.scala index 19b256a..78c9c33 100644 --- a/book/src/main/scala/book/Main.scala +++ b/book/src/main/scala/book/Main.scala @@ -1,5 +1,5 @@ package book - +import acyclic.file import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.{Paths, Files} @@ -23,16 +23,64 @@ object Main { Files.copy(src, Paths.get(dest)) } + val txt = Index.template + val contentBar = { + def rec(current: Node, depth: Int): Seq[Frag] = { + println("\t"*depth + current.name) + Seq( + li( + a( + current.name, + href:="#"+Utils.munge(current.name), + paddingLeft := s"${depth * 10 + 10}px", + cls := "menu-item" + (if (depth == 1) " menu-item-divided " else "") + ) + ) + ) ++ current.children.flatMap(rec(_, depth + 1)) + } + + println("TABLE OF CONTENTS") + rec(Utils.structure, 0) + } + val site = Seq( + raw("<!doctype html>"), + html( + head( + meta(charset:="utf-8"), + meta(name:="viewport", content:="width=device-width, initial-scale=1.0"), + tags2.title("Hands-on Scala.js"), + Utils.includes + ), + + div(id:="layout")( + a(href:="#menu", id:="menuLink", cls:="menu-link")( + span + ), + + div(id:="menu")( + div(cls:="pure-menu pure-menu-open")( + a(cls:="pure-menu-heading", href:="#")( + "Contents" + ), + ul(cls:="menu-item-list")( + contentBar + ) + ) + ) + ), + div(id:="main", + div(id:="main-box")( + txt + ) + ) + ) + ).render + def main(args: Array[String]): Unit = { println("Writing Book") -// Files.deleteIfExists(Paths.get("output/temp")) -// Git.cloneRepository() -// .setURI("https://github.com/lihaoyi/workbench-example-app") -// .setDirectory(new java.io.File("output/temp")) -// .call() - write(Book.site, "output/index.html") + write(site, "output/index.html") for(res <- Utils.autoResources ++ Utils.manualResources) { copy(getClass.getResourceAsStream("/" + res), "output/" + res) diff --git a/book/src/main/scala/book/Utils.scala b/book/src/main/scala/book/Utils.scala index 4738324..01682da 100644 --- a/book/src/main/scala/book/Utils.scala +++ b/book/src/main/scala/book/Utils.scala @@ -1,6 +1,6 @@ package book - +import acyclic.file import scala.collection.mutable import scalatags.Text.all._ |