X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/4a6ac6b485c7e6e312e42c3c609df693f5e531ec..51e8a4eeda24f0a2cfdb0e579ddf1e6df9972544:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm old mode 100644 new mode 100755 index 156d71daf..cb0196728 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -167,6 +167,7 @@ sub preprocess { my $commentip; my $commentauthor; my $commentauthorurl; + my $commentauthoravatar; my $commentopenid; if (defined $params{username}) { $commentuser = $params{username}; @@ -187,6 +188,23 @@ sub preprocess { $commentauthor = $commentuser; } + + eval q{use Libravatar::URL}; + if (! $@) { + my $https=defined $config{url} && $config{url}=~/^https:/; + + if (defined $commentopenid) { + eval { + $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $https); + } + } + if (! defined $commentauthoravatar && + (my $email = IkiWiki::userinfo_get($commentuser, 'email'))) { + eval { + $commentauthoravatar = libravatar_url(email => $email, https => $https); + } + } + } } else { if (defined $params{ip}) { @@ -200,6 +218,7 @@ sub preprocess { $commentstate{$page}{commentip} = $commentip; $commentstate{$page}{commentauthor} = $commentauthor; $commentstate{$page}{commentauthorurl} = $commentauthorurl; + $commentstate{$page}{commentauthoravatar} = $commentauthoravatar; if (! defined $pagestate{$page}{meta}{author}) { $pagestate{$page}{meta}{author} = $commentauthor; } @@ -216,7 +235,7 @@ sub preprocess { my $url=$params{url}; eval q{use URI::Heuristic}; - if (! $@) { + if (! $@) { $url=URI::Heuristic::uf_uristr($url); } @@ -364,8 +383,8 @@ sub editcomment ($$) { } # The untaint is OK (as in editpage) because we're about to pass - # it to file_pruned anyway - my $page = $form->field('page'); + # it to file_pruned and wiki_file_regexp anyway. + my ($page) = $form->field('page')=~/$config{wiki_file_regexp}/; $page = IkiWiki::possibly_foolish_untaint($page); if (! defined $page || ! length $page || IkiWiki::file_pruned($page)) { @@ -504,7 +523,7 @@ sub editcomment ($$) { IkiWiki::saveindex(); IkiWiki::printheader($session); - print IkiWiki::misctemplate(gettext(gettext("comment stored for moderation")), + print IkiWiki::cgitemplate($cgi, gettext(gettext("comment stored for moderation")), "

". gettext("Your comment will be posted after moderator review"). "

"); @@ -660,7 +679,7 @@ sub commentmoderation ($$) { IkiWiki::run_hooks(format => sub { $out = shift->(page => "", content => $out); }); - print IkiWiki::misctemplate(gettext("comment moderation"), $out); + print IkiWiki::cgitemplate($cgi, gettext("comment moderation"), $out); exit; } @@ -755,10 +774,8 @@ sub previewcomment ($$$) { sub commentsshown ($) { my $page=shift; - return ! pagespec_match($page, "comment(*)", - location => $page) && - pagespec_match($page, $config{comments_pagespec}, - location => $page); + return pagespec_match($page, $config{comments_pagespec}, + location => $page); } sub commentsopen ($) { @@ -785,7 +802,7 @@ sub pagetemplate (@) { my $comments = undef; if ($shown) { $comments = IkiWiki::preprocess_inline( - pages => "comment($page)", + pages => "comment($page) and !comment($page/*)", template => 'comment', show => 0, reverse => 'yes', @@ -876,6 +893,11 @@ sub pagetemplate (@) { $commentstate{$page}{commentauthorurl}); } + if ($template->query(name => 'commentauthoravatar')) { + $template->param(commentauthoravatar => + $commentstate{$page}{commentauthoravatar}); + } + if ($template->query(name => 'removeurl') && IkiWiki::Plugin::remove->can("check_canremove") && length $config{cgiurl}) {