diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-05-26 16:11:53 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-05-26 16:11:53 +0000 |
commit | 65d0aee407f81db9ca2261fc8ecb1958f62302a9 (patch) | |
tree | 5a3e69dd458e7455943e7b18738719cf7eb40fe1 | |
parent | 29507e94a46d0f2006671d31ac6812ebd0715cee (diff) | |
download | ikiwiki-65d0aee407f81db9ca2261fc8ecb1958f62302a9.tar ikiwiki-65d0aee407f81db9ca2261fc8ecb1958f62302a9.tar.gz |
* --getctime had bitrotted (well I only ever used it the once so far..),
* When inlining a page in another one, links from the inlined page are now
expanded the same as they are when rendering the inlined page as a
standalone page. So rather than being expanded from the POV of the
inlining page, they are expanded from the POV of the inlined page.
For example, a link from blog/foo to "bar" will now link to blog/bar
if it exists. Previously this needed to be a link explicitly to
"blog/bar"; such links will also continue to work.
(This was slightly complex to do as the link still has to be constructed
relative to the inlining page.)
-rw-r--r-- | IkiWiki.pm | 14 | ||||
-rw-r--r-- | IkiWiki/CGI.pm | 12 | ||||
-rw-r--r-- | IkiWiki/Plugin/brokenlinks.pm | 4 | ||||
-rw-r--r-- | IkiWiki/Plugin/inline.pm | 4 | ||||
-rw-r--r-- | IkiWiki/Plugin/orphans.pm | 2 | ||||
-rw-r--r-- | IkiWiki/Plugin/smiley.pm | 2 | ||||
-rw-r--r-- | IkiWiki/Render.pm | 11 | ||||
-rw-r--r-- | debian/changelog | 15 | ||||
-rw-r--r-- | doc/news/now_with_style.mdwn | 4 | ||||
-rw-r--r-- | doc/plugins/haiku.mdwn | 4 | ||||
-rw-r--r-- | doc/roadmap.mdwn | 4 | ||||
-rw-r--r-- | doc/sandbox/test.mdwn | 2 | ||||
-rw-r--r-- | doc/todo/done/utf8.mdwn | 13 | ||||
-rw-r--r-- | doc/todo/multiple_templates.mdwn | 3 | ||||
-rw-r--r-- | doc/todo/pageindexes.mdwn | 3 | ||||
-rw-r--r-- | doc/todo/plugin.mdwn | 4 | ||||
-rw-r--r-- | doc/todo/utf8.mdwn | 41 | ||||
-rwxr-xr-x | t/linkify.t | 31 |
18 files changed, 85 insertions, 88 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 81a72d43d..5424d435c 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -260,8 +260,9 @@ sub styleurl (;$) { #{{{ return $page."style.css"; } #}}} -sub htmllink ($$;$$$) { #{{{ - my $page=shift; +sub htmllink ($$$;$$$) { #{{{ + my $lpage=shift; # the page doing the linking + my $page=shift; # the page that will contain the link (different for inline) my $link=shift; my $noimageinline=shift; # don't turn links into inline html images my $forcesubpage=shift; # force a link to a subpage @@ -269,10 +270,10 @@ sub htmllink ($$;$$$) { #{{{ my $bestlink; if (! $forcesubpage) { - $bestlink=bestlink($page, $link); + $bestlink=bestlink($lpage, $link); } else { - $bestlink="$page/".lc($link); + $bestlink="$lpage/".lc($link); } $linktext=pagetitle(basename($link)) unless defined $linktext; @@ -281,14 +282,13 @@ sub htmllink ($$;$$$) { #{{{ # TODO BUG: %renderedfiles may not have it, if the linked to page # was also added and isn't yet rendered! Note that this bug is - # masked by the bug mentioned below that makes all new files - # be rendered twice. + # masked by the bug that makes all new files be rendered twice. if (! grep { $_ eq $bestlink } values %renderedfiles) { $bestlink=htmlpage($bestlink); } if (! grep { $_ eq $bestlink } values %renderedfiles) { return "<span><a href=\"". - cgiurl(do => "create", page => $link, from =>$page). + cgiurl(do => "create", page => $link, from => $page). "\">?</a>$linktext</span>" } diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 2483bf4d8..6ead8fc56 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -19,8 +19,8 @@ sub page_locked ($$;$) { #{{{ my $locked_pages=userinfo_get($admin, "locked_pages"); if (globlist_match($page, userinfo_get($admin, "locked_pages"))) { return 1 if $nonfatal; - error(htmllink("", $page, 1)." is locked by ". - htmllink("", $admin, 1)." and cannot be edited."); + error(htmllink("", "", $page, 1)." is locked by ". + htmllink("", "", $admin, 1)." and cannot be edited."); } } @@ -246,9 +246,9 @@ sub cgi_prefs ($$) { #{{{ $form->field(name => "password", type => "password"); $form->field(name => "confirm_password", type => "password"); $form->field(name => "subscriptions", size => 50, - comment => "(".htmllink("", "GlobList", 1).")"); + comment => "(".htmllink("", "", "GlobList", 1).")"); $form->field(name => "locked_pages", size => 50, - comment => "(".htmllink("", "GlobList", 1).")"); + comment => "(".htmllink("", "", "GlobList", 1).")"); if (! is_admin($user_name)) { $form->field(name => "locked_pages", type => "hidden"); @@ -335,7 +335,7 @@ sub cgi_editpage ($$) { #{{{ $form->tmpl_param("can_commit", $config{rcs}); $form->tmpl_param("indexlink", indexlink()); $form->tmpl_param("helponformattinglink", - htmllink("", "HelpOnFormatting", 1)); + htmllink("", "", "HelpOnFormatting", 1)); $form->tmpl_param("styleurl", styleurl()); $form->tmpl_param("baseurl", "$config{url}/"); if (! $form->submitted) { @@ -351,7 +351,7 @@ sub cgi_editpage ($$) { #{{{ require IkiWiki::Render; $form->tmpl_param("page_preview", htmlize($config{default_pageext}, - linkify($page, $form->field('content')))); + linkify($page, $page, $form->field('content')))); } else { $form->tmpl_param("page_preview", ""); diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index 22590366b..deee58222 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -27,9 +27,9 @@ sub preprocess (@) { #{{{ my $bestlink=IkiWiki::bestlink($page, $link); next if length $bestlink; push @broken, - IkiWiki::htmllink($page, $link, 1). + IkiWiki::htmllink($page, $page, $link, 1). " in ". - IkiWiki::htmllink($params{page}, $page, 1); + IkiWiki::htmllink($params{page}, $params{page}, $page, 1); } } } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a11e5a52b..8b67bfa61 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -59,7 +59,7 @@ sub preprocess_inline (@) { #{{{ foreach my $page (blog_list($params{pages}, $params{show})) { next if $page eq $params{page}; push @pages, $page; - $template->param(pagelink => htmllink($params{page}, $page)); + $template->param(pagelink => htmllink($params{page}, $params{page}, $page)); $template->param(content => get_inline_content($params{page}, $page)) if $params{archive} eq "no"; $template->param(ctime => scalar(gmtime($pagectime{$page}))); @@ -100,7 +100,7 @@ sub get_inline_content ($$) { #{{{ my $file=$pagesources{$page}; my $type=pagetype($file); if ($type ne 'unknown') { - return htmlize($type, linkify($parentpage, readfile(srcfile($file)))); + return htmlize($type, linkify($page, $parentpage, readfile(srcfile($file)))); } else { return ""; diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index a7aa89f58..f8035db54 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -36,7 +36,7 @@ sub preprocess (@) { #{{{ } return "All pages are linked to by other pages." unless @orphans; - return "<ul>\n".join("\n", map { "<li>".IkiWiki::htmllink($params{page}, $_, 1)."</li>" } sort @orphans)."</ul>\n"; + return "<ul>\n".join("\n", map { "<li>".IkiWiki::htmllink($params{page}, $params{page}, $_, 1)."</li>" } sort @orphans)."</ul>\n"; } # }}} 1 diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm index 5f05e3a4c..f49c9b62f 100644 --- a/IkiWiki/Plugin/smiley.pm +++ b/IkiWiki/Plugin/smiley.pm @@ -35,7 +35,7 @@ sub filter (@) { #{{{ my %params=@_; $params{content} =~ s{(?<=\s)(\\?)$smiley_regexp(?=\s)}{ - $1 ? $2 : IkiWiki::htmllink($params{page}, $smileys{$2}, 0, 0, $2) + $1 ? $2 : IkiWiki::htmllink($params{page}, $params{page}, $smileys{$2}, 0, 0, $2) }egs; return $params{content}; diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 08f5e7e95..df08eb49c 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -7,13 +7,14 @@ use strict; use File::Spec; use IkiWiki; -sub linkify ($$) { #{{{ +sub linkify ($$$) { #{{{ + my $lpage=shift; my $page=shift; my $content=shift; $content =~ s{(\\?)$config{wiki_link_regexp}}{ - $2 ? ( $1 ? "[[$2|$3]]" : htmllink($page, titlepage($3), 0, 0, pagetitle($2))) - : ( $1 ? "[[$3]]" : htmllink($page, titlepage($3))) + $2 ? ( $1 ? "[[$2|$3]]" : htmllink($lpage, $page, titlepage($3), 0, 0, pagetitle($2))) + : ( $1 ? "[[$3]]" : htmllink($lpage, $page, titlepage($3))) }eg; return $content; @@ -181,7 +182,7 @@ sub genpage ($$$) { #{{{ $actions++; } if ($config{discussion}) { - $template->param(discussionlink => htmllink($page, "Discussion", 1, 1)); + $template->param(discussionlink => htmllink($page, $page, "Discussion", 1, 1)); $actions++; } @@ -267,7 +268,7 @@ sub render ($) { #{{{ $links{$page}=[findlinks($page, $content)]; - $content=linkify($page, $content); + $content=linkify($page, $page, $content); $content=preprocess($page, $content); $content=htmlize($type, $content); diff --git a/debian/changelog b/debian/changelog index 5be298136..f35314afe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,12 +19,23 @@ ikiwiki (1.4) UNRELEASED; urgency=low * Enable full utf-8 support for page input and output. * Add a workaround for markdown, which does not work well with utf-8 strings. - * --getctime had bitrotted (well I only ever used it the once so far..), + * --getctime had bitrotted (well I only ever used it the once so far..), fix and make it a bit more flexible * rcs_getctime is changed, now rather than needing to loop over all pages, it should just use the rcs to get the ctime of the passed file. + * When inlining a page in another one, links from the inlined page are now + expanded the same as they are when rendering the inlined page as a + standalone page. So rather than being expanded from the POV of the + inlining page, they are expanded from the POV of the inlined page. - -- Joey Hess <joeyh@debian.org> Fri, 26 May 2006 04:49:49 -0400 + For example, a link from blog/foo to "bar" will now link to blog/bar + if it exists. Previously this needed to be a link explicitly to + "blog/bar"; such links will also continue to work. + + (This was slightly complex to do as the link still has to be constructed + relative to the inlining page.) + + -- Joey Hess <joeyh@debian.org> Fri, 26 May 2006 11:43:08 -0400 ikiwiki (1.3) unstable; urgency=low diff --git a/doc/news/now_with_style.mdwn b/doc/news/now_with_style.mdwn index 9f4237683..f04530163 100644 --- a/doc/news/now_with_style.mdwn +++ b/doc/news/now_with_style.mdwn @@ -1 +1,3 @@ -Ikiwiki also supports style sheets now. I've not done too much with the default style sheet, but you can customise [[style.css]] to do whatever you like with the look of your wiki.
\ No newline at end of file +Ikiwiki also supports style sheets now. I've not done too much with the +default style sheet, but you can customise [[style.css]] to do whatever you +like with the look of your wiki. diff --git a/doc/plugins/haiku.mdwn b/doc/plugins/haiku.mdwn index 5a9f89c6f..be462645b 100644 --- a/doc/plugins/haiku.mdwn +++ b/doc/plugins/haiku.mdwn @@ -8,7 +8,9 @@ what to write the haiku about. If no hint is given, it might base it on the page name. Since the vocabulary it knows is very small, many hints won't affect the result at all. -This plugin is included in ikiwiki, but is not enabled by default. +This plugin is included in ikiwiki, but is not enabled by default. As a +special bonus, enabling this plugin makes any error messages ikiwiki should +display be written in haiku. You need to have the Coy module installed for this plugin to do anything interesting. That does all the heavy lifting. diff --git a/doc/roadmap.mdwn b/doc/roadmap.mdwn index 338ccd0be..8e9c5b462 100644 --- a/doc/roadmap.mdwn +++ b/doc/roadmap.mdwn @@ -13,8 +13,8 @@ Released 29 April 2006. * Unit test suite (with tests of at least core stuff like [[GlobList]]). -* [[todo/Plugin]] mechanism. -* Should have fully working [[todo/utf8]] support. +* [[Plugins]] +* Should have fully working [[todo/done/utf8]] support. * [[Optimised_rendering|todo/optimisations]] if possible. Deal with other scalability issues. * improved [[todo/html]] stylesheets and templates * A version of the logo in a different font, possibly with the dots on the i's highlighted in some other color. diff --git a/doc/sandbox/test.mdwn b/doc/sandbox/test.mdwn index 3b53e07e0..3bbc982de 100644 --- a/doc/sandbox/test.mdwn +++ b/doc/sandbox/test.mdwn @@ -1 +1 @@ -This is a [[SubPage]] of the [[SandBox]].
\ No newline at end of file +This page, [[test]], is a [[SubPage]] of the [[SandBox]]. diff --git a/doc/todo/done/utf8.mdwn b/doc/todo/done/utf8.mdwn new file mode 100644 index 000000000..b49bb3376 --- /dev/null +++ b/doc/todo/done/utf8.mdwn @@ -0,0 +1,13 @@ +ikiwiki should support utf-8 pages, both input and output. To test, here's a +utf-8 smiley: + +# ☺ + +Currently ikiwiki is belived to be utf-8 clean itself; it tells perl to use +binmode when reading possibly binary files (such as images) and it uses +utf-8 compatable regexps etc. + +Notes: + +* Apache "AddDefaultCharset on" settings will not play well with utf-8 + pages. Turn it off. diff --git a/doc/todo/multiple_templates.mdwn b/doc/todo/multiple_templates.mdwn index 809a089eb..459a5fa4f 100644 --- a/doc/todo/multiple_templates.mdwn +++ b/doc/todo/multiple_templates.mdwn @@ -4,3 +4,6 @@ Well, that would probably be fairly easy to add if it used globlists to specify which pages use the non-default template. + +Hmm, I think the pagetemplate hook should allow one to get close enough to +this in a plugin now. diff --git a/doc/todo/pageindexes.mdwn b/doc/todo/pageindexes.mdwn index ac4c460ae..c4a9df9a3 100644 --- a/doc/todo/pageindexes.mdwn +++ b/doc/todo/pageindexes.mdwn @@ -1,2 +1,3 @@ Might be nice to support automatically generating an index based on headers -in a page, for long pages. The question is, how to turn on such an index? Well, make it a [[plugin]] enabled by a [[preprocessordirective]]. +in a page, for long pages. The question is, how to turn on such an index? +Well, make it a [[plugin]] enabled by a [[preprocessordirective]]. diff --git a/doc/todo/plugin.mdwn b/doc/todo/plugin.mdwn index fc0107b6f..03183d119 100644 --- a/doc/todo/plugin.mdwn +++ b/doc/todo/plugin.mdwn @@ -1,8 +1,8 @@ Suggestions of ideas for plugins: * list of registered users - tricky because it sorta calls for a way to rebuild the page when a new user is registered. Might be better as a cgi? -* a [[todo/link_map]] -* [[todo/sigs]] ? +* a [[link_map]] +* [[sigs]] ? * [[pageindexes]] * Wiki stats, such as total number of links, most linked to pages diff --git a/doc/todo/utf8.mdwn b/doc/todo/utf8.mdwn deleted file mode 100644 index b905e4633..000000000 --- a/doc/todo/utf8.mdwn +++ /dev/null @@ -1,41 +0,0 @@ -ikiwiki should support utf-8 pages, both input and output. To test, here's a -utf-8 smiley: - -# ☺ - -Currently ikiwiki is belived to be utf-8 clean itself; it tells perl to use -binmode when reading possibly binary files (such as images) and it uses -utf-8 compatable regexps etc. - -utf-8 IO is not enabled by default though. While you can probably embed -utf-8 in pages anyway, ikiwiki will not treat it right in the cases where -it deals with things on a per-character basis (mostly when escaping and -de-escaping special characters in filenames). - -To enable utf-8, edit ikiwiki and add -CSD to the perl hashbang line. -(This should probably be configurable via a --utf8 or better --encoding= -switch.) - -The following problems have been observed when running ikiwiki this way: - -* If invalid utf-8 creeps into a file, ikiwiki will crash rendering it as - follows: - - Malformed UTF-8 character (unexpected continuation byte 0x97, with no preceding start byte) in substitution iterator at /usr/bin/markdown line 1317. - Malformed UTF-8 character (fatal) at /usr/bin/markdown line 1317. - - In this example, a literal 0x97 character had gotten into a markdown - file. - - Running this before markdown can avoid it: - - $content = Encode::encode_utf8($content); - - I'm not sure how, or what should be done after markdown to get the string - back into a form that perl can treat as utf-8. - -* Apache "AddDefaultCharset on" settings will not play well with utf-8 - pages. - -* CGI::FormBuilder needs to be told to set `charset => "utf-8"` so that - utf-8 is used in the edit form. (done) diff --git a/t/linkify.t b/t/linkify.t index 47eee6e0d..d1d02cd27 100755 --- a/t/linkify.t +++ b/t/linkify.t @@ -1,10 +1,12 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 11; +use Test::More tests => 13; -sub linkify ($$$) { +sub linkify ($$$$) { + my $lpage=shift; my $page=shift; + my $content=shift; my @existing_pages=@{shift()}; @@ -17,7 +19,7 @@ sub linkify ($$$) { } %IkiWiki::config=IkiWiki::defaultconfig(); - return IkiWiki::linkify($page, $content); + return IkiWiki::linkify($lpage, $page, $content); } sub links_to ($$) { @@ -62,13 +64,16 @@ sub links_text ($$) { BEGIN { use_ok("IkiWiki::Render"); } -ok(links_to("bar", linkify("foo", "link to [[bar]] ok", ["foo", "bar"])), "ok link"); -ok(not_links_to("bar", linkify("foo", "link to \\[[bar]] ok", ["foo", "bar"])), "escaped link"); -ok(links_to("page=bar", linkify("foo", "link to [[bar]] ok", ["foo"])), "broken link"); -ok(links_to("bar", linkify("foo", "link to [[baz]] and [[bar]] ok", ["foo", "baz", "bar"])), "dual links"); -ok(links_to("baz", linkify("foo", "link to [[baz]] and [[bar]] ok", ["foo", "baz", "bar"])), "dual links"); -ok(links_to("bar", linkify("foo", "link to [[some_page|bar]] ok", ["foo", "bar"])), "named link"); -ok(links_text("some page", linkify("foo", "link to [[some_page|bar]] ok", ["foo", "bar"])), "named link text"); -ok(links_to("bar", linkify("foo", "link to [[some page|bar]] ok", ["foo", "bar"])), "named link, with whitespace"); -ok(links_text("some page", linkify("foo", "link to [[some page|bar]] ok", ["foo", "bar"])), "named link text, with whitespace"); -ok(links_text("Some long, & complex page name.", linkify("foo", "link to [[Some long, & complex page name.|bar]] ok, and this is not a link]] here", ["foo", "bar"])), "complex named link text"); +ok(links_to("bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo", "bar"])), "ok link"); +ok(not_links_to("bar", linkify("foo", "foo", "link to \\[[bar]] ok", ["foo", "bar"])), "escaped link"); +ok(links_to("page=bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo"])), "broken link"); +ok(links_to("bar", linkify("foo", "foo", "link to [[baz]] and [[bar]] ok", ["foo", "baz", "bar"])), "dual links"); +ok(links_to("baz", linkify("foo", "foo", "link to [[baz]] and [[bar]] ok", ["foo", "baz", "bar"])), "dual links"); +ok(links_to("bar", linkify("foo", "foo", "link to [[some_page|bar]] ok", ["foo", "bar"])), "named link"); +ok(links_text("some page", linkify("foo", "foo", "link to [[some_page|bar]] ok", ["foo", "bar"])), "named link text"); +ok(links_to("bar", linkify("foo", "foo", "link to [[some page|bar]] ok", ["foo", "bar"])), "named link, with whitespace"); +ok(links_text("some page", linkify("foo", "foo", "link to [[some page|bar]] ok", ["foo", "bar"])), "named link text, with whitespace"); +ok(links_text("Some long, & complex page name.", linkify("foo", "foo", "link to [[Some long, & complex page name.|bar]] ok, and this is not a link]] here", ["foo", "bar"])), "complex named link text"); +ok(links_to("foo/bar", linkify("foo/item", "foo", "link to [[bar]] ok", ["foo", "foo/item", "foo/bar"])), "inline page link"); +ok(links_to("bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo", "foo/item", "foo/bar"])), "same except not inline"); + |