".
- gettext("Your comment will be posted after moderator review"),
+ gettext("Your comment will be posted after moderator review").
"
");
exit;
}
--
cgit v1.2.3
From 4e92548ebc39c083e7ed8b870f4c13ba229127cd Mon Sep 17 00:00:00 2001
From: Simon McVittie ".
- sprintf(gettext("The page %s does not exist."),
- htmllink("", "", $page)).
- "
");
- }
- else {
- IkiWiki::redirect($cgi, urlto($link, undef, 1));
- }
-
- exit;
- }
-}
-
sub sessioncgi ($$) {
my $cgi=shift;
my $session=shift;
--
cgit v1.2.3
From a981d6857f1eab350460116c1b5d868ed0215d29 Mon Sep 17 00:00:00 2001
From: Simon McVittie ".
- sprintf(gettext("The page %s does not exist."),
- htmllink("", "", $page)).
- "
");
- }
- else {
- IkiWiki::redirect($cgi, urlto($link, undef, 1));
- }
-
- exit;
- }
-}
-
sub store ($$$) {
my $change=shift;
@@ -138,7 +95,7 @@ sub store ($$$) {
if (length $config{cgiurl}) {
$_->{link} = " "recentchanges_link",
+ do => "goto",
page => $_->{page}
).
"\" rel=\"nofollow\">".
--
cgit v1.2.3
From 46b880f8390ac82d746add01de38a05155743374 Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Sat, 31 Jan 2009 22:32:10 +0000
Subject: Split apache404 into an independent plugin
Also make it ignore the 'do' parameter at Joey's suggestion, to have one
less thing to remember when configuring.
---
IkiWiki/CGI.pm | 49 +-------------------------
IkiWiki/Plugin/apache404.pm | 76 ++++++++++++++++++++++++++++++++++++++++
doc/plugins/apache404.mdwn | 11 ++++++
doc/tips/apache_404_handler.mdwn | 10 ------
t/apache404.t | 45 ++++++++++++++++++++++++
t/cgi_page_from_404.t | 43 -----------------------
6 files changed, 133 insertions(+), 101 deletions(-)
create mode 100644 IkiWiki/Plugin/apache404.pm
create mode 100644 doc/plugins/apache404.mdwn
delete mode 100644 doc/tips/apache_404_handler.mdwn
create mode 100755 t/apache404.t
delete mode 100755 t/cgi_page_from_404.t
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 8734cdd49..e75ebcd27 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -338,46 +338,6 @@ sub cgi_goto ($;$) {
exit;
}
-sub cgi_page_from_404 ($$$) {
- my $path = shift;
- my $baseurl = shift;
- my $usedirs = shift;
-
- # fail if missing from environment or whatever
- return undef unless defined $path;
- return undef unless defined $baseurl;
-
- # with usedirs on, path is like /~fred/foo/bar/ or /~fred/foo/bar or
- # /~fred/foo/bar/index.html
- # with usedirs off, path is like /~fred/foo/bar.html
- # baseurl is like 'http://people.example.com/~fred'
-
- # convert baseurl to ~fred
- unless ($baseurl =~ s{^https?://[^/]+/?}{}) {
- return undef;
- }
-
- # convert path to /~fred/foo/bar
- if ($usedirs) {
- $path =~ s/\/*(?:index\.$config{htmlext})?$//;
- }
- else {
- $path =~ s/\.$config{htmlext}$//;
- }
-
- # remove /~fred/
- unless ($path =~ s{^/*\Q$baseurl\E/*}{}) {
- return undef;
- }
-
- # special case for the index
- unless ($path) {
- return 'index';
- }
-
- return $path;
-}
-
sub cgi (;$$) {
my $q=shift;
my $session=shift;
@@ -409,14 +369,7 @@ sub cgi (;$$) {
# commenter are for compatibility with any saved URLs
if ($do eq 'goto' || $do eq 'recentchanges_link' ||
$do eq 'commenter') {
- my $page = undef;
-
- if ($ENV{REDIRECT_STATUS} eq '404') {
- $page = cgi_page_from_404($ENV{REDIRECT_URL},
- $config{url}, $config{usedirs});
- }
-
- cgi_goto($q, $page);
+ cgi_goto($q);
}
# Need to lock the wiki before getting a session.
diff --git a/IkiWiki/Plugin/apache404.pm b/IkiWiki/Plugin/apache404.pm
new file mode 100644
index 000000000..3ac6b3af5
--- /dev/null
+++ b/IkiWiki/Plugin/apache404.pm
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+# Copyright © 2009 Simon McVittie
+# Licensed under the GNU GPL, version 2, or any later version published by the
+# Free Software Foundation
+package IkiWiki::Plugin::apache404;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+ hook(type => "cgi", id => 'apache404', call => \&cgi);
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ # not really a matter of safety, but enabling/disabling
+ # through a web interface is useless - it needs web
+ # server admin action too
+ safe => 0,
+ rebuild => 0,
+ }
+}
+
+sub cgi_page_from_404 ($$$) {
+ my $path = shift;
+ my $baseurl = shift;
+ my $usedirs = shift;
+
+ # fail if missing from environment or whatever
+ return undef unless defined $path;
+ return undef unless defined $baseurl;
+
+ # with usedirs on, path is like /~fred/foo/bar/ or /~fred/foo/bar or
+ # /~fred/foo/bar/index.html
+ # with usedirs off, path is like /~fred/foo/bar.html
+ # baseurl is like 'http://people.example.com/~fred'
+
+ # convert baseurl to ~fred
+ unless ($baseurl =~ s{^https?://[^/]+/?}{}) {
+ return undef;
+ }
+
+ # convert path to /~fred/foo/bar
+ if ($usedirs) {
+ $path =~ s/\/*(?:index\.$config{htmlext})?$//;
+ }
+ else {
+ $path =~ s/\.$config{htmlext}$//;
+ }
+
+ # remove /~fred/
+ unless ($path =~ s{^/*\Q$baseurl\E/*}{}) {
+ return undef;
+ }
+
+ # special case for the index
+ unless ($path) {
+ return 'index';
+ }
+
+ return $path;
+}
+
+sub cgi ($) {
+ my $cgi=shift;
+
+ if ($ENV{REDIRECT_STATUS} eq '404') {
+ my $page = cgi_page_from_404($ENV{REDIRECT_URL},
+ $config{url}, $config{usedirs});
+ IkiWiki::cgi_goto($cgi, $page);
+ }
+}
+
+1;
diff --git a/doc/plugins/apache404.mdwn b/doc/plugins/apache404.mdwn
new file mode 100644
index 000000000..bab8fb59d
--- /dev/null
+++ b/doc/plugins/apache404.mdwn
@@ -0,0 +1,11 @@
+[[!template id=plugin name=apache404 author="[[Simon_McVittie|smcv]]"]]
+[[!tag type/useful]]
+
+This plugin lets you use the IkiWiki CGI script as an Apache 404 handler,
+to give the behaviour of various other wiki engines where visiting a
+nonexistent page provides you with a link to create it.
+
+To achieve this, put something like this in the wiki's Apache configuration
+file:
+
+ ErrorDocument 404 /cgi-bin/ikiwiki.cgi
diff --git a/doc/tips/apache_404_handler.mdwn b/doc/tips/apache_404_handler.mdwn
deleted file mode 100644
index 0fda759e7..000000000
--- a/doc/tips/apache_404_handler.mdwn
+++ /dev/null
@@ -1,10 +0,0 @@
-[[!meta title="Apache 404 handler"]]
-
-Sufficiently recent versions of IkiWiki can be used as an Apache 404 handler,
-to give the behaviour of various other wiki engines where visiting a
-nonexistent page provides you with a link to create it.
-
-To achieve this, put something like this in the wiki's Apache configuration
-file:
-
- ErrorDocument 404 /cgi-bin/ikiwiki.cgi?do=goto
diff --git a/t/apache404.t b/t/apache404.t
new file mode 100755
index 000000000..00fc35250
--- /dev/null
+++ b/t/apache404.t
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 17;
+
+BEGIN { use_ok("IkiWiki::Plugin::apache404"); }
+
+sub cgi_page_from_404 {
+ return IkiWiki::Plugin::apache404::cgi_page_from_404(shift, shift,
+ shift);
+}
+
+$IkiWiki::config{htmlext} = 'html';
+
+is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
+is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
+is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
+is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
+
+is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
+ 'foo/bar');
+
+is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
+ 'foo/bar');
+
+is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
+ 'foo');
+is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
+ 'foo');
+is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
+ 'foo');
+is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),
+ 'foo');
diff --git a/t/cgi_page_from_404.t b/t/cgi_page_from_404.t
deleted file mode 100755
index adbbdf874..000000000
--- a/t/cgi_page_from_404.t
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/perl
-use warnings;
-use strict;
-use Test::More tests => 18;
-
-BEGIN { use_ok("IkiWiki"); }
-BEGIN { use_ok("IkiWiki::CGI"); }
-
-sub cgi_page_from_404 { return IkiWiki::cgi_page_from_404(shift, shift, shift); }
-
-$IkiWiki::config{htmlext} = 'html';
-
-is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
-is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
-is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
-is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
-
-is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
- 'foo/bar');
-
-is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
- 'foo/bar');
-
-is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
- 'foo');
-is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
- 'foo');
-is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
- 'foo');
-is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),
- 'foo');
--
cgit v1.2.3
From c886bea32084a920f3ba26b3f96327681f5db917 Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Sat, 31 Jan 2009 23:01:10 +0000
Subject: Split cgi_goto into a goto plugin
---
IkiWiki/CGI.pm | 51 ---------------------------
IkiWiki/Plugin/apache404.pm | 3 +-
IkiWiki/Plugin/comments.pm | 2 ++
IkiWiki/Plugin/goto.pm | 76 +++++++++++++++++++++++++++++++++++++++++
IkiWiki/Plugin/recentchanges.pm | 2 ++
doc/plugins/goto.mdwn | 10 ++++++
6 files changed, 92 insertions(+), 52 deletions(-)
create mode 100644 IkiWiki/Plugin/goto.pm
create mode 100644 doc/plugins/goto.mdwn
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index e75ebcd27..c91914564 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -294,50 +294,6 @@ sub cgi_savesession ($) {
umask($oldmask);
}
-# cgi_goto(CGI, [page])
-# Redirect to a specified page, or display "not found". If not specified,
-# the page param from the CGI object is used.
-sub cgi_goto ($;$) {
- my $q = shift;
- my $page = shift;
-
- if (!defined $page) {
- $page = decode_utf8($q->param("page"));
-
- if (!defined $page) {
- error("missing page parameter");
- }
- }
-
- loadindex();
-
- # If the page is internal (like a comment), see if it has a
- # permalink. Comments do.
- if (isinternal($page) &&
- defined $pagestate{$page}{meta}{permalink}) {
- redirect($q, $pagestate{$page}{meta}{permalink});
- }
-
- my $link = bestlink("", $page);
-
- if (! length $link) {
- print $q->header(-status => "404 Not Found");
- print misctemplate(gettext("missing page"),
- "".
- sprintf(gettext("The page %s does not exist."),
- htmllink("", "", $page)).
- "
".
- # Internet Explorer won't show custom 404 responses
- # unless they're >= 512 bytes
- (" " x 512));
- }
- else {
- redirect($q, urlto($link, undef, 1));
- }
-
- exit;
-}
-
sub cgi (;$$) {
my $q=shift;
my $session=shift;
@@ -365,13 +321,6 @@ sub cgi (;$$) {
}
}
- # goto is the preferred name for this; recentchanges_link and
- # commenter are for compatibility with any saved URLs
- if ($do eq 'goto' || $do eq 'recentchanges_link' ||
- $do eq 'commenter') {
- cgi_goto($q);
- }
-
# Need to lock the wiki before getting a session.
lockwiki();
loadindex();
diff --git a/IkiWiki/Plugin/apache404.pm b/IkiWiki/Plugin/apache404.pm
index 3ac6b3af5..e7ce70435 100644
--- a/IkiWiki/Plugin/apache404.pm
+++ b/IkiWiki/Plugin/apache404.pm
@@ -10,6 +10,7 @@ use IkiWiki 3.00;
sub import {
hook(type => "cgi", id => 'apache404', call => \&cgi);
+ IkiWiki::loadplugin("goto");
}
sub getsetup () {
@@ -69,7 +70,7 @@ sub cgi ($) {
if ($ENV{REDIRECT_STATUS} eq '404') {
my $page = cgi_page_from_404($ENV{REDIRECT_URL},
$config{url}, $config{usedirs});
- IkiWiki::cgi_goto($cgi, $page);
+ IkiWiki::Plugin::goto::cgi_goto($cgi, $page);
}
}
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 995d1f4eb..3cdffe856 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -26,6 +26,8 @@ sub import {
hook(type => "htmlize", id => "_comment", call => \&htmlize);
hook(type => "pagetemplate", id => "comments", call => \&pagetemplate);
hook(type => "formbuilder_setup", id => "comments", call => \&formbuilder_setup);
+ # Load goto to fix up user page links for logged-in commenters
+ IkiWiki::loadplugin("goto");
IkiWiki::loadplugin("inline");
}
diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm
new file mode 100644
index 000000000..9e7a2621f
--- /dev/null
+++ b/IkiWiki/Plugin/goto.pm
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::goto;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+ hook(type => "cgi", id => 'goto', call => \&cgi);
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ safe => 1,
+ rebuild => 0,
+ }
+}
+
+# cgi_goto(CGI, [page])
+# Redirect to a specified page, or display "not found". If not specified,
+# the page param from the CGI object is used.
+sub cgi_goto ($;$) {
+ my $q = shift;
+ my $page = shift;
+
+ if (!defined $page) {
+ $page = IkiWiki::decode_utf8($q->param("page"));
+
+ if (!defined $page) {
+ error("missing page parameter");
+ }
+ }
+
+ IkiWiki::loadindex();
+
+ # If the page is internal (like a comment), see if it has a
+ # permalink. Comments do.
+ if (IkiWiki::isinternal($page) &&
+ defined $pagestate{$page}{meta}{permalink}) {
+ redirect($q, $pagestate{$page}{meta}{permalink});
+ }
+
+ my $link = bestlink("", $page);
+
+ if (! length $link) {
+ print $q->header(-status => "404 Not Found");
+ print IkiWiki::misctemplate(gettext("missing page"),
+ "".
+ sprintf(gettext("The page %s does not exist."),
+ htmllink("", "", $page)).
+ "
".
+ # Internet Explorer won't show custom 404 responses
+ # unless they're >= 512 bytes
+ (" " x 512));
+ }
+ else {
+ IkiWiki::redirect($q, urlto($link, undef, 1));
+ }
+
+ exit;
+}
+
+sub cgi ($) {
+ my $cgi=shift;
+ my $do = $cgi->param('do');
+
+ if (defined $do && ($do eq 'goto' || $do eq 'commenter' ||
+ $do eq 'recentchanged_link')) {
+ # goto is the preferred name for this; recentchanges_link and
+ # commenter are for compatibility with any saved URLs
+ cgi_goto($cgi);
+ }
+}
+
+1;
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 56e80e7b8..329dd6f32 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -13,6 +13,8 @@ sub import {
hook(type => "refresh", id => "recentchanges", call => \&refresh);
hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
hook(type => "htmlize", id => "_change", call => \&htmlize);
+ # Load goto to fix up links from recentchanges
+ IkiWiki::loadplugin("goto");
}
sub getsetup () {
diff --git a/doc/plugins/goto.mdwn b/doc/plugins/goto.mdwn
new file mode 100644
index 000000000..21dda16b2
--- /dev/null
+++ b/doc/plugins/goto.mdwn
@@ -0,0 +1,10 @@
+[[!template id=plugin name=goto author="[[Simon_McVittie|smcv]]"]]
+[[!tag type/useful]]
+
+This plugin adds a `do=goto` mode for the IkiWiki CGI script. It's mainly
+for internal use by the [[apache404]], [[comments]] and [[recentchanges]]
+plugins, which enable it automatically.
+
+With this plugin enabled you can link to `ikiwiki.cgi?do=goto&page=some/where`
+to make a link that will redirect to the page `/some/where` if it exists, or
+offer a link to create it if it doesn't.
--
cgit v1.2.3
From b0361b8efde26fbf4f3207be6c3c8f39eb16a9f3 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sat, 31 Jan 2009 19:02:50 -0500
Subject: factor out IE stupididy workaround
---
IkiWiki/CGI.pm | 23 +++++++++++++++++------
IkiWiki/Plugin/goto.pm | 17 ++++++++---------
2 files changed, 25 insertions(+), 15 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index c91914564..3000ed100 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -229,6 +229,20 @@ sub cgi_prefs ($$) {
showform($form, $buttons, $session, $q);
}
+sub cgi_custom_failure ($$) {
+ my $header=shift;
+ my $message=shift;
+
+ print $header;
+ print $message;
+
+ # Internet Explod^Hrer won't show custom 404 responses
+ # unless they're >= 512 bytes
+ print ' ' x 512;
+
+ exit;
+}
+
sub check_banned ($$) {
my $q=shift;
my $session=shift;
@@ -236,14 +250,11 @@ sub check_banned ($$) {
my $name=$session->param("name");
if (defined $name) {
if (grep { $name eq $_ } @{$config{banned_users}}) {
- print $q->header(-status => "403 Forbidden");
$session->delete();
- print gettext("You are banned.");
- # Internet Explorer won't show custom 404 responses
- # unless they're >= 512 bytes
- print " " x 512;
cgi_savesession($session);
- exit;
+ cgi_custom_failure(
+ $q->header(-status => "403 Forbidden"),
+ gettext("You are banned."));
}
}
}
diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm
index 9e7a2621f..7cc8cb484 100644
--- a/IkiWiki/Plugin/goto.pm
+++ b/IkiWiki/Plugin/goto.pm
@@ -44,15 +44,14 @@ sub cgi_goto ($;$) {
my $link = bestlink("", $page);
if (! length $link) {
- print $q->header(-status => "404 Not Found");
- print IkiWiki::misctemplate(gettext("missing page"),
- "".
- sprintf(gettext("The page %s does not exist."),
- htmllink("", "", $page)).
- "
".
- # Internet Explorer won't show custom 404 responses
- # unless they're >= 512 bytes
- (" " x 512));
+ IkiWiki::cgi_custom_failure(
+ $q->header(-status => "404 Not Found"),
+ IkiWiki::misctemplate(gettext("missing page"),
+ "".
+ sprintf(gettext("The page %s does not exist."),
+ htmllink("", "", $page)).
+ "
")
+ )
}
else {
IkiWiki::redirect($q, urlto($link, undef, 1));
--
cgit v1.2.3
From 3b83e520182a83e4ae6c61ab7b360b0eb939469f Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sat, 31 Jan 2009 19:26:36 -0500
Subject: rename apache404 -> 404
This may already work with other web servers that have copied apache's
interface, and it should be easy to add support to it for web servers that
use some other interface. So, make the name more general.
---
IkiWiki/Plugin/404.pm | 77 +++++++++++++++++++++++++++++++++++++++++++++
IkiWiki/Plugin/apache404.pm | 77 ---------------------------------------------
debian/changelog | 2 +-
debian/copyright | 2 +-
doc/plugins/404.mdwn | 11 +++++++
doc/plugins/apache404.mdwn | 11 -------
doc/plugins/goto.mdwn | 2 +-
doc/tips/dot_cgi.mdwn | 9 +++---
t/404.t | 44 ++++++++++++++++++++++++++
t/apache404.t | 45 --------------------------
10 files changed, 139 insertions(+), 141 deletions(-)
create mode 100644 IkiWiki/Plugin/404.pm
delete mode 100644 IkiWiki/Plugin/apache404.pm
create mode 100644 doc/plugins/404.mdwn
delete mode 100644 doc/plugins/apache404.mdwn
create mode 100755 t/404.t
delete mode 100755 t/apache404.t
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/404.pm b/IkiWiki/Plugin/404.pm
new file mode 100644
index 000000000..5550ea7d1
--- /dev/null
+++ b/IkiWiki/Plugin/404.pm
@@ -0,0 +1,77 @@
+#!/usr/bin/perl
+# Copyright © 2009 Simon McVittie
+# Licensed under the GNU GPL, version 2, or any later version published by the
+# Free Software Foundation
+package IkiWiki::Plugin::404;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+ hook(type => "cgi", id => '404', call => \&cgi);
+ IkiWiki::loadplugin("goto");
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ # not really a matter of safety, but enabling/disabling
+ # through a web interface is useless - it needs web
+ # server admin action too
+ safe => 0,
+ rebuild => 0,
+ }
+}
+
+sub cgi_page_from_404 ($$$) {
+ my $path = shift;
+ my $baseurl = shift;
+ my $usedirs = shift;
+
+ # fail if missing from environment or whatever
+ return undef unless defined $path;
+ return undef unless defined $baseurl;
+
+ # with usedirs on, path is like /~fred/foo/bar/ or /~fred/foo/bar or
+ # /~fred/foo/bar/index.html
+ # with usedirs off, path is like /~fred/foo/bar.html
+ # baseurl is like 'http://people.example.com/~fred'
+
+ # convert baseurl to ~fred
+ unless ($baseurl =~ s{^https?://[^/]+/?}{}) {
+ return undef;
+ }
+
+ # convert path to /~fred/foo/bar
+ if ($usedirs) {
+ $path =~ s/\/*(?:index\.$config{htmlext})?$//;
+ }
+ else {
+ $path =~ s/\.$config{htmlext}$//;
+ }
+
+ # remove /~fred/
+ unless ($path =~ s{^/*\Q$baseurl\E/*}{}) {
+ return undef;
+ }
+
+ # special case for the index
+ unless ($path) {
+ return 'index';
+ }
+
+ return $path;
+}
+
+sub cgi ($) {
+ my $cgi=shift;
+
+ if ($ENV{REDIRECT_STATUS} eq '404') {
+ my $page = cgi_page_from_404($ENV{REDIRECT_URL},
+ $config{url}, $config{usedirs});
+ IkiWiki::Plugin::goto::cgi_goto($cgi, $page);
+ }
+}
+
+1;
diff --git a/IkiWiki/Plugin/apache404.pm b/IkiWiki/Plugin/apache404.pm
deleted file mode 100644
index e7ce70435..000000000
--- a/IkiWiki/Plugin/apache404.pm
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/perl
-# Copyright © 2009 Simon McVittie
-# Licensed under the GNU GPL, version 2, or any later version published by the
-# Free Software Foundation
-package IkiWiki::Plugin::apache404;
-
-use warnings;
-use strict;
-use IkiWiki 3.00;
-
-sub import {
- hook(type => "cgi", id => 'apache404', call => \&cgi);
- IkiWiki::loadplugin("goto");
-}
-
-sub getsetup () {
- return
- plugin => {
- # not really a matter of safety, but enabling/disabling
- # through a web interface is useless - it needs web
- # server admin action too
- safe => 0,
- rebuild => 0,
- }
-}
-
-sub cgi_page_from_404 ($$$) {
- my $path = shift;
- my $baseurl = shift;
- my $usedirs = shift;
-
- # fail if missing from environment or whatever
- return undef unless defined $path;
- return undef unless defined $baseurl;
-
- # with usedirs on, path is like /~fred/foo/bar/ or /~fred/foo/bar or
- # /~fred/foo/bar/index.html
- # with usedirs off, path is like /~fred/foo/bar.html
- # baseurl is like 'http://people.example.com/~fred'
-
- # convert baseurl to ~fred
- unless ($baseurl =~ s{^https?://[^/]+/?}{}) {
- return undef;
- }
-
- # convert path to /~fred/foo/bar
- if ($usedirs) {
- $path =~ s/\/*(?:index\.$config{htmlext})?$//;
- }
- else {
- $path =~ s/\.$config{htmlext}$//;
- }
-
- # remove /~fred/
- unless ($path =~ s{^/*\Q$baseurl\E/*}{}) {
- return undef;
- }
-
- # special case for the index
- unless ($path) {
- return 'index';
- }
-
- return $path;
-}
-
-sub cgi ($) {
- my $cgi=shift;
-
- if ($ENV{REDIRECT_STATUS} eq '404') {
- my $page = cgi_page_from_404($ENV{REDIRECT_URL},
- $config{url}, $config{usedirs});
- IkiWiki::Plugin::goto::cgi_goto($cgi, $page);
- }
-}
-
-1;
diff --git a/debian/changelog b/debian/changelog
index f3927f121..be32d3abf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
ikiwiki (3.04) UNRELEASED; urgency=low
- * apache404: New plugin which lets you use the IkiWiki CGI script as
+ * 404: New plugin which lets you use the IkiWiki CGI script as
an Apache 404 handler, to give the behaviour of various other wiki
engines where visiting a nonexistent page provides you with a link
to create it. (smcv)
diff --git a/debian/copyright b/debian/copyright
index bdfbaa573..f589b4a8f 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -118,7 +118,7 @@ Copyright:
© 2008 Simon McVittie
License: GPL-2+
-Files: apache404.pm
+Files: 404.pm
Copyright: © 2009 Simon McVittie
License: GPL-2+
diff --git a/doc/plugins/404.mdwn b/doc/plugins/404.mdwn
new file mode 100644
index 000000000..8d36279c8
--- /dev/null
+++ b/doc/plugins/404.mdwn
@@ -0,0 +1,11 @@
+[[!template id=plugin name=404 author="[[Simon_McVittie|smcv]]"]]
+[[!tag type/useful]]
+
+This plugin lets you use the IkiWiki CGI script as an Apache 404 handler,
+to give the behaviour of various other wiki engines where visiting a
+nonexistent page provides you with a link to create it.
+
+To achieve this, put something like this in the wiki's Apache configuration
+file:
+
+ ErrorDocument 404 /cgi-bin/ikiwiki.cgi
diff --git a/doc/plugins/apache404.mdwn b/doc/plugins/apache404.mdwn
deleted file mode 100644
index bab8fb59d..000000000
--- a/doc/plugins/apache404.mdwn
+++ /dev/null
@@ -1,11 +0,0 @@
-[[!template id=plugin name=apache404 author="[[Simon_McVittie|smcv]]"]]
-[[!tag type/useful]]
-
-This plugin lets you use the IkiWiki CGI script as an Apache 404 handler,
-to give the behaviour of various other wiki engines where visiting a
-nonexistent page provides you with a link to create it.
-
-To achieve this, put something like this in the wiki's Apache configuration
-file:
-
- ErrorDocument 404 /cgi-bin/ikiwiki.cgi
diff --git a/doc/plugins/goto.mdwn b/doc/plugins/goto.mdwn
index 21dda16b2..9c401c5d2 100644
--- a/doc/plugins/goto.mdwn
+++ b/doc/plugins/goto.mdwn
@@ -2,7 +2,7 @@
[[!tag type/useful]]
This plugin adds a `do=goto` mode for the IkiWiki CGI script. It's mainly
-for internal use by the [[apache404]], [[comments]] and [[recentchanges]]
+for internal use by the [[404]], [[comments]] and [[recentchanges]]
plugins, which enable it automatically.
With this plugin enabled you can link to `ikiwiki.cgi?do=goto&page=some/where`
diff --git a/doc/tips/dot_cgi.mdwn b/doc/tips/dot_cgi.mdwn
index ffcbf95d4..04d7a9721 100644
--- a/doc/tips/dot_cgi.mdwn
+++ b/doc/tips/dot_cgi.mdwn
@@ -26,11 +26,10 @@ configuration changes should work anywhere.
Or, if you've put it in a `~/public_html`, edit
`/etc/apache2/mods-available/userdir.conf`.
-You may also want to enable the [[plugins/apache404]]
-plugin. To make apache use it, the apache config file
-will need a further modification to make it use ikiwiki's CGI
-as the apache 404 handler. Something like this, with
-the path adjusted to where you've put the CGI:
+* You may also want to enable the [[plugins/404]] plugin.
+ To make apache use it, the apache config file will need a further
+ modification to make it use ikiwiki's CGI as the apache 404 handler.
+ Something like this, with the path adjusted to where you've put the CGI:
ErrorDocument 404 /cgi-bin/ikiwiki.cgi
diff --git a/t/404.t b/t/404.t
new file mode 100755
index 000000000..0bb3c6063
--- /dev/null
+++ b/t/404.t
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 17;
+
+BEGIN { use_ok("IkiWiki::Plugin::404"); }
+
+sub cgi_page_from_404 {
+ return IkiWiki::Plugin::404::cgi_page_from_404(shift, shift, shift);
+}
+
+$IkiWiki::config{htmlext} = 'html';
+
+is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
+is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
+is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
+is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
+
+is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
+ 'foo/bar');
+
+is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
+ 'foo/bar');
+is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
+ 'foo/bar');
+
+is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
+ 'foo');
+is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
+ 'foo');
+is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
+ 'foo');
+is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),
+ 'foo');
diff --git a/t/apache404.t b/t/apache404.t
deleted file mode 100755
index 00fc35250..000000000
--- a/t/apache404.t
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-use warnings;
-use strict;
-use Test::More tests => 17;
-
-BEGIN { use_ok("IkiWiki::Plugin::apache404"); }
-
-sub cgi_page_from_404 {
- return IkiWiki::Plugin::apache404::cgi_page_from_404(shift, shift,
- shift);
-}
-
-$IkiWiki::config{htmlext} = 'html';
-
-is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
-is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
-is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
-is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
-
-is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
- 'foo/bar');
-
-is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
- 'foo/bar');
-is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
- 'foo/bar');
-
-is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
- 'foo');
-is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
- 'foo');
-is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
- 'foo');
-is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),
- 'foo');
--
cgit v1.2.3
From dd862b4639bd470cbc3e726798af2f07587cb62e Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Tue, 3 Feb 2009 19:48:55 +0000
Subject: Work around XML::Atom strangeness that results in double-encoded
posts
See [[bugs/Aggregated_Atom_feeds_are_double-encoded]]. By default,
XML::Atom outputs strings of UTF-8 bytes with the Perl UTF8 flag stripped
off, which IkiWiki assumes to be Latin-1 and re-encodes as UTF-8 on
output. XML::Feed does not currently (0.41-1) set the magic variable to
change this behaviour (I've filed a bug on CPAN), but IkiWiki can
usefully set the same variable as a workaround.
---
IkiWiki/Plugin/aggregate.pm | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index c667ee2a9..e1baae666 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -534,6 +534,11 @@ sub aggregate (@) {
}
foreach my $entry ($f->entries) {
+ # XML::Feed doesn't work around XML::Atom's bizarre
+ # API, so we will. Real unicode strings? Yes please.
+ # See [[bugs/Aggregated_Atom_feeds_are_double-encoded]]
+ local $XML::Atom::ForceUnicode = 1;
+
my $c=$entry->content;
# atom feeds may have no content, only a summary
if (! defined $c && ref $entry->summary) {
--
cgit v1.2.3
From 5e2e95a516e7f967654108bbc4d8e9ab71a6820f Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Wed, 11 Feb 2009 12:29:39 -0500
Subject: doubled semicolons
---
IkiWiki/Plugin/graphviz.pm | 2 +-
IkiWiki/Plugin/sparkline.pm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/graphviz.pm b/IkiWiki/Plugin/graphviz.pm
index b43e96a73..32e994d6b 100644
--- a/IkiWiki/Plugin/graphviz.pm
+++ b/IkiWiki/Plugin/graphviz.pm
@@ -45,7 +45,7 @@ sub render_graph (\%) {
if (! -e "$config{destdir}/$dest") {
my $pid;
- my $sigpipe=0;;
+ my $sigpipe=0;
$SIG{PIPE}=sub { $sigpipe=1 };
$pid=open2(*IN, *OUT, "$params{prog} -Tpng");
diff --git a/IkiWiki/Plugin/sparkline.pm b/IkiWiki/Plugin/sparkline.pm
index 1ed65e5b7..458192695 100644
--- a/IkiWiki/Plugin/sparkline.pm
+++ b/IkiWiki/Plugin/sparkline.pm
@@ -130,7 +130,7 @@ sub preprocess (@) {
if (! -e "$config{destdir}/$fn") {
my $pid;
- my $sigpipe=0;;
+ my $sigpipe=0;
$SIG{PIPE}=sub { $sigpipe=1 };
$pid=open2(*IN, *OUT, "php");
--
cgit v1.2.3
From 46819b530bca5a3adf00278500a34363a94c1fb2 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Thu, 12 Feb 2009 13:02:58 -0500
Subject: shortcut: If default_pageext is set, first look for
shortcuts.default_pageext
Falls back to looking for shortcuts.mdwn for backwards compatabiity; there
probably exist wikis that have changed the pageext but still use
shortcuts.mdwn.
---
IkiWiki/Plugin/shortcut.pm | 8 ++++++--
debian/changelog | 2 ++
doc/plugins/mdwn/discussion.mdwn | 4 ----
doc/plugins/shortcut/discussion.mdwn | 21 +++------------------
4 files changed, 11 insertions(+), 24 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm
index 0e7cbd4d1..c1e6a7eb3 100644
--- a/IkiWiki/Plugin/shortcut.pm
+++ b/IkiWiki/Plugin/shortcut.pm
@@ -23,9 +23,13 @@ sub checkconfig () {
if (defined $config{srcdir}) {
# Preprocess the shortcuts page to get all the available shortcuts
# defined before other pages are rendered.
- my $srcfile=srcfile("shortcuts.mdwn", 1);
+ my $srcfile=srcfile("shortcuts.".$config{default_pageext}, 1);
if (! defined $srcfile) {
- error(gettext("shortcut plugin will not work without a shortcuts.mdwn"));
+ $srcfile=srcfile("shortcuts.mdwn", 1);
+ }
+ if (! defined $srcfile) {
+ error(sprintf(gettext("shortcut plugin will not work without %s"),
+ "shortcuts.".$config{default_pageext}));
}
IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile));
}
diff --git a/debian/changelog b/debian/changelog
index 294d23197..7467508f6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,8 @@ ikiwiki (3.04) UNRELEASED; urgency=low
* Fix unusual --setup --post-commit command line option combo.
* Create any missing directory necessary to put the wrapper
file into. Closes: #514384
+ * shortcut: If default_pageext is set, first look for
+ shortcuts.default_pageext.
-- Joey Hess Sat, 31 Jan 2009 19:04:45 -0500
diff --git a/doc/plugins/mdwn/discussion.mdwn b/doc/plugins/mdwn/discussion.mdwn
index 9ebf99b7e..4b05e7f4e 100644
--- a/doc/plugins/mdwn/discussion.mdwn
+++ b/doc/plugins/mdwn/discussion.mdwn
@@ -5,7 +5,3 @@ you need to overwrite the underlay
dir (set underlaydir in ikiwiki.setup
to your own underlay dir or replace underlay pages
in your $SRC).
-
-Specially, the [[shortcut]] plugin is hardcoded to
-use shortcuts.mdwn. So you need pay more care if
-you [[use shortcut without mdwn|shortcut/discussion]].
diff --git a/doc/plugins/shortcut/discussion.mdwn b/doc/plugins/shortcut/discussion.mdwn
index 770c95836..4e11ce08c 100644
--- a/doc/plugins/shortcut/discussion.mdwn
+++ b/doc/plugins/shortcut/discussion.mdwn
@@ -3,25 +3,10 @@ disabled [[mdwn]], to get [[shortcut]] work, you need
commit in a shortcuts.ext (ext is `rcs|creole|html|txt|etc`),
and edit/patch [[shortcut]].
-Maybe use the $default_pageext is better than hardcode .mdwn?
-
-
---- shortcut.pm.orig 2009-02-12 02:05:22.000000000 -0600
-+++ shortcut.pm 2009-02-12 04:41:30.000000000 -0600
-@@ -23,9 +23,9 @@
- if (defined $config{srcdir}) {
- # Preprocess the shortcuts page to get all the available shortcuts
- # defined before other pages are rendered.
-- my $srcfile=srcfile("shortcuts.mdwn", 1);
-+ my $srcfile=srcfile("shortcuts.$config{default_pageext}", 1);
- if (! defined $srcfile) {
-- error(gettext("shortcut plugin will not work without a shortcuts.mdwn"));
-+ error(gettext("shortcut plugin will not work without a shortcuts.$config{default_pageext}"));
- }
- IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile));
- }
-
+Maybe use the `default_pageext` is better than hardcode .mdwn?
--[[weakish]]
+> done, it will use `default_pageext` now --[[Joey]]
+
--
cgit v1.2.3
From 2c51b18aec0cebd1a433cb541fe80f8ade7b3936 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Thu, 12 Feb 2009 16:31:05 -0500
Subject: move check_canedit, check_content to IkiWiki library from editpage
It no longer makes sense to keep these functions in editpage, because
serveral plugins now exist that use them, and users may want to disable
editpage, while leaving those plugins enabled.
Most notably, comments uses both functions, and it's entirely appropriate
to disable editpage but still want to have comments enabled.
Less likely, attachments, rename, and remove all use check_canedit -- but
it would be unusual indeed to want to use these w/o editpage.
---
IkiWiki.pm | 64 ++++++++++++++++++++++++++++++++++++++++++++
IkiWiki/Plugin/editpage.pm | 66 +---------------------------------------------
debian/changelog | 2 ++
3 files changed, 67 insertions(+), 65 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 66fea4369..ce1ceb351 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1293,6 +1293,70 @@ sub indexlink () {
return "$config{wikiname}";
}
+sub check_canedit ($$$;$) {
+ my $page=shift;
+ my $q=shift;
+ my $session=shift;
+ my $nonfatal=shift;
+
+ my $canedit;
+ run_hooks(canedit => sub {
+ return if defined $canedit;
+ my $ret=shift->($page, $q, $session);
+ if (defined $ret) {
+ if ($ret eq "") {
+ $canedit=1;
+ }
+ elsif (ref $ret eq 'CODE') {
+ $ret->() unless $nonfatal;
+ $canedit=0;
+ }
+ elsif (defined $ret) {
+ error($ret) unless $nonfatal;
+ $canedit=0;
+ }
+ }
+ });
+ return defined $canedit ? $canedit : 1;
+}
+
+sub check_content (@) {
+ my %params=@_;
+
+ return 1 if ! exists $hooks{checkcontent}; # optimisation
+
+ if (exists $pagesources{$params{page}}) {
+ my @diff;
+ my %old=map { $_ => 1 }
+ split("\n", readfile(srcfile($pagesources{$params{page}})));
+ foreach my $line (split("\n", $params{content})) {
+ push @diff, $line if ! exists $old{$_};
+ }
+ $params{content}=join("\n", @diff);
+ }
+
+ my $ok;
+ run_hooks(checkcontent => sub {
+ return if defined $ok;
+ my $ret=shift->(%params);
+ if (defined $ret) {
+ if ($ret eq "") {
+ $ok=1;
+ }
+ elsif (ref $ret eq 'CODE') {
+ $ret->() unless $params{nonfatal};
+ $ok=0;
+ }
+ elsif (defined $ret) {
+ error($ret) unless $params{nonfatal};
+ $ok=0;
+ }
+ }
+
+ });
+ return defined $ok ? $ok : 1;
+}
+
my $wikilock;
sub lockwiki () {
diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm
index c206d96a4..0068a6b11 100644
--- a/IkiWiki/Plugin/editpage.pm
+++ b/IkiWiki/Plugin/editpage.pm
@@ -51,73 +51,9 @@ sub refresh () {
# Back to ikiwiki namespace for the rest, this code is very much
# internal to ikiwiki even though it's separated into a plugin,
-# and other plugins use the functions below.
+# and other plugins use the function below.
package IkiWiki;
-sub check_canedit ($$$;$) {
- my $page=shift;
- my $q=shift;
- my $session=shift;
- my $nonfatal=shift;
-
- my $canedit;
- run_hooks(canedit => sub {
- return if defined $canedit;
- my $ret=shift->($page, $q, $session);
- if (defined $ret) {
- if ($ret eq "") {
- $canedit=1;
- }
- elsif (ref $ret eq 'CODE') {
- $ret->() unless $nonfatal;
- $canedit=0;
- }
- elsif (defined $ret) {
- error($ret) unless $nonfatal;
- $canedit=0;
- }
- }
- });
- return defined $canedit ? $canedit : 1;
-}
-
-sub check_content (@) {
- my %params=@_;
-
- return 1 if ! exists $hooks{checkcontent}; # optimisation
-
- if (exists $pagesources{$params{page}}) {
- my @diff;
- my %old=map { $_ => 1 }
- split("\n", readfile(srcfile($pagesources{$params{page}})));
- foreach my $line (split("\n", $params{content})) {
- push @diff, $line if ! exists $old{$_};
- }
- $params{content}=join("\n", @diff);
- }
-
- my $ok;
- run_hooks(checkcontent => sub {
- return if defined $ok;
- my $ret=shift->(%params);
- if (defined $ret) {
- if ($ret eq "") {
- $ok=1;
- }
- elsif (ref $ret eq 'CODE') {
- $ret->() unless $params{nonfatal};
- $ok=0;
- }
- elsif (defined $ret) {
- error($ret) unless $params{nonfatal};
- $ok=0;
- }
- }
-
- });
- return defined $ok ? $ok : 1;
-}
-
sub cgi_editpage ($$) {
my $q=shift;
my $session=shift;
diff --git a/debian/changelog b/debian/changelog
index 7467508f6..8da3f8849 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ ikiwiki (3.04) UNRELEASED; urgency=low
file into. Closes: #514384
* shortcut: If default_pageext is set, first look for
shortcuts.default_pageext.
+ * Allow comments, rename, remove, and attazhments plugins to be used
+ even if the editpage plugin is disabled.
-- Joey Hess Sat, 31 Jan 2009 19:04:45 -0500
--
cgit v1.2.3
From 684cd73a79405ee58e115e603213c39a33d710cf Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sat, 14 Feb 2009 03:01:35 -0500
Subject: downgrade missing shortcuts page error to warning
and response to bug report
---
IkiWiki/Plugin/shortcut.pm | 8 +++++---
...shortcut_plugin_will_not_work_without_shortcuts.mdwn.mdwn | 12 ++++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm
index c1e6a7eb3..5693ee782 100644
--- a/IkiWiki/Plugin/shortcut.pm
+++ b/IkiWiki/Plugin/shortcut.pm
@@ -28,10 +28,12 @@ sub checkconfig () {
$srcfile=srcfile("shortcuts.mdwn", 1);
}
if (! defined $srcfile) {
- error(sprintf(gettext("shortcut plugin will not work without %s"),
- "shortcuts.".$config{default_pageext}));
+ print STDERR sprintf(gettext("shortcut plugin will not work without %s"),
+ "shortcuts.".$config{default_pageext})."\n";
+ }
+ else {
+ IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile));
}
- IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile));
}
}
diff --git a/doc/bugs/shortcut_plugin_will_not_work_without_shortcuts.mdwn.mdwn b/doc/bugs/shortcut_plugin_will_not_work_without_shortcuts.mdwn.mdwn
index 994929bfc..85844132d 100644
--- a/doc/bugs/shortcut_plugin_will_not_work_without_shortcuts.mdwn.mdwn
+++ b/doc/bugs/shortcut_plugin_will_not_work_without_shortcuts.mdwn.mdwn
@@ -6,3 +6,15 @@ On my initial ikiwiki -setup auto.setup, I get the following error:
This is using the latest git pull of ikiwiki.
I am not sure why it is not finding shortcuts.mdwn. -- [[JosephTurian]]
+
+> The error, and the weird paths suggest to me that you
+> have installed ikiwiki in a strange way, and it is failing
+> to find its basewiki underlay. The `$installdir` is
+> hardcoded into IkiWiki.pm at build time, based on the PREFIX
+> setting (see README).
+>
+> If that's not set right, you'll have other problems than just this one,
+> so I suggest you check how you installed ikiwiki.
+>
+> Anyway, I've made the shortcut plugin only warn about this..
+> --[[Joey]]
--
cgit v1.2.3
From adcc349d89ada08c106f39ecb9338e3cde9668a8 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sat, 14 Feb 2009 03:04:11 -0500
Subject: check for empty srcdir
This happens when using -dumpsetup
---
IkiWiki/Plugin/shortcut.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm
index 5693ee782..1840a5722 100644
--- a/IkiWiki/Plugin/shortcut.pm
+++ b/IkiWiki/Plugin/shortcut.pm
@@ -20,7 +20,7 @@ sub getsetup () {
}
sub checkconfig () {
- if (defined $config{srcdir}) {
+ if (defined $config{srcdir} && length $config{srcdir}) {
# Preprocess the shortcuts page to get all the available shortcuts
# defined before other pages are rendered.
my $srcfile=srcfile("shortcuts.".$config{default_pageext}, 1);
--
cgit v1.2.3
From bb8b8787ef9477c027b9e5d8b7b5e1addfd1ca32 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Tue, 17 Feb 2009 13:25:06 -0500
Subject: comments
---
IkiWiki/Plugin/template.pm | 3 ++-
debian/changelog | 4 ++++
doc/bugs/cannot_reliably_use_meta_in_template.mdwn | 2 ++
doc/bugs/tags__44___backlinks_and_3.x.mdwn | 2 ++
doc/todo/tag_pagespec_function.mdwn | 7 +++++++
5 files changed, 17 insertions(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index 57bff20ff..b872f0962 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -10,7 +10,8 @@ use Encode;
sub import {
hook(type => "getsetup", id => "template", call => \&getsetup);
- hook(type => "preprocess", id => "template", call => \&preprocess);
+ hook(type => "preprocess", id => "template", call => \&preprocess,
+ scan => 1);
}
sub getsetup () {
diff --git a/debian/changelog b/debian/changelog
index 62374d2dc..c28d36c84 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,10 @@
ikiwiki (3.05) UNRELEASED; urgency=low
* debhelper v7.2; rules file minimisation.
+ * template: Load templates in scan mode.
+ This is potentially expensive, but is necessary so that meta and tag
+ directives, and other links on templates affect the page using the
+ template reliably.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
diff --git a/doc/bugs/cannot_reliably_use_meta_in_template.mdwn b/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
index 48288a2b3..de6c227f6 100644
--- a/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
+++ b/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
@@ -14,3 +14,5 @@ scan pass, every page containing a template will cause the template to be
loaded and filled out. This can be some serious additional overhead.
--[[Joey]]
+
+[[done]]
diff --git a/doc/bugs/tags__44___backlinks_and_3.x.mdwn b/doc/bugs/tags__44___backlinks_and_3.x.mdwn
index ea0eecc80..4fe9a4723 100644
--- a/doc/bugs/tags__44___backlinks_and_3.x.mdwn
+++ b/doc/bugs/tags__44___backlinks_and_3.x.mdwn
@@ -30,3 +30,5 @@ time, so went ahead and migrated live, spamming planet debian in the process
> [[cannot_reliably_use_meta_in_template]]. AFAIK, this has never worked
> reliably, although the linked page has a simple, though potentially
> expensive fix. --[[Joey]]
+
+> fix made, [[done]] --[[Joey]]
diff --git a/doc/todo/tag_pagespec_function.mdwn b/doc/todo/tag_pagespec_function.mdwn
index 0a51c7220..060368179 100644
--- a/doc/todo/tag_pagespec_function.mdwn
+++ b/doc/todo/tag_pagespec_function.mdwn
@@ -8,6 +8,13 @@ match tagged pages independent of whatever the tagbase is set to.
-- [[users/Jon]] 2009/02/17
+> So, this looks good, appreciate the patch.
+>
+> The only problem I see is it could be confusing if `tag(foo)` matched
+> a page that just linked to the tag via a wikilink, w/o actually tagging it.
+>
+> One other thing, perhaps it should be called `tagged()`? --[[Joey]]
+
[[!tag patch]]
--- a/plugins/IkiWiki/Plugin/tag.pm 2009-02-16 11:30:11.000000000 +0000
--
cgit v1.2.3
From a4497591f958f3d2fb28ef597c7870bfc4db72e3 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Tue, 17 Feb 2009 13:29:08 -0500
Subject: Revert "comments" (stupid commit)
This reverts commit bb8b8787ef9477c027b9e5d8b7b5e1addfd1ca32.
---
IkiWiki/Plugin/template.pm | 3 +--
debian/changelog | 4 ----
doc/bugs/cannot_reliably_use_meta_in_template.mdwn | 2 --
doc/bugs/tags__44___backlinks_and_3.x.mdwn | 2 --
doc/todo/tag_pagespec_function.mdwn | 7 -------
5 files changed, 1 insertion(+), 17 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index b872f0962..57bff20ff 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -10,8 +10,7 @@ use Encode;
sub import {
hook(type => "getsetup", id => "template", call => \&getsetup);
- hook(type => "preprocess", id => "template", call => \&preprocess,
- scan => 1);
+ hook(type => "preprocess", id => "template", call => \&preprocess);
}
sub getsetup () {
diff --git a/debian/changelog b/debian/changelog
index c28d36c84..62374d2dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,6 @@
ikiwiki (3.05) UNRELEASED; urgency=low
* debhelper v7.2; rules file minimisation.
- * template: Load templates in scan mode.
- This is potentially expensive, but is necessary so that meta and tag
- directives, and other links on templates affect the page using the
- template reliably.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
diff --git a/doc/bugs/cannot_reliably_use_meta_in_template.mdwn b/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
index de6c227f6..48288a2b3 100644
--- a/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
+++ b/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
@@ -14,5 +14,3 @@ scan pass, every page containing a template will cause the template to be
loaded and filled out. This can be some serious additional overhead.
--[[Joey]]
-
-[[done]]
diff --git a/doc/bugs/tags__44___backlinks_and_3.x.mdwn b/doc/bugs/tags__44___backlinks_and_3.x.mdwn
index 4fe9a4723..ea0eecc80 100644
--- a/doc/bugs/tags__44___backlinks_and_3.x.mdwn
+++ b/doc/bugs/tags__44___backlinks_and_3.x.mdwn
@@ -30,5 +30,3 @@ time, so went ahead and migrated live, spamming planet debian in the process
> [[cannot_reliably_use_meta_in_template]]. AFAIK, this has never worked
> reliably, although the linked page has a simple, though potentially
> expensive fix. --[[Joey]]
-
-> fix made, [[done]] --[[Joey]]
diff --git a/doc/todo/tag_pagespec_function.mdwn b/doc/todo/tag_pagespec_function.mdwn
index 060368179..0a51c7220 100644
--- a/doc/todo/tag_pagespec_function.mdwn
+++ b/doc/todo/tag_pagespec_function.mdwn
@@ -8,13 +8,6 @@ match tagged pages independent of whatever the tagbase is set to.
-- [[users/Jon]] 2009/02/17
-> So, this looks good, appreciate the patch.
->
-> The only problem I see is it could be confusing if `tag(foo)` matched
-> a page that just linked to the tag via a wikilink, w/o actually tagging it.
->
-> One other thing, perhaps it should be called `tagged()`? --[[Joey]]
-
[[!tag patch]]
--- a/plugins/IkiWiki/Plugin/tag.pm 2009-02-16 11:30:11.000000000 +0000
--
cgit v1.2.3
From 9acc4d578d7468ebb54a02377e571c89bb76ad9b Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Tue, 17 Feb 2009 13:30:07 -0500
Subject: template: Load templates in scan mode
This is potentially expensive, but is necessary so that meta and tag
directives, and other links on templates affect the page using the template
reliably.
---
IkiWiki/Plugin/template.pm | 3 ++-
debian/changelog | 4 ++++
doc/bugs/cannot_reliably_use_meta_in_template.mdwn | 2 ++
doc/bugs/tags__44___backlinks_and_3.x.mdwn | 2 ++
4 files changed, 10 insertions(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index 57bff20ff..b872f0962 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -10,7 +10,8 @@ use Encode;
sub import {
hook(type => "getsetup", id => "template", call => \&getsetup);
- hook(type => "preprocess", id => "template", call => \&preprocess);
+ hook(type => "preprocess", id => "template", call => \&preprocess,
+ scan => 1);
}
sub getsetup () {
diff --git a/debian/changelog b/debian/changelog
index 62374d2dc..c28d36c84 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,10 @@
ikiwiki (3.05) UNRELEASED; urgency=low
* debhelper v7.2; rules file minimisation.
+ * template: Load templates in scan mode.
+ This is potentially expensive, but is necessary so that meta and tag
+ directives, and other links on templates affect the page using the
+ template reliably.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
diff --git a/doc/bugs/cannot_reliably_use_meta_in_template.mdwn b/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
index 48288a2b3..de6c227f6 100644
--- a/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
+++ b/doc/bugs/cannot_reliably_use_meta_in_template.mdwn
@@ -14,3 +14,5 @@ scan pass, every page containing a template will cause the template to be
loaded and filled out. This can be some serious additional overhead.
--[[Joey]]
+
+[[done]]
diff --git a/doc/bugs/tags__44___backlinks_and_3.x.mdwn b/doc/bugs/tags__44___backlinks_and_3.x.mdwn
index ea0eecc80..4fe9a4723 100644
--- a/doc/bugs/tags__44___backlinks_and_3.x.mdwn
+++ b/doc/bugs/tags__44___backlinks_and_3.x.mdwn
@@ -30,3 +30,5 @@ time, so went ahead and migrated live, spamming planet debian in the process
> [[cannot_reliably_use_meta_in_template]]. AFAIK, this has never worked
> reliably, although the linked page has a simple, though potentially
> expensive fix. --[[Joey]]
+
+> fix made, [[done]] --[[Joey]]
--
cgit v1.2.3
From 52f2235e6072bfb2e39a52bd8c106ae890ba4a5a Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Tue, 17 Feb 2009 19:36:58 -0500
Subject: goto: Fix redirect to comments.
---
IkiWiki/Plugin/goto.pm | 2 +-
debian/changelog | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm
index 7cc8cb484..4fd1471e9 100644
--- a/IkiWiki/Plugin/goto.pm
+++ b/IkiWiki/Plugin/goto.pm
@@ -38,7 +38,7 @@ sub cgi_goto ($;$) {
# permalink. Comments do.
if (IkiWiki::isinternal($page) &&
defined $pagestate{$page}{meta}{permalink}) {
- redirect($q, $pagestate{$page}{meta}{permalink});
+ Ikiwiki::redirect($q, $pagestate{$page}{meta}{permalink});
}
my $link = bestlink("", $page);
diff --git a/debian/changelog b/debian/changelog
index c28d36c84..b644ac99c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ ikiwiki (3.05) UNRELEASED; urgency=low
This is potentially expensive, but is necessary so that meta and tag
directives, and other links on templates affect the page using the
template reliably.
+ * goto: Fix redirect to comments.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
--
cgit v1.2.3
From 5f96944dd5ad099d96adbf0273b4dc7d1da98829 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Tue, 17 Feb 2009 19:37:36 -0500
Subject: typo
---
IkiWiki/Plugin/goto.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm
index 4fd1471e9..06ec0bdca 100644
--- a/IkiWiki/Plugin/goto.pm
+++ b/IkiWiki/Plugin/goto.pm
@@ -38,7 +38,7 @@ sub cgi_goto ($;$) {
# permalink. Comments do.
if (IkiWiki::isinternal($page) &&
defined $pagestate{$page}{meta}{permalink}) {
- Ikiwiki::redirect($q, $pagestate{$page}{meta}{permalink});
+ IkiWiki::redirect($q, $pagestate{$page}{meta}{permalink});
}
my $link = bestlink("", $page);
--
cgit v1.2.3
From e611d4cdc10d2fb66d41ec8e101e6e35ddc9fdbf Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Thu, 19 Feb 2009 18:49:30 -0500
Subject: add tag() pagespec
patch from jon
---
IkiWiki/Plugin/tag.pm | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index d43910910..48c197748 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -125,4 +125,12 @@ sub pagetemplate (@) {
}
}
+package IkiWiki::PageSpec;
+
+sub match_tag ($$;@) {
+ my $page = shift;
+ my $glob = shift;
+ return match_link($page, IkiWiki::Plugin::tag::tagpage($glob));
+}
+
1
--
cgit v1.2.3
From f813b10fef13682c95ada9c9a9ccf05ff602c172 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Thu, 19 Feb 2009 18:54:25 -0500
Subject: rename tag() to tagged(); add docs
---
IkiWiki/Plugin/tag.pm | 2 +-
debian/changelog | 1 +
doc/ikiwiki/pagespec.mdwn | 3 ++-
doc/plugins/tag.mdwn | 3 +++
doc/todo/tag_pagespec_function.mdwn | 2 +-
5 files changed, 8 insertions(+), 3 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index 48c197748..8fe9c6828 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -127,7 +127,7 @@ sub pagetemplate (@) {
package IkiWiki::PageSpec;
-sub match_tag ($$;@) {
+sub match_tagged ($$;@) {
my $page = shift;
my $glob = shift;
return match_link($page, IkiWiki::Plugin::tag::tagpage($glob));
diff --git a/debian/changelog b/debian/changelog
index 810c59f4e..80b3c5d8e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,7 @@ ikiwiki (3.05) UNRELEASED; urgency=low
template reliably.
* goto: Fix redirect to comments.
* Add noextension parameter to htmlize hooks to support, eg, Makefile.
+ * Add tagged() PageSpec.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
diff --git a/doc/ikiwiki/pagespec.mdwn b/doc/ikiwiki/pagespec.mdwn
index 86abe5745..b476bde1f 100644
--- a/doc/ikiwiki/pagespec.mdwn
+++ b/doc/ikiwiki/pagespec.mdwn
@@ -25,6 +25,7 @@ match all pages except for Discussion pages and the SandBox:
Some more elaborate limits can be added to what matches using these functions:
* "`link(page)`" - match only pages that link to a given page (or glob)
+* "`tagged(tag)`" - match pages that are tagged or link to the given tag (or glob)
* "`backlink(page)`" - match only pages that a given page links to
* "`creation_month(month)`" - match only pages created on the given month
* "`creation_day(mday)`" - or day of the month
@@ -65,7 +66,7 @@ More complex expressions can also be created, by using parentheses for
grouping. For example, to match pages in a blog that are tagged with either
of two tags, use:
- blog/* and (link(tag/foo) or link(tag/bar))
+ blog/* and (tagged(foo) or tagged(bar))
Note that page names in PageSpecs are matched against the absolute
filenames of the pages in the wiki, so a pagespec "foo" used on page
diff --git a/doc/plugins/tag.mdwn b/doc/plugins/tag.mdwn
index 17bb086a1..8ff70a069 100644
--- a/doc/plugins/tag.mdwn
+++ b/doc/plugins/tag.mdwn
@@ -5,6 +5,9 @@ This plugin provides the [[ikiwiki/directive/tag]] and
[[ikiwiki/directive/taglink]] [[directives|ikiwiki/directive]].
These directives allow tagging pages.
+It also provides the `tagged()` [[ikiwiki/PageSpec]], which can be used to
+match pages that are tagged with a specific tag.
+
[[!if test="enabled(tag)" then="""
This wiki has the tag plugin enabled, so you'll see a note below that this
page is tagged with the "tags" tag.
diff --git a/doc/todo/tag_pagespec_function.mdwn b/doc/todo/tag_pagespec_function.mdwn
index 060368179..681a1f661 100644
--- a/doc/todo/tag_pagespec_function.mdwn
+++ b/doc/todo/tag_pagespec_function.mdwn
@@ -15,7 +15,7 @@ match tagged pages independent of whatever the tagbase is set to.
>
> One other thing, perhaps it should be called `tagged()`? --[[Joey]]
-[[!tag patch]]
+[[!tag patch done]]
--- a/plugins/IkiWiki/Plugin/tag.pm 2009-02-16 11:30:11.000000000 +0000
+++ b/plugins/IkiWiki/Plugin/tag.pm 2009-02-17 15:40:03.000000000 +0000
--
cgit v1.2.3
From 63439fa10b2b59e85337d7a0f71ddaa38dfb0018 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Wed, 25 Feb 2009 16:56:02 -0500
Subject: bzr: Add missing stub rcs_diff.
---
IkiWiki/Plugin/bzr.pm | 4 ++++
debian/changelog | 1 +
2 files changed, 5 insertions(+)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm
index 16c959069..783623dee 100644
--- a/IkiWiki/Plugin/bzr.pm
+++ b/IkiWiki/Plugin/bzr.pm
@@ -255,6 +255,10 @@ sub rcs_recentchanges ($) {
return @ret;
}
+sub rcs_diff ($) {
+ # TODO
+}
+
sub rcs_getctime ($) {
my ($file) = @_;
diff --git a/debian/changelog b/debian/changelog
index 1dc01878b..ac7e2f21d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ ikiwiki (3.05) UNRELEASED; urgency=low
* Add tagged() PageSpec.
* Updated German translation (Kai Wasserbäch). Closes: #516770
* Setup automator: Prompt for password twice. Closes: #516973
+ * bzr: Add missing stub rcs_diff.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
--
cgit v1.2.3
From b30c1b0c38bc8e6730a76135e6bff695d0f778c2 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Thu, 26 Feb 2009 02:31:13 -0500
Subject: comments: Avoid showing comment moderation button in prefs to
non-admins.
---
IkiWiki/Plugin/comments.pm | 3 ++-
debian/changelog | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 3cdffe856..ee53dbc91 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -605,7 +605,8 @@ sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
- if ($form->title eq "preferences") {
+ if ($form->title eq "preferences" &&
+ IkiWiki::is_admin($params{session}->param("name"))) {
push @{$params{buttons}}, "Comment Moderation";
if ($form->submitted && $form->submitted eq "Comment Moderation") {
commentmoderation($params{cgi}, $params{session});
diff --git a/debian/changelog b/debian/changelog
index ac7e2f21d..68d08ad8e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ ikiwiki (3.05) UNRELEASED; urgency=low
* Updated German translation (Kai Wasserbäch). Closes: #516770
* Setup automator: Prompt for password twice. Closes: #516973
* bzr: Add missing stub rcs_diff.
+ * comments: Avoid showing comment moderation button in prefs to non-admins.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
--
cgit v1.2.3
From 596b2906fdc863fac2a3c86abbdb39416eee1961 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Thu, 26 Feb 2009 14:09:26 -0500
Subject: bzr: Add missing rcs_diff. (liw)
---
IkiWiki/Plugin/bzr.pm | 18 ++++++++++-
debian/changelog | 2 +-
.../bzr_plugin_does_not_define_rcs__95__diff.mdwn | 36 +---------------------
3 files changed, 19 insertions(+), 37 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm
index 783623dee..883007367 100644
--- a/IkiWiki/Plugin/bzr.pm
+++ b/IkiWiki/Plugin/bzr.pm
@@ -256,7 +256,23 @@ sub rcs_recentchanges ($) {
}
sub rcs_diff ($) {
- # TODO
+ my $taintedrev=shift;
+ my ($rev) = $taintedrev =~ /^(\d+(\.\d+)*)$/; # untaint
+
+ my $prevspec = "before:" . $rev;
+ my $revspec = "revno:" . $rev;
+ my @cmdline = ("bzr", "diff", "--old", $config{srcdir},
+ "--new", $config{srcdir},
+ "-r", $prevspec . ".." . $revspec);
+ open (my $out, "@cmdline |");
+
+ my @lines = <$out>;
+ if (wantarray) {
+ return @lines;
+ }
+ else {
+ return join("", @lines);
+ }
}
sub rcs_getctime ($) {
diff --git a/debian/changelog b/debian/changelog
index 68d08ad8e..90b672e8d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,7 +10,7 @@ ikiwiki (3.05) UNRELEASED; urgency=low
* Add tagged() PageSpec.
* Updated German translation (Kai Wasserbäch). Closes: #516770
* Setup automator: Prompt for password twice. Closes: #516973
- * bzr: Add missing stub rcs_diff.
+ * bzr: Add missing rcs_diff. (liw)
* comments: Avoid showing comment moderation button in prefs to non-admins.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
diff --git a/doc/bugs/bzr_plugin_does_not_define_rcs__95__diff.mdwn b/doc/bugs/bzr_plugin_does_not_define_rcs__95__diff.mdwn
index 110f769c7..0294ec62e 100644
--- a/doc/bugs/bzr_plugin_does_not_define_rcs__95__diff.mdwn
+++ b/doc/bugs/bzr_plugin_does_not_define_rcs__95__diff.mdwn
@@ -24,38 +24,4 @@ Grepping to verify absence of rcs_diff:
>> seems to work. I am unfortunately not ready to set up a git repository that you
>> can pull from. --liw
- diff --git a/IkiWiki/Plugin/.bzr.pm.swp b/IkiWiki/Plugin/.bzr.pm.swp
- new file mode 100644
- index 0000000..712120c
- Binary files /dev/null and b/IkiWiki/Plugin/.bzr.pm.swp differ
- diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm
- index 783623d..f1d5854 100644
- --- a/IkiWiki/Plugin/bzr.pm
- +++ b/IkiWiki/Plugin/bzr.pm
- @@ -256,7 +256,25 @@ sub rcs_recentchanges ($) {
- }
-
- sub rcs_diff ($) {
- - # TODO
- + my $taintedrev=shift;
- + my ($rev) = $taintedrev =~ /^(\d+(\.\d+)*)$/; # untaint
- + print STDERR "taintedrev: $taintedrev\nrev: $rev\n";
- +
- + my $prevspec = "before:" . $rev;
- + my $revspec = "revno:" . $rev;
- + my @cmdline = ("bzr", "diff", "--old", $config{srcdir},
- + "--new", $config{srcdir},
- + "-r", $prevspec . ".." . $revspec);
- + print STDERR "cmdline: @cmdline\n";
- + open (my $out, "@cmdline |");
- +
- + my @lines = <$out>;
- + if (wantarray) {
- + return @lines;
- + }
- + else {
- + return join("", @lines);
- + }
- }
-
- sub rcs_getctime ($) {
+[[done]] --[[Joey]]
--
cgit v1.2.3
From affd4ca3daa8da233d915516fb668c8f99fffe51 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Fri, 27 Feb 2009 13:21:29 -0500
Subject: goto: Fix typo that broke recentchanges_link compatability.
---
IkiWiki/Plugin/goto.pm | 2 +-
debian/changelog | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm
index 06ec0bdca..3f40c5859 100644
--- a/IkiWiki/Plugin/goto.pm
+++ b/IkiWiki/Plugin/goto.pm
@@ -65,7 +65,7 @@ sub cgi ($) {
my $do = $cgi->param('do');
if (defined $do && ($do eq 'goto' || $do eq 'commenter' ||
- $do eq 'recentchanged_link')) {
+ $do eq 'recentchanges_link')) {
# goto is the preferred name for this; recentchanges_link and
# commenter are for compatibility with any saved URLs
cgi_goto($cgi);
diff --git a/debian/changelog b/debian/changelog
index 90b672e8d..0b1eec6cf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ ikiwiki (3.05) UNRELEASED; urgency=low
* Setup automator: Prompt for password twice. Closes: #516973
* bzr: Add missing rcs_diff. (liw)
* comments: Avoid showing comment moderation button in prefs to non-admins.
+ * goto: Fix typo that broke recentchanges_link compatability.
-- Joey Hess Sun, 15 Feb 2009 20:11:57 -0500
--
cgit v1.2.3
From e7d2da564145d4ad05c3dcbe9d71bbf091243b91 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sat, 7 Mar 2009 14:33:11 -0500
Subject: wmd plugin from willu
---
IkiWiki/Plugin/wmd.pm | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 IkiWiki/Plugin/wmd.pm
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm
new file mode 100644
index 000000000..074e1df6f
--- /dev/null
+++ b/IkiWiki/Plugin/wmd.pm
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::wmd;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+use POSIX;
+use Encode;
+
+sub import {
+ add_underlay("wmd");
+ hook(type => "getsetup", id => "wmd", call => \&getsetup);
+ hook(type => "formbuilder_setup", id => "wmd", call => \&formbuilder_setup);
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ safe => 1,
+ rebuild => 1,
+ },
+}
+
+sub formbuilder_setup (@) {
+ my %params=@_;
+ my $form=$params{form};
+
+ return if ! defined $form->field("do");
+
+ return unless (($form->field("do") eq "edit") ||
+ ($form->field("do") eq "create"));
+
+ $form->tmpl_param("wmd_preview", "\n".include_javascript(undef, 1));
+}
+
+sub include_javascript ($;$) {
+ my $page=shift;
+ my $absolute=shift;
+
+ return ''."\n";
+}
+
+1
+
--
cgit v1.2.3
From 029cf94493ca6fc7e13245539c138d3884adc61f Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sat, 7 Mar 2009 14:34:31 -0500
Subject: rebuild not needed
This plugin only affects the page edit, not the compiled wiki.
---
IkiWiki/Plugin/wmd.pm | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
(limited to 'IkiWiki/Plugin')
diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm
index 074e1df6f..3372ffe38 100644
--- a/IkiWiki/Plugin/wmd.pm
+++ b/IkiWiki/Plugin/wmd.pm
@@ -17,7 +17,6 @@ sub getsetup () {
return
plugin => {
safe => 1,
- rebuild => 1,
},
}
@@ -30,7 +29,8 @@ sub formbuilder_setup (@) {
return unless (($form->field("do") eq "edit") ||
($form->field("do") eq "create"));
- $form->tmpl_param("wmd_preview", "\n".include_javascript(undef, 1));
+ $form->tmpl_param("wmd_preview", "\n".
+ include_javascript(undef, 1));
}
sub include_javascript ($;$) {
@@ -42,4 +42,3 @@ sub include_javascript ($;$) {
}
1
-
--
cgit v1.2.3