summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-07-11 15:52:51 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-07-11 15:52:51 -0400
commit42fcafa57d50b3859ab55443e54f446d662ef157 (patch)
tree2e44e2b823c35c306ad43580e6a2884a4d2afe30
parentd5be42a0910a1f0b0f6a9796fdbb43d1f02284f2 (diff)
parente12b7f5e54730325c751a889ed2e08580b5ef6ba (diff)
Merge commit 'e12b7f5e54730325c751a889ed2e08580b5ef6ba'
-rw-r--r--IkiWiki.pm35
-rw-r--r--IkiWiki/Plugin/openid.pm39
2 files changed, 35 insertions, 39 deletions
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 "<a href=\"$bestlink\"@attrs>$linktext</a>";
}
+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