]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
support arbitrary characters in page titles, via some ugly use of unicode
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 23 Mar 2006 19:25:08 +0000 (19:25 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 23 Mar 2006 19:25:08 +0000 (19:25 +0000)
character numbers

IkiWiki/Render.pm
doc/todo.mdwn
doc/wikilink.mdwn
ikiwiki

index 98c86bac8b5d4d87b76de9252e1955f8dff4fd80..df24fd5680ab13a3bc74f3a35bd979bfd93553ba 100644 (file)
@@ -84,8 +84,7 @@ sub finalize ($$$) { #{{{
        my $page=shift;
        my $mtime=shift;
 
        my $page=shift;
        my $mtime=shift;
 
-       my $title=basename($page);
-       $title=~s/_/ /g;
+       my $title=pagetitle(basename($page));
        
        my $template=HTML::Template->new(blind_cache => 1,
                filename => "$config{templatedir}/page.tmpl");
        
        my $template=HTML::Template->new(blind_cache => 1,
                filename => "$config{templatedir}/page.tmpl");
index 7926fd95417c979939f2a011beae24f3bf87bb2a..f01753e33d8d8a3ba62fc2a79b81433bcce65645 100644 (file)
@@ -100,15 +100,10 @@ Requirements:
 * Need to keep track of the globlists in the index file.
    - Probably need to redesign the index file format to allow for this sort
      of future expansion.
 * Need to keep track of the globlists in the index file.
    - Probably need to redesign the index file format to allow for this sort
      of future expansion.
-* Need to make _ render as " " in page titles.
-* Also need to support as much other punctuation as possible in page
-  titles, ideally all of it. Punctuation that is illegal in filenames for
-  various good reasons should be embedded encoded in the filenames. Blogs
-  tend to have more punctuation-intensive page titles than wikis.
 * Need to pick a good token and note that the token will need to be passed
   multiple parameters. Possibly something like this:
 
 * Need to pick a good token and note that the token will need to be passed
   multiple parameters. Possibly something like this:
 
-       [[rss pages="myblog/*" show="30"]]
+       [[embed pages="myblog/*" show="30"]]
 
 ## revisit case
 
 
 ## revisit case
 
index ac0ec9d564d84ba0e4688f9ff2fd54cdf351b202..1da5fb64d842fc46e25432a252fcdbefa4655c6e 100644 (file)
@@ -11,5 +11,15 @@ play when linking between [[SubPage]]s.
 WikiLinks can be entered in any case you like, the page they link to is
 always lowercased.
 
 WikiLinks can be entered in any case you like, the page they link to is
 always lowercased.
 
+While a WikiLink is limited to alphanumerics and only a few special
+charaters, it is possible to create page names containing other characters:
+
+* To display a page name with a space in it, use "_" in the WikiLink, for
+  example, [[Multi_Word_Page_Name]]. 
+* For any other special character, you can use "__nnnn__" where `nnnn` is the
+  unicode character number. For example,
+  [[This_page_name_is__44___uselessly__44___a_complete_sentence__46__]]
+  Limiting use of this to when you really need it is a good idea.
+
 Note that if the file linked to by a WikiLink looks like an image, it will
 be displayed inline on the page.
 Note that if the file linked to by a WikiLink looks like an image, it will
 be displayed inline on the page.
diff --git a/ikiwiki b/ikiwiki
index 936b0a1733cbf7decac4ac22066f3aa02e0069e8..3540f86675c9d449f41a09b3075b7c17012fd43d 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -19,7 +19,7 @@ sub getconfig () { #{{{
                %config=(
                        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
                        wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
                %config=(
                        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
                        wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
-                       wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
+                       wiki_file_regexp => qr/(^[-A-Za-z0-9_.\&;:\/+]+$)/,
                        verbose => 0,
                        wikiname => "wiki",
                        default_pageext => ".mdwn",
                        verbose => 0,
                        wikiname => "wiki",
                        default_pageext => ".mdwn",
@@ -92,11 +92,11 @@ sub checkconfig () { #{{{
                unless exists $config{wikistatedir};
        
        if ($config{svn}) {
                unless exists $config{wikistatedir};
        
        if ($config{svn}) {
-               require IkiWiki::RCS::SVN;
+               require IkiWiki::Rcs::SVN;
                $config{rcs}=1;
        }
        else {
                $config{rcs}=1;
        }
        else {
-               require IkiWiki::RCS::Stub;
+               require IkiWiki::Rcs::Stub;
                $config{rcs}=0;
        }
 } #}}}
                $config{rcs}=0;
        }
 } #}}}
@@ -234,6 +234,13 @@ sub isinlinableimage ($) { #{{{
        $file=~/\.(png|gif|jpg|jpeg)$/;
 } #}}}
 
        $file=~/\.(png|gif|jpg|jpeg)$/;
 } #}}}
 
+sub pagetitle ($) { #{{{
+       my $page=shift;
+       $page=~s/__(\d+)__/&#$1;/g;
+       $page=~y/_/ /;
+       return $page;
+} #}}}
+
 sub htmllink ($$;$$) { #{{{
        my $page=shift;
        my $link=shift;
 sub htmllink ($$;$$) { #{{{
        my $page=shift;
        my $link=shift;
@@ -248,7 +255,9 @@ sub htmllink ($$;$$) { #{{{
                $bestlink="$page/".lc($link);
        }
 
                $bestlink="$page/".lc($link);
        }
 
-       return $link if length $bestlink && $page eq $bestlink;
+       my $linktext=pagetitle($link);
+       
+       return $linktext if length $bestlink && $page eq $bestlink;
        
        # TODO BUG: %renderedfiles may not have it, if the linked to page
        # was also added and isn't yet rendered! Note that this bug is
        
        # TODO BUG: %renderedfiles may not have it, if the linked to page
        # was also added and isn't yet rendered! Note that this bug is
@@ -258,7 +267,7 @@ sub htmllink ($$;$$) { #{{{
                $bestlink=htmlpage($bestlink);
        }
        if (! grep { $_ eq $bestlink } values %renderedfiles) {
                $bestlink=htmlpage($bestlink);
        }
        if (! grep { $_ eq $bestlink } values %renderedfiles) {
-               return "<a href=\"$config{cgiurl}?do=create&page=$link&from=$page\">?</a>$link"
+               return "<a href=\"$config{cgiurl}?do=create&page=$link&from=$page\">?</a>$linktext"
        }
        
        $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
        }
        
        $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
@@ -266,7 +275,7 @@ sub htmllink ($$;$$) { #{{{
        if (! $noimageinline && isinlinableimage($bestlink)) {
                return "<img src=\"$bestlink\">";
        }
        if (! $noimageinline && isinlinableimage($bestlink)) {
                return "<img src=\"$bestlink\">";
        }
-       return "<a href=\"$bestlink\">$link</a>";
+       return "<a href=\"$bestlink\">$linktext</a>";
 } #}}}
 
 sub indexlink () { #{{{
 } #}}}
 
 sub indexlink () { #{{{