* 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.
master
joey 2006-11-20 02:46:58 +00:00
parent 8a06d15e50
commit 702b8721d3
7 changed files with 34 additions and 14 deletions

View File

@ -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",

View File

@ -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} = "<a href=\"".$change->{user}."\">".escapeHTML($oid->display)."</a>";
}
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;

View File

@ -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 {

View File

@ -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;
}

View File

@ -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;
}

12
debian/NEWS vendored
View File

@ -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 <joeyh@debian.org> 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

7
debian/changelog vendored
View File

@ -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 <joeyh@debian.org> Sun, 19 Nov 2006 16:40:26 -0500