]> sipb.mit.edu Git - ikiwiki.git/commitdiff
jump to comment after posting
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 19 Dec 2008 01:58:16 +0000 (20:58 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 19 Dec 2008 01:58:16 +0000 (20:58 -0500)
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.

IkiWiki/Plugin/comments.pm
IkiWiki/Plugin/inline.pm
doc/todo/comments.mdwn
templates/comments_display.tmpl

index 2ca2d0a1d02d2e9332571ea1f3fe2ef5876afdb0..3b87528941e4b6ffd8467b70e0d265400b6dd559 100644 (file)
@@ -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,
index d37db97ec4f3d1fd68ed9d6f4fc71f94e9540060..8490b455fa8b50153f1368f31b8e6d1e27afd745 100644 (file)
@@ -340,6 +340,7 @@ sub preprocess_inline (@) {
                                        $template->param(content => $content);
                                }
                                $template->param(pageurl => urlto(bestlink($params{page}, $page), $params{destpage}));
+                               $template->param(inlinepage => $page);
                                $template->param(title => pagetitle(basename($page)));
                                $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
                                $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
index c81947e7480c08d6d5e4353d75e192c78b883855..2bcec69ba923d777e64f46f57abe934f589ccc69 100644 (file)
@@ -81,5 +81,7 @@ Known issues with the [[plugins/comments]] plugin:
   with id="comment_123" or something. I'll fix this, unless Joey gets there
   first. --[[smcv]]
 
+  > done --[[Joey]] 
+
 * Now that inline has some comments-specific functionality anyway, it would
   be good to output <link rel="comments"> in Atom and the equivalent in RSS.
index bc4b70273c7b36e78c6e811e3392e20aea4119f6..e7e283bbfb16005522decdfc501e610eff217e32 100644 (file)
@@ -1,4 +1,4 @@
-<div class="comments-display">
+<div class="comments-display" id="<TMPL_VAR NAME=INLINEPAGE>">
 
 <div class="comments-header">
 Posted by