From 9f25e3436b2b918845acbd8cf2ff2d358e0ea105 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 28 Jan 2008 22:57:22 -0500 Subject: change rcs_recentchanges when to absolute, not relative, time No point in using a relative time value in rcs_recentchanges. Different consumers of the info want different things. --- IkiWiki/CGI.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 65a1d7fa0..03c448923 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -100,7 +100,7 @@ sub cgi_recentchanges ($) { #{{{ my $changelog=[rcs_recentchanges(100)]; foreach my $change (@$changelog) { - $change->{when} = concise(ago($change->{when})); + $change->{when} = concise(ago(time - $change->{when})); $change->{user} = userlink($change->{user}); -- cgit v1.2.3 From 29f3082772095030895111f199d6420ef1835250 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 28 Jan 2008 22:58:31 -0500 Subject: move userlink to IkiWiki.pm I have a plugin that needs to use userlink. --- IkiWiki.pm | 28 ++++++++++++++++++++++++++++ IkiWiki/CGI.pm | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 46060c1b2..15402211f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -609,6 +609,34 @@ sub htmllink ($$$;@) { #{{{ return "$linktext"; } #}}} +sub userlink ($) { #{{{ + my $user=shift; + + eval q{use CGI 'escapeHTML'}; + error($@) if $@; + if ($user =~ m!^https?://! && + eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) { + # Munge user-urls, as used by eg, OpenID. + my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user); + my $display=$oid->display; + # Convert "user.somehost.com" to "user [somehost.com]". + if ($display !~ /\[/) { + $display=~s/^(.*?)\.([^.]+\.[a-z]+)$/$1 [$2]/; + } + # Convert "http://somehost.com/user" to "user [somehost.com]". + if ($display !~ /\[/) { + $display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/; + } + $display=~s!^https?://!!; # make sure this is removed + return "".escapeHTML($display).""; + } + else { + return htmllink("", "", escapeHTML( + length $config{userdir} ? $config{userdir}."/".$user : $user + ), noimageinline => 1); + } +} #}}} + sub htmlize ($$$) { #{{{ my $page=shift; my $type=shift; diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 03c448923..5de90e1a8 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -726,32 +726,4 @@ sub cgi (;$$) { #{{{ } } #}}} -sub userlink ($) { #{{{ - my $user=shift; - - eval q{use CGI 'escapeHTML'}; - error($@) if $@; - if ($user =~ m!^https?://! && - eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) { - # Munge user-urls, as used by eg, OpenID. - my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user); - my $display=$oid->display; - # Convert "user.somehost.com" to "user [somehost.com]". - if ($display !~ /\[/) { - $display=~s/^(.*?)\.([^.]+\.[a-z]+)$/$1 [$2]/; - } - # Convert "http://somehost.com/user" to "user [somehost.com]". - if ($display !~ /\[/) { - $display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/; - } - $display=~s!^https?://!!; # make sure this is removed - return "".escapeHTML($display).""; - } - else { - return htmllink("", "", escapeHTML( - length $config{userdir} ? $config{userdir}."/".$user : $user - ), noimageinline => 1); - } -} #}}} - 1 -- cgit v1.2.3 From 0d2894711c6aeadcee0d4f2799a0956f7beed499 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 28 Jan 2008 23:08:48 -0500 Subject: support for internal-use page types If a page type starts with an underscore, hide it from the list of page types in the edit form, and don't allow editing pages of that type. This allows for plugins to add page types for internal use. --- IkiWiki/CGI.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 5de90e1a8..5062a448f 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -341,7 +341,7 @@ sub cgi_editpage ($$) { #{{{ if (exists $pagesources{$page} && $form->field("do") ne "create") { $file=$pagesources{$page}; $type=pagetype($file); - if (! defined $type) { + if (! defined $type || $type=~/^_/) { error(sprintf(gettext("%s is not an editable page"), $page)); } if (! $form->submitted) { @@ -470,7 +470,8 @@ sub cgi_editpage ($$) { #{{{ my @page_types; if (exists $hooks{htmlize}) { - @page_types=keys %{$hooks{htmlize}}; + @page_types=grep { !/^_/ } + keys %{$hooks{htmlize}}; } $form->tmpl_param("page_select", 1); -- cgit v1.2.3 From d7fdd04b5a113b6dded40cb79b670b16570c11b3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 00:36:58 -0500 Subject: * Removed support for sending commit notification mails. Along with it went the svnrepo and notify settings, though both will be ignored if left in setup files. --- IkiWiki.pm | 2 - IkiWiki/CGI.pm | 13 +--- IkiWiki/Rcs/Stub.pm | 7 -- IkiWiki/Rcs/git.pm | 41 ---------- IkiWiki/Rcs/mercurial.pm | 4 - IkiWiki/Rcs/monotone.pm | 48 ------------ IkiWiki/Rcs/svn.pm | 38 ---------- IkiWiki/Rcs/tla.pm | 45 ----------- IkiWiki/UserInfo.pm | 87 ---------------------- IkiWiki/Wrapper.pm | 16 ---- debian/changelog | 3 + doc/bugs/git_mail_notification_race.mdwn | 2 + doc/features.mdwn | 7 +- doc/ikiwiki.setup | 3 - doc/index/discussion.mdwn | 3 + doc/rcs/monotone.mdwn | 1 - doc/setup.mdwn | 3 +- ...e_to_this_page__34___checkbox_on_edit_form.mdwn | 6 +- doc/todo/bzr.mdwn | 2 + doc/todo/mercurial.mdwn | 2 +- doc/usage.mdwn | 10 --- doc/wikitemplates.mdwn | 3 - docwiki.setup | 7 +- ikiwiki.in | 8 +- t/svn.t | 9 ++- templates/notifymail.tmpl | 4 - 26 files changed, 33 insertions(+), 341 deletions(-) delete mode 100644 templates/notifymail.tmpl (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index b326dbdb8..2c3ddac23 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -62,7 +62,6 @@ sub defaultconfig () { #{{{ cgi => 0, post_commit => 0, rcs => '', - notify => 0, url => '', cgiurl => '', historyurl => '', @@ -76,7 +75,6 @@ sub defaultconfig () { #{{{ w3mmode => 0, wrapper => undef, wrappermode => undef, - svnrepo => undef, svnpath => "trunk", gitorigin_branch => "origin", gitmaster_branch => "master", 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']); diff --git a/debian/changelog b/debian/changelog index b57ef1178..47273ea94 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,9 @@ ikiwiki (2.21) UNRELEASED; urgency=low function. * Pages with extensions starting with "_" are internal-use, and will not be rendered or web-edited. + * Removed support for sending commit notification mails. Along with it went + the svnrepo and notify settings, though both will be ignored if left in + setup files. -- Joey Hess Fri, 11 Jan 2008 15:09:37 -0500 diff --git a/doc/bugs/git_mail_notification_race.mdwn b/doc/bugs/git_mail_notification_race.mdwn index 3538b0764..58bd82325 100644 --- a/doc/bugs/git_mail_notification_race.mdwn +++ b/doc/bugs/git_mail_notification_race.mdwn @@ -1,3 +1,5 @@ +[[done]] (in this branch); fixed removing email notification support! + I was suprised to receive two mails from ikiwiki about one web edit: 1 F Oct 30 To joey+ikiwiki update of ikiwiki's plugins/contrib/gallery.mdwn by http://arpitjain11.myopenid.com/ diff --git a/doc/features.mdwn b/doc/features.mdwn index a7b5c19ab..42eede916 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -127,7 +127,7 @@ with that there's no new commit marker syntax to learn. Nearly the definition of a wiki, although perhaps ikiwiki challenges how much of that web gunk a wiki really needs. These features are optional -and can be enabled by enabling [[CGI]]. +and can be enabled by enabling [[CGI]] and a [[Revision_Control_Systems|rcs]]. ### User registration @@ -161,11 +161,6 @@ Well, sorta. Rather than implementing YA history browser, it can link to ikiwiki can use the [[HyperEstraier]] search engine to add powerful full text search capabilities to your wiki. -### Commit mails - -ikiwiki can be configured to send you commit mails with diffs of changes -to selected pages. - ### [[w3mmode]] Can be set up so that w3m can be used to browse a wiki and edit pages diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 44cb35425..c9616e849 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -23,7 +23,6 @@ use IkiWiki::Setup::Standard { #rcs => "svn", #historyurl => "http://svn.example.org/trunk/[[file]]", #diffurl => "http://svn.example.org/trunk/[[file]]?root=wiki&r1=[[r1]]&r2=[[r2]]", - #svnrepo => "/svn/wiki", #svnpath => "trunk", # Git stuff. @@ -72,8 +71,6 @@ use IkiWiki::Setup::Standard { # # what you want. # wrapper => "/svn/wikirepo/hooks/post-commit", # wrappermode => "04755", - # # Enable mail notifications of commits. - # notify => 1, # # Log to syslog since svn post-commit hooks # # hide output and errors. # syslog => 1, diff --git a/doc/index/discussion.mdwn b/doc/index/discussion.mdwn index d5a48f282..4cf38e9cb 100644 --- a/doc/index/discussion.mdwn +++ b/doc/index/discussion.mdwn @@ -405,6 +405,9 @@ I'm playing around with various ways that I can use subversion with ikiwiki. > away without running the post-commit wrapper on commit, and all you lose > is the ability to send commit notification emails. +> (And now that [[recentchanges]] includes rss, you can just subscribe to +> that, no need to worry about commit notification emails anymore.) + * Is it possible / sensible to have ikiwiki share a subversion repository with other data (either completely unrelated files or another ikiwiki instance)? This works in part but again the post-commit hook seems problematic. --[[AdamShand]] diff --git a/doc/rcs/monotone.mdwn b/doc/rcs/monotone.mdwn index d79381571..1d3cd2bc4 100644 --- a/doc/rcs/monotone.mdwn +++ b/doc/rcs/monotone.mdwn @@ -10,7 +10,6 @@ The module is available from the monotone source repository at: Monotone support works, but there are still a few minor missing bits (listed here so they are not forgotten): * At the moment there are no links to display diffs between revisions. It shouldn't be hard to add links to a [ViewMTN](http://grahame.angrygoats.net/moinmoin/ViewMTN) instance, but it hasn't been done yet. -* The [[post-commit]] hook support, so that Ikiwiki sends change notifications when people commit using Monotone rather than the web interface, is partially implemented and untested. * Documentation (this page) could be improved. There is also a mismatch between the way Ikiwiki handles conflicts and the way Monotone handles conflicts. At present, if there is a conflict, then Ikiwiki will commit a revision with conflict markers before presenting it to the user. This is ugly, but there is no clean way to fix it at present. diff --git a/doc/setup.mdwn b/doc/setup.mdwn index af1adc235..9bf7f7c7b 100644 --- a/doc/setup.mdwn +++ b/doc/setup.mdwn @@ -180,8 +180,7 @@ about using the git repositories. Once your wiki is checked in to the revision control system, you should configure ikiwiki to use revision control. Edit your ikiwiki.setup, and uncomment the lines for the revision control system -you chose to use. Be sure to set `svnrepo` to $REPOSITORY, if using -subversion. Uncomment the block for the wrapper for your revision +you chose to use. Uncomment the block for the wrapper for your revision control system, and configure the wrapper path in that block appropriately (for Git, it should be `$REPOSITORY/hooks/post-update`). diff --git a/doc/todo/__34__subscribe_to_this_page__34___checkbox_on_edit_form.mdwn b/doc/todo/__34__subscribe_to_this_page__34___checkbox_on_edit_form.mdwn index 70970c6cc..dc456bbbf 100644 --- a/doc/todo/__34__subscribe_to_this_page__34___checkbox_on_edit_form.mdwn +++ b/doc/todo/__34__subscribe_to_this_page__34___checkbox_on_edit_form.mdwn @@ -3,4 +3,8 @@ user to add a page to their subscribed list while editing. This would prove particularly useful for [[todo]] and [bug](bugs) items, to allow users to receive notifications for activity on their reports. ---[[JoshTriplett]] \ No newline at end of file +--[[JoshTriplett]] + +I went and removed commit notification mails entirely, the idea is that you +subscribe using the [[RecentChanges]] rss feed, and filter it on your end. +Good enough? --[[Joey]] diff --git a/doc/todo/bzr.mdwn b/doc/todo/bzr.mdwn index 9650b9da8..51ae08146 100644 --- a/doc/todo/bzr.mdwn +++ b/doc/todo/bzr.mdwn @@ -4,6 +4,8 @@ rcs_commit was only changed to work around bzr's lack of a switch to set the username). bzr_log could probably be written better by someone better at perl, and rcs_getctime and rcs_notify aren't written at all. --[[bma]] +(rcs_notify is not needed in this branch --[[Joey]]) + #!/usr/bin/perl use warnings; diff --git a/doc/todo/mercurial.mdwn b/doc/todo/mercurial.mdwn index e5de93521..608c7d681 100644 --- a/doc/todo/mercurial.mdwn +++ b/doc/todo/mercurial.mdwn @@ -1,6 +1,6 @@ * Need to get post commit hook working (or an example of how to use it.) * See below. --[[bma]] -* rcs_notify is not implemented +* rcs_notify is not implemented (not needed in this branch --[[Joey]]) * Is the code sufficiently robust? It just warns when mercurial fails. * When rcs_commit is called with a $user that is an openid, it will be passed through to mercurial -u. Will mercurial choke on this? diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 136e969c2..354e266f1 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -133,11 +133,6 @@ configuration options of their own. access controlled by a group, it makes sense for the ikiwiki wrappers to run setgid to that group. -* --notify, --no-notify - - Enable email notification of commits. This should be used when running - ikiwiki as a [[post-commit]] hook. - * --rcs=svn|git|.., --no-rcs Enable or disable use of a [[revision_control_system|rcs]]. @@ -151,11 +146,6 @@ configuration options of their own. No revision control is enabled by default. -* --svnrepo /svn/wiki - - Specify the location of the svn repository for the wiki. This is required - for using --notify with [[Subversion|rcs/svn]]. - * --svnpath trunk Specify the path inside your svn repository where the wiki is located. diff --git a/doc/wikitemplates.mdwn b/doc/wikitemplates.mdwn index 8a579e183..b8341b637 100644 --- a/doc/wikitemplates.mdwn +++ b/doc/wikitemplates.mdwn @@ -11,9 +11,6 @@ located in /usr/share/ikiwiki/templates by default. * `misc.tmpl` - Generic template used for any page that doesn't have a custom template. * `editpage.tmpl` - Create/edit page. -* `notifymail.tmpl` - Not a html template, this is used to - generate change notification mails for users who have subscribed to - changes to a page. * `recentchanges.tmpl` - Used to generate a RecentChanges table with inline. * `change.tmpl` - Used to create a page describing a change made to the wiki. * `passwordmail.tmpl` - Not a html template, this is used to diff --git a/docwiki.setup b/docwiki.setup index 0a6a86678..5793d87bf 100644 --- a/docwiki.setup +++ b/docwiki.setup @@ -15,5 +15,10 @@ use IkiWiki::Setup::Standard { syslog => 0, userdir => "users", usedirs => 0, - add_plugins => [qw{goodstuff version haiku polygen fortune}], + rcs => 'git', + rss => 1, + cgiurl => "http://ikiwiki.info/ikiwiki.cgi", + url => "http://ikiwiki.info", + add_plugins => [qw{goodstuff version haiku polygen fortune + recentchanges }], } diff --git a/ikiwiki.in b/ikiwiki.in index 2aeaf94ec..9d1f6b520 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -36,12 +36,10 @@ sub getconfig () { #{{{ "cgi!" => \$config{cgi}, "discussion!" => \$config{discussion}, "w3mmode!" => \$config{w3mmode}, - "notify!" => \$config{notify}, "url=s" => \$config{url}, "cgiurl=s" => \$config{cgiurl}, "historyurl=s" => \$config{historyurl}, "diffurl=s" => \$config{diffurl}, - "svnrepo" => \$config{svnrepo}, "svnpath" => \$config{svnpath}, "adminemail=s" => \$config{adminemail}, "timeformat=s" => \$config{timeformat}, @@ -132,10 +130,7 @@ sub main () { #{{{ commandline_render(); } elsif ($config{post_commit} && ! commit_hook_enabled()) { - if ($config{notify}) { - loadindex(); - rcs_notify(); - } + # do nothing } else { lockwiki(); @@ -143,7 +138,6 @@ sub main () { #{{{ require IkiWiki::Render; rcs_update(); refresh(); - rcs_notify() if $config{notify}; saveindex(); } } #}}} diff --git a/t/svn.t b/t/svn.t index a1878a73d..8a8282c73 100755 --- a/t/svn.t +++ b/t/svn.t @@ -21,13 +21,14 @@ BEGIN { use_ok("IkiWiki"); } %config=IkiWiki::defaultconfig(); $config{rcs} = "svn"; $config{srcdir} = "$dir/src"; -$config{svnrepo} = "$dir/repo"; $config{svnpath} = "trunk"; IkiWiki::checkconfig(); -system "svnadmin create $config{svnrepo} >/dev/null"; -system "svn mkdir file://$config{svnrepo}/trunk -m add >/dev/null"; -system "svn co file://$config{svnrepo}/trunk $config{srcdir} >/dev/null"; +my $svnrepo = "$dir/repo"; + +system "svnadmin create $svnrepo >/dev/null"; +system "svn mkdir file://$svnrepo/trunk -m add >/dev/null"; +system "svn co file://$svnrepo/trunk $config{srcdir} >/dev/null"; # Web commit my $test1 = readfile("t/test1.mdwn"); diff --git a/templates/notifymail.tmpl b/templates/notifymail.tmpl deleted file mode 100644 index e3a1dd330..000000000 --- a/templates/notifymail.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -The following change was made by : - - - -- cgit v1.2.3 From 21f44880cdd8f23264b2416bf39793aadcb87df6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 01:48:55 -0500 Subject: non-tabular recentchanges display Doesn't look as good as the old table, but works as a rss feed. --- IkiWiki.pm | 23 +++++++++++++----- IkiWiki/CGI.pm | 53 ----------------------------------------- IkiWiki/Plugin/recentchanges.pm | 23 +++++++++++++----- doc/recentchanges.mdwn | 3 +-- doc/wikitemplates.mdwn | 1 - templates/change.tmpl | 49 ++++++++++++++++++------------------- templates/recentchanges.tmpl | 16 ------------- 7 files changed, 58 insertions(+), 110 deletions(-) delete mode 100644 templates/recentchanges.tmpl (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 2c3ddac23..c70307b5f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -607,14 +607,11 @@ sub htmllink ($$$;@) { #{{{ return "$linktext"; } #}}} -sub userlink ($) { #{{{ +sub openiduser ($) { #{{{ my $user=shift; - eval q{use CGI 'escapeHTML'}; - error($@) if $@; if ($user =~ m!^https?://! && eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) { - # Munge user-urls, as used by eg, OpenID. my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user); my $display=$oid->display; # Convert "user.somehost.com" to "user [somehost.com]". @@ -626,10 +623,24 @@ sub userlink ($) { #{{{ $display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/; } $display=~s!^https?://!!; # make sure this is removed - return "".escapeHTML($display).""; + eval q{use CGI 'escapeHTML'}; + error($@) if $@; + return escapeHTML($display); + } + return; +} + +sub userlink ($) { #{{{ + my $user=shift; + + my $oiduser=openiduser($user); + if (defined $oiduser) { + return "$oiduser"; } else { - return $user; + return htmllink("", "", escapeHTML( + length $config{userdir} ? $config{userdir}."/".$user : $user + ), noimageinline => 1); } } #}}} diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 55ee5d86a..c8c1b63dd 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -84,53 +84,6 @@ sub decode_cgi_utf8 ($) { #{{{ } } #}}} -sub cgi_recentchanges ($) { #{{{ - my $q=shift; - - # Optimisation: building recentchanges means calculating lots of - # links. Memoizing htmllink speeds it up a lot (can't be memoized - # during page builds as the return values may change, but they - # won't here.) - eval q{use Memoize}; - error($@) if $@; - memoize("htmllink"); - - eval q{use Time::Duration}; - error($@) if $@; - - my $changelog=[rcs_recentchanges(100)]; - foreach my $change (@$changelog) { - $change->{when} = concise(ago(time - $change->{when})); - - $change->{user} = userlink($change->{user}); - - my $is_excess = exists $change->{pages}[10]; # limit pages to first 10 - delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess; - $change->{pages} = [ - map { - $_->{link} = htmllink("", "", $_->{page}, - noimageinline => 1, - linktext => pagetitle($_->{page})); - $_; - } @{$change->{pages}} - ]; - push @{$change->{pages}}, { link => '...' } if $is_excess; - } - - my $template=template("recentchanges.tmpl"); - $template->param( - title => "RecentChanges", - indexlink => indexlink(), - wikiname => $config{wikiname}, - changelog => $changelog, - baseurl => baseurl(), - ); - run_hooks(pagetemplate => sub { - shift->(page => "", destpage => "", template => $template); - }); - print $q->header(-charset => 'utf-8'), $template->output; -} #}}} - # Check if the user is signed in. If not, redirect to the signin form and # save their place to return to later. sub needsignin ($$) { #{{{ @@ -661,12 +614,6 @@ sub cgi (;$$) { #{{{ } } - # Things that do not need a session. - if ($do eq 'recentchanges') { - cgi_recentchanges($q); - return; - } - # Need to lock the wiki before getting a session. lockwiki(); diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 6b36ea4c8..fb9841ffd 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -67,14 +67,25 @@ sub store ($$) { #{{{ ]; push @{$change->{pages}}, { link => '...' } if $is_excess; + # Take the first line of the commit message as a summary. + my $m=shift @{$change->{message}}; + $change->{summary}=$m->{line}; + + # See if the committer is an openid. + my $oiduser=IkiWiki::openiduser($change->{user}); + if (defined $oiduser) { + $change->{authorurl}=$change->{user}; + $change->{user}=$oiduser; + } + elsif (length $config{url}) { + $change->{authorurl}="$config{url}/". + (length $config{userdir} ? "$config{userdir}/" : ""). + $change->{user}; + } + # Fill out a template with the change info. my $template=template("change.tmpl", blind_cache => 1); - $template->param( - user => IkiWiki::userlink($change->{user}), - when => IkiWiki::displaytime($change->{when}, "%X %x"), - pages => $change->{pages}, - message => $change->{message}, - ); + $template->param(%$change); $template->param(baseurl => "$config{url}/") if length $config{url}; IkiWiki::run_hooks(pagetemplate => sub { shift->(page => $page, destpage => $page, template => $template); diff --git a/doc/recentchanges.mdwn b/doc/recentchanges.mdwn index a027bf462..b2c7f5d07 100644 --- a/doc/recentchanges.mdwn +++ b/doc/recentchanges.mdwn @@ -1,3 +1,2 @@ [[recentchanges pages="*" num=100 template=change]] -[[inline pages="recentchanges/change_* and !*/Discussion" -template=recentchanges show=0]] +[[inline pages="recentchanges/change_* and !*/Discussion" show=0]] diff --git a/doc/wikitemplates.mdwn b/doc/wikitemplates.mdwn index b8341b637..1f6325b4b 100644 --- a/doc/wikitemplates.mdwn +++ b/doc/wikitemplates.mdwn @@ -11,7 +11,6 @@ located in /usr/share/ikiwiki/templates by default. * `misc.tmpl` - Generic template used for any page that doesn't have a custom template. * `editpage.tmpl` - Create/edit page. -* `recentchanges.tmpl` - Used to generate a RecentChanges table with inline. * `change.tmpl` - Used to create a page describing a change made to the wiki. * `passwordmail.tmpl` - Not a html template, this is used to generate the mail with the user's password in it. diff --git a/templates/change.tmpl b/templates/change.tmpl index 9dbc97ec2..f02b5eb19 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -1,27 +1,24 @@ +[[meta author=""""""]] + +[[meta authorurl=""""""]] + +[[meta title=""""""]] +

+ + +
+
+
+

+

+ + + + "> + diff + + + + +changed via - - - - - - - "> - diff - - - - - - - - - - - - - -
-
-
- - diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl deleted file mode 100644 index 2e33b79f9..000000000 --- a/templates/recentchanges.tmpl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - -
usertimechanges
-
-- cgit v1.2.3 From 80915c830a03cf67c6770ef5e62d5178824b101e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 3 Feb 2008 00:23:04 -0500 Subject: * cgi hooks are now run before ikiwiki state is loaded. * This allows locking the wiki before loading state, which avoids some tricky locking code when saving a web edit. --- IkiWiki/CGI.pm | 5 +---- debian/changelog | 3 +++ doc/plugins/write.mdwn | 7 +++++-- ikiwiki.in | 1 - 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index c8c1b63dd..3f588e427 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -539,10 +539,6 @@ sub cgi_editpage ($$) { #{{{ # may have been committed while the post-commit hook was # disabled. require IkiWiki::Render; - # Reload index, since the first time it's loaded is before - # the wiki is locked, and things may have changed in the - # meantime. - loadindex(); refresh(); saveindex(); @@ -616,6 +612,7 @@ sub cgi (;$$) { #{{{ # Need to lock the wiki before getting a session. lockwiki(); + loadindex(); if (! $session) { $session=cgi_getsession($q); diff --git a/debian/changelog b/debian/changelog index df7b8b424..ceaf3cf71 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,9 @@ ikiwiki (2.31) UNRELEASED; urgency=low too complex to do. * aggregate: Forking a child broke the one state that mattered: Forcing the aggregating page to be rebuilt. Fix this. + * cgi hooks are now run before ikiwiki state is loaded. + * This allows locking the wiki before loading state, which avoids some + tricky locking code when saving a web edit. -- Joey Hess Sat, 02 Feb 2008 23:36:31 -0500 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 9c3a36b8f..216cfa51c 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -222,8 +222,11 @@ source files that were rendered. Use this to hook into ikiwiki's cgi script. Each registered cgi hook is called in turn, and passed a CGI object. The hook should examine the -parameters, and if it will handle this CGI request, output a page (including the http headers) and -terminate the program. +parameters, and if it will handle this CGI request, output a page +(including the http headers) and terminate the program. + +Note that cgi hooks are called as early as possible, before any ikiwiki +state is loaded, and with no session information. ### auth diff --git a/ikiwiki.in b/ikiwiki.in index 9d1f6b520..1ce7e1688 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -121,7 +121,6 @@ sub main () { #{{{ gen_wrapper(); } elsif ($config{cgi}) { - loadindex(); require IkiWiki::CGI; cgi(); } -- cgit v1.2.3 From 408419ca3e76aa629222af81694042c2fb02d8ec Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 3 Feb 2008 19:47:01 -0500 Subject: remove another commit mail mention --- IkiWiki/CGI.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 3f588e427..1ec23df68 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -526,7 +526,7 @@ sub cgi_editpage ($$) { #{{{ # Prevent deadlock with post-commit hook by # signaling to it that it should not try to - # do anything (except send commit mails). + # do anything. disable_commit_hook(); $conflict=rcs_commit($file, $message, $form->field("rcsinfo"), -- cgit v1.2.3 From a3f224cb6cf82b89cf0cbadbd661fd5d71ebf8ae Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 3 Feb 2008 19:51:00 -0500 Subject: move saveindex call into preview block This call is only present to handle the case where previewing a page actually causes files to be rendered. --- IkiWiki/CGI.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 1ec23df68..4d4464c28 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -357,6 +357,8 @@ sub cgi_editpage ($$) { #{{{ linkify($page, "", preprocess($page, $page, filter($page, $page, $content), 0, 1)))); + # previewing may have created files on disk + saveindex(); } elsif ($form->submitted eq "Save Page") { $form->tmpl_param("page_preview", ""); @@ -448,7 +450,6 @@ sub cgi_editpage ($$) { #{{{ } showform($form, \@buttons, $session, $q); - saveindex(); } else { # save page -- cgit v1.2.3