|  | 
| 1 | 1 | package readme | 
| 2 | 2 | 
 | 
| 3 |  | -import java.nio.file.{Paths, Files} | 
| 4 |  | - | 
| 5 |  | -import scalatags.Text.all._ | 
| 6 |  | -import ammonite.ops._ | 
| 7 |  | -object Main{ | 
| 8 |  | - def main(args: Array[String]): Unit = { | 
| 9 |  | - val ghLink = a( | 
| 10 |  | - href:="https://github.com/scala-js/scala-js-dom", | 
| 11 |  | - position.absolute, | 
| 12 |  | - top:=0,right:=0,border:=0, | 
| 13 |  | - img( | 
| 14 |  | - src:="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67", | 
| 15 |  | - alt:="Fork me on GitHub" | 
| 16 |  | - ) | 
| 17 |  | - ) | 
| 18 |  | - new scalatex.site.Site{ | 
| 19 |  | - def content = Map("index.html" -> Index()) | 
| 20 |  | - override def autoResources = super.autoResources ++ Seq( | 
| 21 |  | - root/"example-opt.js", | 
| 22 |  | - root/'scalatex/'scrollspy/"scrollspy.js" | 
| 23 |  | - ) | 
| 24 |  | - | 
| 25 |  | - override def bodyFrag(frag: Frag) = { | 
| 26 |  | - Seq( | 
| 27 |  | - ghLink, | 
| 28 |  | - div( | 
| 29 |  | - position.fixed, | 
| 30 |  | - overflow.scroll, | 
| 31 |  | - backgroundColor := "#191818", | 
| 32 |  | - height := "100%", | 
| 33 |  | - width := 250, | 
| 34 |  | - left := 0, | 
| 35 |  | - top := 0, | 
| 36 |  | - a(href:="#menu", id:="menu-link", cls:="menu-link")( | 
| 37 |  | - span | 
| 38 |  | - ), | 
| 39 |  | - div(id:="menu") | 
| 40 |  | - ), | 
| 41 |  | - div( | 
| 42 |  | - marginLeft := 250, | 
| 43 |  | - super.bodyFrag(frag) | 
| 44 |  | - ), | 
| 45 |  | - script(raw(s""" | 
| 46 |  | - scalatex.scrollspy.Controller().main( | 
| 47 |  | - ${upickle.write(sect.structure.children(0))}, | 
| 48 |  | - document.getElementById("menu"), | 
| 49 |  | - document.getElementById("menu-link") | 
| 50 |  | - )""")) | 
| 51 |  | - ) | 
| 52 |  | - } | 
| 53 |  | - override def generateHtml(outputRoot: Path) = { | 
| 54 |  | - for((path, frag) <- content){ | 
| 55 |  | - val txt = html( | 
| 56 |  | - head(headFrags), | 
| 57 |  | - bodyFrag(frag) | 
| 58 |  | - ).render | 
| 59 |  | - write.over( | 
| 60 |  | - outputRoot/path, | 
| 61 |  | - ("<!DOCTYPE html>" + txt).getBytes | 
| 62 |  | - ) | 
| 63 |  | - } | 
| 64 |  | - | 
| 65 |  | - } | 
| 66 |  | - }.renderTo(cwd/'readme/'target/'output) | 
| 67 |  | - } | 
| 68 |  | -} | 
| 69 |  | -object sect extends scalatex.site.Section() | 
| 70 |  | -object hl extends scalatex.site.Highlighter{ | 
| 71 |  | - def scala(s: String) = this.highlight(s, "scala") | 
| 72 |  | - def suffixMappings = Map( | 
| 73 |  | - "scala" -> "scala" | 
| 74 |  | - ) | 
| 75 |  | - override def pathMappings = Seq( | 
| 76 |  | - root -> "https://github.com/scala-js/scala-js-dom/tree/master" | 
| 77 |  | - ) | 
| 78 |  | -} | 
|  | 3 | +import scalatex.site | 
|  | 4 | + | 
|  | 5 | +object Main extends site.Main( | 
|  | 6 | + "https://github.com/scala-js/scala-js-dom/tree/master", | 
|  | 7 | + ammonite.ops.cwd, | 
|  | 8 | + ammonite.ops.cwd/'target/'site, | 
|  | 9 | + readme.Index() | 
|  | 10 | +) | 
0 commit comments