X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/cd27ffc61458ecb1c4b7f2f919556b112620f671..5c0e0e19d17ceb8f2ad3027db652f3ef147212fe:/IkiWiki/Plugin/openid.pm?ds=inline diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index ab9fc560b..de31f38ee 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -42,7 +42,7 @@ sub formbuilder_setup (@) { #{{{ $form->field( name => "openid_url", - label => gettext("Log in with")." ".htmllink("", "", "OpenID", noimageinline => 1), + label => gettext("Log in with")." ".htmllink("", "", "ikiwiki/OpenID", noimageinline => 1), fieldset => "OpenID", size => 30, comment => ($config{openidsignup} ? " | ".gettext("Get an OpenID")."" : "") @@ -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