summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/comments.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-18 20:58:16 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-18 20:58:16 -0500
commit7521dd6c7571cba4a3b882ecffc02dbcbed2805e (patch)
treeee9ca6225ca64319d67e27ba71d974c33c630c0e /IkiWiki/Plugin/comments.pm
parentd7855474fdf6002711ef3d0411ece375ce44015d (diff)
jump to comment after posting
Jumping to the just posted comment was the imputus, but I killed a number of birds here. Added a INLINEPAGE template variable, which can be used to add anchors to any inline template. To keep that sufficiently general, it is the full page name, so the comment anchors and links changed form. Got rid of the FIXMEd hardcoded html anchor div. More importantly, the anchor is now to the very top of the comment, not the text below. So you can see the title, and how it attributes you. Avoid changing the permalink of pages that are not really comments, but happen to contain the _comment directive. I think that behavior was a bug, though not a likely one to occur since _comment should only really be used on comment pages.
Diffstat (limited to 'IkiWiki/Plugin/comments.pm')
-rw-r--r--IkiWiki/Plugin/comments.pm14
1 files changed, 4 insertions, 10 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 2ca2d0a1d..3b8752894 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -193,12 +193,10 @@ sub preprocess {
$pagestate{$page}{meta}{title} = $params{subject};
}
- my $baseurl = urlto($params{destpage}, undef, 1);
- my $anchor = "";
if ($params{page} =~ m/\/(\Q$config{comments_pagename}\E\d+)$/) {
- $anchor = $1;
+ $pagestate{$page}{meta}{permalink} = urlto($params{destpage}, undef, 1).
+ "#".$params{page};
}
- $pagestate{$page}{meta}{permalink} = "${baseurl}#${anchor}";
eval q{use Date::Parse};
if (! $@) {
@@ -206,8 +204,6 @@ sub preprocess {
$IkiWiki::pagectime{$page} = $time if defined $time;
}
- # FIXME: hard-coded HTML (although it's just to set an ID)
- return "<div id=\"$anchor\">$content</div>" if $anchor;
return $content;
}
@@ -499,10 +495,8 @@ sub sessioncgi ($$) {
# breaks it or something
error($conflict) if defined $conflict;
- # Bounce back to where we were, but defeat broken caches
- # and jump to the comments anchor.
- my $anticache = "?updated=$page/$config{comments_pagename}$i#comments";
- IkiWiki::redirect($cgi, urlto($page, undef, 1).$anticache);
+ # Jump to the new comment on the page.
+ IkiWiki::redirect($cgi, urlto($page, undef, 1)."#$location");
}
else {
IkiWiki::showform ($form, \@buttons, $session, $cgi,