diff options
-rw-r--r-- | IkiWiki.pm | 10 | ||||
-rw-r--r-- | IkiWiki/Plugin/comments.pm | 28 | ||||
-rw-r--r-- | doc/bugs/Comments_link_is_to_index.html_if_usedirs_is_on.mdwn | 5 | ||||
-rw-r--r-- | doc/bugs/beautify__95__urlpath_will_add_.__47___even_if_it_is_already_present.mdwn | 3 | ||||
-rw-r--r-- | doc/style.css | 1 | ||||
-rw-r--r-- | doc/todo/Improve_display_of_OpenIDs.mdwn | 5 | ||||
-rw-r--r-- | doc/todo/comments.mdwn | 71 | ||||
-rw-r--r-- | doc/wikiicons/anonymous.png | bin | 302 -> 0 bytes | |||
-rw-r--r-- | doc/wikiicons/openid.png | bin | 297 -> 0 bytes | |||
-rw-r--r-- | doc/wikiicons/signedin.png | bin | 370 -> 0 bytes | |||
-rwxr-xr-x | t/beautify_urlpath.t | 17 | ||||
-rw-r--r-- | templates/atomitem.tmpl | 6 | ||||
-rw-r--r-- | templates/comment.tmpl | 35 | ||||
-rw-r--r-- | templates/rssitem.tmpl | 3 |
14 files changed, 121 insertions, 63 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 47116089b..6747a3ba4 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -949,16 +949,16 @@ sub formattime ($;$) { sub beautify_urlpath ($) { my $url=shift; - if ($config{usedirs}) { - $url =~ s!/index.$config{htmlext}$!/!; - } - # Ensure url is not an empty link, and if necessary, # add ./ to avoid colon confusion. - if ($url !~ /^\// && $url !~ /^\.\.\//) { + if ($url !~ /^\// && $url !~ /^\.\.?\//) { $url="./$url"; } + if ($config{usedirs}) { + $url =~ s!/index.$config{htmlext}$!/!; + } + return $url; } diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 644ef1be8..0ae9eefe3 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -432,8 +432,8 @@ sub sessioncgi ($$) { if ($form->submitted eq PREVIEW) { my $preview = IkiWiki::htmlize($location, $page, '_comment', - IkiWiki::linkify($page, $page, - IkiWiki::preprocess($page, $page, + IkiWiki::linkify($location, $page, + IkiWiki::preprocess($location, $page, IkiWiki::filter($location, $page, $content), 0, 1))); @@ -447,6 +447,12 @@ sub sessioncgi ($$) { $template->param(title => $form->field('subject')); $template->param(ctime => displaytime(time)); + IkiWiki::run_hooks(pagetemplate => sub { + shift->(page => $location, + destpage => $page, + template => $template); + }); + $form->tmpl_param(page_preview => $template->output); } else { @@ -525,6 +531,8 @@ sub pagetemplate (@) { my $page = $params{page}; my $template = $params{template}; my $shown = ($template->query(name => 'commentslink') || + $template->query(name => 'commentsurl') || + $template->query(name => 'atomcommentsurl') || $template->query(name => 'comments')) && commentsshown($page); @@ -554,6 +562,22 @@ sub pagetemplate (@) { } } + if ($template->query(name => 'commentsurl')) { + if ($shown) { + $template->param(commentsurl => + urlto($page, undef, 1).'#comments'); + } + } + + if ($template->query(name => 'atomcommentsurl') && $config{usedirs}) { + if ($shown) { + # This will 404 until there are some comments, but I + # think that's probably OK... + $template->param(atomcommentsurl => + urlto($page, undef, 1).'comments.atom'); + } + } + if ($template->query(name => 'commentslink')) { # XXX Would be nice to say how many comments there are in # the link. But, to update the number, blog pages diff --git a/doc/bugs/Comments_link_is_to_index.html_if_usedirs_is_on.mdwn b/doc/bugs/Comments_link_is_to_index.html_if_usedirs_is_on.mdwn new file mode 100644 index 000000000..6df3ccd9c --- /dev/null +++ b/doc/bugs/Comments_link_is_to_index.html_if_usedirs_is_on.mdwn @@ -0,0 +1,5 @@ +When a page links to its own #comments anchor you get a link like +"index.html#comments" rather than "./#comments". Fixed in commit 0844bd0b +on my 'comments' branch. --[[smcv]] + +[[!tag patch done]] diff --git a/doc/bugs/beautify__95__urlpath_will_add_.__47___even_if_it_is_already_present.mdwn b/doc/bugs/beautify__95__urlpath_will_add_.__47___even_if_it_is_already_present.mdwn new file mode 100644 index 000000000..8e96b1f56 --- /dev/null +++ b/doc/bugs/beautify__95__urlpath_will_add_.__47___even_if_it_is_already_present.mdwn @@ -0,0 +1,3 @@ +beautify_urlpath will prepend a useless "./" to the URL "./foo". Fixed in commit 5b1cf21a on my comments branch. --[[smcv]] + +[[!tag patch done]] diff --git a/doc/style.css b/doc/style.css index 1fabf6b29..81a260afd 100644 --- a/doc/style.css +++ b/doc/style.css @@ -375,6 +375,7 @@ span.color { .comment-header { font-style: italic; + margin-top: .3em; } .comment .author { font-weight: bold; diff --git a/doc/todo/Improve_display_of_OpenIDs.mdwn b/doc/todo/Improve_display_of_OpenIDs.mdwn new file mode 100644 index 000000000..9c21e8234 --- /dev/null +++ b/doc/todo/Improve_display_of_OpenIDs.mdwn @@ -0,0 +1,5 @@ +Some OpenIDs seen in the IkiWiki git history are displayed poorly in [[RecentChanges]], including mine :-) (`http://smcv.pseudorandom.co.uk/`, shown as `smcv.pseudorandom [co.uk]`) + +My `openid` branch on <http://git.pseudorandom.co.uk/> improves on a couple of cases and adds a regression test. --[[smcv]] + +[[!tag patch]] diff --git a/doc/todo/comments.mdwn b/doc/todo/comments.mdwn index 7e35a2619..bab46a0b2 100644 --- a/doc/todo/comments.mdwn +++ b/doc/todo/comments.mdwn @@ -18,11 +18,43 @@ > Won't the remove plugin refuse to remove internal pages? This would be > a good feature to have, though. --[[smcv]] -* 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. - ## Patches pending merge +* There is some common code cargo-culted from other plugins (notably inline and editpage) which + should probably be shared + + > Actually, there's less of this now than there used to be - a lot of simple + > things that were shared have become unshareable as they became more + > complex. --[[smcv]] + + > There's still goto. You have a branch for that. --[[Joey]] + +## Won't fix + +* It would be useful to have a pagespec that always matches all comments on + pages matching a glob. Something like `comment(blog/*)`. + Perhaps postcomment could also be folded into this? Then the pagespec + would match both existing comments, as well as new comments that are + being posted. + + > Please see [[plugins/comments/discussion]]. If I've convinced you that + > internal pages are the way forward, then sure, we can do that, because + > people who can comment still won't be able to edit others' comments + > (one of my goals is that commenters can't put words into each other's + > mouths :-) ) + > + > On the other hand, if you still want me to switch this plugin to "real" + > pages, or if internal pages might become editable in future, then + > configuring lockedit/anonok so a user X can add comments to blog pages + > would also let X edit/delete comments on blog pages (including those + > written by others) in arbitrary ways, which doesn't seem good. --[[smcv]] + + > I had a look at implementing comment() and fell afoul of + > some optimisations that assume only internal() will be used to match + > internal pages. So probably this isn't worth doing. --[[Joey]] + +## Done + * The default template should have a (?) icon next to unauthenticated users (with the IP address as title) and an OpenID icon next to OpenIDs @@ -67,38 +99,11 @@ > and c42f174e fix another `beautify_urlpath` bug and add a regression test > --[[smcv]] -## Won't fix - -* There is some common code cargo-culted from other plugins (notably inline and editpage) which - should probably be shared - - > Actually, there's less of this now than there used to be - a lot of simple - > things that were shared have become unshareable as they became more - > complex. --[[smcv]] - -* It would be useful to have a pagespec that always matches all comments on - pages matching a glob. Something like `comment(blog/*)`. - Perhaps postcomment could also be folded into this? Then the pagespec - would match both existing comments, as well as new comments that are - being posted. - - > Please see [[plugins/comments/discussion]]. If I've convinced you that - > internal pages are the way forward, then sure, we can do that, because - > people who can comment still won't be able to edit others' comments - > (one of my goals is that commenters can't put words into each other's - > mouths :-) ) - > - > On the other hand, if you still want me to switch this plugin to "real" - > pages, or if internal pages might become editable in future, then - > configuring lockedit/anonok so a user X can add comments to blog pages - > would also let X edit/delete comments on blog pages (including those - > written by others) in arbitrary ways, which doesn't seem good. --[[smcv]] +* 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. - > I had a look at implementing comment() and fell afoul of - > some optimisations that assume only internal() will be used to match - > internal pages. So probably this isn't worth doing. --[[Joey]] + > Fixed in my comments branch by d0d598e4, 3feebe31, 9e5f504e --[[smcv]] -## Done * Add `COMMENTOPENID`: the authenticated/verified user name, if and only if it was an OpenID diff --git a/doc/wikiicons/anonymous.png b/doc/wikiicons/anonymous.png Binary files differdeleted file mode 100644 index df22152e6..000000000 --- a/doc/wikiicons/anonymous.png +++ /dev/null diff --git a/doc/wikiicons/openid.png b/doc/wikiicons/openid.png Binary files differdeleted file mode 100644 index c5535c3de..000000000 --- a/doc/wikiicons/openid.png +++ /dev/null diff --git a/doc/wikiicons/signedin.png b/doc/wikiicons/signedin.png Binary files differdeleted file mode 100644 index 969908d39..000000000 --- a/doc/wikiicons/signedin.png +++ /dev/null diff --git a/t/beautify_urlpath.t b/t/beautify_urlpath.t new file mode 100755 index 000000000..94b923d3b --- /dev/null +++ b/t/beautify_urlpath.t @@ -0,0 +1,17 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Test::More tests => 8; + +BEGIN { use_ok("IkiWiki"); } + +$IkiWiki::config{usedirs} = 1; +$IkiWiki::config{htmlext} = "HTML"; +is(IkiWiki::beautify_urlpath("foo/bar"), "./foo/bar"); +is(IkiWiki::beautify_urlpath("../badger"), "../badger"); +is(IkiWiki::beautify_urlpath("./bleh"), "./bleh"); +is(IkiWiki::beautify_urlpath("foo/index.HTML"), "./foo/"); +is(IkiWiki::beautify_urlpath("index.HTML"), "./"); +is(IkiWiki::beautify_urlpath("../index.HTML"), "../"); +$IkiWiki::config{usedirs} = 0; +is(IkiWiki::beautify_urlpath("foo/index.HTML"), "./foo/index.HTML"); diff --git a/templates/atomitem.tmpl b/templates/atomitem.tmpl index 1ff7f4f4e..768695a2c 100644 --- a/templates/atomitem.tmpl +++ b/templates/atomitem.tmpl @@ -39,4 +39,10 @@ <TMPL_VAR CONTENT ESCAPE=HTML> </content> </TMPL_IF> + <TMPL_IF NAME="COMMENTSURL"> + <link rel="comments" href="<TMPL_VAR NAME="COMMENTSURL">" type="text/html" /> + </TMPL_IF> + <TMPL_IF NAME="ATOMCOMMENTSURL"> + <link rel="comments" href="<TMPL_VAR NAME="ATOMCOMMENTSURL">" type="application/atom+xml" /> + </TMPL_IF> </entry> diff --git a/templates/comment.tmpl b/templates/comment.tmpl index b419404ea..6f2b1619e 100644 --- a/templates/comment.tmpl +++ b/templates/comment.tmpl @@ -1,31 +1,29 @@ <div class="comment" id="<TMPL_VAR NAME=INLINEPAGE>"> +<div class="comment-subject"><a href="<TMPL_VAR PERMALINK>"><TMPL_VAR TITLE></a></div> + +<div class="inlinecontent"> +<TMPL_VAR CONTENT> +</div> + <div class="comment-header"> -By +Comment by <TMPL_IF NAME="COMMENTUSER"> -<span class="author"> <TMPL_IF NAME="COMMENTOPENID"> - +<span class="author" title="OpenID"> <a href="<TMPL_VAR NAME=COMMENTOPENID>"><TMPL_VAR NAME=COMMENTAUTHOR></a> -<img src="/wikiicons/openid.png" width="20" height="15" alt="[OpenID]" - title="Signed in with OpenID" /> - +</span> <TMPL_ELSE> - +<span class="author" title="Signed in"> <TMPL_IF NAME="COMMENTAUTHORURL"> <a href="<TMPL_VAR NAME=COMMENTAUTHORURL>"><TMPL_VAR NAME=COMMENTAUTHOR></a> <TMPL_ELSE> <TMPL_VAR NAME=COMMENTAUTHOR> </TMPL_IF> -<img src="/wikiicons/signedin.png" width="15" height="15" alt="[Signed in]" - title="Signed in directly" /> - -</TMPL_IF> </span> - +</TMPL_IF> <TMPL_ELSE><!-- !COMMENTUSER --> - <TMPL_IF NAME=COMMENTIP> <span class="author" title="Unauthenticated, from <TMPL_VAR NAME=COMMENTIP>"> <TMPL_ELSE><!-- !COMMENTIP --> @@ -36,18 +34,9 @@ By <TMPL_ELSE> <TMPL_VAR NAME=AUTHOR> </TMPL_IF> -<img src="/wikiicons/anonymous.png" width="15" height="15" alt="[Unauthenticated]" /> </span> - </TMPL_IF><!-- !COMMENTUSER --> -(<TMPL_VAR CTIME>) +— <TMPL_VAR CTIME> </div> - -<div class="comment-subject"><a href="<TMPL_VAR PERMALINK>"><TMPL_VAR TITLE></a></div> - -<div class="inlinecontent"> -<TMPL_VAR CONTENT> -</div> - </div><!--.comment--> diff --git a/templates/rssitem.tmpl b/templates/rssitem.tmpl index 42936a668..a61b92b61 100644 --- a/templates/rssitem.tmpl +++ b/templates/rssitem.tmpl @@ -23,4 +23,7 @@ <TMPL_ELSE> <description><TMPL_VAR CONTENT ESCAPE=HTML></description> </TMPL_IF> + <TMPL_IF NAME="COMMENTSURL"> + <comments><TMPL_VAR NAME="COMMENTSURL"></comments> + </TMPL_IF> </item> |