]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/patchqueue/index.html_allowed.mdwn
minor
[ikiwiki.git] / doc / patchqueue / index.html_allowed.mdwn
index dc527bbc4b1854c5d70b7863bfa6595a1a5901f4..f8bf15ac464bc22b20436d7d7afff40e8c4be18b 100644 (file)
-Instead of having files foo.html "in front of" foo/, I prefer to have foo/index.html. This patch allows that. Specifically, foo/index.type is translated to $links{'foo/'}, and bestlink looks for either "foo" or "foo/" when linking to pages. There are other miscellaneous changes that go with that -- parentlinks for "foo/" are the same as for "foo", except one directory higher; basename of "foo/" is "foo"; links to "foo/" are translated to "foo/index.html" rather than "foo/.html". (Links to "foo/" might be preferred, but that causes an infinite loop in writefile, because apparently dirname("foo/") == "foo/" on my system for reasons that aren't clear to me.)
-
-    diff -ur -x .svn ikiwiki-orig/IkiWiki/Render.pm ikiwiki/IkiWiki/Render.pm
-    --- ikiwiki-orig/IkiWiki/Render.pm  2006-11-08 01:02:33.000000000 -0500
-    +++ ikiwiki/IkiWiki/Render.pm       2006-11-08 01:02:46.000000000 -0500
-    @@ -57,6 +57,10 @@
-        my $path="";
-        my $skip=1;
-        return if $page eq 'index'; # toplevel
-    +   if ($page =~ m{/$}){
-    +           $page =~s{/$}{};
-    +           $path="..";
-    +   }
-        foreach my $dir (reverse split("/", $page)) {
-                if (! $skip) {
-                        $path.="../";
-    diff -ur -x .svn ikiwiki-orig/IkiWiki.pm ikiwiki/IkiWiki.pm
-    --- ikiwiki-orig/IkiWiki.pm 2006-11-08 01:02:38.000000000 -0500
-    +++ ikiwiki/IkiWiki.pm      2006-11-08 01:02:48.000000000 -0500
-    @@ -174,6 +174,7 @@
-     sub basename ($) { #{{{
-        my $file=shift;
+This page used to be used for two patches, one of which is applied
+providing the usedirs option for output. The remaining patch, discussed
+below, concerns wanting to use foo/index.mdwn source files and get an
+output page name of foo, rather than foo/index. --[[Joey]]
 
-    +   $file=~s!/$!!;
-        $file=~s!.*/+!!;
-        return $file;
-     } #}}}
-    @@ -200,12 +201,14 @@
-        my $type=pagetype($file);
-        my $page=$file;
-        $page=~s/\Q.$type\E*$// if defined $type;
-    +   $page=~s#index$## if $page=~m{/index$};
-        return $page;
-     } #}}}
+---
+
+I independently implemented a similar, but smaller patch.
+(It's smaller because I only care about rendering; not CGI, for example.)
+The key to this patch is that "A/B/C" is treated as equivalent
+to "A/B/C/index".
+Here it is:  --Per Bothner
+
+    --- IkiWiki/Render.pm~  2007-01-11 15:01:51.000000000 -0800
+    +++ IkiWiki/Render.pm   2007-02-02 22:24:12.000000000 -0800
+    @@ -60,9 +60,9 @@
+            foreach my $dir (reverse split("/", $page)) {
+                    if (! $skip) {
+                            $path.="../";
+    -                       unshift @ret, { url => $path.htmlpage($dir), page => pagetitle($dir) };
+    +                       unshift @ret, { url => abs2rel(htmlpage(bestlink($page, $dir)), dirname($page)), page => pagetitle($dir) };
+                    }
+    -               else {
+    +               elsif ($dir ne "index") {
+                            $skip=0;
+                    }
+            }
+
+    --- IkiWiki.pm~ 2007-01-12 12:47:09.000000000 -0800
+    +++ IkiWiki.pm  2007-02-02 18:02:16.000000000 -0800
+    @@ -315,6 +315,12 @@
+                    elsif (exists $pagecase{lc $l}) {
+                            return $pagecase{lc $l};
+                     }
+    +               else {
+    +                   my $lindex = $l . "/index";
+    +                   if (exists $links{$lindex}) {
+    +                       return $lindex;
+    +               }
+    +               }
+             } while $cwd=~s!/?[^/]+$!!;
+     
+            if (length $config{userdir} && exists $links{"$config{userdir}/".lc($link)}) {
 
-     sub htmlpage ($) { #{{{
-        my $page=shift;
+Note I handle setting the url; slightly differently.
+Also note that an initial "index" is ignored.  I.e. a
+page "A/B/index.html" is treated as "A/B".
 
-    +   return $page."index.html" if $page=~m{/$};
-        return $page.".html";
+> Actually, your patch is shorter because it's more elegant and better :)
+> I'm withdrawing my old patch, because yours is much more in line with
+> ikiwiki's design and architecture.
+> I would like to make one suggestion to your patch, which is:
+
+    diff -urX ignorepats clean-ikidev/IkiWiki/Plugin/inline.pm ikidev/IkiWiki/Plugin/inline.pm
+    --- clean-ikidev/IkiWiki/Plugin/inline.pm   2007-02-25 12:26:54.099113000 -0800
+    +++ ikidev/IkiWiki/Plugin/inline.pm 2007-02-25 14:55:21.163340000 -0800
+    @@ -154,7 +154,7 @@
+                        $link=htmlpage($link) if defined $type;
+                        $link=abs2rel($link, dirname($params{destpage}));
+                        $template->param(pageurl => $link);
+    -                   $template->param(title => pagetitle(basename($page)));
+    +                   $template->param(title => titlename($page));
+                        $template->param(ctime => displaytime($pagectime{$page}));
+
+                        if ($actions) {
+    @@ -318,7 +318,7 @@
+                my $pcontent = absolute_urls(get_inline_content($p, $page), $url);
+
+                $itemtemplate->param(
+    -                   title => pagetitle(basename($p), 1),
+    +                   title => titlename($p, 1),
+                        url => $u,
+                        permalink => $u,
+                        date_822 => date_822($pagectime{$p}),
+    diff -urX ignorepats clean-ikidev/IkiWiki/Render.pm ikidev/IkiWiki/Render.pm
+    --- clean-ikidev/IkiWiki/Render.pm  2007-02-25 12:26:54.745833000 -0800
+    +++ ikidev/IkiWiki/Render.pm        2007-02-25 14:54:01.564715000 -0800
+    @@ -110,7 +110,7 @@
+        $template->param(
+                title => $page eq 'index'
+                        ? $config{wikiname}
+    -                   : pagetitle(basename($page)),
+    +                   : titlename($page),
+                wikiname => $config{wikiname},
+                parentlinks => [parentlinks($page)],
+                content => $content,
+    diff -urX ignorepats clean-ikidev/IkiWiki.pm ikidev/IkiWiki.pm
+    --- clean-ikidev/IkiWiki.pm 2007-02-25 12:26:58.812850000 -0800
+    +++ ikidev/IkiWiki.pm       2007-02-25 15:05:22.328852000 -0800
+    @@ -192,6 +192,12 @@
+        return $untainted;
      } #}}}
 
-    @@ -289,6 +292,7 @@
-        my $page=shift;
-        my $link=shift;
-
-    +   $page =~ s!/$!!;
-        my $cwd=$page;
-        do {
-                my $l=$cwd;
-    @@ -298,6 +302,9 @@
-                if (exists $links{$l}) {
-                        return $l;
-                }
-    +           if (exists $links{$l.'/'}){
-    +                   return $l.'/';
-    +           }
-                elsif (exists $pagecase{lc $l}) {
-                        return $pagecase{lc $l};
-                }
+    +sub titlename($;@) { #{{{
+    +   my $page = shift;
+    +   $page =~ s!/index$!!;
+    +   return pagetitle(basename($page), @_);
+    +} #}}}
+    +
+     sub basename ($) { #{{{
+        my $file=shift;
+
 
+> This way foo/index gets "foo" as its title, not "index". --Ethan