diff options
Diffstat (limited to 'tears.cgi')
-rwxr-xr-x | tears.cgi | 42 |
1 files changed, 22 insertions, 20 deletions
@@ -3,8 +3,6 @@ <% VERSION=0.4 -BASE="/tears" -HOST="happiest.place" path=$(/opt/bin/pdecode <<<"${PATH_INFO#/}") @@ -43,7 +41,7 @@ qlink() { } redirect() { - echo -ne "Location: https://$HOST$1\r\n" + echo -ne "Location: $SCHEME$HOST$1\r\n" echo -ne "Status: 302\r\n" echo -ne "Content-Type: text/html; charset=utf-8\r\n\r\n" echo "٩(͡๏̯͡๏)۶>" @@ -104,6 +102,8 @@ meny() { echo "<!doctype html>" echo "<title>tears</title>" echo "<link href=$BASE/tears.css rel=stylesheet>" + echo "<script src=$BASE/date.js></script>" + echo "<script src=$BASE/sortable.js></script>" echo "<script src=$BASE/tears.js></script>" echo "<div id='meny'>" link "<pre>$(figlet -f threepoint tears)</pre>" "" @@ -124,13 +124,13 @@ meny() { liste() { n=$((${GET_n:-0} + 7)) - $finder -printf '%h\t%TT\t%f\n' | sort -r | head -$n | tail -7 | while read - do - ok=1 + finder="$finder -printf '%h\t%TT\t%f\n'" + while read; do d=$(cut -f 1 <<<"$REPLY") f=$(cut -f 3 <<<"$REPLY") - kort $d/$f - done + ok=1 + [ "$f" ] && kort $d/$f + done <<< $(eval $finder | sort -r | head -$n | tail -7) if [ -z "$ok" ]; then echo "<p><b>Ingen artikler</b>" else @@ -162,8 +162,8 @@ stikk() { skjema() { [ ! -f "$1" ] && echo "<p>finner ikke $1: <pre>$(xxd <<<$1)</pre>" && exit [ ! -w "$1" ] && echo "<p>du har ikke skrivetilgang" && exit - echo "<form method='post' action='$BASE/oppdater/$1'>" - lupin -f <$1 + echo "<form id=update-article method=post action='$BASE/oppdater/$1'>" + lupin -f $1 echo "<p><label>Stikkord:</label>" echo "<input type='text' name='stikkord' value='$(stikkord $1)'>" echo "<p>" @@ -172,13 +172,15 @@ skjema() { echo "<input name=publish type='submit' value='Publiser'>" [ -r "$1" ] && link "Vis" $(/opt/bin/pencode / <<<"vis/$1") preview echo "</form>" - echo "<p><b>$(info $1)</b>" + #echo "<p><b>$(info $1)</b>" } vis() { [ ! -f "$1" ] && echo "<p>finner ikke $1: <pre>$(xxd <<<$1)</pre>" && exit [ ! -r "$1" ] && echo "<p>du har ikke lesetilgang" && exit - lupin -h <$1 + echo "<article>" + lupin $1 | /opt/bin/refine + echo "</article>" } lagre() { @@ -188,7 +190,7 @@ lagre() { [ -f "artikler/$path/$slug.txt" ] && error "Artikkelen finnes allerede" umask 0000 mkdir -p "artikler/$path" - lupin -l -e >"artikler/$path/$slug.txt" + lupin -p -e - >"artikler/$path/$slug.txt" if [ -z "$POST_privat" ]; then chmod 660 "artikler/$path/$slug.txt" else @@ -212,20 +214,20 @@ oppdater() { [ -z "$POST_stikkord" ] && error "ingen stikkord" stikk "$1" "$POST_stikkord" - lupin -l -e >$1 + lupin -p -e - >$1 irc "$(whoami) redigerte $POST_title" [ -n "$POST_publish" ] && chmod o+r "$1" - pushd /home/bie/maker >/dev/null; sudo -uwww ./maker; popd >/dev/null + # pushd /home/bie/code/maker >/dev/null; ./maker; popd >/dev/null redirect "$BASE/rediger/$1" } kort() { IFS=/. read -r type y m d hhmm slug ext <<< "$1" - lupin -t -h <$1 + lupin -t $1 echo "<p class='x'>$(byline $1), $y/$m/$d" [ -r "$1" ] && echo "·" && link "vis" $(/opt/bin/pencode / <<<"vis/$1") [ -w "$1" ] && echo "·" && link "rediger" $(/opt/bin/pencode / <<<"rediger/$1") - lupin -s -h <$1 + lupin -s $1 } velkommen() { @@ -241,7 +243,7 @@ forbered() { echo "<input type=date name=publisert value=$(date +%Y-%m-%d) size=10>" echo "<p><label>*</label>" echo "<select name='type'>" - for type in lupin/*.lua; do + for type in blueprints/*.lua; do id=$(basename $type .lua) echo "<option value='$id'>$id</option>" done @@ -275,10 +277,10 @@ fi mappe="artikler" [ -n "$GET_stikkord" ] && mappe="stikkord/$GET_stikkord" kilde="$mappe/$(sed 's|-|/|g' <<<$GET_dato)" -finder="find -L $kilde -type f" +finder="find -L $kilde -type f -not -name '*~'" [ "$action" = gruppe ] && finder="$finder -group $args" [ "$action" = ditt ] && finder="$finder -user $REMOTE_USER" -[ "$REQUEST_METHOD" = GET ] && $finder | meny +[ "$REQUEST_METHOD" = GET ] && eval $finder | meny case $action in "") velkommen;; index.html|ditt|gruppe) liste;; |