summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-08-18 00:24:22 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-08-18 00:24:22 +0000
commitcedb48765b52d3e074f43703cf55611b3bce101d (patch)
treeeb35fa82b6ed9f2c63cb111453de2a5af59d9188
parent5d37a3837c6a047d47ec6eadc0859c97db65416e (diff)
* Add a tail fin^W^Wsidebar plugin by Tuomo Valkonen.
* If a page links to itself, mark up the link text in a span with class="selflink" so that it can be styled. I don't have a useful style defined for that though.
-rw-r--r--IkiWiki.pm3
-rw-r--r--IkiWiki/Plugin/sidebar.pm48
-rw-r--r--basewiki/style.css9
-rw-r--r--debian/changelog9
-rw-r--r--doc/ikiwiki.setup3
-rw-r--r--doc/plugins.mdwn2
-rw-r--r--doc/plugins/sidebar.mdwn12
-rw-r--r--doc/plugins/type/chrome.mdwn1
-rw-r--r--templates/page.tmpl6
9 files changed, 90 insertions, 3 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 4fc37110b..4e3011918 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -345,7 +345,8 @@ sub htmllink ($$$;$$$) { #{{{
$linktext=pagetitle(basename($link)) unless defined $linktext;
- return $linktext if length $bestlink && $page eq $bestlink;
+ return "<span class=\"selflink\">$linktext</span>"
+ if length $bestlink && $page eq $bestlink;
# 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
diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm
new file mode 100644
index 000000000..a6efc6b8e
--- /dev/null
+++ b/IkiWiki/Plugin/sidebar.pm
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+# Sidebar plugin.
+# by Tuomo Valkonen <tuomov at iki dot fi>
+
+package IkiWiki::Plugin::sidebar;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+sub import { #{{{
+ IkiWiki::hook(type => "pagetemplate", id => "sidebar",
+ call => \&pagetemplate);
+} # }}}
+
+sub sidebar_content ($) { #{{{
+ my $page=shift;
+
+ my $sidebar_page=IkiWiki::bestlink($page, "sidebar") || return;
+ my $sidebar_file=$IkiWiki::pagesources{$sidebar_page} || return;
+ my $sidebar_type=IkiWiki::pagetype($sidebar_file);
+
+ if (defined $sidebar_type) {
+ IkiWiki::add_depends($page, $sidebar_page);
+ my $content=IkiWiki::readfile(IkiWiki::srcfile($sidebar_file));
+ return unless length $content;
+ return IkiWiki::htmlize($sidebar_type,
+ IkiWiki::preprocess($sidebar_page, $page,
+ IkiWiki::linkify($sidebar_page, $page, $content)));
+ }
+
+} # }}}
+
+sub pagetemplate (@) { #{{{
+ my %params=@_;
+
+ my $page=$params{page};
+ my $template=$params{template};
+
+ if ($template->query(name => "sidebar")) {
+ my $content=sidebar_content($page);
+ if (defined $content && length $content) {
+ $template->param(sidebar => $content);
+ }
+ }
+} # }}}
+
+1
diff --git a/basewiki/style.css b/basewiki/style.css
index 3eb565da2..b975c89f2 100644
--- a/basewiki/style.css
+++ b/basewiki/style.css
@@ -129,3 +129,12 @@ td.changelog {
.normalPC { font-size: 100%; }
.bigPC { font-size: 115%; }
.biggestPC { font-size: 130%; }
+
+#sidebar {
+ line-height: 3ex;
+ width: 20ex;
+ float: right;
+ margin-left: 40px;
+ margin-bottom: 40px;
+ padding: 2ex 2ex;
+}
diff --git a/debian/changelog b/debian/changelog
index af03c72f5..9223500f9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+ikiwiki (1.21) UNRELEASED; urgency=low
+
+ * Add a tail fin^W^Wsidebar plugin by Tuomo Valkonen.
+ * If a page links to itself, mark up the link text in a span with
+ class="selflink" so that it can be styled. I don't have a useful style
+ defined for that though.
+
+ -- Joey Hess <joeyh@debian.org> Thu, 17 Aug 2006 20:18:23 -0400
+
ikiwiki (1.20) unstable; urgency=low
* Relicense the templates and basewiki under the 2-clause BSD license.
diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup
index e14991299..a0ce5a468 100644
--- a/doc/ikiwiki.setup
+++ b/doc/ikiwiki.setup
@@ -80,7 +80,8 @@ use IkiWiki::Setup::Standard {
# To add plugins, list them here.
#add_plugins => [qw{meta tag pagecount brokenlinks search smiley
- # wikitext camelcase pagestats htmltidy fortune}],
+ # wikitext camelcase pagestats htmltidy fortune
+ # sidebar}],
# If you want to disable any of the default plugins, list them here.
#disable_plugins => [qw{inline htmlscrubber}],
}
diff --git a/doc/plugins.mdwn b/doc/plugins.mdwn
index 1c04d09f5..efcf65a7d 100644
--- a/doc/plugins.mdwn
+++ b/doc/plugins.mdwn
@@ -1,7 +1,7 @@
Most of ikiwiki's [[features]] are implemented as plugins. Beyond the
[[type/core]] features, there are plugins to [[type/format]] text,
use [[type/tags]], show [[type/meta]] information, do other [[type/useful]]
-stuff, or just have [[type/fun]].
+stuff, add [[type/chrome]] to the wiki, or just have [[type/fun]].
There's documentation if you want to [[write]] your own plugins, or you can
install and use plugins contributed by others.
diff --git a/doc/plugins/sidebar.mdwn b/doc/plugins/sidebar.mdwn
new file mode 100644
index 000000000..644d1e630
--- /dev/null
+++ b/doc/plugins/sidebar.mdwn
@@ -0,0 +1,12 @@
+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".
+
+Typically this will be a page in the root of the wiki, but it can also be a
+[[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.
+
+This plugin is included in ikiwiki, but is not enabled by default.
+
+[[tag type/chrome]]
diff --git a/doc/plugins/type/chrome.mdwn b/doc/plugins/type/chrome.mdwn
new file mode 100644
index 000000000..d3f0eb3d3
--- /dev/null
+++ b/doc/plugins/type/chrome.mdwn
@@ -0,0 +1 @@
+These plugins affect the look and feel of the wiki.
diff --git a/templates/page.tmpl b/templates/page.tmpl
index 5bdde1fbc..47bbfcda3 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -45,6 +45,12 @@
</div>
</TMPL_IF>
+<TMPL_IF SIDEBAR>
+<div id="sidebar">
+<TMPL_VAR SIDEBAR>
+</div>
+</TMPL_IF>
+
<div id="content">
<TMPL_VAR CONTENT>
</div>