markdowntogopher.sh - www.codemadness.org - www.codemadness.org saait content files
(HTM) git clone git://git.codemadness.org/www.codemadness.org
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
markdowntogopher.sh (898B)
---
1 #!/bin/sh
2
3 for f in pages/*.md feeds/pages/atom.md; do
4 b=$(basename "$f" ".md")
5 test -f "$f" || continue
6
7 cfg="${f%%.md}.cfg"
8
9 (awk -v 'host=codemadness.org' -v 'port=70' '
10 function trim(s) {
11 gsub("^[ ]*", "", s);
12 gsub("[ ]*$", "", s);
13 return s;
14 }
15 # config file.
16 {
17 i = index($0, "=");
18 if (i <= 0)
19 next;
20
21 key = trim(substr($0, 1, i - 1));
22 value = trim(substr($0, i + 1));
23 values[key] = value;
24 }
25 END {
26 printf("1<- Back\t/\t%s\t%s\r\n", host, port);
27 printf("i\t\t%s\t%s\r\n", host, port);
28 printf("i\t\t%s\t%s\r\n", host, port);
29 if (length(values["title"]))
30 printf("i# %s\t\t%s\t%s\r\n", values["title"], host, port);
31 printf("i\t\t%s\t%s\r\n", host, port);
32 if (length(values["updated"]))
33 printf("iLast modification on %s\t\t%s\t%s\r\n", values["updated"], host, port);
34 printf("i\t\t%s\t%s\r\n", host, port);
35 }
36 ' "$cfg"
37
38 scripts/md2gopher.sh < "$f") > "output/phlog/$b"
39 done