aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/CGI.pm13
-rw-r--r--IkiWiki/Rcs/Stub.pm7
-rw-r--r--IkiWiki/Rcs/git.pm41
-rw-r--r--IkiWiki/Rcs/mercurial.pm4
-rw-r--r--IkiWiki/Rcs/monotone.pm48
-rw-r--r--IkiWiki/Rcs/svn.pm38
-rw-r--r--IkiWiki/Rcs/tla.pm45
-rw-r--r--IkiWiki/UserInfo.pm87
-rw-r--r--IkiWiki/Wrapper.pm16
9 files changed, 3 insertions, 296 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 5062a448f..55ee5d86a 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -242,9 +242,6 @@ sub cgi_prefs ($$) { #{{{
$form->field(name => "do", type => "hidden");
$form->field(name => "email", size => 50, fieldset => "preferences");
- $form->field(name => "subscriptions", size => 50,
- fieldset => "preferences",
- comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")");
$form->field(name => "banned_users", size => 50,
fieldset => "admin");
@@ -256,8 +253,6 @@ sub cgi_prefs ($$) { #{{{
if (! $form->submitted) {
$form->field(name => "email", force => 1,
value => userinfo_get($user_name, "email"));
- $form->field(name => "subscriptions", force => 1,
- value => userinfo_get($user_name, "subscriptions"));
if (is_admin($user_name)) {
$form->field(name => "banned_users", force => 1,
value => join(" ", get_banned_users()));
@@ -274,11 +269,9 @@ sub cgi_prefs ($$) { #{{{
return;
}
elsif ($form->submitted eq 'Save Preferences' && $form->validate) {
- foreach my $field (qw(email subscriptions)) {
- if (defined $form->field($field)) {
- userinfo_set($user_name, $field, $form->field($field)) ||
- error("failed to set $field");
- }
+ if (defined $form->field('email')) {
+ userinfo_set($user_name, 'email', $form->field('email')) ||
+ error("failed to set email");
}
if (is_admin($user_name)) {
set_banned_users(grep { ! is_admin($_) }
diff --git a/IkiWiki/Rcs/Stub.pm b/IkiWiki/Rcs/Stub.pm
index ab80a9a47..df347f6a9 100644
--- a/IkiWiki/Rcs/Stub.pm
+++ b/IkiWiki/Rcs/Stub.pm
@@ -57,13 +57,6 @@ sub rcs_recentchanges ($) {
# }
}
-sub rcs_notify () {
- # This function is called when a change is committed to the wiki,
- # and ikiwiki is running as a post-commit hook from the RCS.
- # It should examine the repository to somehow determine what pages
- # changed, and then send emails to users subscribed to those pages.
-}
-
sub rcs_getctime ($) {
# Optional, used to get the page creation time from the RCS.
error gettext("getctime not implemented");
diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm
index f70582136..26a6f4266 100644
--- a/IkiWiki/Rcs/git.pm
+++ b/IkiWiki/Rcs/git.pm
@@ -419,47 +419,6 @@ sub rcs_recentchanges ($) { #{{{
return @rets;
} #}}}
-sub rcs_notify () { #{{{
- # Send notification mail to subscribed users.
- #
- # In usual Git usage, hooks/update script is presumed to send
- # notification mails (see git-receive-pack(1)). But we prefer
- # hooks/post-update to support IkiWiki commits coming from a
- # cloned repository (through command line) because post-update
- # is called _after_ each ref in repository is updated (update
- # hook is called _before_ the repository is updated).
- #
- # Here, we rely on a simple fact: we can extract all parts of the
- # notification content by parsing the "HEAD" commit.
-
- my $ci = git_commit_info('HEAD');
- return if !defined $ci;
-
- my @changed_pages = map { $_->{'file'} } @{ $ci->{'details'} };
-
- my ($user, $message);
- if (@{ $ci->{'comment'} }[0] =~ m/$config{web_commit_regexp}/) {
- $user = defined $2 ? $2 : $3;
- $message = $4;
- }
- else {
- $user = $ci->{'author_username'};
- $message = join "\n", @{ $ci->{'comment'} };
- }
-
- my $sha1 = $ci->{'sha1'};
-
- require IkiWiki::UserInfo;
- send_commit_mails(
- sub {
- $message;
- },
- sub {
- join "\n", run_or_die('git', 'diff', "${sha1}^", $sha1);
- }, $user, @changed_pages
- );
-} #}}}
-
sub rcs_getctime ($) { #{{{
my $file=shift;
# Remove srcdir prefix
diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm
index 13a88379c..db6a396ac 100644
--- a/IkiWiki/Rcs/mercurial.pm
+++ b/IkiWiki/Rcs/mercurial.pm
@@ -151,10 +151,6 @@ sub rcs_recentchanges ($) { #{{{
return @ret;
} #}}}
-sub rcs_notify () { #{{{
- # TODO
-} #}}}
-
sub rcs_getctime ($) { #{{{
my ($file) = @_;
diff --git a/IkiWiki/Rcs/monotone.pm b/IkiWiki/Rcs/monotone.pm
index b48ac92db..0ae2c1a32 100644
--- a/IkiWiki/Rcs/monotone.pm
+++ b/IkiWiki/Rcs/monotone.pm
@@ -452,54 +452,6 @@ sub rcs_recentchanges ($) { #{{{
return @ret;
} #}}}
-sub rcs_notify () { #{{{
- debug("The monotone rcs_notify function is currently untested. Use at own risk!");
-
- if (! exists $ENV{REV}) {
- error(gettext("REV is not set, not running from mtn post-commit hook, cannot send notifications"));
- }
- if ($ENV{REV} !~ m/($sha1_pattern)/) { # sha1 is untainted now
- error(gettext("REV is not a valid revision identifier, cannot send notifications"));
- }
- my $rev = $1;
-
- check_config();
-
- my $automator = Monotone->new();
- $automator->open(undef, $config{mtnrootdir});
-
- my $certs = [read_certs($automator, $rev)];
- my $user;
- my $message;
- my $when;
-
- foreach my $cert (@$certs) {
- if ($cert->{signature} eq "ok" && $cert->{trust} eq "trusted") {
- if ($cert->{name} eq "author") {
- $user = $cert->{value};
- } elsif ($cert->{name} eq "date") {
- $when = $cert->{value};
- } elsif ($cert->{name} eq "changelog") {
- $message = $cert->{value};
- }
- }
- }
-
- my @changed_pages = get_changed_files($automator, $rev);
-
- $automator->close();
-
- require IkiWiki::UserInfo;
- send_commit_mails(
- sub {
- return $message;
- },
- sub {
- `mtn --root=$config{mtnrootdir} au content_diff -r $rev`;
- },
- $user, @changed_pages);
-} #}}}
-
sub rcs_getctime ($) { #{{{
my $file=shift;
diff --git a/IkiWiki/Rcs/svn.pm b/IkiWiki/Rcs/svn.pm
index 075f8da5a..f7d2242f0 100644
--- a/IkiWiki/Rcs/svn.pm
+++ b/IkiWiki/Rcs/svn.pm
@@ -217,44 +217,6 @@ sub rcs_recentchanges ($) { #{{{
return @ret;
} #}}}
-sub rcs_notify () { #{{{
- if (! exists $ENV{REV}) {
- error(gettext("REV is not set, not running from svn post-commit hook, cannot send notifications"));
- }
- my $rev=int(possibly_foolish_untaint($ENV{REV}));
-
- my $user=`svnlook author $config{svnrepo} -r $rev`;
- chomp $user;
-
- my $message=`svnlook log $config{svnrepo} -r $rev`;
- if ($message=~/$config{web_commit_regexp}/) {
- $user=defined $2 ? "$2" : "$3";
- $message=$4;
- }
-
- my @changed_pages;
- foreach my $change (`svnlook changed $config{svnrepo} -r $rev`) {
- chomp $change;
- if (length $config{svnpath}) {
- if ($change =~ /^[A-Z]+\s+\Q$config{svnpath}\E\/(.*)/) {
- push @changed_pages, $1;
- }
- }
- else {
- push @changed_pages, $change;
- }
- }
-
- require IkiWiki::UserInfo;
- send_commit_mails(
- sub {
- return $message;
- },
- sub {
- `svnlook diff $config{svnrepo} -r $rev --no-diff-deleted`;
- }, $user, @changed_pages);
-} #}}}
-
sub rcs_getctime ($) { #{{{
my $file=shift;
diff --git a/IkiWiki/Rcs/tla.pm b/IkiWiki/Rcs/tla.pm
index 15824ffaf..ecc561bde 100644
--- a/IkiWiki/Rcs/tla.pm
+++ b/IkiWiki/Rcs/tla.pm
@@ -160,51 +160,6 @@ sub rcs_recentchanges ($) {
return @ret;
}
-sub rcs_notify () { #{{{
- # FIXME: Not set
- if (! exists $ENV{ARCH_VERSION}) {
- error("ARCH_VERSION is not set, not running from tla post-commit hook, cannot send notifications");
- }
- my $rev=int(possibly_foolish_untaint($ENV{REV}));
-
- eval q{use Mail::Header};
- error($@) if $@;
- open(LOG, $ENV{"ARCH_LOG"});
- my $head = Mail::Header->new(\*LOG);
- close(LOG);
-
- my $user = $head->get("Creator");
-
- my $newfiles = $head->get("New-files");
- my $modfiles = $head->get("Modified-files");
- my $remfiles = $head->get("Removed-files");
-
- my @changed_pages = grep { !/(^.*\/)?\.arch-ids\/.*\.id$/ }
- split(/ /, "$newfiles $modfiles $remfiles .arch-ids/fake.id");
-
- require IkiWiki::UserInfo;
- send_commit_mails(
- sub {
- my $message = $head->get("Summary");
- if ($message =~ /$config{web_commit_regexp}/) {
- $user=defined $2 ? "$2" : "$3";
- $message=$4;
- }
- },
- sub {
- my $logs = `tla logs -d $config{srcdir}`;
- my @changesets = reverse split(/\n/, $logs);
- my $i;
-
- for($i=0;$i<$#changesets;$i++) {
- last if $changesets[$i] eq $rev;
- }
-
- my $revminusone = $changesets[$i+1];
- `tla diff -d $ENV{ARCH_TREE_ROOT} $revminusone`;
- }, $user, @changed_pages);
-} #}}}
-
sub rcs_getctime ($) { #{{{
my $file=shift;
eval q{use Date::Parse};
diff --git a/IkiWiki/UserInfo.pm b/IkiWiki/UserInfo.pm
index cfc27609d..2ffc51c55 100644
--- a/IkiWiki/UserInfo.pm
+++ b/IkiWiki/UserInfo.pm
@@ -92,91 +92,4 @@ sub set_banned_users (@) { #{{{
return userinfo_store($userinfo);
} #}}}
-sub commit_notify_list ($@) { #{{{
- my $committer=shift;
- my @pages = map pagename($_), @_;
-
- my @ret;
- my $userinfo=userinfo_retrieve();
- foreach my $user (keys %{$userinfo}) {
- next if $user eq $committer;
- if (exists $userinfo->{$user}->{subscriptions} &&
- length $userinfo->{$user}->{subscriptions} &&
- exists $userinfo->{$user}->{email} &&
- length $userinfo->{$user}->{email} &&
- grep { pagespec_match($_,
- $userinfo->{$user}->{subscriptions},
- user => $committer) }
- map pagename($_), @_) {
- push @ret, $userinfo->{$user}->{email};
- }
- }
- return @ret;
-} #}}}
-
-sub send_commit_mails ($$$@) { #{{{
- my $messagesub=shift;
- my $diffsub=shift;
- my $user=shift;
- my @changed_pages=@_;
-
- return unless @changed_pages;
-
- my @email_recipients=commit_notify_list($user, @changed_pages);
- if (@email_recipients) {
- # TODO: if a commit spans multiple pages, this will send
- # subscribers a diff that might contain pages they did not
- # sign up for. Should separate the diff per page and
- # reassemble into one mail with just the pages subscribed to.
- my $diff=$diffsub->();
- my $message=$messagesub->();
-
- my $pagelist;
- if (@changed_pages > 2) {
- $pagelist="$changed_pages[0] $changed_pages[1] ...";
- }
- else {
- $pagelist.=join(" ", @changed_pages);
- }
- #translators: The three variables are the name of the wiki,
- #translators: A list of one or more pages that were changed,
- #translators: And the name of the user making the change.
- #translators: This is used as the subject of a commit email.
- my $subject=sprintf(gettext("update of %s's %s by %s"),
- $config{wikiname}, $pagelist, $user);
-
- my $template=template("notifymail.tmpl");
- $template->param(
- wikiname => $config{wikiname},
- diff => $diff,
- user => $user,
- message => $message,
- );
-
- # Daemonize, in case the mail sending takes a while.
- defined(my $pid = fork) or error("Can't fork: $!");
- return if $pid;
- setsid() or error("Can't start a new session: $!");
- chdir '/';
- open STDIN, '/dev/null';
- open STDOUT, '>/dev/null';
- open STDERR, '>&STDOUT' or error("Can't dup stdout: $!");
-
- unlockwiki(); # don't need to keep a lock on the wiki
-
- eval q{use Mail::Sendmail};
- error($@) if $@;
- foreach my $email (@email_recipients) {
- sendmail(
- To => $email,
- From => "$config{wikiname} <$config{adminemail}>",
- Subject => $subject,
- Message => $template->output,
- );
- }
-
- exit 0; # daemon process done
- }
-} #}}}
-
1
diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm
index 2103ea53a..90a4c46c7 100644
--- a/IkiWiki/Wrapper.pm
+++ b/IkiWiki/Wrapper.pm
@@ -36,22 +36,6 @@ sub gen_wrapper () { #{{{
addenv("$var", s);
EOF
}
- if ($config{rcs} eq "svn" && $config{notify}) {
- # Support running directly as hooks/post-commit by passing
- # $2 in REV in the environment.
- $envsave.=<<"EOF"
- if (argc == 3)
- addenv("REV", argv[2]);
- else if ((s=getenv("REV")))
- addenv("REV", s);
-EOF
- }
- if ($config{rcs} eq "tla" && $config{notify}) {
- $envsave.=<<"EOF"
- if ((s=getenv("ARCH_VERSION")))
- addenv("ARCH_VERSION", s);
-EOF
- }
$Data::Dumper::Indent=0; # no newlines
my $configstring=Data::Dumper->Dump([\%config], ['*config']);