[pmwiki-users] How use lowercase in Group Names

Patrick R. Michaud pmichaud at pobox.com
Wed Sep 28 13:16:41 CDT 2005


On Wed, Sep 28, 2005 at 01:47:05PM -0400, Waylan Limberg wrote:
> > Although, come to think of it, for this we don't need case insensitivity
> > throughout the system -- only at the point where we're processing
> > url information.  We might be able to come up with a reasonably
> > fast method for converting a case-insensitive url into a case-sensitive
> > pagename.
> 
> 
> I've explored the possibilities here before as well, but gave up (ok,
> not really, just moved it to the very back burner) when I realized how
> intertwined the uppercase group and page names are in the core. If
> this could be done, that would be excellent. The problem as I saw it,
> was that much the url resolution code is before config.php is included
> so the work was already done before I had a chance to manipulate it
> with my own code, unless I altered the core somehow. Of course, if you
> built in the ability, my issues would (more) easily be solved.

The ability is built-in and always has been ... just because PmWiki
sets a value of $pagename prior to calling config.php doesn't
mean that you cannot do your own url resolution and set a different
value for $pagename at the top of config.php.  :-)

> Anyway, later I came across another project
> that used an interesting approach to the rewrite rules. They were in
> part as follows (modified for PmWiki):
> 
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ phwiki.php?n=$1 [QSA,L]

Very interesting -- I'll need to look at that a bit further!  Excellent
find, and thanks!

> whatever format you want, and generate the URLs in whatever format the
> admin wants (well, it would be nice if this was more configurable),
> but all requests should be case insensitive IMO.

Oh, I'd very much like to do that as well -- I just haven't found a good
way to do it on case-sensitive filesystems such as Unix.

Let me try to frame the overall problem a bit -- given a url 
such as .../pmwiki.php?n=main.homepage, PmWiki has to determine the
correct case of "main.homepage" so that it can be stored in $pagename.

On a case-insensitive filesystem this isn't too much of an issue,
because "main.homepage" and "Main.HomePage" will both be treated the
same when looking up the page file in wiki.d/ .  However, it's a
bit trickier in Unix, because AFAIK there's not a quick "case-insensitive
search".

One possibility is to convert all page filenames to lowercase when
saving pages to wiki.d, but this means that determining a page's true 
case requires a scan of the pagefile, as opposed to simply having
the directory entry as PmWiki does now.  While scanning the pagefiles
is probably okay for reading just a few pages, doing a scan of all
pagefiles for a (:pagelist:) or backlinks operation could get really
expensive.

At this point my suggestion would be to start with something like:

    if ($pagename && !PageExists($pagename)) {
      $l = ListPages("/^$pagename\$/i");
      if ($l) Redirect($l[0]);
    }

This basically says that if we have a pagename for a page that doesn't
exist, then search for a matching pagename using a case-insensitive match.
If we find one, then redirect to it.  (If there are multiple matches,
redirect to the first one found.)

I've now enabled this little hack for the test group on pmwiki.org,
for experimentation and testing.  Try, for example:

     http://www.pmwiki.org/wiki/test/geminithemes
     http://www.pmwiki.org/wiki/teST/markUP
     http://www.pmwiki.org/wiki/TeSt/WiKiStYLES
     http://www.pmwiki.org/wiki?n=test.recentchanges

If this or something close to it works out then I'll see
about adding it to the standard distribution somehow...

Pm




More information about the pmwiki-users mailing list