From f4e69ed815ca65f38ee9d19219f33dabeb92b97e Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Thu, 18 Dec 2008 19:56:36 +0000
Subject: _comment directive: if the user looks like an OpenID, store that
---
IkiWiki/Plugin/comments.pm | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index c50729a34..336ed1a82 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -151,11 +151,28 @@ sub preprocess {
my $commentip;
my $commentauthor;
my $commentauthorurl;
+ my $commentopenid;
if (defined $params{username}) {
$commentuser = $params{username};
- ($commentauthorurl, $commentauthor) =
- linkuser($params{username});
+
+ my $oiduser = eval { IkiWiki::openiduser($commentuser) };
+
+ if (defined $oiduser) {
+ # looks like an OpenID
+ $commentauthorurl = $commentuser;
+ $commentauthor = $oiduser;
+ $commentopenid = $commentuser;
+ }
+ else {
+ $commentauthorurl = IkiWiki::cgiurl(
+ do => 'commenter',
+ page => (length $config{userdir}
+ ? "$config{userdir}/$commentuser"
+ : "$commentuser"));
+
+ $commentauthor = $commentuser;
+ }
}
else {
if (defined $params{ip}) {
@@ -165,6 +182,7 @@ sub preprocess {
}
$pagestate{$page}{comments}{commentuser} = $commentuser;
+ $pagestate{$page}{comments}{commentopenid} = $commentopenid;
$pagestate{$page}{comments}{commentip} = $commentip;
$pagestate{$page}{comments}{commentauthor} = $commentauthor;
$pagestate{$page}{comments}{commentauthorurl} = $commentauthorurl;
--
cgit v1.2.3
From 8a9f4e225f1c54705fa6d7061724b62fe11ae8fa Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Thu, 18 Dec 2008 19:57:03 +0000
Subject: comments: remove linkuser(), it's been integrated into preprocess()
now
---
IkiWiki/Plugin/comments.pm | 21 ---------------------
1 file changed, 21 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 336ed1a82..bd09c6b25 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -254,27 +254,6 @@ sub linkcgi ($) {
}
}
-# FIXME: basically the same logic as recentchanges
-# returns (author URL, pretty-printed version)
-sub linkuser ($) {
- my $user = shift;
- my $oiduser = eval { IkiWiki::openiduser($user) };
-
- if (defined $oiduser) {
- return ($user, $oiduser);
- }
- # FIXME: it'd be good to avoid having such a link for anonymous
- # posts
- else {
- return (IkiWiki::cgiurl(
- do => 'commenter',
- page => (length $config{userdir}
- ? "$config{userdir}/$user"
- : "$user")
- ), $user);
- }
-}
-
# Mostly cargo-culted from IkiWiki::plugin::editpage
sub sessioncgi ($$) {
my $cgi=shift;
--
cgit v1.2.3
From 8ed94c0a18435f3a1934e19949153c7ccf8ec78a Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Thu, 18 Dec 2008 19:57:25 +0000
Subject: comments: pass COMMENTOPENID to templates
---
IkiWiki/Plugin/comments.pm | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index bd09c6b25..d095a00bd 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -573,6 +573,11 @@ sub pagetemplate (@) {
$pagestate{$page}{comments}{commentuser});
}
+ if ($template->query(name => 'commentopenid')) {
+ $template->param(commentopenid =>
+ $pagestate{$page}{comments}{commentopenid});
+ }
+
if ($template->query(name => 'commentip')) {
$template->param(commentip =>
$pagestate{$page}{comments}{commentip});
--
cgit v1.2.3
From 9e889c39ed9971e31dc33f4dea73a91d6938b535 Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Thu, 18 Dec 2008 20:01:08 +0000
Subject: comments: Rename COMMENTURL to ADDCOMMENTURL to avoid confusion with
COMMENTAUTHORURL
Also refactor page.tmpl to use if/else rather than unless/if.
---
IkiWiki/Plugin/comments.pm | 4 ++--
templates/page.tmpl | 9 ++++-----
2 files changed, 6 insertions(+), 7 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index d095a00bd..4f3b76db3 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -548,9 +548,9 @@ sub pagetemplate (@) {
}
if ($shown && commentsopen($page)) {
- my $commenturl = IkiWiki::cgiurl(do => 'comment',
+ my $addcommenturl = IkiWiki::cgiurl(do => 'comment',
page => $page);
- $template->param(commenturl => $commenturl);
+ $template->param(addcommenturl => $addcommenturl);
}
}
diff --git a/templates/page.tmpl b/templates/page.tmpl
index 21abc979d..f75491127 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -74,13 +74,12 @@
--
cgit v1.2.3