Print a debug message if a page has multiple source files.
authorJoey Hess <joey@kodama.kitenet.net>
Tue, 23 Sep 2008 17:32:41 +0000 (13:32 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Tue, 23 Sep 2008 17:32:41 +0000 (13:32 -0400)
IkiWiki/Render.pm
debian/changelog
doc/bugs/multiple_pages_with_same_name.mdwn

index 752d17643b1a18198481f0fc740f843fcd87925c..ceb7c842cb309b0154fcdefe98aea376f6917b33 100644 (file)
@@ -279,7 +279,11 @@ sub refresh () { #{{{
                                else {
                                        $f=~s/^\Q$config{srcdir}\E\/?//;
                                        push @files, $f;
                                else {
                                        $f=~s/^\Q$config{srcdir}\E\/?//;
                                        push @files, $f;
-                                       $exists{pagename($f)}=1;
+                                       my $pagename = pagename($f);
+                                       if ($exists{$pagename}) {
+                                               debug(sprintf(gettext("%s has multiple possible source pages"), $pagename));
+                                       }
+                                       $exists{$pagename}=1;
                                }
                        }
                },
                                }
                        }
                },
index d67fb73ce0aee3edd39d9ea36cc6ef7e715db1f2..5f7cc1be233ad8fb6713d4dfb46b0b7c9d2e0840 100644 (file)
@@ -16,6 +16,7 @@ ikiwiki (2.65) UNRELEASED; urgency=low
   * edittemplate: Link to template, to allow creating it. (Willu)
   * editpage: Add a missing check that the page name contains only legal
     characters, in addition to the existing check for pruned filenames.
   * edittemplate: Link to template, to allow creating it. (Willu)
   * editpage: Add a missing check that the page name contains only legal
     characters, in addition to the existing check for pruned filenames.
+  * Print a debug message if a page has multiple source files.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 17 Sep 2008 14:26:56 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Wed, 17 Sep 2008 14:26:56 -0400
 
index 26269c9ce9227041238b122d272256ded9f4aaa3..548954f8f94f9977fe2a40afdbf3511fe89ad069 100644 (file)
@@ -4,6 +4,10 @@ I realised that this is going to have problems when you ask it to process `.c` a
 
 I tested it briefly with `test.java` and `test.mdwn` just to see what would happen.  Things got quite strange.  The source-highlighting plugin was called (probably for the java file), but then when it calls `pagetype($pagesources{$page})` to figure out the file type, that function returns `mdwn`, which confuses things somewhat.
 
 
 I tested it briefly with `test.java` and `test.mdwn` just to see what would happen.  Things got quite strange.  The source-highlighting plugin was called (probably for the java file), but then when it calls `pagetype($pagesources{$page})` to figure out the file type, that function returns `mdwn`, which confuses things somewhat.
 
+> This is a known possible point of confusion. If there are multiple source
+> files, it will render them both, in an arbitrary sequence, so one "wins".
+> --[[Joey]]
+
 Anyway, I'm thinking about possible solutions.  The best option I've come up with so far is: when registering an htmlize hook, add a new optional paramter 'keep_extension'.  This would make a source file of `hello.c` generate a page with name `hello.c` rather than the current `hello`.  This would keep the pages unique (until someone makes `hello.c.mdwn`...).
 
 Suggestions welcome.
 Anyway, I'm thinking about possible solutions.  The best option I've come up with so far is: when registering an htmlize hook, add a new optional paramter 'keep_extension'.  This would make a source file of `hello.c` generate a page with name `hello.c` rather than the current `hello`.  This would keep the pages unique (until someone makes `hello.c.mdwn`...).
 
 Suggestions welcome.
@@ -12,6 +16,11 @@ Suggestions welcome.
 
 > Ok, this turned out not to be a hard change.  [[patch]] is below.  With this patch you can tell IkiWiki not to drop the suffix when you register a hook: `hook(type => "htmlize", id => $lang, call => \&htmlize, leavesuffix => 1);`
 
 
 > Ok, this turned out not to be a hard change.  [[patch]] is below.  With this patch you can tell IkiWiki not to drop the suffix when you register a hook: `hook(type => "htmlize", id => $lang, call => \&htmlize, leavesuffix => 1);`
 
+>> I think that's a good solution to the problem that most syntax plugins
+>> have struggled with. It makes sense. It doesn't solve the case where
+>> you have source files without any extension (eg `Makefile`), but at
+>> least it covers the common cases.
+
     diff --git a/IkiWiki.pm b/IkiWiki.pm
     index 4e4da11..853f905 100644
     --- a/IkiWiki.pm
     diff --git a/IkiWiki.pm b/IkiWiki.pm
     index 4e4da11..853f905 100644
     --- a/IkiWiki.pm