added webblog

This commit is contained in:
Fulton Browne 2021-05-28 03:51:46 +00:00
parent 6ad3da3f46
commit 598addf2fe
4 changed files with 39 additions and 3 deletions

2
blog
View File

@ -20,7 +20,7 @@ fn header{
fn gettitle{
echo `{echo $1 | sed 's/\+/ /g'}
}
posts=`{ls -p $webroot/posts}
posts=`{ls -pr $webroot/posts}
fullurl=`{read}
echo $fullurl >[1=2]
url=`{echo $fullurl | sed 's/gemini:\/\/[0-9 a-z .]*//

View File

@ -1,5 +1,5 @@
$1 == "#" { print "<h1>", $0, "</h1>"; next}
$1 == "##" { print "<h2>", $0, "</h2>"; next}
$1 == "###" { print "<h3>", $0, "</h3>"; next}
$1 == "=>" { print "<a href=\"", $2, "\">" substr($0,index($0,$3)), "</a>"; next}
{ print }
$1 == "=>" { print "<a href=\"", $2, "\">" substr($0,index($0,$3)), "</a> <br>"; next}
{ print $0, "<br>" }

View File

@ -1,3 +1,4 @@
#! /bin/rc
mkdir -p /rc/bin/g9srv
cp rfs blog /rc/bin/g9srv
cp gemtohtm /lib/

35
webblog Executable file
View File

@ -0,0 +1,35 @@
#!/bin/rc
webroot = ./
o=./
fn gettitle{
echo `{echo $1 | sed 's/\+/ /g'}
}
while(! ~ $#* 0) {
switch ($1) {
case -w
webroot=$2
shift
case -o
o=$2
shift
case *
echo Usage: g9srv/webblog [-w webroot] [-o output dir]
exit usage
}
shift
}
posts=`{ls -pr $webroot/posts}
for(i in $posts){
awk -f /lib/gemtohtm < $webroot'/posts/'$i'' > $o'/'$i.html
}
echo '<link rel="stylesheet" href="/style.css">' > $o'/'index.html
echo '<title>fulton.software blog</title>' >> $o'/'index.html
for(i in $posts){
name=`{gettitle $i}
echo '<a href="'$i'.html">'$"name'</a> <br>' >> $o'/'index.html
}
exit 0