aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-28 22:58:31 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-28 22:58:31 -0500
commit29f3082772095030895111f199d6420ef1835250 (patch)
treea9eb0af660c02665b482eb8e390a97223ee45056
parent9f25e3436b2b918845acbd8cf2ff2d358e0ea105 (diff)
downloadikiwiki-29f3082772095030895111f199d6420ef1835250.tar
ikiwiki-29f3082772095030895111f199d6420ef1835250.tar.gz
move userlink to IkiWiki.pm
I have a plugin that needs to use userlink.
-rw-r--r--IkiWiki.pm28
-rw-r--r--IkiWiki/CGI.pm28
2 files changed, 28 insertions, 28 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 46060c1b2..15402211f 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -609,6 +609,34 @@ sub htmllink ($$$;@) { #{{{
return "<a href=\"$bestlink\"@attrs>$linktext</a>";
} #}}}
+sub userlink ($) { #{{{
+ my $user=shift;
+
+ eval q{use CGI 'escapeHTML'};
+ error($@) if $@;
+ if ($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 => $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
+ return "<a href=\"$user\">".escapeHTML($display)."</a>";
+ }
+ else {
+ return htmllink("", "", escapeHTML(
+ length $config{userdir} ? $config{userdir}."/".$user : $user
+ ), noimageinline => 1);
+ }
+} #}}}
+
sub htmlize ($$$) { #{{{
my $page=shift;
my $type=shift;
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 03c448923..5de90e1a8 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -726,32 +726,4 @@ sub cgi (;$$) { #{{{
}
} #}}}
-sub userlink ($) { #{{{
- my $user=shift;
-
- eval q{use CGI 'escapeHTML'};
- error($@) if $@;
- if ($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 => $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
- return "<a href=\"$user\">".escapeHTML($display)."</a>";
- }
- else {
- return htmllink("", "", escapeHTML(
- length $config{userdir} ? $config{userdir}."/".$user : $user
- ), noimageinline => 1);
- }
-} #}}}
-
1