]> git.armaanb.net Git - bin.git/commitdiff
scoop-cgi: add logbot archive capabilities
authorArmaan Bhojwani <me@armaanb.net>
Mon, 21 Jun 2021 13:56:39 +0000 (09:56 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 21 Jun 2021 13:56:39 +0000 (09:56 -0400)
man/scoop-cgi.1.scd
scoop-cgi

index 75a051d516ceb5ed5989127c4297c5cbbdedd98c..812eaf1e10a461c22aa8f6b2d01ae551de203935 100644 (file)
@@ -9,7 +9,8 @@ Run with your favorite web server
 # DESCRIPTION
 june's scooper is a great, full-featured web interface to litterbox, however it
 is relatively complex. The plaintext output of scoop is good enough for me. This
-script just makes it accesible via the web. Requires scoop and litterbox.
+script just makes it accesible via the web. It can also support logbot
+archive files. Requires scoop and litterbox.
 
 # URL SCHEME
 */*
@@ -24,10 +25,16 @@ script just makes it accesible via the web. Requires scoop and litterbox.
        will work, however for portability, using ISO8601 (YYYY-MM-DD) is safest.
 
 # CONFIGURATION
-There are two config files that go in /etc/scoop-cgi/channels, and
-/etc/scoop-cgi/database. The channels file has a list of channels for which
-public logging is enabled, and the database file has the path to the litterbox
-database file.
+*/etc/scoop-cgi/channels*
+       Contains a newline delimited list of channels to be publicly logged
+       from scoop.
+
+*/etc/scoop-cgi/database*
+       Contains the path to the litterbox database file.
+
+*/etc/scoop-cgi/logbot*
+       Contains a newline delimited list of channels to be publicly logged
+       from logbot archive files in /srv/www/scoop-cgi/.
 
 # DRAWBACKS
 - No built-in search functionality. Combine with YaCy or scoot for a searching
index 8f56f3e37790bf4459fd09b6fbbb886ccead4af1..a54e15563e0a018abe3edae2311189c76db7c412 100755 (executable)
--- a/scoop-cgi
+++ b/scoop-cgi
@@ -12,6 +12,7 @@ acheam's IRC logs
 logged channels
 ---------------
 $(awk '{print "  * " $0}' /etc/scoop-cgi/channels)
+$(awk '{print "  * " $0}' /etc/scoop-cgi/logbot)
 
 url format
 ----------
@@ -25,7 +26,11 @@ it's in the public domain!"
                exit 0
 fi
 
-channel=$(grep -x "$channel" /etc/scoop-cgi/channels)
+time=$(echo "$PATH_INFO" | awk -F / -v date="$(date -I)" '
+{($3 != "" ) ? outp = $3 : outp = date; print outp}' | xargs date -I -d)
+
+all=$(cat /etc/scoop-cgi/channels /etc/scoop-cgi/logbot)
+channel=$(echo "$all" | grep -x "$channel")
 if [ -z "$channel" ]; then
                echo "Status: 404"
                printf "Content-type: text/plain\n\n"
@@ -33,11 +38,15 @@ if [ -z "$channel" ]; then
                exit 0
 fi
 
-time=$(echo "$PATH_INFO" | awk -F / '{print $3}' | xargs date -I -d)
-today=$(date -I)
-time=${time:-$today}
-db=$(cat /etc/scoop-cgi/database)
-
 printf "Content-type: text/plain\n\n"
-PAGER=/dev/tty scoop -d "$db" -p "$channel" -D "$time" -F "%Y-%m-%d %H:%M:%S" \
-               | awk '{$1=""; print substr($0, 2, length($0) - 1)}'
+
+if grep -qx "$channel" /etc/scoop-cgi/channels; then
+               db=$(cat /etc/scoop-cgi/database)
+               PAGER=/dev/tty scoop -d "$db" -p "$channel" -D "$time" \
+                                -F "%Y-%m-%d %H:%M:%S" \
+                               | awk '{$1=""; print substr($0, 2, length($0) - 1)}'
+elif grep -qx "$channel" /etc/scoop-cgi/logbot; then
+               awk -v date="$time" 'substr($1, 0, 11) == date {outp = substr($1, 12);
+for (i = 3; i <= NF; i++) outp = outp " " $i; print outp}' \
+                               "/srv/www/scoop-cgi/$channel"
+fi