1 ;; Copyright (C) 2016 Ian Kelling
3 ;; This program is free software: you can redistribute it and/or modify
4 ;; it under the terms of the GNU General Public License as published by
5 ;; the Free Software Foundation, either version 3 of the License, or
6 ;; (at your option) any later version.
8 ;; This program is distributed in the hope that it will be useful,
9 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ;; GNU General Public License for more details.
13 ;; You should have received a copy of the GNU General Public License
14 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 ;; generally, use m-x iankmod-start. c-u to run on local testing
18 ;; instance. Alternatively, run get-comments with whatever args,
19 ;; manually open /tmp/hcomments, then run (iankmod).
21 (defun iankmod-start (arg)
23 (setq iankmod-last-arg (if (equal arg '(4)) " -l" ""))
24 (let ((cmd (concat "/a/h/get-comments" iankmod-last-arg)))
25 (shell-command cmd "*messages*")
26 (find-file "/tmp/hcomments")
29 (defun iankmod-save ()
32 (let ((cmd (concat "/a/h/set-comments" iankmod-last-arg)))
33 (shell-command cmd "*messages*")))
36 (defun iankmod-set-state (state)
38 (re-search-forward "|" nil t)
39 (re-search-forward "[^|]*" nil t)
43 (defun iankmod-pick ()
45 (iankmod-set-state "picked"))
49 (iankmod-set-state "banned"))
51 ;; for test comments, or comments we just want to delete from the
52 ;; db for whatever reason.
53 (defun iankmod-delete ()
55 (iankmod-set-state "delete"))
57 (defun iankmod-moderate ()
59 (iankmod-set-state "moderated"))
61 (define-minor-mode iankmod
62 "Moderation of comments for iankelling.org"
63 :keymap (let ((map (make-sparse-keymap)))
64 (define-key map (kbd "p") 'iankmod-pick)
65 (define-key map (kbd "b") 'iankmod-ban)
66 (define-key map (kbd "m") 'iankmod-moderate)
67 (define-key map (kbd "x") 'iankmod-save)
68 (define-key map (kbd "d") 'iankmod-delete)