proper main sub and loadindex optimisation for cgis
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 23 Mar 2006 07:51:52 +0000 (07:51 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 23 Mar 2006 07:51:52 +0000 (07:51 +0000)
IkiWiki/CGI.pm
ikiwiki

index 3ac984d309448596e3ef60e386a732602b2ff404..4a16856ec0314a8671179ee3bff163e2972651ce 100644 (file)
@@ -271,6 +271,8 @@ sub cgi_editpage ($$) { #{{{
        my $q=shift;
        my $session=shift;
 
+       loadindex();
+       
        eval q{use CGI::FormBuilder};
        my $form = CGI::FormBuilder->new(
                fields => [qw(do rcsinfo from page content comments)],
@@ -446,7 +448,6 @@ sub cgi_editpage ($$) { #{{{
                }
                else {
                        require IkiWiki::Render;
-                       loadindex();
                        refresh();
                        saveindex();
                }
diff --git a/ikiwiki b/ikiwiki
index 7f6480e0c7438b561c644872e685c29477aea1d7..79b7eff90d1744dcbf356eb5cbda1389f7707faf 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -424,26 +424,31 @@ sub globlist_match ($$) { #{{{
        return 0;
 } #}}}
 
-# main {{{
-if ($config{setup}) {
-       require IkiWiki::Setup;
-       setup();
-}
-lockwiki();
-if ($config{wrapper}) {
-       require IkiWiki::Wrapper;
-       gen_wrapper();
-       exit;
-}
-loadindex() unless $config{rebuild};
-if ($config{cgi}) {
-       require IkiWiki::CGI;
-       cgi();
-}
-else {
-       require IkiWiki::Render;
-       rcs_update();
-       refresh();
-       saveindex();
-}
-#}}}
+sub main () { #{{{
+       if ($config{setup}) {
+               require IkiWiki::Setup;
+               setup();
+       }
+       
+       lockwiki();
+       
+       if ($config{wrapper}) {
+               require IkiWiki::Wrapper;
+               gen_wrapper();
+               exit;
+       }
+       
+       if ($config{cgi}) {
+               require IkiWiki::CGI;
+               cgi();
+       }
+       else {
+               loadindex() unless $config{rebuild};
+               require IkiWiki::Render;
+               rcs_update();
+               refresh();
+               saveindex();
+       }
+} #}}}
+
+main;