From ea4686a565067b8c9a4cd1f1a76c205c7a38bfed Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Sun, 21 Jun 2009 12:12:30 +0100
Subject: Update IkiWiki::openiduser to work with Net::OpenID 2.x
openiduser previously used a constructor that no longer works in 2.x.
However, all we actually want is the (undocumented) DisplayOfURL function
that is invoked by the display method, so try to use that.
(cherry picked from commit c3dd0ff5c7c10743107f203a5b456fdcd1b171df)
---
IkiWiki/Plugin/openid.pm | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
(limited to 'IkiWiki/Plugin/openid.pm')
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index 5424c57e2..87569915b 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -189,8 +189,18 @@ sub openiduser ($) {
if ($user =~ m!^https?://! &&
eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
- my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
- my $display=$oid->display;
+ my $display;
+
+ if (Net::OpenID::VerifiedIdentity->can("DisplayOfURL")) {
+ # this works in at least 2.x
+ $display = Net::OpenID::VerifiedIdentity::DisplayOfURL($user);
+ }
+ else {
+ # this only works in 1.x
+ my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
+ $display=$oid->display;
+ }
+
# Convert "user.somehost.com" to "user [somehost.com]"
# (also "user.somehost.co.uk")
if ($display !~ /\[/) {
--
cgit v1.2.3
From e12b7f5e54730325c751a889ed2e08580b5ef6ba Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Fri, 10 Jul 2009 18:41:16 +0100
Subject: Move OpenID pretty-printing from openid plugin to core
On various sites I have two IkiWiki instances running from the same
repository: one accessible via http and only accepting openid logins,
and one accessible via authenticated https and only accepting httpauth.
The https version should still pretty-print OpenIDs seen in git history,
even though it does not itself accept OpenID logins.
---
IkiWiki.pm | 35 +++++++++++++++++++++++++++++++++++
IkiWiki/Plugin/openid.pm | 39 ---------------------------------------
2 files changed, 35 insertions(+), 39 deletions(-)
(limited to 'IkiWiki/Plugin/openid.pm')
diff --git a/IkiWiki.pm b/IkiWiki.pm
index a0a61ac64..0cb3bf143 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1063,6 +1063,41 @@ sub htmllink ($$$;@) {
return "$linktext";
}
+sub openiduser ($) {
+ my $user=shift;
+
+ if ($user =~ m!^https?://! &&
+ eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
+ my $display;
+
+ if (Net::OpenID::VerifiedIdentity->can("DisplayOfURL")) {
+ # this works in at least 2.x
+ $display = Net::OpenID::VerifiedIdentity::DisplayOfURL($user);
+ }
+ else {
+ # this only works in 1.x
+ my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
+ $display=$oid->display;
+ }
+
+ # Convert "user.somehost.com" to "user [somehost.com]"
+ # (also "user.somehost.co.uk")
+ if ($display !~ /\[/) {
+ $display=~s/^([-a-zA-Z0-9]+?)\.([-.a-zA-Z0-9]+\.[a-z]+)$/$1 [$2]/;
+ }
+ # Convert "http://somehost.com/user" to "user [somehost.com]".
+ # (also "https://somehost.com/user/")
+ 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;
+}
+
sub userlink ($) {
my $user=shift;
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index 87569915b..dc0e0f48e 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -180,43 +180,4 @@ 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 $display;
-
- if (Net::OpenID::VerifiedIdentity->can("DisplayOfURL")) {
- # this works in at least 2.x
- $display = Net::OpenID::VerifiedIdentity::DisplayOfURL($user);
- }
- else {
- # this only works in 1.x
- my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
- $display=$oid->display;
- }
-
- # Convert "user.somehost.com" to "user [somehost.com]"
- # (also "user.somehost.co.uk")
- if ($display !~ /\[/) {
- $display=~s/^([-a-zA-Z0-9]+?)\.([-.a-zA-Z0-9]+\.[a-z]+)$/$1 [$2]/;
- }
- # Convert "http://somehost.com/user" to "user [somehost.com]".
- # (also "https://somehost.com/user/")
- 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
--
cgit v1.2.3