halfass.min(文件已创建)
| @@ -0,0 +1,80 @@ | |||
| 1 | + | (symbol make-wiki (==>) (args rest first build-sitemap-for)) :: | |
| 2 | + | ||
| 3 | + | (symbol build-sitemap-for | |
| 4 | + | (str :dir ==>) (get-wiki-pages make-list-of-links write-wiki) | |
| 5 | + | ) :: | |
| 6 | + | ||
| 7 | + | (symbol get-wiki-pages | |
| 8 | + | (==>) ( | |
| 9 | + | get-files get-filenames ("index.html" ==) reject '> sort | |
| 10 | + | ) | |
| 11 | + | ) :: | |
| 12 | + | ||
| 13 | + | (symbol make-list-of-links | |
| 14 | + | (quot :filenames ==> dict:xml-element :document) ( | |
| 15 | + | html"<html><ul></ul></html>" | |
| 16 | + | ("children" 0 "children") (stack.pop make-list-items) update | |
| 17 | + | @document | |
| 18 | + | ) | |
| 19 | + | ) :: | |
| 20 | + | ||
| 21 | + | (symbol write-wiki | |
| 22 | + | (==>) (xml.to-xml dir ("index.html") prepend fs.join-path fs.write) | |
| 23 | + | ) :: | |
| 24 | + | ||
| 25 | + | (symbol get-files (==>) (dir sys.ls)) :: | |
| 26 | + | ||
| 27 | + | (symbol get-filenames (quot :files ==>) (files (fs.filename) map)) :: | |
| 28 | + | ||
| 29 | + | (symbol make-list-items (==>) (filenames (a-tag li-tag) map)) :: | |
| 30 | + | ||
| 31 | + | (symbol a-tag | |
| 32 | + | (str :destination ==> dict:xml-element :tag) ( | |
| 33 | + | html"<a/>" | |
| 34 | + | ("children") (destination xml.text stack.swap append) update | |
| 35 | + | ("attributes") (destination "href" dict.set) update | |
| 36 | + | @tag | |
| 37 | + | ) | |
| 38 | + | ) :: | |
| 39 | + | ||
| 40 | + | (symbol li-tag | |
| 41 | + | (dict:xml-element :content ==> dict:xml-element :tag) ( | |
| 42 | + | html"<li/>" | |
| 43 | + | ("children") (content stack.swap append) update | |
| 44 | + | @tag | |
| 45 | + | ) | |
| 46 | + | ) :: | |
| 47 | + | ||
| 48 | + | (sigil html | |
| 49 | + | (str :html ==> dict:xml-element :result) | |
| 50 | + | (html xml.from-html @result) | |
| 51 | + | ) :: | |
| 52 | + | ||
| 53 | + | (symbol update | |
| 54 | + | (quot|dict :structure quot :path quot :operation ==> quot|dict :updated) ( | |
| 55 | + | path first :index | |
| 56 | + | ( | |
| 57 | + | ((path size 1 == structure "quot" type? and) ( | |
| 58 | + | structure structure index get operation -> | |
| 59 | + | index set @updated | |
| 60 | + | )) | |
| 61 | + | ||
| 62 | + | ((path size 1 == structure "dict" type? and) ( | |
| 63 | + | structure structure index dict.get operation -> | |
| 64 | + | index dict.set @updated | |
| 65 | + | )) | |
| 66 | + | ||
| 67 | + | ((structure "quot" type?) ( | |
| 68 | + | structure index get path rest operation update :value | |
| 69 | + | structure value index set @updated | |
| 70 | + | )) | |
| 71 | + | ||
| 72 | + | ((structure "dict" type?) ( | |
| 73 | + | structure index dict.get path rest operation update :value | |
| 74 | + | structure value index dict.set @updated | |
| 75 | + | )) | |
| 76 | + | ) case | |
| 77 | + | ) | |
| 78 | + | ) :: | |
| 79 | + | ||
| 80 | + | make-wiki | |
上一页
下一页