* Support for looking in multiple directories for underlay files.

* Plugins can add new directories to the search path with the add_underlay
  function.
* Split out smiley underlay files into a separate underlay, so if the plugin
  isn't used, the wiki isn't bloated with all those files.
master
joey 2007-08-28 01:59:01 +00:00
parent 21c4bd8444
commit 9c5f4761d8
57 changed files with 142 additions and 89 deletions

View File

@ -17,6 +17,7 @@ use Exporter q{import};
our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
bestlink htmllink readfile writefile pagetype srcfile pagename
displaytime will_render gettext urlto targetpage
add_underlay
%config %links %renderedfiles %pagesources %destsources);
our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
@ -83,6 +84,7 @@ sub defaultconfig () { #{{{
pingurl => [],
templatedir => "$installdir/share/ikiwiki/templates",
underlaydir => "$installdir/share/ikiwiki/basewiki",
underlaydirs => [],
setup => undef,
adminuser => undef,
adminemail => undef,
@ -285,11 +287,26 @@ sub srcfile ($) { #{{{
my $file=shift;
return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
return "$config{underlaydir}/$file" if -e "$config{underlaydir}/$file";
error("internal error: $file cannot be found in $config{srcdir} or $config{underlaydir}");
foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
return "$dir/$file" if -e "$dir/$file";
}
error("internal error: $file cannot be found in $config{srcdir} or underlay");
return;
} #}}}
sub add_underlay ($) { #{{{
my $dir=shift;
if ($dir=~/^\//) {
unshift @{$config{underlaydirs}}, $dir;
}
else {
unshift @{$config{underlaydirs}}, "$config{underlaydir}/../$dir";
}
return 1;
} #}}}
sub readfile ($;$$) { #{{{
my $file=shift;
my $binary=shift;

View File

@ -335,7 +335,8 @@ sub cgi_editpage ($$) { #{{{
# characters.
my ($page)=$form->field('page');
$page=titlepage(possibly_foolish_untaint($page));
if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
if (! defined $page || ! length $page ||
file_pruned($page, $config{srcdir}) || $page=~/^\//) {
error("bad page name");
}
@ -512,8 +513,8 @@ sub cgi_editpage ($$) { #{{{
my $exists=-e "$config{srcdir}/$file";
if ($form->field("do") ne "create" &&
! $exists && ! -e "$config{underlaydir}/$file") {
if ($form->field("do") ne "create" && ! $exists &&
! eval { srcfile($file) }) {
$form->tmpl_param("page_gone", 1);
$form->field(name => "do", value => "create", force => 1);
$form->tmpl_param("page_select", 0);

View File

@ -9,6 +9,7 @@ my %smileys;
my $smiley_regexp;
sub import { #{{{
add_underlay("smiley");
hook(type => "filter", id => "smiley", call => \&filter);
} # }}}

View File

@ -270,11 +270,12 @@ sub refresh () { #{{{
}
},
}, $config{srcdir});
foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
find({
no_chdir => 1,
wanted => sub {
$_=decode_utf8($_);
if (file_pruned($_, $config{underlaydir})) {
if (file_pruned($_, $dir)) {
$File::Find::prune=1;
}
elsif (! -d $_ && ! -l $_) {
@ -283,9 +284,10 @@ sub refresh () { #{{{
warn(sprintf(gettext("skipping bad filename %s"), $_)."\n");
}
else {
# Don't add pages that are in the
# srcdir.
$f=~s/^\Q$config{underlaydir}\E\/?//;
$f=~s/^\Q$dir\E\/?//;
# avoid underlaydir
# override attacks; see
# security.mdwn
if (! -e "$config{srcdir}/$f" &&
! -l "$config{srcdir}/$f") {
my $page=pagename($f);
@ -297,7 +299,8 @@ sub refresh () { #{{{
}
}
},
}, $config{underlaydir});
}, $dir);
};
my %rendered;

View File

@ -32,7 +32,7 @@ ikiwiki.out: ikiwiki.in
extra_build: ikiwiki.out
LANG= perl -I. $(extramodules) $(tflag) ikiwiki.out doc html --templatedir=templates \
--underlaydir=basewiki --nousedirs\
--underlaydir=underlays/basewiki --nousedirs\
--wikiname="ikiwiki" --verbose \
--exclude=/discussion --no-discussion --userdir=users \
--plugin=goodstuff \
@ -49,7 +49,13 @@ extra_clean:
extra_install:
install -d $(DESTDIR)$(PREFIX)/share/ikiwiki
for dir in `find basewiki templates -follow -type d ! -regex '.*\.svn.*'`; do \
for dir in `cd underlays && find . -follow -type d ! -regex '.*\.svn.*'`; do \
install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
for file in `find underlays/$$dir -follow -maxdepth 1 -type f`; do \
install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
done; \
done
for dir in `find templates -follow -type d ! -regex '.*\.svn.*'`; do \
install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
for file in `find $$dir -follow -maxdepth 1 -type f`; do \
install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \

View File

@ -1 +0,0 @@
../doc/blog.mdwn

View File

@ -1 +0,0 @@
../doc/favicon.ico

View File

@ -1 +0,0 @@
../doc/helponformatting.mdwn

View File

@ -1 +0,0 @@
../doc/basewiki/index.mdwn

View File

@ -1 +0,0 @@
../doc/local.css

View File

@ -1 +0,0 @@
../doc/markdown.mdwn

View File

@ -1 +0,0 @@
../doc/openid.mdwn

View File

@ -1 +0,0 @@
../doc/pagespec.mdwn

View File

@ -1 +0,0 @@
../doc/preprocessordirective.mdwn

View File

@ -1 +0,0 @@
../doc/basewiki/sandbox.mdwn

View File

@ -1 +0,0 @@
../doc/shortcuts.mdwn

View File

@ -1 +0,0 @@
../doc/smileys

View File

@ -1 +0,0 @@
../doc/smileys.mdwn

View File

@ -1 +0,0 @@
../doc/style.css

View File

@ -1 +0,0 @@
../doc/subpage

View File

@ -1 +0,0 @@
../doc/subpage.mdwn

View File

@ -1 +0,0 @@
../doc/templates.mdwn

View File

@ -1 +0,0 @@
../../doc/templates/note.mdwn

View File

@ -1 +0,0 @@
../../doc/templates/popup.mdwn

View File

@ -1 +0,0 @@
../doc/wikiicons

View File

@ -1 +0,0 @@
../doc/wikilink.mdwn

9
debian/changelog vendored
View File

@ -1,8 +1,13 @@
ikiwiki (2.6.2) UNRELEASED; urgency=low
ikiwiki (2.7) UNRELEASED; urgency=low
* Add an editcontent hook.
* Support for looking in multiple directories for underlay files.
* Plugins can add new directories to the search path with the add_underlay
function.
* Split out smiley underlay files into a separate underlay, so if the plugin
isn't used, the wiki isn't bloated with all those files.
-- Joey Hess <joeyh@debian.org> Sun, 26 Aug 2007 16:50:24 -0400
-- Joey Hess <joeyh@debian.org> Mon, 27 Aug 2007 20:48:51 -0400
ikiwiki (2.6.1) unstable; urgency=low

View File

@ -13,7 +13,6 @@ It currently includes these pages:
* [[pagespec]]
* [[PreprocessorDirective]]
* [[shortcuts]]
* [[smileys]]
* [[subpage]]
* [[wikilink]]

View File

@ -67,7 +67,7 @@ directive:
* `quick` - Build archives in quick mode, without reading page contents for
metadata. By default, this also turns off generation of any feeds.
* `template` - Specifies the template to fill out to display each inlined
page. By default the `inlinepage` [[template|wikitemplates]] is used, while
page. By default the `inlinepage` template is used, while
the `archivepage` template is used for archives. Set this parameter to
use some other, custom template, such as the `titlepage` template that
only shows post titles. Note that you should still set `archive=yes` if

View File

@ -0,0 +1,6 @@
The [[plugin/brokenlinks]] plugin falsely complains that
[[helponformatting]] has a broken link to [[smileys]], if the smiley plgin
is disabled. While the helponformatting page links to it inside a
conditional, and so doesn't show the link in this case, ikiwiki scans for
links w/o looking at conditionals and so still thinks the page contains the
link.

View File

@ -461,8 +461,16 @@ that corresponds to that file.
#### `srcfile($)`
Given the name of a source file in the wiki, searches for the file in
the source directory and the underlay directory, and returns the full
path to the first file found.
the source directory and the underlay directories (most recently added
underlays first), and returns the full path to the first file found.
#### `add_underlay($)`
Adds a directory to the set of underlay directories that ikiwiki will
search for files.
If the directory name is not absolute, ikiwiki will assume it is in
the parent directory of the configured underlaydir.
#### `displaytime($)`

View File

@ -1,7 +1,3 @@
[[if test="enabled(smiley)"
then="This wiki has smileys **enabled**."
else="This wiki has smileys **disabled**."]]
This page is used to control what smileys are supported by the wiki.
Just write the text of a smiley to display it.

View File

@ -21,4 +21,9 @@ hackish.
> plugins were enabled.
>
> Using the conditionals in a page to control what other pages get built
> feels complex to me, --[[Joey]]
> feels complex to me.
>
> Instead, this has been implmented as the `add_underlay()` function.
> [[done]]
> --[[Joey]]

View File

@ -70,6 +70,9 @@ changes.diff:
you have something pretty specific in mind. I can talk to you about that more
on IRC later(assuming my internet is working right).
* Basically the idea is to change `$config{underlaydir}` to an array..
Ok, take a look at the new `add_underlay()` function. You can now just
`add_underlay("wikiwyg")` and it'll look in
/usr/share/ikiwiki/wikiwyg/ for the files.
* When is the WIKIWYG variable in misc.tmpl used?
* The WIKIWYG variable in misc.tmpl is used for the edit page. I believe that is what
you wanted me to do (Check [Revision 3840][]).

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-08-26 13:39-0400\n"
"POT-Creation-Date: 2007-08-27 21:24-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -36,34 +36,34 @@ msgstr ""
msgid "Preferences saved."
msgstr ""
#: ../IkiWiki/CGI.pm:353
#: ../IkiWiki/CGI.pm:354
#, perl-format
msgid "%s is not an editable page"
msgstr ""
#: ../IkiWiki/CGI.pm:432 ../IkiWiki/Plugin/brokenlinks.pm:24
#: ../IkiWiki/CGI.pm:441 ../IkiWiki/Plugin/brokenlinks.pm:24
#: ../IkiWiki/Plugin/inline.pm:209 ../IkiWiki/Plugin/opendiscussion.pm:17
#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:99
#: ../IkiWiki/Render.pm:179
msgid "discussion"
msgstr ""
#: ../IkiWiki/CGI.pm:478
#: ../IkiWiki/CGI.pm:487
#, perl-format
msgid "creating %s"
msgstr ""
#: ../IkiWiki/CGI.pm:496 ../IkiWiki/CGI.pm:514 ../IkiWiki/CGI.pm:524
#: ../IkiWiki/CGI.pm:550 ../IkiWiki/CGI.pm:594
#: ../IkiWiki/CGI.pm:505 ../IkiWiki/CGI.pm:523 ../IkiWiki/CGI.pm:533
#: ../IkiWiki/CGI.pm:566 ../IkiWiki/CGI.pm:610
#, perl-format
msgid "editing %s"
msgstr ""
#: ../IkiWiki/CGI.pm:688
#: ../IkiWiki/CGI.pm:704
msgid "You are banned."
msgstr ""
#: ../IkiWiki/CGI.pm:708
#: ../IkiWiki/CGI.pm:724
msgid "login failed, perhaps you need to turn on cookies?"
msgstr ""
@ -374,7 +374,7 @@ msgstr ""
msgid "shortcut %s points to <i>%s</i>"
msgstr ""
#: ../IkiWiki/Plugin/smiley.pm:22
#: ../IkiWiki/Plugin/smiley.pm:23
msgid "failed to parse any smileys"
msgstr ""
@ -476,47 +476,47 @@ msgid ""
"notifications"
msgstr ""
#: ../IkiWiki/Render.pm:263 ../IkiWiki/Render.pm:283
#: ../IkiWiki/Render.pm:263 ../IkiWiki/Render.pm:284
#, perl-format
msgid "skipping bad filename %s"
msgstr ""
#: ../IkiWiki/Render.pm:323
#: ../IkiWiki/Render.pm:326
#, perl-format
msgid "removing old page %s"
msgstr ""
#: ../IkiWiki/Render.pm:356
#: ../IkiWiki/Render.pm:359
#, perl-format
msgid "scanning %s"
msgstr ""
#: ../IkiWiki/Render.pm:361
#: ../IkiWiki/Render.pm:364
#, perl-format
msgid "rendering %s"
msgstr ""
#: ../IkiWiki/Render.pm:373
#: ../IkiWiki/Render.pm:376
#, perl-format
msgid "rendering %s, which links to %s"
msgstr ""
#: ../IkiWiki/Render.pm:390
#: ../IkiWiki/Render.pm:393
#, perl-format
msgid "rendering %s, which depends on %s"
msgstr ""
#: ../IkiWiki/Render.pm:428
#: ../IkiWiki/Render.pm:431
#, perl-format
msgid "rendering %s, to update its backlinks"
msgstr ""
#: ../IkiWiki/Render.pm:440
#: ../IkiWiki/Render.pm:443
#, perl-format
msgid "removing %s, no longer rendered by %s"
msgstr ""
#: ../IkiWiki/Render.pm:466
#: ../IkiWiki/Render.pm:469
#, perl-format
msgid "ikiwiki: cannot render %s"
msgstr ""
@ -593,11 +593,11 @@ msgstr ""
msgid "usage: --set var=value"
msgstr ""
#: ../IkiWiki.pm:126
#: ../IkiWiki.pm:128
msgid "Must specify url to wiki with --url when using --cgi"
msgstr ""
#: ../IkiWiki.pm:191 ../IkiWiki.pm:192
#: ../IkiWiki.pm:193 ../IkiWiki.pm:194
msgid "Error"
msgstr ""
@ -605,7 +605,7 @@ msgstr ""
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
#: ../IkiWiki.pm:688
#: ../IkiWiki.pm:705
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""

View File

@ -1,9 +1,12 @@
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 3;
use Test::More 'no_plan';
ok(! system("make ikiwiki.out"));
ok(! system("LANG=C perl -T -I. ./ikiwiki.out -plugin brokenlinks -rebuild -underlaydir=basewiki -templatedir=templates t/basewiki_brokenlinks t/basewiki_brokenlinks/out"));
ok(`grep 'no broken links' t/basewiki_brokenlinks/out/index.html`);
system("rm -rf t/basewiki_brokenlinks/out t/basewiki_brokenlinks/.ikiwiki");
ok(! system("mkdir t/tmp"));
ok(! system("make -q ikiwiki.out"));
ok(! system("make extra_install DESTDIR=t/tmp/install PREFIX=/usr >/dev/null"));
ok(! system("LANG= perl -T -I. ./ikiwiki.out -plugin smiley -plugin brokenlinks -rebuild -underlaydir=t/tmp/install/usr/share/ikiwiki/basewiki -templatedir=templates t/basewiki_brokenlinks t/tmp/out"));
ok(`grep 'no broken links' t/tmp/out/index.html`);
ok(-e "t/tmp/out/style.css");
ok(! system("rm -rf t/tmp t/basewiki_brokenlinks/.ikiwiki"));

View File

@ -0,0 +1 @@
../../doc/blog.mdwn

View File

@ -0,0 +1 @@
../../doc/favicon.ico

View File

@ -0,0 +1 @@
../../doc/helponformatting.mdwn

View File

@ -0,0 +1 @@
../../doc/basewiki/index.mdwn

View File

@ -0,0 +1 @@
../../doc/local.css

View File

@ -0,0 +1 @@
../../doc/markdown.mdwn

View File

@ -0,0 +1 @@
../../doc/openid.mdwn

View File

@ -0,0 +1 @@
../../doc/pagespec.mdwn

View File

@ -0,0 +1 @@
../../doc/preprocessordirective.mdwn

View File

@ -0,0 +1 @@
../../doc/basewiki/sandbox.mdwn

View File

@ -0,0 +1 @@
../../doc/shortcuts.mdwn

View File

@ -0,0 +1 @@
../../doc/style.css

View File

@ -0,0 +1 @@
../../doc/subpage

View File

@ -0,0 +1 @@
../../doc/subpage.mdwn

View File

@ -0,0 +1 @@
../../doc/templates.mdwn

View File

@ -0,0 +1 @@
../../../doc/templates/note.mdwn

View File

@ -0,0 +1 @@
../../../doc/templates/popup.mdwn

View File

@ -0,0 +1 @@
../../doc/wikiicons

View File

@ -0,0 +1 @@
../../doc/wikilink.mdwn

View File

@ -0,0 +1 @@
../../doc/smileys

View File

@ -0,0 +1 @@
../../doc/smileys.mdwn