Package: ikiwiki
Version: 2.48~bpo40+1
Severity: wishlist
Tags: patch
Hello, the enclosed patch allows the map plugin to use fields from the
meta plugin instead of the page name as the list item text. By default,
the meta title will be used but a different field can be used by
specifying the key parameter. E.g.
[[map pages="*" key="description"]]
and
[[meta title="Serious article" description="PANCAKES!"]]
would render PANCAKES! as the link text.
The only dodgy bit you might want to reject is the line where I use
HTML::Entities::decode. The problem is that the meta plugin already
encodes fields that contain unicode characters. So when I try and use
Devanagari text as the link text I get e.g.
जैमिनि
instead of:
à¤à¥à¤®à¤¿à¤¨à¤¿
HTML::Entities::decode works for me but I don't know if it is the best
approach. What do you think?
--- map.pm.orig 2008-06-02 23:42:37.000000000 -0500
+++ map.pm 2008-06-04 08:55:34.000000000 -0500
@@ -18,6 +18,7 @@
sub preprocess (@) { #{{{
my [EMAIL PROTECTED];
$params{pages}="*" unless defined $params{pages};
+ $params{key}="title" unless defined $params{key};
my $common_prefix;
@@ -25,8 +26,12 @@
my %mapitems;
foreach my $page (keys %pagesources) {
if (pagespec_match($page, $params{pages}, location => $params{page})) {
- $mapitems{$page}=1;
-
+ if (exists $pagestate{$page}{meta}{$params{key}}) {
+ $mapitems{$page}=$pagestate{$page}{meta}{$params{key}};
+ }
+ else {
+ $mapitems{$page}=$page;
+ }
# Check for a common prefix.
if (! defined $common_prefix) {
$common_prefix=$page;
@@ -66,7 +71,8 @@
my $openli=0;
my $dummy=0;
my $map = "<div class='map'>\n<ul>\n";
- foreach my $item (sort keys %mapitems) {
+ foreach my $item (sort { $mapitems{$a} cmp $mapitems{$b} } keys %mapitems) {
+ my $linktext = $mapitems{$item};
$item=~s/^\Q$common_prefix\E\///
if defined $common_prefix && length $common_prefix;
my $depth = ($item =~ tr/\//\//) + 1;
@@ -114,6 +120,7 @@
$map .= "<li>"
.htmllink($params{page}, $params{destpage},
"/".$common_prefix."/".$item,
+ linktext => HTML::Entities::decode_entities($linktext),
class => "mapitem", noimageinline => 1)
."\n";
$openli=1;