From e02cd51eb9c9ac3f84a84fefd567d7217e34bc38 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 26 Aug 2016 21:07:22 -0700 Subject: [PATCH 1/1] fixup remote comment admin --- README | 2 ++ _site/cgi/comment | 20 ++++++++++---------- feed.xml | 0 get-comments | 12 ++++++------ iank-mod.el | 7 +++++++ index.html | 2 +- set-comments | 10 +++++++--- 7 files changed, 33 insertions(+), 20 deletions(-) delete mode 100644 feed.xml diff --git a/README b/README index 017260f..4cbefb7 100644 --- a/README +++ b/README @@ -14,6 +14,8 @@ https://iankelling.org/git/?p=distro-functions;a=summary And some programs need to be in PATH: https://iankelling.org/git/?p=basic-https-conf;a=summary https://sallymae.club/git/?p=acme-tiny-wrapper;a=summary +chost from +https://iankelling.org/git/?p=fai;a=summary This repo does not include the repos under /git. In my own version, under /git are links to the .git dirs of the respective repos under the hardcoded directory in setup.sh: gitroot=/a/bin/githtml. These diff --git a/_site/cgi/comment b/_site/cgi/comment index b1e8796..4b14c3c 100755 --- a/_site/cgi/comment +++ b/_site/cgi/comment @@ -292,20 +292,27 @@ state != 'rate_limited' and state != 'suspect' SQL +$db.execute('insert into c values (NULL, ?, ?, ?, ?, ?)', + [state, + IP, + NOW, + GOTO, + COMMENT_TXT]) if date new_count = $db.execute(query + 'and date > ?',date) else new_count = $db.execute(query) end +new_count = new_count[0][0] if new_count == 1 require 'net/smtp' def send_email(opts={}) - opts[:to] ||= ENV['USER'] + opts[:to] ||= 'root' opts[:server] ||= 'localhost' - opts[:from] ||= ENV['USER'] - opts[:from_alias] ||= ENV['USER'] + opts[:from] ||= 'root' + opts[:from_alias] ||= 'root' opts[:subject] ||= "test subject" opts[:body] ||= "" @@ -324,13 +331,6 @@ END_OF_MESSAGE send_email :subject => 'new comments on iankelling.org' end -$db.execute('insert into c values (NULL, ?, ?, ?, ?, ?)', - [state, - IP, - NOW, - GOTO, - COMMENT_TXT]) - post(md_file) redir diff --git a/feed.xml b/feed.xml deleted file mode 100644 index e69de29..0000000 diff --git a/get-comments b/get-comments index 36bbe0d..54ea99a 100755 --- a/get-comments +++ b/get-comments @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # Copyright (C) 2016 Ian Kelling # This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd "${BASH_SOURCE%/*}/proposed-comments" all=false -shell="ssh iankelling.org" +shell="ssh $(chost iankelling.org)" while [[ $1 ]]; do case $1 in -a) all=true; shift ;; @@ -41,9 +41,9 @@ EOF fi # we may want to avoid rate limited posts here too. -sql="select * from c" +sql="select * from c;" if [[ $date ]]; then - date_clause=" where date > cast('$date' as real)" + sql+=" where date > cast('$date' as real)" fi -echo "$sql" -$s "$sql" > /tmp/hcomments +echo "executing: $sql" +$s > /tmp/hcomments <<<"$sql" diff --git a/iank-mod.el b/iank-mod.el index 26da79d..4faea5f 100644 --- a/iank-mod.el +++ b/iank-mod.el @@ -38,6 +38,12 @@ (interactive) (iankmod-set-state "banned")) +;; for test comments, or comments we just want to delete from the +;; db for whatever reason. +(defun iankmod-delete () + (interactive) + (iankmod-set-state "delete")) + (defun iankmod-moderate () (interactive) (iankmod-set-state "moderated")) @@ -49,4 +55,5 @@ (define-key map (kbd "b") 'iankmod-ban) (define-key map (kbd "m") 'iankmod-moderate) (define-key map (kbd "x") 'iankmod-save) + (define-key map (kbd "d") 'iankmod-delete) map)) diff --git a/index.html b/index.html index 049259f..5585e87 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,6 @@
  • git
  • ofswiki.org
  • resume
  • -
  • favorite stuff
  • +
  • favorite things
  • gpg key
  • diff --git a/set-comments b/set-comments index 5694629..b87f211 100755 --- a/set-comments +++ b/set-comments @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # Copyright (C) 2016 Ian Kelling # This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd "${BASH_SOURCE%/*}/proposed-comments" -shell="ssh iankelling.org" +shell="ssh -oStrictHostKeyChecking=no $(chost iankelling.org)" while [[ $1 ]]; do case $1 in -a) all=true; shift ;; @@ -32,6 +32,10 @@ s="$shell sqlite3 $PWD/comments.sqlite" grep -Eo '^[^|]+\|[^|]+' /tmp/hcomments | while IFS='|' read -r id state; do #echo "$id -- $state" # debug print - sqlite3 comments.sqlite "update c set state='$state' where id = '$id'" + if [[ $state == delete ]]; then + $s <<<"delete from c where id = '$id';" + else + $s <<<"update c set state='$state' where id = '$id';" + fi done $shell $PWD/../build.rb -- 2.30.2