diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-10 21:10:07 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-10 21:10:07 -0800 |
commit | 8ced367e0d736b429f0b39ae7fde2b76b1d64ed5 (patch) | |
tree | e1154648219f8367c2537580f207e8f100e75590 /book/src/main/scala/book/Main.scala | |
parent | 2846d28c95d183792d6d809d1c3884b619b6f937 (diff) | |
download | hands-on-scala-js-8ced367e0d736b429f0b39ae7fde2b76b1d64ed5.tar.gz hands-on-scala-js-8ced367e0d736b429f0b39ae7fde2b76b1d64ed5.tar.bz2 hands-on-scala-js-8ced367e0d736b429f0b39ae7fde2b76b1d64ed5.zip |
More refactoring
Diffstat (limited to 'book/src/main/scala/book/Main.scala')
-rw-r--r-- | book/src/main/scala/book/Main.scala | 65 |
1 files changed, 3 insertions, 62 deletions
diff --git a/book/src/main/scala/book/Main.scala b/book/src/main/scala/book/Main.scala index 78c9c33..8ebcbd4 100644 --- a/book/src/main/scala/book/Main.scala +++ b/book/src/main/scala/book/Main.scala @@ -1,14 +1,8 @@ package book import acyclic.file import java.io.InputStream -import java.nio.charset.StandardCharsets import java.nio.file.{Paths, Files} -import org.eclipse.jgit.api.Git - -import scala.collection.mutable -import scalatags.Text.all._ -import scalatags.Text.tags2 object Main { @@ -23,68 +17,15 @@ 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") + write(Book.site, "output/index.html") - write(site, "output/index.html") - - for(res <- Utils.autoResources ++ Utils.manualResources) { + for(res <- Book.autoResources ++ Book.manualResources) { copy(getClass.getResourceAsStream("/" + res), "output/" + res) } + sect.structure println("Writing Done") } |