summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-30 02:39:17 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-30 02:39:17 -0500
commit870adf3bbf459e3f234fb06322b750582ab47912 (patch)
tree1d90d7fac3c40792baf0213aa8e519afb897cb75 /IkiWiki/Plugin
parent55e16be44a2aa1da578ef896ebac40095f606e15 (diff)
move openiduser function to the openid plugin
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/openid.pm27
-rw-r--r--IkiWiki/Plugin/recentchanges.pm2
2 files changed, 28 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index e8dbe964f..de31f38ee 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -164,4 +164,31 @@ sub getobj ($$) { #{{{
);
} #}}}
+package IkiWiki;
+
+# This is not used by this plugin, but this seems the best place to put it.
+# Used elsewhere to pretty-display the name of an openid user.
+sub openiduser ($) { #{{{
+ my $user=shift;
+
+ if ($user =~ m!^https?://! &&
+ eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
+ 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
+ eval q{use CGI 'escapeHTML'};
+ error($@) if $@;
+ return escapeHTML($display);
+ }
+ return;
+}
+
1
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 8ceb2dfbf..337fb7ac5 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -82,7 +82,7 @@ sub store ($$$) { #{{{
# See if the committer is an openid.
$change->{author}=$change->{user};
- my $oiduser=IkiWiki::openiduser($change->{user});
+ my $oiduser=eval { IkiWiki::openiduser($change->{user}) };
if (defined $oiduser) {
$change->{authorurl}=$change->{user};
$change->{user}=$oiduser;