From 702b8721d360ca132ff5c8f43d332757694b98da Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 20 Nov 2006 02:46:58 +0000 Subject: [PATCH] * Add an openid plugin to support logging in using OpenID. * Web commits by OpenID users will record the full OpenID url for the user, but in recentchanges, these urls will be converted to a simplified display form+link. * Modified svn, git, tla backends to recognise such web commits. --- IkiWiki.pm | 1 + IkiWiki/CGI.pm | 11 ++++++++++- IkiWiki/Rcs/git.pm | 5 ++--- IkiWiki/Rcs/svn.pm | 6 ++---- IkiWiki/Rcs/tla.pm | 6 ++---- debian/NEWS | 12 ++++++++++++ debian/changelog | 7 +++++-- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index efacb20ed..3803bb917 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -30,6 +30,7 @@ sub defaultconfig () { #{{{ wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.x?html?$|\.rss$|\.atom$|.arch-ids/|{arch}/)}, wiki_link_regexp => qr/\[\[(?:([^\]\|]+)\|)?([^\s\]]+)\]\]/, wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/, + web_commit_regexp => qr/^web commit (by (.*?(?=: )|[^:]+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/, verbose => 0, syslog => 0, wikiname => "wiki", diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index def0549c5..fe1c5153e 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -85,7 +85,16 @@ sub cgi_recentchanges ($) { #{{{ my $changelog=[rcs_recentchanges(100)]; foreach my $change (@$changelog) { $change->{when} = concise(ago($change->{when})); - $change->{user} = htmllink("", "", escapeHTML($change->{user}), 1); + + if ($change->{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 => $change->{user}); + $change->{user} = "{user}."\">".escapeHTML($oid->display).""; + } + else { + $change->{user} = htmllink("", "", escapeHTML($change->{user}), 1); + } my $is_excess = exists $change->{pages}[10]; # limit pages to first 10 delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess; diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm index c8b5adc45..868bec40d 100644 --- a/IkiWiki/Rcs/git.pm +++ b/IkiWiki/Rcs/git.pm @@ -12,7 +12,6 @@ my $origin_branch = 'origin'; # Git ref for main repository my $master_branch = 'master'; # working branch my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate Git sha1sums my $dummy_commit_msg = 'dummy commit'; # message to skip in recent changes -my $web_commit_msg = qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/; sub _safe_git (&@) { #{{{ # Start a child process safely without resorting /bin/sh. @@ -375,7 +374,7 @@ sub rcs_recentchanges ($) { #{{{ push @message, { line => $title }; if (defined $message[0] && - $message[0]->{line} =~ m/$web_commit_msg/) { + $message[0]->{line} =~ m/$config{web_commit_regexp}/) { $user=defined $2 ? "$2" : "$3"; $message[0]->{line}=$4; } else { @@ -424,7 +423,7 @@ sub rcs_notify () { #{{{ my @changed_pages = map { $_->{'file'} } @{ $ci->{'details'} }; my ($user, $message); - if (@{ $ci->{'comment'} }[0] =~ m/$web_commit_msg/) { + if (@{ $ci->{'comment'} }[0] =~ m/$config{web_commit_regexp}/) { $user = defined $2 ? "$2" : "$3"; $message = $4; } else { diff --git a/IkiWiki/Rcs/svn.pm b/IkiWiki/Rcs/svn.pm index 2d3ad046c..71189c82e 100644 --- a/IkiWiki/Rcs/svn.pm +++ b/IkiWiki/Rcs/svn.pm @@ -7,8 +7,6 @@ use POSIX qw(setlocale LC_CTYPE); package IkiWiki; -my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/; - # svn needs LC_CTYPE set to a UTF-8 locale, so try to find one. Any will do. sub find_lc_ctype() { my $current = setlocale(LC_CTYPE()); @@ -162,7 +160,7 @@ sub rcs_recentchanges ($) { #{{{ my $committype="web"; if (defined $message[0] && - $message[0]->{line}=~/$svn_webcommit/) { + $message[0]->{line}=~/$config{web_commit_regexp}/) { $user=defined $2 ? "$2" : "$3"; $message[0]->{line}=$4; } @@ -204,7 +202,7 @@ sub rcs_notify () { #{{{ my $user=`svnlook author $config{svnrepo} -r $rev`; chomp $user; my $message=`svnlook log $config{svnrepo} -r $rev`; - if ($message=~/$svn_webcommit/) { + if ($message=~/$config{web_commit_regexp}/) { $user=defined $2 ? "$2" : "$3"; $message=$4; } diff --git a/IkiWiki/Rcs/tla.pm b/IkiWiki/Rcs/tla.pm index c71c9e6ee..00ee7e7a0 100644 --- a/IkiWiki/Rcs/tla.pm +++ b/IkiWiki/Rcs/tla.pm @@ -7,8 +7,6 @@ use POSIX qw(setlocale LC_CTYPE); package IkiWiki; -my $tla_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/; - sub quiet_system (@) { # See Debian bug #385939. open (SAVEOUT, ">&STDOUT"); @@ -117,7 +115,7 @@ sub rcs_recentchanges ($) { my $when = time - str2time($sdate, 'UTC'); my $committype = "web"; - if (defined $summ && $summ =~ /$tla_webcommit/) { + if (defined $summ && $summ =~ /$config{web_commit_regexp}/) { $user = defined $2 ? "$2" : "$3"; $summ = $4; } @@ -176,7 +174,7 @@ sub rcs_notify () { #{{{ my @changed_pages = grep { !/(^.*\/)?\.arch-ids\/.*\.id$/ } split(/ /, "$newfiles $modfiles $remfiles .arch-ids/fake.id"); - if ($message =~ /$tla_webcommit/) { + if ($message =~ /$config{web_commit_regexp}/) { $user=defined $2 ? "$2" : "$3"; $message=$4; } diff --git a/debian/NEWS b/debian/NEWS index 781a32f59..dd19e26b4 100644 --- a/debian/NEWS +++ b/debian/NEWS @@ -1,3 +1,15 @@ +ikiwiki (1.34) unstable; urgency=low + + The httpauth setting in config files has been removed. To enable + httpauth support on your wiki, you should now enable the httpauth plugin, + instead. + + This release includes OpenID support that is enabled through the openid + plugin. I recommend turning this on to make it easier for users to sign + in to your wiki. + + -- Joey Hess Sun, 19 Nov 2006 20:53:05 -0500 + ikiwiki (1.32) unstable; urgency=low There is a change to the plugin interface in this version. Any plugins that diff --git a/debian/changelog b/debian/changelog index f261f92c9..26778719d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,11 @@ ikiwiki (1.34) UNRELEASED; urgency=low - * Make auth methods pluggable. - * Move httpauth support to a plugin. * Add an openid plugin to support logging in using OpenID. + * Web commits by OpenID users will record the full OpenID url for the user, + but in recentchanges, these urls will be converted to a simplified display + form+link. + * Modified svn, git, tla backends to recognise such web commits. + * Move httpauth support to a plugin. -- Joey Hess Sun, 19 Nov 2006 16:40:26 -0500 -- 2.45.2