aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--IkiWiki/Plugin/comments.pm9
-rwxr-xr-xMakefile.PL4
-rw-r--r--debian/changelog6
-rw-r--r--doc/ikiwiki-comment.mdwn31
-rwxr-xr-xikiwiki-comment.in50
6 files changed, 97 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 8528fe9be..77c0b3dcc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ html/*
ikiwiki.out
ikiwiki-transition.out
ikiwiki-calendar.out
+ikiwiki-comment.out
pm_to_blib
/MYMETA.json
/MYMETA.yml
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index c5177833f..d7666c852 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -507,8 +507,7 @@ sub editcomment ($$) {
$subject = "comment ".(num_comments($page, $config{srcdir}) + 1);
}
$content .= " subject=\"$subject\"\n";
-
- $content .= " date=\"" . strftime_utf8('%Y-%m-%dT%H:%M:%SZ', gmtime) . "\"\n";
+ $content .= " " . commentdate() . "\n";
my $editcontent = $form->field('editcontent');
$editcontent="" if ! defined $editcontent;
@@ -636,6 +635,10 @@ sub editcomment ($$) {
exit;
}
+sub commentdate () {
+ "date=\"" . strftime_utf8('%Y-%m-%dT%H:%M:%SZ', gmtime) . "\"";
+}
+
sub getavatar ($) {
my $user=shift;
return undef unless defined $user;
@@ -1012,7 +1015,7 @@ sub num_comments ($$) {
return int @comments;
}
-sub unique_comment_location ($$$$) {
+sub unique_comment_location ($$$;$) {
my $page=shift;
eval q{use Digest::MD5 'md5_hex'};
error($@) if $@;
diff --git a/Makefile.PL b/Makefile.PL
index 312a1482c..5feb304cf 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -24,7 +24,7 @@ MANDIR?=$(PREFIX)/share/man
tflag=$(shell if [ -n "$$NOTAINT" ] && [ "$$NOTAINT" != 1 ]; then printf -- "-T"; fi)
extramodules=$(shell if [ "$$PROFILE" = 1 ]; then printf -- "-d:NYTProf"; fi)
-outprogs=ikiwiki.out ikiwiki-transition.out ikiwiki-calendar.out
+outprogs=ikiwiki.out ikiwiki-transition.out ikiwiki-calendar.out ikiwiki-comment.out
scripts=ikiwiki-update-wikilist ikiwiki-makerepo
sysconfdir_scripts=ikiwiki-mass-rebuild ikiwiki-update-wikilist
shebang_scripts=$(shell $(FIND) . -type f \( -name '*.in' -o -name '*.cgi' -o -name '*.pm' -o -name '*.pm.example' -o -name '*.t' -o -name '*.setup' -o -name 'ikiwiki-mass-rebuild' -o -name 'ikiwiki-update-wikilist' -o -name 'gitremotes' -o -name 'mdwn2man' -o -name 'pm_filter' -o -name 'po2wiki' -o -name 'externaldemo' \))
@@ -53,6 +53,7 @@ extra_build: perl_shebangs $(outprogs) ikiwiki.setup docwiki sysconfdir
./mdwn2man ikiwiki-transition 1 doc/ikiwiki-transition.mdwn > ikiwiki-transition.man
./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
./mdwn2man ikiwiki-calendar 1 doc/ikiwiki-calendar.mdwn > ikiwiki-calendar.man
+ ./mdwn2man ikiwiki-comment 1 doc/ikiwiki-comment.mdwn > ikiwiki-comment.man
$(MAKE) -C po
$(PERL) -pi.bkp -e "s/Version:.*/Version: $(VER)/" ikiwiki.spec
rm -f ikiwiki.spec.bkp
@@ -156,6 +157,7 @@ extra_install: underlay_install
install -m 644 ikiwiki-transition.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-transition.1
install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-update-wikilist.1
install -m 644 ikiwiki-calendar.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-calendar.1
+ install -m 644 ikiwiki-comment.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-comment.1
install -d $(DESTDIR)$(MANDIR)/man8
install -m 644 ikiwiki-mass-rebuild.man $(DESTDIR)$(MANDIR)/man8/ikiwiki-mass-rebuild.8
diff --git a/debian/changelog b/debian/changelog
index 7dc576313..5b0b2f304 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ikiwiki (3.20141017) UNRELEASED; urgency=medium
+
+ * Added ikiwiki-comment program.
+
+ -- Joey Hess <joeyh@debian.org> Mon, 20 Oct 2014 12:04:49 -0400
+
ikiwiki (3.20141016) unstable; urgency=medium
[ Joey Hess ]
diff --git a/doc/ikiwiki-comment.mdwn b/doc/ikiwiki-comment.mdwn
new file mode 100644
index 000000000..22dbd6083
--- /dev/null
+++ b/doc/ikiwiki-comment.mdwn
@@ -0,0 +1,31 @@
+# NAME
+
+ikiwiki-comment - posts a comment
+
+# SYNOPSIS
+
+ikiwiki-comment page.mdwn
+
+# DESCRIPTION
+
+`ikiwiki-comment` creates a comment for the specified wiki page file,
+and opens your editor to edit it.
+
+Once you're done, it's up to you to add the comment to whatever version
+control system is being used by the wiki, and do any necessary pushing to
+publish it.
+
+Note that since ikiwiki-comment is not passed the configuration of
+the wiki it's acting on, it doesn't know what types of markup are
+available. Instead, it always removes one level of extensions from the
+file, so when run on a page.mdwn file, it puts the comment in page/
+
+The username field is set to the unix account name you're using.
+You may want to edit it to match the username you use elsewhere
+on the wiki.
+
+# AUTHOR
+
+Joey Hess <joey@ikiwiki.info>
+
+Warning: this page is automatically made into ikiwiki-comments's man page, edit with care
diff --git a/ikiwiki-comment.in b/ikiwiki-comment.in
new file mode 100755
index 000000000..ef2751eca
--- /dev/null
+++ b/ikiwiki-comment.in
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use lib '.'; # For use in nonstandard directory, munged by Makefile.
+use IkiWiki;
+use IkiWiki::Plugin::comments;
+
+sub usage () {
+ die gettext("usage: ikiwiki-comment pagefile"), "\n";
+}
+
+my $pagefile=shift || usage ();
+
+my $dir=IkiWiki::dirname($pagefile);
+$dir="." unless length $dir;
+my $page=IkiWiki::basename($pagefile);
+$page=~s/\.[^.]+$//;
+
+IkiWiki::Plugin::comments::checkconfig();
+my $comment_num=1 + IkiWiki::Plugin::comments::num_comments($page, $dir);
+
+my $username = getpwuid($<);
+if (! defined $username) { $username="" }
+
+my $comment="[[!comment format=mdwn\n";
+$comment.=" username=\"$username\"\n";
+$comment.=" subject=\"\"\"comment $comment_num\"\"\"\n";
+$comment.=" " . IkiWiki::Plugin::comments::commentdate() . "\n";
+$comment.=" content=\"\"\"\n\n\"\"\"]]\n";
+
+# This will yield a hash of the comment before it's edited,
+# but that's ok; the date provides sufficient entropy to avoid collisions,
+# and the hash of a comment does not need to match its actual content.
+# Doing it this way avoids needing to move the file to a final
+# location after it's edited.
+my $location=IkiWiki::Plugin::comments::unique_comment_location($page, $comment, $dir)."._comment";
+
+IkiWiki::writefile($location, $dir, $comment);
+
+my @editor="vi";
+if (-x "/usr/bin/editor") {
+ @editor="/usr/bin/editor";
+}
+if (exists $ENV{EDITOR}) {
+ @editor=split(' ', $ENV{EDITOR});
+}
+if (exists $ENV{VISUAL}) {
+@editor=split(' ', $ENV{VISUAL});
+}
+exec(@editor, "$dir/$location");