ad3b8987c4
FossilOrigin-Name: 9467b600c6b6112d385bec36c199991051f09f27eb99bc6cbb2d99acb5373f4c
55 lines
1.2 KiB
Forth
Executable file
55 lines
1.2 KiB
Forth
Executable file
#!/usr/bin/env retro
|
|
|
|
This program generates an HTML index and exports (using the
|
|
`export-as-html.forth` example) the samples to HTML. The files
|
|
are stored in `/home/crc/public/examples`.
|
|
|
|
# Configuration
|
|
|
|
~~~
|
|
'/home/crc/public/examples/ 'FILE-PATH s:const
|
|
~~~
|
|
|
|
~~~
|
|
:unix:count-files (-n)
|
|
'ls_-1_|_wc_-l file:R unix:popen
|
|
[ file:read-line s:trim s:to-number ] [ unix:pclose ] bi ;
|
|
|
|
:unix:for-each-file (q-)
|
|
'ls_-1_-p file:R unix:popen
|
|
unix:count-files-in-cwd
|
|
[ [ file:read-line s:temp over call ] sip ] times
|
|
unix:pclose drop ;
|
|
|
|
:dir? (s-sf)
|
|
dup s:length over + n:dec fetch $/ eq? ;
|
|
~~~
|
|
|
|
# Generate index.html
|
|
|
|
~~~
|
|
FILE-PATH 'index.html s:append file:W file:open 'FID const
|
|
|
|
:index:put [ FID file:write ] s:for-each ;
|
|
|
|
:css
|
|
'<style>*{background:#111;color:#fff;font-family:monospace;}</style>
|
|
index:put ;
|
|
|
|
:header '<!DOCTYPE_html> index:put css ;
|
|
|
|
:link dup '<a_href="/examples/%s.html">%s</a><br> s:format index:put $. c:put ;
|
|
|
|
header
|
|
[ dir? &drop &link choose ] unix:for-each-file nl
|
|
FID file:close
|
|
~~~
|
|
|
|
# Generate HTML Files
|
|
|
|
~~~
|
|
:export FILE-PATH over
|
|
'./export-as-html.forth_%s_>%s%s.html s:format unix:system $. c:put ;
|
|
|
|
[ dir? &drop [ export ] choose ] unix:for-each-file nl
|
|
~~~
|