]> sipb.mit.edu Git - ikiwiki.git/commitdiff
replace discussion links on pages with comments link
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 19 Dec 2008 18:55:41 +0000 (13:55 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 19 Dec 2008 18:55:41 +0000 (13:55 -0500)
The thinking here is that having both a Discussion page and comments for
the same page is redundant, and certianly not what you want if you enable
comments for a page. At first I considered making configurable via pagespec
what pages got discussion links. But that would mean testing a new pagespec
for every page, and a redundant config setting to keep in sync. So intead,
take a lead from my previous change to make inlined pages have a comments
link, and change the discussion link at the top of regular pages to link to
their comments.

(Implementation is a bit optimised to avoid redundant pagespec checking.)

IkiWiki/Plugin/comments.pm
templates/page.tmpl

index 3b87528941e4b6ffd8467b70e0d265400b6dd559..fd9f0acb48fc54a6a27d2f60a5b8f2b5940a687d 100644 (file)
@@ -529,10 +529,11 @@ sub pagetemplate (@) {
 
        my $page = $params{page};
        my $template = $params{template};
 
        my $page = $params{page};
        my $template = $params{template};
+       my $shown = ($template->query(name => 'commentslink') ||
+                    $template->query(name => 'comments')) &&
+                   commentsshown($page);
 
        if ($template->query(name => 'comments')) {
 
        if ($template->query(name => 'comments')) {
-               my $shown = commentsshown($page);
-
                my $comments = undef;
                if ($shown) {
                        $comments = IkiWiki::preprocess_inline(
                my $comments = undef;
                if ($shown) {
                        $comments = IkiWiki::preprocess_inline(
@@ -563,7 +564,7 @@ sub pagetemplate (@) {
                # the link. But, to update the number, blog pages
                # would have to update whenever comments of any inlines
                # page are added, which is not currently done.
                # the link. But, to update the number, blog pages
                # would have to update whenever comments of any inlines
                # page are added, which is not currently done.
-               if (commentsshown($page)) {
+               if ($shown) {
                        $template->param(commentslink =>
                                htmllink($page, $params{destpage}, $page,
                                        linktext => gettext("Comments"),
                        $template->param(commentslink =>
                                htmllink($page, $params{destpage}, $page,
                                        linktext => gettext("Comments"),
index 79c2b8b6ee774fdfafb446869adf5fb9c88fed8b..21abc979dc71f66d9ac3aa886a2e2b44e14429b7 100644 (file)
 <TMPL_IF NAME="PREFSURL">
 <li><a href="<TMPL_VAR PREFSURL>">Preferences</a></li>
 </TMPL_IF>
 <TMPL_IF NAME="PREFSURL">
 <li><a href="<TMPL_VAR PREFSURL>">Preferences</a></li>
 </TMPL_IF>
+<TMPL_IF NAME="COMMENTSLINK">
+<li><TMPL_VAR COMMENTSLINK><br /></li>
+<TMPL_ELSE>
 <TMPL_IF NAME="DISCUSSIONLINK">
 <li><TMPL_VAR DISCUSSIONLINK><br /></li>
 </TMPL_IF>
 <TMPL_IF NAME="DISCUSSIONLINK">
 <li><TMPL_VAR DISCUSSIONLINK><br /></li>
 </TMPL_IF>
+</TMPL_IF>
 </ul>
 </div>
 </TMPL_IF>
 </ul>
 </div>
 </TMPL_IF>