aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-02-20 03:05:47 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-02-20 03:05:47 +0000
commitfa52a730ff3b30c7d2cdd8cd5f9c8c25a0c0a2a5 (patch)
tree3a4eadd971ccd69bd4037ad3647b6cce64047833 /IkiWiki
parent2ce6c23f9485d26d443fb5a1f8c5286a5e668625 (diff)
downloadikiwiki-fa52a730ff3b30c7d2cdd8cd5f9c8c25a0c0a2a5.tar
ikiwiki-fa52a730ff3b30c7d2cdd8cd5f9c8c25a0c0a2a5.tar.gz
* Changed calling convention for httmllink slightly. The first three
parameters remain the same, but additional options are now passed in using named parameters. * Change plugin interface version to 1.02 to reflect this change. * Add a new anchor option to htmllink. Thanks Ben for the idea. * Support anchors in wikilinks. * Add a "more" plugin based on one contributed by Ben to allow implementing those dreaded "Read more" links in blogs.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/CGI.pm10
-rw-r--r--IkiWiki/Plugin/brokenlinks.pm4
-rw-r--r--IkiWiki/Plugin/inline.pm7
-rw-r--r--IkiWiki/Plugin/lockedit.pm4
-rw-r--r--IkiWiki/Plugin/map.pm3
-rw-r--r--IkiWiki/Plugin/more.pm32
-rw-r--r--IkiWiki/Plugin/openid.pm2
-rw-r--r--IkiWiki/Plugin/orphans.pm10
-rw-r--r--IkiWiki/Plugin/otl.pm4
-rw-r--r--IkiWiki/Plugin/pagestats.pm2
-rw-r--r--IkiWiki/Plugin/smiley.pm2
-rw-r--r--IkiWiki/Render.pm2
12 files changed, 65 insertions, 17 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 973053427..af3bb8a4a 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -89,7 +89,9 @@ sub cgi_recentchanges ($) { #{{{
delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess;
$change->{pages} = [
map {
- $_->{link} = htmllink("", "", $_->{page}, 1, 0, pagetitle($_->{page}));
+ $_->{link} = htmllink("", "", $_->{page},
+ noimageinline => 1,
+ linktext => pagetitle($_->{page}));
$_;
} @{$change->{pages}}
];
@@ -219,7 +221,7 @@ sub cgi_prefs ($$) { #{{{
$form->field(name => "do", type => "hidden");
$form->field(name => "email", size => 50);
$form->field(name => "subscriptions", size => 50,
- comment => "(".htmllink("", "", "PageSpec", 1).")");
+ comment => "(".htmllink("", "", "PageSpec", noimageinline => 1).")");
$form->field(name => "banned_users", size => 50);
my $user_name=$session->param("name");
@@ -360,7 +362,7 @@ sub cgi_editpage ($$) { #{{{
$form->tmpl_param("can_commit", $config{rcs});
$form->tmpl_param("indexlink", indexlink());
$form->tmpl_param("helponformattinglink",
- htmllink("", "", "HelpOnFormatting", 1));
+ htmllink("", "", "HelpOnFormatting", noimageinline => 1));
$form->tmpl_param("baseurl", baseurl());
if (! $form->submitted) {
$form->field(name => "rcsinfo", value => rcs_prepedit($file),
@@ -709,7 +711,7 @@ sub userlink ($) { #{{{
else {
return htmllink("", "", escapeHTML(
length $config{userdir} ? $config{userdir}."/".$user : $user
- ), 1);
+ ), noimageinline => 1);
}
} #}}}
diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm
index af2418ff4..d9d50f75f 100644
--- a/IkiWiki/Plugin/brokenlinks.pm
+++ b/IkiWiki/Plugin/brokenlinks.pm
@@ -27,9 +27,9 @@ sub preprocess (@) { #{{{
my $bestlink=bestlink($page, $link);
next if length $bestlink;
push @broken,
- htmllink($page, $params{destpage}, $link, 1).
+ htmllink($page, $params{destpage}, $link, noimageinline => 1).
" from ".
- htmllink($params{page}, $params{destpage}, $page, 1);
+ htmllink($params{page}, $params{destpage}, $page, noimageinline => 1);
}
}
}
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 57b4057d7..ebfcee9ed 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -166,7 +166,12 @@ sub preprocess_inline (@) { #{{{
(length $config{cgiurl} ||
exists $links{$page."/".$discussionlink})) {
$template->param(have_actions => 1);
- $template->param(discussionlink => htmllink($page, $params{page}, gettext("Discussion"), 1, 1));
+ $template->param(discussionlink =>
+ htmllink($page,
+ $params{page},
+ gettext("Discussion"),
+ noimageinline => 1,
+ forcesubpage => 1));
}
}
if (length $config{cgiurl} && defined $type) {
diff --git a/IkiWiki/Plugin/lockedit.pm b/IkiWiki/Plugin/lockedit.pm
index 2b72fabe5..f204e72c0 100644
--- a/IkiWiki/Plugin/lockedit.pm
+++ b/IkiWiki/Plugin/lockedit.pm
@@ -22,7 +22,7 @@ sub canedit ($$) { #{{{
foreach my $admin (@{$config{adminuser}}) {
if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"), "")) {
return sprintf(gettext("%s is locked by %s and cannot be edited"),
- htmllink("", "", $page, 1),
+ htmllink("", "", $page, noimageinline => 1),
IkiWiki::userlink($admin));
}
}
@@ -40,7 +40,7 @@ sub formbuilder_setup (@) { #{{{
if ($form->title eq "preferences") {
$form->field(name => "locked_pages", size => 50,
- comment => "(".htmllink("", "", "PageSpec", 1).")");
+ comment => "(".htmllink("", "", "PageSpec", noimageinline => 1).")");
if (! IkiWiki::is_admin($user_name)) {
$form->field(name => "locked_pages", type => "hidden");
}
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
index 3c41194f4..07b63cb70 100644
--- a/IkiWiki/Plugin/map.pm
+++ b/IkiWiki/Plugin/map.pm
@@ -49,7 +49,8 @@ sub preprocess (@) { #{{{
}
$map .= "</li>\n" if $openli;
$map .= "<li>"
- .htmllink($params{page}, $params{destpage}, $item) ."\n";
+ .htmllink($params{page}, $params{destpage}, $item)
+ ."\n";
$openli=1;
}
while ($indent > 0) {
diff --git a/IkiWiki/Plugin/more.pm b/IkiWiki/Plugin/more.pm
new file mode 100644
index 000000000..dae3728ba
--- /dev/null
+++ b/IkiWiki/Plugin/more.pm
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::more;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+my $linktext = gettext("more");
+
+sub import { #{{{
+ hook(type => "preprocess", id => "more", call => \&preprocess);
+} # }}}
+
+sub preprocess (@) { #{{{
+ my %params=@_;
+
+ $params{linktext} = $linktext unless defined $params{linktext};
+
+ if ($params{page} ne $params{destpage}) {
+ return "\n".
+ htmllink($params{page}, $params{destpage}, $params{page},
+ linktext => $params{linktext},
+ anchor => "more");
+ }
+ else {
+ $params{text}=IkiWiki::preprocess($params{page}, $params{destpage},
+ IkiWiki::filter($params{page}, $params{text}));
+ return "<a name=\"more\"></a>\n\n".$params{text};
+ }
+}
+
+1
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index 5d387fbc6..65b884814 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -33,7 +33,7 @@ sub formbuilder_setup (@) { #{{{
label => "OpenID",
size => 30,
comment => '('.
- htmllink("", "", "OpenID", 1, 0, gettext("What's this?"))
+ htmllink("", "", "OpenID", noimageinline => 1, linktext => gettext("What's this?"))
.($config{openidsignup} ? " | <a href=\"$config{openidsignup}\">".gettext("Get an OpenID")."</a>" : "")
.')'
);
diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm
index 39d836a01..f221954b8 100644
--- a/IkiWiki/Plugin/orphans.pm
+++ b/IkiWiki/Plugin/orphans.pm
@@ -40,7 +40,15 @@ sub preprocess (@) { #{{{
}
return gettext("All pages are linked to by other pages.") unless @orphans;
- return "<ul>\n".join("\n", map { "<li>".htmllink($params{page}, $params{destpage}, $_, 1)."</li>" } sort @orphans)."</ul>\n";
+ return "<ul>\n".
+ join("\n",
+ map {
+ "<li>".
+ htmllink($params{page}, $params{destpage}, $_,
+ noimageinline => 1).
+ "</li>"
+ } sort @orphans).
+ "</ul>\n";
} # }}}
1
diff --git a/IkiWiki/Plugin/otl.pm b/IkiWiki/Plugin/otl.pm
index 3f3413390..94a2b80f6 100644
--- a/IkiWiki/Plugin/otl.pm
+++ b/IkiWiki/Plugin/otl.pm
@@ -17,9 +17,9 @@ sub filter (@) { #{{{
# Munge up check boxes to look a little bit better. This is a hack.
my $checked=htmllink($params{page}, $params{page},
- "smileys/star_on.png", 0, 0, "[X]");
+ "smileys/star_on.png", linktext => "[X]");
my $unchecked=htmllink($params{page}, $params{page},
- "smileys/star_off.png", 0, 0, "[_]");
+ "smileys/star_off.png", linktext => "[_]");
$params{content}=~s/^(\s*)\[X\]\s/${1}$checked /mg;
$params{content}=~s/^(\s*)\[_\]\s/${1}$unchecked /mg;
diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
index f9a54ab56..1edb39455 100644
--- a/IkiWiki/Plugin/pagestats.pm
+++ b/IkiWiki/Plugin/pagestats.pm
@@ -45,7 +45,7 @@ sub preprocess (@) { #{{{
return "<table class='pageStats'>\n".
join("\n", map {
"<tr><td>".
- htmllink($params{page}, $params{destpage}, $_, 1).
+ htmllink($params{page}, $params{destpage}, $_, noimageinline => 1).
"</td><td>".$counts{$_}."</td></tr>"
}
sort { $counts{$b} <=> $counts{$a} } keys %counts).
diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm
index 45d00abea..14b8cacf8 100644
--- a/IkiWiki/Plugin/smiley.pm
+++ b/IkiWiki/Plugin/smiley.pm
@@ -35,7 +35,7 @@ sub filter (@) { #{{{
my %params=@_;
$params{content} =~ s{(?:^|(?<=\s))(\\?)$smiley_regexp(?:(?=\s)|$)}{
- $1 ? $2 : htmllink($params{page}, $params{page}, $smileys{$2}, 0, 0, $2)
+ $1 ? $2 : htmllink($params{page}, $params{page}, $smileys{$2}, linktext => $2)
}egs;
return $params{content};
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index cbba28251..3545df05a 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -98,7 +98,7 @@ sub genpage ($$$) { #{{{
if ($page !~ /.*\/\Q$discussionlink\E$/ &&
(length $config{cgiurl} ||
exists $links{$page."/".$discussionlink})) {
- $template->param(discussionlink => htmllink($page, $page, gettext("Discussion"), 1, 1));
+ $template->param(discussionlink => htmllink($page, $page, gettext("Discussion"), noimageinline => 1, forcesubpage => 1));
$actions++;
}
}