[pmwiki-users] Completely clean URLs (Was: Get rid of groups altogether?)

Waylan Limberg waylan at gmail.com
Wed Oct 26 15:02:04 CDT 2005


On 10/26/05, Michael Widowitz <michael at widowitz.com> wrote:
> Hello group,
> maybe in the previous message the subject was a bit confusing. Therefore
> I repost the question:
>
> Is it possible - under the assumption that one can accept having only a
> single group - to have totally clean URLs as in
>
> http://mysite.com/HomePage
>
> instead of having the group name in between
> (http://mysite.com/Main/HomePage) ?
>
> I'd also be happy about a definite "no"... :-)
>
> Thanks,
> Mike
>
Yeah, that does clear up what you are asking and to my knowledge the
answer is currently  no. Here's why: There seems to be no easy way to
alter the format PmWiki uses when it generates links to PmWiki pages.
Personally I find this the most annoying thing about the package, but
have found a few workarounds. Unfortunately those do not work in your
case. It would be easy to make PmWiki assume the group for requests
when only one group is used, but it still can't create the links
right. Say you want to create a link to your HomePage from another
page on your wiki. Notice what happens in each of these cases:

HomePage    --->   http://example.com/Main/HomePage
[[HomePage]]    --->   http://example.com/Main/HomePage
[[/HomePage]]    --->   http://example.com/Main/HomePage
[[http://example.com/HomePage | HomePage]]    --->   http://example.com/HomePage

The last one almost works, although not nearly as easy to use or
pretty. But, upon following the link, the browser is redirected to
http://example.com/Main/HomePage. In other words, that is the URL
displayed in the browsers address bar and what gets bookmarked. So we
don't actually get rid of the group in the URL.

As a side point. You can point to a group without a page [[Main]], and
PmWiki will give you the default page, but again, both the group and
page names are always displayed by PmWiki. I contend that this is
unnecessary. If PmWiki can understand the request without the extra
stuff, then allow the URL's to be generated that way and don't
redirect (or at least allow the redirection to be turned off by the
admin). Unfortunately, it seems that the code is built into the core
and is not so easy to override.


> >
> > Is there a way (cookbook?) to achieve such URLs?
> >

Not that I've seen, although I wouldn't mind writing one if I had the
time (I don't) and the URL generation was all in one easy to find
place (it isn't). I imagine something along the lines of the various
MVC frameworks that have recently become available. A familiar example
may be Ruby on Rails 'Routes'. Here's links to a few different
projects in different languages:

RoR: http://manuals.rubyonrails.com/read/chapter/65
Python Routes (basicly a Rails clone):  http://routes.groovie.org/trac/
Django (also Python with powerful regex - the most flexible, but
probably overkill):
http://www.djangoproject.com/documentation/url_dispatch/
CakePHP: http://wiki.cakephp.org/tutorials_routes

I'd love to have something like this in PmWiki. Of course, the CakePHP
example would be the easiest to copy, as it's already in PHP, but it
will take some changes to the core to make it happen.

--
----
Waylan Limberg
waylan at gmail.com




More information about the pmwiki-users mailing list