[#7197] Use Horde_Routes in jonah/delivery/index.php
Summary Use Horde_Routes in jonah/delivery/index.php
Queue Jonah
Type Enhancement
State Assigned
Priority 1. Low
Owners bklang@horde.org
Requester chuck@horde.org
Created 2008-08-13 (4629 days ago)
Updated 2010-07-17 (3926 days ago)
Patch No

Chuck Hagenbuch <chuck@horde.org> 2008-08-13 04:59:43
Here's some example routes code:

$m = new Horde_Routes_Mapper();


$m->connect('/admin/:section/:page', array(

     'controller' => 'admin',

     'section' => '',

     'page' => '',


$m->connect('/minutes/:date', array(

     'controller' => 'minutes',

     'date' => '',

     'requirements' => array('date' => '\d{4}\-?\d{2}\-?\d{2}'),


$m->connect('/page/:page', array(

     'controller' => 'pages',

     'requirements' => array('page' => '\w+'),


$result = $m->routematch($_SERVER['REQUEST_URI']);

if (!is_null($result)) {

     list($vars, $route) = $result;

     switch ($vars['controller']) {


Ben: I'm assigning this to you so you can write out the URL rules that 
should be matched here (to make sure I get the intent right instead of 
just looking at that switch statement). If you want to pass this off 
afterward that's fine.

Ben Klang <bklang@horde.org> 2008-08-22 19:06:50
I've spent some time over the last few days trying to puzzle this 
together to match what I implemented in delivery/index.php.  While 
simple cases seem to map directly I can't seem to figure out how to 
get exactly what I want from Horde_Routes.

For example, it's pretty straightforward to set up routes for 
channel/:channel_id, for story/:story_id or for tags/:tag_id.  What I 
can't figure out, short of using query args, is providing the ability 
to filter based on arbitrary criteria.  Some examples:




While I don't think it's important to allow mixing the order of 
attributes I do think it's important to allow for any combination of 
valid attributes.  Short of accounting for every possible permutation 
with a route map (which is obviously unmaintainable) I don't see how 
to accomplish this with Routes.  Am I missing something?  All of the 
examples I see are either for direct "controller/action/id" tuples or 
strictly nested attributes such as 
"region/:region_id/location/:location_id/action" where it would never 
make sense to specify a location without a region or vice versa.  The 
Jonah attributes have no relation to the other attributes, except in 
certain cases like it would not result in a sensible combination 
("/story/:story_id/tag/:tag_id" for example).

Ben Klang <bklang@horde.org> 2008-08-22 20:15:04
Chuck, Ben and Mike Naberezny just discussed this in IRC.  Here is the 

* Routes will be created for the feed slug, the tag, the author and 
the month (including the year).  This will result in URLs like:





* The output format will be determined by the URL suffix (XML vs. HTML)

* All other filterable attributes will be implemented as query 
strings.  The format of these attributes will be modeled after GData 
(ref: http://code.google.com/apis/gdata/reference.html#Queries)



This returns all articles dated 2008-08-01 through 2008-08-31 tagged 
with EITHER tag1 or tag2 from the "myfeed" feed in HTML format


This returns all articles by bklang from the "hordefeed" feed 
containing the text "some search text" in RSS2 form.


This returns all articles tagged "elephant" starting at the 23rd 
article of the "otherfeed" feed in Atom format.


This returns all the articles from the "airplanes" feed in HTML form.

Chuck Hagenbuch <chuck@horde.org> 2008-08-23 01:08:24
Sounds good, except I thought we agreed to implement tag urls like 
Gdata does categories  - with /-/tag1/tag2 or /-/tag1|tag2.

Ben Klang <bklang@horde.org> 2008-08-23 01:46:41
> Sounds good, except I thought we agreed to implement tag urls like

> Gdata does categories  - with /-/tag1/tag2 or /-/tag1|tag2.

Yes, that is part of the spec.  Actually both forms are valid per the 
Gdata standard, but I'll need guidance on how to use Routes to parse 
the /-/ format.

CVS Commit <cvs@lists.horde.org> 2008-08-23 02:02:39

CVS Commit <cvs@lists.horde.org> 2008-08-23 02:10:54

Chuck Hagenbuch <chuck@horde.org> 2008-08-23 03:35:31
> Yes, that is part of the spec.  Actually both forms are valid per the

> Gdata standard, but I'll need guidance on how to use Routes to parse

> the /-/ format.

Probably just matching everything after /-/ in the route and parsing 
it by hand, since it would come after a feed route and before a query 

Michael Rubinsky <mrubinsk@horde.org> 2008-08-25 15:21:13
Another summary of a quick conversation on IRC:

To be more flexible and compatible with web servers like Lighttpd 
(which doesn't ignore existing files/directories when rewriting URLs) 
a default prefix of 'feeds/' will be added to the routes.  Also, the 
routes should be defined in a configuration file so that they can be 
modified easily.

Michael Rubinsky <mrubinsk@horde.org> 2010-07-17 15:04:22
See also Ticket: 7206