]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 15 Apr 2010 21:40:18 +0000 (17:40 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 15 Apr 2010 21:40:18 +0000 (17:40 -0400)
19 files changed:
IkiWiki/Plugin/calendar.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/pagestats.pm
IkiWiki/Plugin/sidebar.pm
auto-blog.setup
debian/changelog
doc/examples/blog.mdwn
doc/examples/blog/archives.mdwn [new file with mode: 0644]
doc/examples/blog/comments.mdwn
doc/examples/blog/index.mdwn
doc/examples/blog/sidebar.mdwn
doc/ikiwiki-calendar.mdwn
doc/ikiwiki/directive/calendar.mdwn
doc/ikiwiki/directive/pagestats.mdwn
doc/ikiwiki/directive/sidebar.mdwn [new file with mode: 0644]
doc/plugins/sidebar.mdwn
doc/style.css
ikiwiki-calendar.in
templates/page.tmpl

index ff84bc4409cd1f397980d4eb14b6d478a08cd70d..0f0e9518adf27b0ca3f912622d89b71ea13f5aa6 100644 (file)
@@ -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 (@) {
index 644cb588d6d0283237f62d92208e58011642ee3a..3359af31410b3c7eb9a5b2c7655ce91c707acdba 100644 (file)
@@ -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) {
index 1c0b46830163da3872a0e4b62f0db4960ca3605c..17b26f7baa75ed3b3e68c95f310f6821227d0c89 100644 (file)
@@ -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;
        }
index 41812e1c1f671da84be1a06a5821695fc5dc6f11..f706480caabaf3f39855e03ec26f6ee627fcd226 100644 (file)
@@ -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,
index 95347167f44cc19364325d50b62b71eb4634bf3a..ef03295d68bf5c9c4d3b93c208c17a346be5ad38 100644 (file)
@@ -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",
index 26b00a07c527dba49ba787a6a6b3b5ca364ea74a..c379253d7e38eb6a98be4f384e93ec540847dd60 100644 (file)
@@ -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
 
index f542cad0cc7f0eda437975610f804d284f552a43..8775c01abc2f12cffd9ae34939be51f3acdeb07c 100644 (file)
@@ -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 (file)
index 0000000..d07b73b
--- /dev/null
@@ -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.
+"""]]
index 4735dea08f8c87813a56a340f3c0bb55d8b09ff6..0b503ba0198057b9b23d898d6f5bcfbd5ed3b9ad 100644 (file)
@@ -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_*)"]]
index 01b714fcdfbcd6744a962bbe9f5bdf24f8dd021e..a22c40c72049c39eae000c03563f99e60a104780 100644 (file)
@@ -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).
index a9fac388ea953f6f973dedde8e247e31c441721c..f24a8e57a3bcfdc16f02d402a93029616d86bb3c 100644 (file)
@@ -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"]]
+"""]]
index 982892fca25a21ec62458b11f3e98602ec5602b6..c1f4d72670c92cc0bc79aafb40ec4dcb3aa76089 100644 (file)
@@ -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
index b2ac75b11694eed8cc67178cf2508814ee30f96d..198da9d51c33cef97bbf2884b6c77b27e5137419 100644 (file)
@@ -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
index 68f4d2734ad06f1be5c2c379a8953a3a7ac0bb51..d0e0e7be720b738859b8d6788f721b3d410ab722 100644 (file)
@@ -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 (file)
index 0000000..401d7c7
--- /dev/null
@@ -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"]]
index 4e356d65a8984885a256788f82f1f2173ffeaa67..01273345630233b49720490af9867beaff46f8b5 100644 (file)
@@ -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
index 317d4c7aacbb3efb76b52a8c664d11a4cdfdb163..bdd4bb4666faca9bbc74bb785f3c35778b2ed4a5 100644 (file)
@@ -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;
 }
 
index 9738ea5f7195cef46bf6480fc5c515fd89438cbe..cdfecff3f3a41e2c5c2ff3d2ef9230eb1453d6df 100755 (executable)
@@ -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";
index c24f88823e29a8bd008752141017e3cc73eee238..7e850a56bacd93549d07f4920e4bc35b9507f414 100644 (file)
@@ -92,7 +92,7 @@
 </div> <!-- .pageheader -->
 
 <TMPL_IF SIDEBAR>
-<div id="sidebar">
+<div class="sidebar">
 <TMPL_VAR SIDEBAR>
 </div>
 </TMPL_IF>