]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Fix ugly display when editing a page that has vanished.
authorJoey Hess <joey@kodama.kitenet.net>
Fri, 2 May 2008 17:02:07 +0000 (13:02 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Fri, 2 May 2008 17:02:07 +0000 (13:02 -0400)
srcfile now has an optional second parameter to avoid it throwing an error
if the source file does not exist.

IkiWiki.pm
IkiWiki/CGI.pm
IkiWiki/Plugin/shortcut.pm
debian/changelog
doc/plugins/write.mdwn
po/ikiwiki.pot

index 3802559a53d6c60569464a17b95109f9eab807a5..f5cf8ba96bbc8d61a6e801d9058e13955e5108c6 100644 (file)
@@ -282,14 +282,15 @@ sub htmlpage ($) { #{{{
        return targetpage($page, $config{htmlext});
 } #}}}
 
-sub srcfile ($) { #{{{
+sub srcfile ($;$) { #{{{
        my $file=shift;
+       my $nothrow=shift;
 
        return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
        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");
+       error("internal error: $file cannot be found in $config{srcdir} or underlay") unless $nothrow;
        return;
 } #}}}
 
index 65136a26947a2cae9ee5eeecc52ed092e33b197b..781974c13d5c8dde65e772bc0c4c3f952fc0f958 100644 (file)
@@ -503,7 +503,7 @@ sub cgi_editpage ($$) { #{{{
                my $exists=-e "$config{srcdir}/$file";
 
                if ($form->field("do") ne "create" && ! $exists &&
-                   ! eval { srcfile($file) }) {
+                   ! defined srcfile($file, 1)) {
                        $form->tmpl_param("page_gone", 1);
                        $form->field(name => "do", value => "create", force => 1);
                        $form->tmpl_param("page_select", 0);
index c3e1f5446f6c98ca9f3c9c65a7a014b7c7e15c59..f1a38ea48070ed255ea8046e8b4d5c1dd6787af3 100644 (file)
@@ -13,7 +13,7 @@ sub import { #{{{
 sub checkconfig () { #{{{
        # Preprocess the shortcuts page to get all the available shortcuts
        # defined before other pages are rendered.
-       my $srcfile=eval {srcfile("shortcuts.mdwn")};
+       my $srcfile=srcfile("shortcuts.mdwn", 1);
        if (! defined $srcfile) {
                error(gettext("shortcut plugin will not work without a shortcuts.mdwn"));
        }
index 1d06b4f5deda33d3151bf9ede7f14df030b0ab7c..dc16f5ac28cab5035e995370e4f651daf9053393 100644 (file)
@@ -10,6 +10,9 @@ ikiwiki (2.45) UNRELEASED; urgency=low
     Closes: #478718
   * anonk: Add anonok_pagespec configuration setting that can be used to
     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
 
index ea2d006300db5d1cfb5e5a70f9030171f9324b07..183675c53435319a8f629f838dc0eb8a38267aa7 100644 (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
 that corresponds to that file.
 
-#### `srcfile($)`
+#### `srcfile($;$)`
 
 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
 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($)`
 
 Adds a directory to the set of underlay directories that ikiwiki will
index f66cdec071b022abb37da98d7a19940d2412e08d..835b2773bbfaf109a524076c42c6ce3289dfae2a 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\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"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -183,23 +183,23 @@ msgstr ""
 msgid "prog not a valid graphviz program"
 msgstr ""
 
-#: ../IkiWiki/Plugin/img.pm:53
+#: ../IkiWiki/Plugin/img.pm:55
 #, perl-format
 msgid "bad size \"%s\""
 msgstr ""
 
-#: ../IkiWiki/Plugin/img.pm:63 ../IkiWiki/Plugin/img.pm:67
-#: ../IkiWiki/Plugin/img.pm:84
+#: ../IkiWiki/Plugin/img.pm:65 ../IkiWiki/Plugin/img.pm:69
+#: ../IkiWiki/Plugin/img.pm:86
 #, perl-format
 msgid "failed to read %s: %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/img.pm:70
+#: ../IkiWiki/Plugin/img.pm:72
 #, perl-format
 msgid "failed to resize: %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/img.pm:101
+#: ../IkiWiki/Plugin/img.pm:103
 #, perl-format
 msgid "failed to determine size of image %s"
 msgstr ""
@@ -640,7 +640,7 @@ msgstr ""
 #. translators: preprocessor directive name,
 #. translators: the second a page name, the
 #. translators: third a number.
-#: ../IkiWiki.pm:750
+#: ../IkiWiki.pm:751
 #, perl-format
 msgid "%s preprocessing loop detected on %s at depth %i"
 msgstr ""