scripts/web.hex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
"2024" "meta-year" : "0.1.0" "meta-release" : "web/assets" "d-assets" : "web/templates" "d-templates" : "web/contents" "d-contents" : "web/out" "d-out" : "releases" "d-releases" : ; Get all files from a directory ("ls " swap cat run 0x1 get "\n" split) "ls" : ; Get relevant files d-contents ls . "contents" : d-assets ls . "assets" : d-releases ls . "releases" : d-templates "/page.html" cat "t-page" : ; Symbols to substitute with the corresponding links, ; if found in text. ("split" "run" "get" "puts") "symbol-links" : ; Convenience symbol for debugging (dup puts) "_" : ; Generate tag placeholder ( "{{" swap "}}" cat cat ) "tag" : ; Replace tag ( "pt-repl" : "pt-tag" : "pt-content" : (pt-content pt-tag tag . index 0x0 >) (pt-content pt-tag tag . pt-repl replace "pt-content" :) while pt-content ) "process-tag" : ; Replace symbol placeholder with link to spec ( "t-symbol" : "t-content" : ("<a href=\"/spec#" t-symbol "-symbol\">" t-symbol "</a>") () map "" join "t-repl" : ; Push replacement content on the stack t-content "sym-" t-symbol cat t-repl process-tag . ; Free temporary symbols "t-repl" # "t-symtag" # "t-symbol" # ) "process-symbol" : ; Load releases content for changelog "" "releases-content" : ( releases ( "id-release" : ; Update releases-content d-releases "/" id-release cat cat read releases-content swap cat "releases-content" : ) each ) "process-releases" : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; Generate CHANGELOG "*** Updating CHANGELOG.md..." puts process-releases . ; Read changelog template and add generated release content d-contents "/" "changelog.html" cat cat read "releases" releases-content process-tag . ; Write CHANGELOG.md "CHANGELOG.md" write "*** Done!" puts ;;;;; Write web site contents "*** Generating hex web site..." puts contents ( "fn-content" : fn-content ".html" "" replace "id-content" : d-contents "/" fn-content cat cat read "content" : t-page read ; Replace tags "content" content process-tag . "title" id-content process-tag . "release" meta-release process-tag . "year" meta-year process-tag . "releases" releases-content process-tag . "new-content" : ; Replace symbols with links symbol-links (new-content swap process-symbol . "new-content" :) each (fn-content "home.html" ==) ( ; Process home page d-out "/index.html" cat "dst-file" : ) ( ("sh -c \"mkdir -p " d-out "/" id-content "\"") () map "" join exec (d-out id-content "index.html") () map "/" join "dst-file" : ) if " - Writing: " dst-file cat puts new-content dst-file write ) each ; Write assets ("sh -c \"mkdir -p " d-out "/assets\"") () map "" join exec assets ( "fn-asset" : (d-out "assets" fn-asset) () map "/" join "dst-file" : (fn-asset "robots.txt" ==) ((d-out fn-asset) () map "/" join "dst-file" :) when (d-assets fn-asset) () map "/" join "src-file" : " - Writing: " dst-file cat puts ("cp" src-file dst-file) () map " " join exec ) each "*** Done!" puts |