gen_recipes.sh (2042B)
1 #!/bin/sh 2 3 echo '<!DOCTYPE html> 4 <html> 5 <head> 6 <meta charset="utf-8" /> 7 <meta name="viewport" content="width=device-width,initial-scale=1" /> 8 <title>Recipes</title> 9 </head> 10 <body> 11 <h1>Recipes</h1>' > html/recipes/index.html 12 13 echo 'Recipes\n' > gph/recipes/index.gph 14 echo '[1|All Images|/recipes/images/|server|port]\n' >> gph/recipes/index.gph 15 echo 'Text version:' >> gph/recipes/index.gph 16 17 # generate text and html versions 18 for i in recipes/*.md 19 do 20 base=`basename $i .md` 21 lowdown -s --html-no-head-ids --out-no-smarty -o html/recipes/$base.html $i 22 tail -n +3 $i | 23 sed 's/\[[^]]*\](\([^)]*\))/gopher:\/\/lumidify.org\/I\/recipes\/\1/g' | # generate full urls 24 sed 's/(gopher:\/\//( gopher:\/\//g' | # add space after left parenthesis for double-click selecting 25 sed 's/\(images\/[^)]*\.jpg\))/\1 )/g' > gph/recipes/$base.md # add space before right parenthesis 26 title=`head -n 1 $i | sed 's/^.*://' | tr -d '\n'` 27 echo "<a href=\"$base.html\">$title</a>" >> html/recipes/index.html 28 echo "[0|$title|/recipes/$base.md|server|port]" >> gph/recipes/index.gph 29 done 30 31 echo '<a href="images/">All Images</a> 32 </body> 33 </html>' >> html/recipes/index.html 34 35 echo '\nGopher menu version (with direct links to images):' >> gph/recipes/index.gph 36 # generate gopher menu version 37 for i in recipes/*.md 38 do 39 base=`basename $i .md` 40 # FIXME: handle '[' properly, in case it ever is written at the beginning of a line 41 tail -n +3 $i | 42 sed 's/(\[\([^]]*\)\](\([^)]*\)))/[(\1)](\2)/g' | # move parentheses into image name 43 sed -r 's/^([[:space:]]*)\[([^]]*)\]\(([^)]*)\)$/[\1\2](\3)/' | # move indent into image name 44 sed 's/^\[\([^]]*\)\](\([^)]*\))$/[I|\1|\/recipes\/\2|server|port]/g' > gph/recipes/$base.gph # generate gph links 45 title=`head -n 1 $i | sed 's/^.*://' | tr -d '\n'` 46 echo "[1|$title|/recipes/$base.gph|server|port]" >> gph/recipes/index.gph 47 done 48 49 echo '\nNote: The links in both versions are generated automatically 50 from relative markdown links, so there may be mistakes. 51 Let me know if you find any problems.' >> gph/recipes/index.gph