aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2010-03-24 03:18:24 +0000
committerSimon McVittie <smcv@debian.org>2010-03-24 03:18:24 +0000
commitb0ae19872d443860aeaab7069255e3a68a520887 (patch)
treeacaec88d259d9a9d31397603a2fa407db0d84e7a /IkiWiki
parent0618f099dab8bd4f7f47e2695db01eabe49e3316 (diff)
downloadikiwiki-b0ae19872d443860aeaab7069255e3a68a520887.tar
ikiwiki-b0ae19872d443860aeaab7069255e3a68a520887.tar.gz
Add an optional "sort" argument to meta titles, defaulting to the title
This allows correct sorting of titles, names, etc., with: [[!meta title="David Bowie" sort="Bowie, David"]] [[!meta title="The Beatles" sort="Beatles, The"]]
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/meta.pm16
1 files changed, 11 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index bf8159814..a470041c9 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -90,6 +90,12 @@ sub preprocess (@) {
# Metadata collection that needs to happen during the scan pass.
if ($key eq 'title') {
$pagestate{$page}{meta}{title}=HTML::Entities::encode_numeric($value);
+ if (exists $params{sort}) {
+ $pagestate{$page}{meta}{titlesort}=$params{sort};
+ }
+ else {
+ $pagestate{$page}{meta}{titlesort}=$value;
+ }
return "";
}
elsif ($key eq 'description') {
@@ -283,18 +289,18 @@ sub pagetemplate (@) {
}
}
-sub title {
- my $title = $pagestate{$_[0]}{meta}{title};
+sub titlesort {
+ my $key = $pagestate{$_[0]}{meta}{titlesort};
- if (defined $title) {
- return $title;
+ if (defined $key) {
+ return $key;
}
return pagetitle(IkiWiki::basename($_[0]));
}
sub sort_meta_title {
- return title($_[0]) cmp title($_[1]);
+ return titlesort($_[0]) cmp titlesort($_[1]);
}
sub match {