summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/calendar.pm8
-rw-r--r--IkiWiki/Plugin/inline.pm2
-rw-r--r--IkiWiki/Plugin/pagestats.pm21
-rw-r--r--IkiWiki/Plugin/sidebar.pm54
-rw-r--r--auto-blog.setup4
-rw-r--r--debian/changelog16
-rw-r--r--doc/examples/blog.mdwn9
-rw-r--r--doc/examples/blog/archives.mdwn8
-rw-r--r--doc/examples/blog/comments.mdwn2
-rw-r--r--doc/examples/blog/index.mdwn9
-rw-r--r--doc/examples/blog/sidebar.mdwn12
-rw-r--r--doc/ikiwiki-calendar.mdwn8
-rw-r--r--doc/ikiwiki/directive/calendar.mdwn7
-rw-r--r--doc/ikiwiki/directive/pagestats.mdwn11
-rw-r--r--doc/ikiwiki/directive/sidebar.mdwn20
-rw-r--r--doc/plugins/sidebar.mdwn25
-rw-r--r--doc/style.css13
-rwxr-xr-xikiwiki-calendar.in9
-rw-r--r--templates/page.tmpl2
19 files changed, 186 insertions, 54 deletions
diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
index ff84bc440..0f0e9518a 100644
--- a/IkiWiki/Plugin/calendar.pm
+++ b/IkiWiki/Plugin/calendar.pm
@@ -47,6 +47,14 @@ sub getsetup () {
safe => 1,
rebuild => 1,
},
+ archive_pagespec => {
+ type => "pagespec",
+ example => "posts/* and !*/Discussion",
+ description => "PageSpec of pages to include in the archives; used by ikiwiki-calendar command",
+ link => 'ikiwiki/PageSpec',
+ safe => 1,
+ rebuild => 0,
+ },
}
sub is_leap_year (@) {
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 644cb588d..3359af314 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -160,7 +160,7 @@ sub preprocess_inline (@) {
my $rss=(($config{rss} || $config{allowrss}) && exists $params{rss}) ? yesno($params{rss}) : $config{rss};
my $atom=(($config{atom} || $config{allowatom}) && exists $params{atom}) ? yesno($params{atom}) : $config{atom};
my $quick=exists $params{quick} ? yesno($params{quick}) : 0;
- my $feeds=! $nested && (exists $params{feeds} ? yesno($params{feeds}) : !$quick);
+ my $feeds=! $nested && (exists $params{feeds} ? yesno($params{feeds}) : !$quick && ! $raw);
my $emptyfeeds=exists $params{emptyfeeds} ? yesno($params{emptyfeeds}) : 1;
my $feedonly=yesno($params{feedonly});
if (! exists $params{show} && ! $archive) {
diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
index 1c0b46830..17b26f7ba 100644
--- a/IkiWiki/Plugin/pagestats.pm
+++ b/IkiWiki/Plugin/pagestats.pm
@@ -75,7 +75,7 @@ sub preprocess (@) {
}
if ($style eq 'table') {
- return "<table class='pageStats'>\n".
+ return "<table class='".(exists $params{class} ? $params{class} : "pageStats")."'>\n".
join("\n", map {
"<tr><td>".
htmllink($params{page}, $params{destpage}, $_, noimageinline => 1).
@@ -87,16 +87,31 @@ sub preprocess (@) {
else {
# In case of misspelling, default to a page cloud
- my $res = "<div class='pagecloud'>\n";
+ my $res;
+ if ($style eq 'list') {
+ $res = "<ul class='".(exists $params{class} ? $params{class} : "list")."'>\n";
+ }
+ else {
+ $res = "<div class='".(exists $params{class} ? $params{class} : "pagecloud")."'>\n";
+ }
foreach my $page (sort keys %counts) {
next unless $counts{$page} > 0;
my $class = $classes[$counts{$page} * scalar(@classes) / ($max + 1)];
+
+ $res.="<li>" if $style eq 'list';
$res .= "<span class=\"$class\">".
htmllink($params{page}, $params{destpage}, $page).
"</span>\n";
+ $res.="</li>" if $style eq 'list';
+
+ }
+ if ($style eq 'list') {
+ $res .= "</ul>\n";
+ }
+ else {
+ $res .= "</div>\n";
}
- $res .= "</div>\n";
return $res;
}
diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm
index 41812e1c1..f706480ca 100644
--- a/IkiWiki/Plugin/sidebar.pm
+++ b/IkiWiki/Plugin/sidebar.pm
@@ -10,6 +10,7 @@ use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "sidebar", call => \&getsetup);
+ hook(type => "preprocess", id => "sidebar", call => \&preprocess);
hook(type => "pagetemplate", id => "sidebar", call => \&pagetemplate);
}
@@ -19,11 +20,53 @@ sub getsetup () {
safe => 1,
rebuild => 1,
},
+ global_sidebars => {
+ type => "boolean",
+ examples => 1,
+ description => "show sidebar page on all pages?",
+ safe => 1,
+ rebuild => 1,
+ },
+}
+
+my %pagesidebar;
+
+sub preprocess (@) {
+ my %params=@_;
+ my $content=shift;
+ shift;
+
+ my $page=$params{page};
+ return "" unless $page eq $params{destpage};
+
+ if (! defined $content) {
+ $pagesidebar{$page}=undef;
+ }
+ else {
+ my $file = $pagesources{$page};
+ my $type = pagetype($file);
+
+ $pagesidebar{$page}=
+ IkiWiki::htmlize($page, $page, $type,
+ IkiWiki::linkify($page, $page,
+ IkiWiki::preprocess($page, $page,
+ IkiWiki::filter($page, $page, $content))));
+ }
+
+ return "";
}
+my $oldfile;
+my $oldcontent;
+
sub sidebar_content ($) {
my $page=shift;
+ return $pagesidebar{$page} if defined $pagesidebar{$page};
+
+ return if ! exists $pagesidebar{$page} &&
+ defined $config{global_sidebars} && ! $config{global_sidebars};
+
my $sidebar_page=bestlink($page, "sidebar") || return;
my $sidebar_file=$pagesources{$sidebar_page} || return;
my $sidebar_type=pagetype($sidebar_file);
@@ -34,7 +77,16 @@ sub sidebar_content ($) {
# currently requires a wiki rebuild.
add_depends($page, $sidebar_page);
- my $content=readfile(srcfile($sidebar_file));
+ my $content;
+ if (defined $oldfile && $sidebar_file eq $oldfile) {
+ $content=$oldcontent;
+ }
+ else {
+ $content=readfile(srcfile($sidebar_file));
+ $oldcontent=$content;
+ $oldfile=$sidebar_file;
+ }
+
return unless length $content;
return IkiWiki::htmlize($sidebar_page, $page, $sidebar_type,
IkiWiki::linkify($sidebar_page, $page,
diff --git a/auto-blog.setup b/auto-blog.setup
index 95347167f..ef03295d6 100644
--- a/auto-blog.setup
+++ b/auto-blog.setup
@@ -36,7 +36,7 @@ IkiWiki::Setup::Automator->import(
cgiurl => "http://$domain/~$ENV{USER}/$wikiname_short/ikiwiki.cgi",
cgi_wrapper => "$ENV{HOME}/public_html/$wikiname_short/ikiwiki.cgi",
adminemail => "$ENV{USER}\@$domain",
- add_plugins => [qw{goodstuff websetup comments opendiscussion blogspam}],
+ add_plugins => [qw{goodstuff websetup comments opendiscussion blogspam calendar sidebar}],
disable_plugins => [qw{}],
libdir => "$ENV{HOME}/.ikiwiki",
rss => 1,
@@ -46,6 +46,8 @@ IkiWiki::Setup::Automator->import(
example => "blog",
comments_pagespec => "posts/* and !*/Discussion",
blogspam_pagespec => "postcomment(*)",
+ archive_pagespec => "posts/* and !*/Discussion",
+ global_sidebars => 0,
discussion => 0,
locked_pages => "*",
tagbase => "tags",
diff --git a/debian/changelog b/debian/changelog
index 26b00a07c..c379253d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ikiwiki (3.20100410) UNRELEASED; urgency=low
+ikiwiki (3.20100415) UNRELEASED; urgency=low
[ Joey Hess ]
* bzr: Fix bzr log parsing to work with bzr 2.0. (liw)
@@ -27,6 +27,20 @@ ikiwiki (3.20100410) UNRELEASED; urgency=low
for master language.
* po: Configuring the same language as master and slave confuses processing;
so filter out such a misconfiguration.
+ * calendar: Add archive_pagespec, which is used by ikiwiki-calendar to
+ specify which pages to include on the calendar archive pages.
+ (The pagespec can still also be specified on the ikiwiki-calendar command
+ line.)
+ * pagestats: Class parameter can be used to override default class for
+ custom styling.
+ * pagestats: Use style=list to get a list of tags, scaled by use like
+ in a tag cloud. This is useful to put in a sidebar.
+ * Rework example blog front page.
+ * CSS and templates for sidebar changed to use a class, not an id.
+ * sidebar: Now a sidebar directive can be used to override the sidebar
+ shown on a page.
+ * Enable calendar and sidebar in auto-blog.setup.
+ * sidebar: Add global_sidebars setting.
-- Joey Hess <joeyh@debian.org> Sun, 04 Apr 2010 12:17:11 -0400
diff --git a/doc/examples/blog.mdwn b/doc/examples/blog.mdwn
index f542cad0c..8775c01ab 100644
--- a/doc/examples/blog.mdwn
+++ b/doc/examples/blog.mdwn
@@ -13,16 +13,11 @@ Some additional configuration you might want to do:
example of how to tag a post is:
\[[!tag tags/life]]
-* Enable the [[sidebar|plugins/sidebar]] plugin to get a sidebar listing all
- the categories you've tagged posts with.
-
* Enable the [[pagestats|plugins/pagestats]] plugin to get a tag cloud
to display on the [[index]].
-* Enable the [[comments|plugins/comments]] plugin and configure it to
- enable comments to posts to the blog:
-
- comments_pagespec => 'blog/posts/* and !*/Discussion',
+* Enable the [[comments|plugins/comments]] plugin to
+ enable comments to posts to the blog.
* Enable the [[calendar|plugins/calendar]] plugin and run the
[[ikiwiki-calendar]] command from cron daily to get an interlinked
diff --git a/doc/examples/blog/archives.mdwn b/doc/examples/blog/archives.mdwn
new file mode 100644
index 000000000..d07b73b74
--- /dev/null
+++ b/doc/examples/blog/archives.mdwn
@@ -0,0 +1,8 @@
+[[!if test="archives/*" then="""
+Browse through blog archives by year:
+[[!map pages="./archives/* and !./archives/*/* and !*/Discussion"]]
+"""
+else="""
+You need to use the `ikiwiki-calendar` program to generate calendar-based
+archive pages.
+"""]]
diff --git a/doc/examples/blog/comments.mdwn b/doc/examples/blog/comments.mdwn
index 4735dea08..0b503ba01 100644
--- a/doc/examples/blog/comments.mdwn
+++ b/doc/examples/blog/comments.mdwn
@@ -1,3 +1,3 @@
-This page will show all comments made to posts in my [[blog|index]].
+This page will show recent comments made to posts in the [[blog|index]].
[[!inline pages="./posts/*/Discussion or internal(./posts/*/comment_*)"]]
diff --git a/doc/examples/blog/index.mdwn b/doc/examples/blog/index.mdwn
index 01b714fcd..a22c40c72 100644
--- a/doc/examples/blog/index.mdwn
+++ b/doc/examples/blog/index.mdwn
@@ -1,13 +1,6 @@
-[[!pagestats pages="./tags/*" among="./posts/*"]]
-
-Welcome to my blog.
-
-Have a look at the most recent posts below, or browse the tag cloud on the
-right. Archives of all [[posts]] and all [[comments]] are also available.
-
[[!inline pages="./posts/* and !*/Discussion" show="10"
actions=yes rootpage="posts"]]
-----
+[[!sidebar]]
This blog is powered by [ikiwiki](http://ikiwiki.info).
diff --git a/doc/examples/blog/sidebar.mdwn b/doc/examples/blog/sidebar.mdwn
index a9fac388e..f24a8e57a 100644
--- a/doc/examples/blog/sidebar.mdwn
+++ b/doc/examples/blog/sidebar.mdwn
@@ -1,7 +1,9 @@
-Example sidebar
+[[Tags]]: [[!pagestats style="list" pages="./tags/*" among="./posts/*"]]
-* [[Blog|index]]
-* [[Archive|posts]]
+[[Recent Comments|comments]]
-Categories:
-[[!map pages="./tags/* and !*/Discussion"]]
+[[Archives]]
+
+[[!if "enabled(calendar)" then="""
+[[!calendar pages="./posts/* and !*/Discussion"]]
+"""]]
diff --git a/doc/ikiwiki-calendar.mdwn b/doc/ikiwiki-calendar.mdwn
index 982892fca..c1f4d7267 100644
--- a/doc/ikiwiki-calendar.mdwn
+++ b/doc/ikiwiki-calendar.mdwn
@@ -16,9 +16,11 @@ You must specify the setup file for your wiki. The pages will
be created inside its `srcdir`, beneath the `archivebase`
directory used by the calendar plugin (default "archives").
-You will probably want to specify a [[ikiwiki/PageSpec]]
-to control which pages are included on the calendars. The
-default is all pages. To limit it to only posts in a blog,
+To control which pages are included on the calendars,
+a [[ikiwiki/PageSpec]] can be specified. The default is
+all pages, or the pages specified by the `comments_pagespec`
+setting in the config file. A pagespec can also be specified
+on the command line. To limit it to only posts in a blog,
use something like "posts/* and !*/Discussion".
It defaults to creating calendar pages for the current
diff --git a/doc/ikiwiki/directive/calendar.mdwn b/doc/ikiwiki/directive/calendar.mdwn
index b2ac75b11..198da9d51 100644
--- a/doc/ikiwiki/directive/calendar.mdwn
+++ b/doc/ikiwiki/directive/calendar.mdwn
@@ -40,9 +40,12 @@ An example crontab:
"month" or "year". The default is a month view calendar.
* `pages` - Specifies the [[ikiwiki/PageSpec]] of pages to link to from the
month calendar. Defaults to "*".
-* `archivebase` - Configures the base of the archives hierarchy. The
- default is "archives". Note that this default can also be overridden
+* `archivebase` - Configures the base of the archives hierarchy.
+ The default is "archives". Note that this default can also be overridden
for the whole wiki by setting `archivebase` in ikiwiki's setup file.
+ Calendars link to pages under here, with names like "2010/04" and
+ "2010". These pages can be automatically created using the
+ `ikiwiki-calendar` program.
* `year` - The year for which the calendar is requested. Defaults to the
current year.
* `month` - The numeric month for which the calendar is requested, in the
diff --git a/doc/ikiwiki/directive/pagestats.mdwn b/doc/ikiwiki/directive/pagestats.mdwn
index 68f4d2734..d0e0e7be7 100644
--- a/doc/ikiwiki/directive/pagestats.mdwn
+++ b/doc/ikiwiki/directive/pagestats.mdwn
@@ -4,10 +4,16 @@ This directive can generate stats about how pages link to each other. It can
produce either a tag cloud, or a table counting the number of links to each
page.
-Here's how to use it to create a [[tag]] cloud:
+Here's how to use it to create a [[tag]] cloud, with tags sized based
+on frequency of use:
\[[!pagestats pages="tags/*"]]
+Here's how to create a list of tags, sized by use as they would be in a
+cloud.
+
+ \[[!pagestats style="list" pages="tags/*"]]
+
And here's how to create a table of all the pages on the wiki:
\[[!pagestats style="table"]]
@@ -28,4 +34,7 @@ links:
\[[!pagestats style="table" show="10"]]
+The optional `class` parameter can be used to control the class
+of the generated tag cloud `div` or page stats `table`.
+
[[!meta robots="noindex, follow"]]
diff --git a/doc/ikiwiki/directive/sidebar.mdwn b/doc/ikiwiki/directive/sidebar.mdwn
new file mode 100644
index 000000000..401d7c786
--- /dev/null
+++ b/doc/ikiwiki/directive/sidebar.mdwn
@@ -0,0 +1,20 @@
+The `sidebar` directive is supplied by the [[!iki plugins/sidebar desc=sidebar]] plugin.
+
+This directive can specify a custom sidebar to display on the page,
+overriding any sidebar that is displayed globally.
+
+If no custom sidebar content is specified, it forces the sidebar page to
+be used as the sidebar, even if the `global_sidebars` setting has been
+used to disable use of the sidebar page by default.
+
+## examples
+
+ \[[!sidebar """
+ This is my custom sidebar for this page.
+
+ \[[!calendar pages="posts/*"]]
+ """]]
+
+ \[[!sidebar]]
+
+[[!meta robots="noindex, follow"]]
diff --git a/doc/plugins/sidebar.mdwn b/doc/plugins/sidebar.mdwn
index 4e356d65a..012733456 100644
--- a/doc/plugins/sidebar.mdwn
+++ b/doc/plugins/sidebar.mdwn
@@ -1,24 +1,27 @@
[[!template id=plugin name=sidebar author="Tuomo Valkonen"]]
[[!tag type/chrome]]
-If this plugin is enabled, then a sidebar is added to pages in the wiki.
-The content of the sidebar is simply the content of a page named
-"sidebar" (ie, create a "sidebar.mdwn").
+This plugin allows adding a sidebar to pages in the wiki.
+
+By default, and unless the `global_sidebars` setting is turned off,
+a sidebar is added to all pages in the wiki. The content of the sidebar
+is simply the content of a page named "sidebar" (ie, create a "sidebar.mdwn").
Typically this will be a page in the root of the wiki, but it can also be a
[[ikiwiki/SubPage]]. In fact, this page,
[[plugins/sidebar|plugins/sidebar]], will be treated as a sidebar for the
[[plugins]] page, and of all of its SubPages, if the plugin is enabled.
-Note that to disable a sidebar for a [[ikiwiki/SubPage]] of a page that has
-a sidebar, you can create a sidebar page that is completely empty. This
-will turn off the sidebar altogether.
+There is also a [[ikiwiki/directive/sidebar]] directive that can be used
+to provide a custom sidebar content for a page.
+
+----
-Warning: Any change to the sidebar will cause a rebuild of the whole wiki,
-since every page includes a copy that has to be updated. This can
-especially be a problem if the sidebar includes an [[ikiwiki/directive/inline]]
-directive, since any changes to pages inlined into the sidebar
-will change the sidebar and cause a full wiki rebuild.
+Warning: Any change to the sidebar page will cause a rebuild of the whole
+wiki, since every page includes a copy that has to be updated. This can
+especially be a problem if the sidebar includes an
+[[ikiwiki/directive/inline]] directive, since any changes to pages inlined
+into the sidebar will change the sidebar and cause a full wiki rebuild.
Instead, if you include a [[ikiwiki/directive/map]] directive on the sidebar,
and it does not use the `show` parameter, only adding or removing pages
diff --git a/doc/style.css b/doc/style.css
index 317d4c7aa..bdd4bb466 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -228,14 +228,15 @@ div.recentchanges {
.bigPC { font-size: 115%; }
.biggestPC { font-size: 130%; }
-#sidebar {
- line-height: 3ex;
- width: 20ex;
+.sidebar {
+ width: 30ex;
float: right;
- margin-left: 40px;
- margin-bottom: 40px;
- padding: 2ex 2ex;
+ margin-left: 4px;
+ margin-bottom: 4px;
+ margin-top: -1px;
+ padding: 0ex 2ex;
background: white;
+ border: 2px solid black;
color: black !important;
}
diff --git a/ikiwiki-calendar.in b/ikiwiki-calendar.in
index 9738ea5f7..cdfecff3f 100755
--- a/ikiwiki-calendar.in
+++ b/ikiwiki-calendar.in
@@ -15,7 +15,7 @@ GetOptions(
"force" => \$force,
) || usage();
my $setup=shift || usage();
-my $pagespec=shift || "*";
+my $pagespec=shift;
my $startyear=shift || 1900+(localtime(time))[5];
my $endyear=shift || $startyear;
@@ -27,6 +27,10 @@ IkiWiki::checkconfig();
my $archivebase = 'archives';
$archivebase = $config{archivebase} if defined $config{archivebase};
+if (! defined $pagespec) {
+ $pagespec=$config{archive_pagespec} || "*";
+}
+
sub writearchive ($$;$) {
my $template=template(shift);
my $year=shift;
@@ -55,4 +59,5 @@ foreach my $y ($startyear..$endyear) {
IkiWiki::rcs_commit_staged(gettext("calendar update"), undef, undef)
if $config{rcs};
-system("ikiwiki", "-setup", $setup, "-refresh");
+exec("ikiwiki", "-setup", $setup, "-refresh");
+die "failed to run ikiwiki -setup $setup -refresh\n";
diff --git a/templates/page.tmpl b/templates/page.tmpl
index c24f88823..7e850a56b 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -92,7 +92,7 @@
</div> <!-- .pageheader -->
<TMPL_IF SIDEBAR>
-<div id="sidebar">
+<div class="sidebar">
<TMPL_VAR SIDEBAR>
</div>
</TMPL_IF>