Fix ugly display when editing a page that has vanished.

srcfile now has an optional second parameter to avoid it throwing an error
if the source file does not exist.
master
Joey Hess 2008-05-02 13:02:07 -04:00
parent 9fca7f2f8b
commit b2dea99417
6 changed files with 20 additions and 12 deletions

View File

@ -282,14 +282,15 @@ sub htmlpage ($) { #{{{
return targetpage($page, $config{htmlext}); return targetpage($page, $config{htmlext});
} #}}} } #}}}
sub srcfile ($) { #{{{ sub srcfile ($;$) { #{{{
my $file=shift; my $file=shift;
my $nothrow=shift;
return "$config{srcdir}/$file" if -e "$config{srcdir}/$file"; return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) { foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
return "$dir/$file" if -e "$dir/$file"; return "$dir/$file" if -e "$dir/$file";
} }
error("internal error: $file cannot be found in $config{srcdir} or underlay"); error("internal error: $file cannot be found in $config{srcdir} or underlay") unless $nothrow;
return; return;
} #}}} } #}}}

View File

@ -503,7 +503,7 @@ sub cgi_editpage ($$) { #{{{
my $exists=-e "$config{srcdir}/$file"; my $exists=-e "$config{srcdir}/$file";
if ($form->field("do") ne "create" && ! $exists && if ($form->field("do") ne "create" && ! $exists &&
! eval { srcfile($file) }) { ! defined srcfile($file, 1)) {
$form->tmpl_param("page_gone", 1); $form->tmpl_param("page_gone", 1);
$form->field(name => "do", value => "create", force => 1); $form->field(name => "do", value => "create", force => 1);
$form->tmpl_param("page_select", 0); $form->tmpl_param("page_select", 0);

View File

@ -13,7 +13,7 @@ sub import { #{{{
sub checkconfig () { #{{{ sub checkconfig () { #{{{
# Preprocess the shortcuts page to get all the available shortcuts # Preprocess the shortcuts page to get all the available shortcuts
# defined before other pages are rendered. # defined before other pages are rendered.
my $srcfile=eval {srcfile("shortcuts.mdwn")}; my $srcfile=srcfile("shortcuts.mdwn", 1);
if (! defined $srcfile) { if (! defined $srcfile) {
error(gettext("shortcut plugin will not work without a shortcuts.mdwn")); error(gettext("shortcut plugin will not work without a shortcuts.mdwn"));
} }

3
debian/changelog vendored
View File

@ -10,6 +10,9 @@ ikiwiki (2.45) UNRELEASED; urgency=low
Closes: #478718 Closes: #478718
* anonk: Add anonok_pagespec configuration setting that can be used to * anonk: Add anonok_pagespec configuration setting that can be used to
allow anonymous users to edit only matching pages. Closes: #478892 allow anonymous users to edit only matching pages. Closes: #478892
* Fix ugly display when editing a page that has vanished.
* srcfile now has an optional second parameter to avoid it throwing an error
if the source file does not exist.
-- Joey Hess <joeyh@debian.org> Sat, 26 Apr 2008 15:09:36 -0400 -- Joey Hess <joeyh@debian.org> Sat, 26 Apr 2008 15:09:36 -0400

View File

@ -529,12 +529,16 @@ a type that ikiwiki knowns how to htmlize. Otherwise, returns undef.
Given the name of a source file, returns the name of the wiki page Given the name of a source file, returns the name of the wiki page
that corresponds to that file. that corresponds to that file.
#### `srcfile($)` #### `srcfile($;$)`
Given the name of a source file in the wiki, searches for the file in Given the name of a source file in the wiki, searches for the file in
the source directory and the underlay directories (most recently added the source directory and the underlay directories (most recently added
underlays first), and returns the full path to the first file found. underlays first), and returns the full path to the first file found.
Normally srcfile will fail with an error message if the source file cannot
be found. The second parameter can be set to a true value to make it return
undef instead.
#### `add_underlay($)` #### `add_underlay($)`
Adds a directory to the set of underlay directories that ikiwiki will Adds a directory to the set of underlay directories that ikiwiki will

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-04-24 13:50-0400\n" "POT-Creation-Date: 2008-05-02 12:52-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -183,23 +183,23 @@ msgstr ""
msgid "prog not a valid graphviz program" msgid "prog not a valid graphviz program"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/img.pm:53 #: ../IkiWiki/Plugin/img.pm:55
#, perl-format #, perl-format
msgid "bad size \"%s\"" msgid "bad size \"%s\""
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/img.pm:63 ../IkiWiki/Plugin/img.pm:67 #: ../IkiWiki/Plugin/img.pm:65 ../IkiWiki/Plugin/img.pm:69
#: ../IkiWiki/Plugin/img.pm:84 #: ../IkiWiki/Plugin/img.pm:86
#, perl-format #, perl-format
msgid "failed to read %s: %s" msgid "failed to read %s: %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/img.pm:70 #: ../IkiWiki/Plugin/img.pm:72
#, perl-format #, perl-format
msgid "failed to resize: %s" msgid "failed to resize: %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/img.pm:101 #: ../IkiWiki/Plugin/img.pm:103
#, perl-format #, perl-format
msgid "failed to determine size of image %s" msgid "failed to determine size of image %s"
msgstr "" msgstr ""
@ -640,7 +640,7 @@ msgstr ""
#. translators: preprocessor directive name, #. translators: preprocessor directive name,
#. translators: the second a page name, the #. translators: the second a page name, the
#. translators: third a number. #. translators: third a number.
#: ../IkiWiki.pm:750 #: ../IkiWiki.pm:751
#, perl-format #, perl-format
msgid "%s preprocessing loop detected on %s at depth %i" msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "" msgstr ""