6.0.0-alpha10
5/14/25

[#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 (at) horde (dot) org
Requester chuck (at) horde (dot) org
Created 08/13/2008 (6118 days ago)
Due
Updated 07/17/2010 (5415 days ago)
Assigned
Resolved
Milestone
Patch No

History
07/17/2010 03:04:22 PM Michael Rubinsky Comment #10 Reply to this comment
See also Ticket: 7206
08/25/2008 03:21:13 PM Michael Rubinsky Comment #9 Reply to this comment
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.
08/23/2008 03:35:31 AM Chuck Hagenbuch Comment #8 Reply to this comment
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 
string.
08/23/2008 01:46:41 AM Ben Klang Comment #5 Reply to this comment
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.
08/23/2008 01:08:24 AM Chuck Hagenbuch Comment #4 Reply to this comment
Sounds good, except I thought we agreed to implement tag urls like 
Gdata does categories  - with /-/tag1/tag2 or /-/tag1|tag2.
08/22/2008 08:15:04 PM Ben Klang Comment #3 Reply to this comment
Chuck, Ben and Mike Naberezny just discussed this in IRC.  Here is the 
outcome:



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

/:feed/author/:author_id

/:feed/tag/:tag_id

/:feed/date/:year-month

/:feed



* 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)



Examples:

/myfeed/date/2008-08.html?tags=tag1|tag2

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



/hordefeed/author/bklang.rss2?q=some%20search%20text

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



/otherfeed/tag/elephants.atom?start-index=23

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



/airplanes.html

This returns all the articles from the "airplanes" feed in HTML form.
08/22/2008 07:06:50 PM Ben Klang Comment #2 Reply to this comment
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:



/channel/:channel_id/tag/:tag_id

/tag/:tag_id/date/:date

/channel/:channel_id/date/:date



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).
08/13/2008 04:59:43 AM Chuck Hagenbuch Comment #1
Priority ⇒ 1. Low
Type ⇒ Enhancement
Summary ⇒ Use Horde_Routes in jonah/delivery/index.php
Queue ⇒ Jonah
Assigned to Ben Klang
Milestone ⇒
Patch ⇒ No
State ⇒ Assigned
Reply to this comment
Here's some example routes code:



$m = new Horde_Routes_Mapper();

$m->connect(':controller/:action/:id');

$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.

Saved Queries