]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Merge commit 'intrigeri/po'
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 28 Aug 2009 23:48:32 +0000 (19:48 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 28 Aug 2009 23:48:32 +0000 (19:48 -0400)
IkiWiki.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/po.pm
IkiWiki/Render.pm
debian/changelog
doc/plugins/po.mdwn
doc/sandbox.mdwn
doc/todo/Restrict_page_viewing.mdwn [new file with mode: 0644]
doc/todo/optimize_simple_dependencies.mdwn
doc/users/emptty.mdwn [new file with mode: 0644]
po/underlay.setup

index 5563a03af7d028a88c184d8f2ac227284c475f52..b8e89b73fb00db7df6d019d07895376b0932cd8f 100644 (file)
@@ -13,8 +13,8 @@ use open qw{:utf8 :std};
 
 use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
            %pagestate %wikistate %renderedfiles %oldrenderedfiles
-           %pagesources %destsources %depends %hooks %forcerebuild
-           %loaded_plugins};
+           %pagesources %destsources %depends %depends_simple %hooks
+           %forcerebuild %loaded_plugins};
 
 use Exporter q{import};
 our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
@@ -1475,7 +1475,8 @@ sub loadindex () {
        %oldrenderedfiles=%pagectime=();
        if (! $config{rebuild}) {
                %pagesources=%pagemtime=%oldlinks=%links=%depends=
-               %destsources=%renderedfiles=%pagecase=%pagestate=();
+               %destsources=%renderedfiles=%pagecase=%pagestate=
+               %depends_simple=();
        }
        my $in;
        if (! open ($in, "<", "$config{wikistatedir}/indexdb")) {
@@ -1515,6 +1516,11 @@ sub loadindex () {
                                $links{$page}=$d->{links};
                                $oldlinks{$page}=[@{$d->{links}}];
                        }
+                       if (exists $d->{depends_simple}) {
+                               $depends_simple{$page}={
+                                       map { $_ => 1 } @{$d->{depends_simple}}
+                               };
+                       }
                        if (exists $d->{dependslist}) {
                                $depends{$page}={
                                        map { $_ => 1 } @{$d->{dependslist}}
@@ -1570,6 +1576,10 @@ sub saveindex () {
                        $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
                }
 
+               if (exists $depends_simple{$page}) {
+                       $index{page}{$src}{depends_simple} = [ keys %{$depends_simple{$page}} ];
+               }
+
                if (exists $pagestate{$page}) {
                        foreach my $id (@hookids) {
                                foreach my $key (keys %{$pagestate{$page}{$id}}) {
@@ -1738,6 +1748,13 @@ sub add_depends ($$) {
        my $page=shift;
        my $pagespec=shift;
 
+       if ($pagespec =~ /$config{wiki_file_regexp}/ &&
+               $pagespec !~ /[\s*?()!]/) {
+               # a simple dependency, which can be matched by string eq
+               $depends_simple{$page}{lc $pagespec} = 1;
+               return 1;
+       }
+
        return unless pagespec_valid($pagespec);
 
        $depends{$page}{$pagespec} = 1;
index c9cbb9cb7112f2384a1f5e30016ae592009f571c..ccfadfd699929a8be1764546118d89ee9f958f56 100644 (file)
@@ -195,10 +195,10 @@ sub preprocess_inline (@) {
 
                @list = map { bestlink($params{page}, $_) }
                        split ' ', $params{pagenames};
-
-               $params{pages} = join(" or ", @list);
        }
        else {
+               add_depends($params{page}, $params{pages});
+
                @list = pagespec_match_list(
                        [ grep { $_ ne $params{page} } keys %pagesources ],
                        $params{pages}, location => $params{page});
@@ -247,7 +247,6 @@ sub preprocess_inline (@) {
                @list=@list[0..$params{show} - 1];
        }
 
-       add_depends($params{page}, $params{pages});
        # Explicitly add all currently displayed pages as dependencies, so
        # that if they are removed or otherwise changed, the inline will be
        # sure to be updated.
index 21e3b8e3766bfc0cb42c9317d08b7212f4147607..792d84261855ccd074421717207d0276cadc1928 100644 (file)
@@ -154,8 +154,10 @@ sub checkconfig () {
                $config{po_link_to}='default';
        }
        unless ($config{po_link_to} eq 'default') {
-               $origsubs{'bestlink'}=\&IkiWiki::bestlink;
-               inject(name => "IkiWiki::bestlink", call => \&mybestlink);
+               if (! exists $origsubs{'bestlink'}) {
+                       $origsubs{'bestlink'}=\&IkiWiki::bestlink;
+                       inject(name => "IkiWiki::bestlink", call => \&mybestlink);
+               }
        }
 
        push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
index da2d7b4ccc1adc480c2acc20f6b5d167a8fc7ff2..246c2260d7748e9fe2b3522d73035564e0fb6754 100644 (file)
@@ -210,6 +210,7 @@ sub render ($) {
        if (defined $type) {
                my $page=pagename($file);
                delete $depends{$page};
+               delete $depends_simple{$page};
                will_render($page, htmlpage($page), 1);
                return if $type=~/^_/;
                
@@ -224,6 +225,7 @@ sub render ($) {
        }
        else {
                delete $depends{$file};
+               delete $depends_simple{$file};
                will_render($file, $file, 1);
                
                if ($config{hardlink}) {
@@ -431,6 +433,7 @@ sub refresh () {
                # internal pages are not rendered
                my $page=pagename($file);
                delete $depends{$page};
+               delete $depends_simple{$page};
                foreach my $old (@{$renderedfiles{$page}}) {
                        delete $destsources{$old};
                }
@@ -454,12 +457,25 @@ sub refresh () {
        if (%rendered || @del || @internal) {
                my @changed=(keys %rendered, @del);
 
+               my %lcchanged = map { lc(pagename($_)) => 1 } @changed;
                # rebuild dependant pages
-               F: foreach my $f (@$files) {
+               foreach my $f (@$files) {
                        next if $rendered{$f};
                        my $p=pagename($f);
-                       if (exists $depends{$p}) {
-                               foreach my $d (keys %{$depends{$p}}) {
+                       my $reason = undef;
+
+                       if (exists $depends_simple{$p}) {
+                               foreach my $d (keys %{$depends_simple{$p}}) {
+                                       if (exists $lcchanged{$d}) {
+                                               $reason = $d;
+                                               last;
+                                       }
+                               }
+                       }
+
+                       if (exists $depends{$p} && ! defined $reason) {
+                               D: foreach my $d (keys %{$depends{$p}}) {
                                        my $sub=pagespec_translate($d);
                                        next if $@ || ! defined $sub;
 
@@ -470,14 +486,18 @@ sub refresh () {
                                                next if $file eq $f;
                                                my $page=pagename($file);
                                                if ($sub->($page, location => $p)) {
-                                                       debug(sprintf(gettext("building %s, which depends on %s"), $f, $page));
-                                                       render($f);
-                                                       $rendered{$f}=1;
-                                                       next F;
+                                                       $reason = $page;
+                                                       last D;
                                                }
                                        }
                                }
                        }
+
+                       if (defined $reason) {
+                               debug(sprintf(gettext("building %s, which depends on %s"), $f, $reason));
+                               render($f);
+                               $rendered{$f}=1;
+                       }
                }
                
                # handle backlinks; if a page has added/removed links,
index d10bc36cfdd2743f47084622f2652d5fabf9f5a2..870abfdd575125c8559fba415de27ab5eebb1248 100644 (file)
@@ -28,6 +28,8 @@ ikiwiki (3.1415926) UNRELEASED; urgency=low
     slower. (smcv)
   * Rebuild wikis on upgrade to this version to fix bloat caused
     by the dependency bug.
+  * Further optimisation of dependency handling by adding a special
+    case for simple page dependencies. (smcv)
   * htmltidy: Return an error message if tidy fails. Closes: #543722
   * po: Fix name of translated toplevel index page. (intrigeri)
   * po: Fix display of links from a translated page to itself (ntrigeri)
index 39b237c73b6a48a98c479bb6a5e65c08ee94b6b3..4fecaeb53b3e06406a18aad40f261012c88a03c7 100644 (file)
@@ -343,6 +343,21 @@ as translation pages are not supposed to have subpages. My po branch
 has code (e671e72053e81fa, which depends on 72ac9821e56637) that fixes
 this. --[[intrigeri]]
 
+link() pagespec on translation pages
+------------------------------------
+
+The `link()` pagespec, on translation pages, currently tests whether
+a given page links to the *current translation page*, rather than
+whether it links to its master page. I believe the later is generally
+expected. Commit 646c9a4c95a480 in my po branch fixes this.
+--[[intrigeri]]
+
+2 test suite failures
+--------------------
+
+t/po is currently failing tests 57 and 59 (and I would like to release
+soon..) --[[Joey]] 
+
 Documentation
 -------------
 
index 6ea8cc60794e9fdc713e53ae79cd8b286906f84b..96b880b348d2c680925f9e1e8bb0d859aee43f73 100644 (file)
@@ -171,3 +171,13 @@ testing
 [[!toc  levels=2]]
 
 [[Mamma Mia]]
+
+----
+
+[[!format  c """
+void main () {
+    printf("hello, world!");
+}
+"""]]
+
+
diff --git a/doc/todo/Restrict_page_viewing.mdwn b/doc/todo/Restrict_page_viewing.mdwn
new file mode 100644 (file)
index 0000000..ec7b05a
--- /dev/null
@@ -0,0 +1,15 @@
+I'd like to have some pages of my wiki to be only viewable by some users.
+
+I could use htaccess for that, but it would force the users to have 2 authentication mecanisms, so I'd prefer to use openID for that too.
+
+* I'm thinking of adding a "show" parameter to the cgi script, thanks to a plugin similar to goto.
+* When called, it would check the credential using the session stuff (that I don't understand yet). If not enough, it would serve a 403 error of course.
+* If enough, it would read the file locally on the server side and return this as a content.
+
+Then, I'd have to generate the private page the regular way with ikiwiki, and prevent apache from serving them with an appropriate and much more maintainable htaccess file.
+
+-- [[users/emptty]]
+
+> While I'm sure a plugin could do this, it adds so much scalability cost
+> and is so counter to ikiwiki's design.. Have you considered using the
+> [[plugins/httpauth]] plugin to unify around htaccess auth? --[[Joey]] 
index 44163311b6206e8dc3a552ff72dd798cd119272a..91e184c292309154db69fef6379a42c2b671aa0f 100644 (file)
@@ -47,6 +47,10 @@ equally valid.)
 
 --[[smcv]]
 
+> Now [[merged|done]] --[[smcv]]
+
+----
+
 > We discussed this on irc; I had some worries that things may have been
 > switched to `add_depends_exact` that were not pure page names. My current
 > feeling is it's all safe, but who knows. It's easy to miss something.
@@ -56,13 +60,38 @@ equally valid.)
 > that is clearly a raw page name, it can add it to the exact depends hash.
 > Else, add it to the pagespec hash. You can tell if it's a pure page name
 > by matching on `$config{wiki_file_regexp}`.
-> 
+
+>> Good thinking. Done in commit 68ce514a 'Auto-detect "simple dependencies"',
+>> with a related bugfix in e8b43825 "Force %depends_exact to lower case".
+>>
+>> Performance impact: Test 2 above takes 0.2s longer to rebuild (probably
+>> from all the calls to lc, which are, however, necessary for correctness)
+>> and has indistinguishable performance for a refresh.
+>>
+>> Test 1 took about 6 minutes to rebuild and 1:25 to refresh; those are
+>> pessimistic figures, since I've added 90 more photos and 90 more pages
+>> (both to the wiki as a whole, and the number touched before refreshing)
+>> since testing the previous version of this branch. --[[smcv]]
+
 > Also I think there may be little optimisation value left in
 > 7227c2debfeef94b35f7d81f42900aa01820caa3, since the "regular" dependency
 > lists will be much shorter.
->
+
+>> You're probably right, but IMO it's not worth reverting it - a set (hash with
+>> dummy values) is still the right data structure. --[[smcv]]
+
 > Sounds like inline pagenames has an already exstant bug WRT
 > pages moving, which this should not make worse. Would be good to verify.
-> 
+
+>> If you mean the standard "add a better match for a link-like construct" bug
+>> that also affects sidebar, then yes, it does have the bug, but I'm pretty
+>> sure this branch doesn't make it any worse. I could solve this at the cost
+>> of making pagenames less useful for interactive use, by making it not
+>> respect [[ikiwiki/subpage/LinkingRules]], but instead always interpret
+>> its paths as relative to the top of the wiki - that's actually all that
+>> [[plugins/contrib/album]] needs. --[[smcv]]
+
 > Re coding, it would be nice if `refresh()` could avoid duplicating
-> the debug message, etc in the two cases. --[[Joey]] 
+> the debug message, etc in the two cases. --[[Joey]]
+
+>> Fixed in commit f805d566 "Avoid duplicating debug message..." --[[smcv]]
diff --git a/doc/users/emptty.mdwn b/doc/users/emptty.mdwn
new file mode 100644 (file)
index 0000000..08ef7d0
--- /dev/null
@@ -0,0 +1,2 @@
+My professional homepage is [here](http://www.loria.fr/~quinson/). I'm currently (09/09) trying to move it from WML to ikiwiki.
+I'm sure I'll have a bunch of ideas, requests and maybe even patches in the process.
index 76df2e29c2fed53f15fa9a7a33112acf133f02f5..237acef5d3a11c7e4b4c0fc96d7c62080b5b7094 100644 (file)
@@ -11,7 +11,7 @@ use IkiWiki::Setup::Standard {
                #'es' => 'Español',
                #'de' => 'Deutsch',
                'da' => 'Dansk',
-               'cs' =" 'česky',
+               'cs' => 'česky',
         },
        po_master_language => { 'code' => 'en', 'name' => 'English' },
        po_translatable_pages => "*",