all repos — hex @ 7df54b94e7da3695208a4b259b7c6744c49f3571

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

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
"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" :

; 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" :

"" "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.html
"*** Updating CHANGELOG.html..." 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.html
"CHANGELOG.html" 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" :
    (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