[pmwiki-devel] New beta Hg with clean urls...

The Editor editor at fast.st
Sun Feb 4 23:10:06 CST 2007


On 2/4/07, The Editor <editor at fast.st> wrote:
> I've been doing a lot of tinkering with Hg to get it to accommodate a
> look like cleanurls, and have a beta upgrade available if others wish
> to help debug. Hg1.1.phpΔ.
>
> This allows you to type in a url like:
>
> http://.../index.php?n=Kingdom/Animal/Canine/Dog
>
> and it will automatically load Kingdom-Animal-Canine.Dog The last part
> is always the page name, with or without a trailing slash. You should
> be able to get rid of index.php?n= by url rewriting.
>
> Also, if you enter a link like [[Kingdom-Animal-Canine.Dog|My Pet]]
> and you click it, n=Kingdom/Animal/Canine/Dog will appear in your
> browser! At some point I'll make this feature optional, but it's not
> so in the beta as I'm still testing...

It's optional now.  Default is set to true, unless I hear of problems
somewhere. To disable set $hgcleanurls to false...  As for typing a
link into a browser, either one will work whether hgcleanurls are
enabled or not.

> I also added an optional $hglinkprefix you can use to keep users in
> some subgroup by automatically prefixing their links with some value.
> Very useful! Can be overwritten by beginning your link with a ".".
>
> Ex: If on page [[Main-Test-One.Hi]] and you set this value to
> "Main-Test" then links like [[Two.Bye]] will automatically be
> converted to Main-Test-Two.Bye. Whereas [[.Two.Bye]] will become
> Two.Bye. Also if a . is prefixed, and there is no hglinkprefix set,
> the dot is ignored--which is useful for things like sidebars,
> pagelists, or included pages.

Had a terribly tough time getting this to work, but think I came up
with a slightly different approach.  If you set a prefix, and then
define your link to begin with a : such as in [[:Group.Name]] or
[[:Name]] from anywhere down the hierarchy, it will make it relative
to the prefix group.  Works nice.

To get users to do this, I thought I'd like to set up a ROS pattern
that changes
[[(.?*)]] into [[:$1]].  It should not add an extra : if one is
already there of course.  Can someone explain exactly how to do this?

> Finally, I set up a system for setting default home pages for groups,
> by resetting the link value when the group and name are identical to
> group.Home (configurable with $hghomepage). Of course it causes a bit
> of a problem when you want Test.Test, but it does come in hand when
> you want to go to the home page in some long chain group that doesn't
> exist and you want to just type [[{$Group}.]].

I notice that in some cases ([[Test.Test]]) the displayed url and the
link url don't match (Test.Test vs Test.Homepage)...  (Can't figure
out how to change the LinkTxt).  For me, rarely leave full page names
out there, so it's ok... And in the other hand it makes
[[{$Group}/{$Group}]] into a nicely displayed link to the Homepage of
the group.  Still learning the curious ins and outs of this thing.

Cheers,
Dan


More information about the pmwiki-devel mailing list