Initial commit
This commit is contained in:
commit
0257b46c7f
27 changed files with 4211 additions and 0 deletions
44
bin/controller.rc
Executable file
44
bin/controller.rc
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/local/plan9/bin/rc
|
||||
|
||||
path=(. ./bin $PLAN9/bin /bin/ /usr/bin)
|
||||
ifs='/' { args = `{ echo -n $REQUEST_URI | sed -e 's/[^a-zA-Z_\-\/]//g' -e 's/\?.*//' } }
|
||||
args=`{echo $args | tr -d '
|
||||
'}
|
||||
cd ..
|
||||
|
||||
|
||||
# config
|
||||
body=index
|
||||
title=Title
|
||||
template=default
|
||||
sidebar=sidebar
|
||||
|
||||
. etc/initrc
|
||||
|
||||
if (! ~ $#args 0 && ! ~ $args '') {
|
||||
title=$args($#args)
|
||||
body=`{ echo -n $"args |sed 's, ,/,g' }
|
||||
}
|
||||
|
||||
l=tpl
|
||||
for ( i in $args ) {
|
||||
l = $l'/'$i
|
||||
if ( test -f $l/_config ) {
|
||||
. $l/_config
|
||||
}
|
||||
}
|
||||
|
||||
template=tpl/$template.tpl
|
||||
if (! ~ $sidebar 0) { sidebar=tpl/_inc/$sidebar.tpl }
|
||||
if (test -d tpl/$body) {
|
||||
body=$body/index
|
||||
}
|
||||
body=`{echo tpl/^$"body^.md | sed 's, ,/,' }
|
||||
|
||||
|
||||
template.awk $template | rc
|
||||
|
||||
echo '<pre>'
|
||||
#echo $"args
|
||||
#env
|
||||
|
||||
4
bin/gensitemaptxt.sh
Executable file
4
bin/gensitemaptxt.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
find . -name '*.md'|sed -e 's/\.md$//' -e 's,/index$,/,' -e 's,^\.,http://harmful.cat-v.org,'
|
||||
|
||||
1447
bin/markdown.pl
Executable file
1447
bin/markdown.pl
Executable file
File diff suppressed because it is too large
Load diff
55
bin/template.awk
Executable file
55
bin/template.awk
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/awk -f
|
||||
function pr(str) {
|
||||
if(lastc !~ "[{(]")
|
||||
gsub(/'/, "''", str)
|
||||
printf "%s", str
|
||||
}
|
||||
function trans(c) {
|
||||
printf "%s", end
|
||||
|
||||
lastc = c
|
||||
end = "\n"
|
||||
if(c == "%")
|
||||
end = ""
|
||||
else if(c == "(")
|
||||
printf "echo -n "
|
||||
else if(c ~ "[})]") {
|
||||
end = "'\n"
|
||||
printf "echo -n '"
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
lastc = "{"
|
||||
trans("}")
|
||||
}
|
||||
END {
|
||||
print end
|
||||
}
|
||||
|
||||
/^%/ && $0 !~ /^%[{()}%]/ && lastc !~ /[({]/ {
|
||||
trans("%")
|
||||
print substr($0, 2)
|
||||
next
|
||||
}
|
||||
{
|
||||
if(lastc == "%")
|
||||
trans("}")
|
||||
n = split($0, a, "%")
|
||||
pr(a[1])
|
||||
for(i=2; i<=n; i++) {
|
||||
c = substr(a[i], 1, 1)
|
||||
rest = substr(a[i], 2)
|
||||
|
||||
if((lastc !~ "[({]" && c ~ "[({]") ||
|
||||
(lastc == "{" && c == "}") ||
|
||||
(lastc == "(" && c == ")"))
|
||||
trans(c)
|
||||
else if(c == "%")
|
||||
pr("%")
|
||||
else
|
||||
pr("%" c)
|
||||
pr(rest)
|
||||
}
|
||||
pr("\n")
|
||||
}
|
||||
39
bin/urldecode.awk
Executable file
39
bin/urldecode.awk
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/awk -f
|
||||
BEGIN {
|
||||
hextab ["0"] = 0; hextab ["8"] = 8;
|
||||
hextab ["1"] = 1; hextab ["9"] = 9;
|
||||
hextab ["2"] = 2; hextab ["A"] = hextab ["a"] = 10
|
||||
hextab ["3"] = 3; hextab ["B"] = hextab ["b"] = 11;
|
||||
hextab ["4"] = 4; hextab ["C"] = hextab ["c"] = 12;
|
||||
hextab ["5"] = 5; hextab ["D"] = hextab ["d"] = 13;
|
||||
hextab ["6"] = 6; hextab ["E"] = hextab ["e"] = 14;
|
||||
hextab ["7"] = 7; hextab ["F"] = hextab ["f"] = 15;
|
||||
}
|
||||
{
|
||||
decoded = ""
|
||||
i = 1
|
||||
len = length ($0)
|
||||
while ( i <= len ) {
|
||||
c = substr ($0, i, 1)
|
||||
if ( c == "%" ) {
|
||||
if ( i+2 <= len ) {
|
||||
c1 = substr ($0, i+1, 1)
|
||||
c2 = substr ($0, i+2, 1)
|
||||
if ( hextab [c1] == "" || hextab [c2] == "" ) {
|
||||
print "WARNING: invalid hex encoding: %" c1 c2 | "cat >&2"
|
||||
} else {
|
||||
code = 0 + hextab [c1] * 16 + hextab [c2] + 0
|
||||
c = sprintf ("%c", code)
|
||||
i = i + 2
|
||||
}
|
||||
} else {
|
||||
print "WARNING: invalid % encoding: " substr ($0, i, len - i)
|
||||
}
|
||||
} else if ( c == "+" ) {
|
||||
c = " "
|
||||
}
|
||||
decoded = decoded c
|
||||
++i
|
||||
}
|
||||
print decoded
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue