From 819a31ed24cfb95da7e37a7524ecf0655e106903 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 1 May 2006 22:27:37 +0000 Subject: [PATCH] * Rename inlinepage to depends, so that it can be used to refer to more dependency relationships than just inlining. This will require a rebuild on upgrade to this version. * Move the rss link, put it in the blogpost form if there is one and at the top if not. This is both nicer because easier to find, and it cleans up the code which had used inlinepage as a flag for adding the link later. * Allow the depends GlobList to be built up from multiple sources (such as plugins) during a page render. * Which means that more than one blog is now supported to appear on a single page. (With some limitations.) --- IkiWiki/Render.pm | 41 +++++++++++++++++++++------------- basewiki/helponformatting.mdwn | 2 +- debian/changelog | 15 +++++++++++++ debian/postinst | 2 +- doc/bugs.mdwn | 2 -- doc/news.mdwn | 6 +++-- doc/templates.mdwn | 2 ++ doc/todo.mdwn | 6 +++++ doc/todo/plugin.mdwn | 6 ++++- ikiwiki | 10 ++++----- templates/blogpost.tmpl | 3 +++ templates/page.tmpl | 3 --- templates/rsslink.tmpl | 5 +++++ 13 files changed, 73 insertions(+), 30 deletions(-) create mode 100644 templates/rsslink.tmpl diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index d0d28e802..f9da33e30 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -139,17 +139,17 @@ sub preprocess ($$) { #{{{ my $command=shift; my $params=shift; if (length $escape) { - "[[$command $params]]"; + return "[[$command $params]]"; } elsif (exists $commands{$command}) { my %params; while ($params =~ /(\w+)=\"([^"]+)"(\s+|$)/g) { $params{$1}=$2; } - $commands{$command}->($page, %params); + return $commands{$command}->($page, %params); } else { - "[[bad directive $command]]"; + return "[[bad directive $command]]"; } }; @@ -200,17 +200,32 @@ sub preprocess_inline ($@) { #{{{ if (! exists $params{show} && $params{archive} eq "no") { $params{show}=10; } - $inlinepages{$parentpage}=$params{pages}; + if (! exists $depends{$parentpage}) { + $depends{$parentpage}=$params{pages}; + } + else { + $depends{$parentpage}.=" ".$params{pages}; + } my $ret=""; if (exists $params{rootpage}) { + # Add a blog post form, with a rss link button. my $formtemplate=HTML::Template->new(blind_cache => 1, filename => "$config{templatedir}/blogpost.tmpl"); $formtemplate->param(cgiurl => $config{cgiurl}); $formtemplate->param(rootpage => $params{rootpage}); - my $form=$formtemplate->output; - $ret.=$form; + if ($config{rss}) { + $formtemplate->param(rssurl => rsspage(basename($parentpage))); + } + $ret.=$formtemplate->output; + } + elsif ($config{rss}) { + # Add a rss link button. + my $linktemplate=HTML::Template->new(blind_cache => 1, + filename => "$config{templatedir}/rsslink.tmpl"); + $linktemplate->param(rssurl => rsspage(basename($parentpage))); + $ret.=$linktemplate->output; } my $template=HTML::Template->new(blind_cache => 1, @@ -267,10 +282,6 @@ sub genpage ($$$) { #{{{ $template->param(hyperestraierurl => cgiurl()); } - if ($config{rss} && $inlinepages{$page}) { - $template->param(rssurl => rsspage(basename($page))); - } - $template->param( title => $title, wikiname => $config{wikiname}, @@ -375,7 +386,7 @@ sub render ($) { #{{{ my $page=pagename($file); $links{$page}=[findlinks($content, $page)]; - delete $inlinepages{$page}; + delete $depends{$page}; $content=linkify($content, $page); $content=preprocess($page, $content); @@ -569,18 +580,18 @@ FILE: foreach my $file (@files) { } # Handle backlinks; if a page has added/removed links, update the - # pages it links to. Also handle inlining here. + # pages it links to. Also handles rebuilding dependat pages. # TODO: inefficient; pages may get rendered above and again here; # problem is the backlinks could be wrong in the first pass render # above if (%rendered || @del) { foreach my $f (@files) { my $p=pagename($f); - if (exists $inlinepages{$p}) { + if (exists $depends{$p}) { foreach my $file (keys %rendered, @del) { my $page=pagename($file); - if (globlist_match($page, $inlinepages{$p})) { - debug("rendering $f, which inlines $page"); + if (globlist_match($page, $depends{$p})) { + debug("rendering $f, which depends on $page"); render($f); $rendered{$f}=1; last; diff --git a/basewiki/helponformatting.mdwn b/basewiki/helponformatting.mdwn index 286946169..9f7bcd9d1 100644 --- a/basewiki/helponformatting.mdwn +++ b/basewiki/helponformatting.mdwn @@ -38,7 +38,7 @@ To quote someone, prefix the quote with ">": > To be or not to be, > that is the question. -To write a code block, indent each line with a tab: +To write a code block, indent each line with a tab or 8 spaces: 10 PRINT "Hello, world!" 20 GOTO 10 diff --git a/debian/changelog b/debian/changelog index e1eb57710..28011339b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +ikiwiki (1.1) UNRELEASED; urgency=low + + * Rename inlinepage to depends, so that it can be used to refer to more + dependency relationships than just inlining. This will require a rebuild + on upgrade to this version. + * Move the rss link, put it in the blogpost form if there is one and at the + top if not. This is both nicer because easier to find, and it cleans up + the code which had used inlinepage as a flag for adding the link later. + * Allow the depends GlobList to be built up from multiple sources (such as + plugins) during a page render. + * Which means that more than one blog is now supported to appear on a + single page. (With some limitations.) + + -- Joey Hess Mon, 1 May 2006 18:21:16 -0400 + ikiwiki (1.0) unstable; urgency=low * First official release. diff --git a/debian/postinst b/debian/postinst index be5f53939..b9630b525 100755 --- a/debian/postinst +++ b/debian/postinst @@ -4,7 +4,7 @@ set -e # Change this when some incompatible change is made that requires # rebuilding all wikis. -firstcompat=0.2 +firstcompat=1.1 wikilist=/etc/ikiwiki/wikilist diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index 6e02e4533..47799676a 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -23,8 +23,6 @@ pages generated from the underlaydir as it can never work for them. * If a page stops inlining anthing, its rss feed file will linger around and not be deleted. -* Currently only one blog is supported per page. Attempts to add more - will make it only update one of the blogs on the page. * RSS output contains relative links. Ie. http://kitenet.net/~joey/blog/index.rss contains a link to http://kitenet.net/~joey/blog/../blog.html * If a file in the srcdir is removed, exposing a file in the underlaydir, ikiwiki will not notice the change and rebuild it until the file in the diff --git a/doc/news.mdwn b/doc/news.mdwn index cc2adcbc1..2141ca286 100644 --- a/doc/news.mdwn +++ b/doc/news.mdwn @@ -1,5 +1,7 @@ -This is where annoucements of new releases, features, and other news is posted. [[IkiWikiUsers]] are recommended to subscribe to this page's RSS feed. +This is where annoucements of new releases, features, and other news is +posted. [[IkiWikiUsers]] are recommended to subscribe to this page's RSS +feed. [[inline pages="news/* !*/Discussion" rootpage="news" show="30"]] -By the way, some other pages with RSS feeds about ikiwiki include [[TODO]] and [[TODO/done]]. \ No newline at end of file +By the way, some other pages with RSS feeds about ikiwiki include [[TODO]] and [[TODO/done]]. diff --git a/doc/templates.mdwn b/doc/templates.mdwn index 97a91d28b..cb07f27ad 100644 --- a/doc/templates.mdwn +++ b/doc/templates.mdwn @@ -24,6 +24,8 @@ It ships with some basic templates which can be customised: * `estseek.conf` - Not a html template, this is actually a template for a config file for the [[HyperEstraier]] search engine. If you like you can read the [[HyperEstraier]] docs and configure it using this. +* `blogpost.tmpl` - Used for a form to add a post to a blog (and a rss link) +* `rsslink.tmpl` - Used to add a rss link if blogpost.tmpl is not used. If you like, you can add these to further customise it: diff --git a/doc/todo.mdwn b/doc/todo.mdwn index 4bf9eb4c0..764872eea 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -7,3 +7,9 @@ Welcome to ikiwiki's todo list. Items are moved to [[todo/done]] when done. # Full list of open items: [[inline pages="todo/* !todo/done* !*/Discussion" archive="yes"]] + +---- + +Test: + +[[inline pages="news/* !*/Discussion" rootpage="news" show="30"]] diff --git a/doc/todo/plugin.mdwn b/doc/todo/plugin.mdwn index 5f070dd92..0a8a0942e 100644 --- a/doc/todo/plugin.mdwn +++ b/doc/todo/plugin.mdwn @@ -20,7 +20,11 @@ Considering ikiwiki plugins, one idea I have is to make the [[PreProcessorDirect Since preprocessing happens before htmlization but after a page is loaded and linkified, it should be possible to use it to create something like a link map or lists, or a page index. Page inlining and rss generation is already done via preprocessor directives and seems a natureal as a plugin too. -Note that things like a link map or a broken link list page would need to be updated whenever a set (or all) pages change; the %inlinepages hash already allows for pages to register this, although it might need to be renamed. +Note that things like a link map or a broken link list page would need to +be updated whenever a set (or all) pages change; the %depends hash +already allows for pages to register this, although there could be some +strange behavior if mixing multiple directives some of which exclude pages +that others might want to include. I need to look at the full range of things that other wikis use their plugin systems for, but preprocessor directives as plugins certianly seems useful, even if it's not a complete solution. diff --git a/ikiwiki b/ikiwiki index 6c157132f..dfb484f64 100755 --- a/ikiwiki +++ b/ikiwiki @@ -9,7 +9,7 @@ use HTML::Template; use lib '.'; # For use without installation, removed by Makefile. use vars qw{%config %links %oldlinks %oldpagemtime %pagectime - %renderedfiles %pagesources %inlinepages}; + %renderedfiles %pagesources %depends}; sub usage () { #{{{ die "usage: ikiwiki [options] source dest\n"; @@ -399,8 +399,8 @@ sub loadindex () { #{{{ $oldpagemtime{$page}=$items{mtime}[0]; $oldlinks{$page}=[@{$items{link}}]; $links{$page}=[@{$items{link}}]; - $inlinepages{$page}=join(" ", @{$items{inlinepage}}) - if exists $items{inlinepage}; + $depends{$page}=join(" ", @{$items{depends}}) + if exists $items{depends}; $renderedfiles{$page}=$items{dest}[0]; } $pagectime{$page}=$items{ctime}[0]; @@ -421,8 +421,8 @@ sub saveindex () { #{{{ "src=$pagesources{$page} ". "dest=$renderedfiles{$page}"; $line.=" link=$_" foreach @{$links{$page}}; - if (exists $inlinepages{$page}) { - $line.=" inlinepage=$_" foreach split " ", $inlinepages{$page}; + if (exists $depends{$page}) { + $line.=" depends=$_" foreach split " ", $depends{$page}; } print OUT $line."\n"; } diff --git a/templates/blogpost.tmpl b/templates/blogpost.tmpl index 22253d60b..1b93adc14 100644 --- a/templates/blogpost.tmpl +++ b/templates/blogpost.tmpl @@ -1,5 +1,8 @@
+ +RSS + diff --git a/templates/page.tmpl b/templates/page.tmpl index c9ec2a34f..4dc8e1139 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -67,9 +67,6 @@ Links: Last edited - -RSS -
diff --git a/templates/rsslink.tmpl b/templates/rsslink.tmpl new file mode 100644 index 000000000..f70c959d6 --- /dev/null +++ b/templates/rsslink.tmpl @@ -0,0 +1,5 @@ + -- 2.32.0.93.g670b81a890