summaryrefslogtreecommitdiff
path: root/book/src/main/scala/book/Main.scala
diff options
context:
space:
mode:
Diffstat (limited to 'book/src/main/scala/book/Main.scala')
-rw-r--r--book/src/main/scala/book/Main.scala62
1 files changed, 55 insertions, 7 deletions
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)