Custom Permalinks URLs

Today I put some effort into making our URL archive (permalink) scheme configurable and flexible. This is my mail I sent to our development mailinglist:



Inspired by a little IRC chat with Ben Ramsey, I decided it shouldn't be that
hard to patch up custom permalink support into serendipity.



The foundation was already there, thanks to Tom. What I did was patch up all
functions and plugins that use the serendipity_ArchiveURL() function.



I created a lookup database table for entries, since users may be able to build
a URL layout that does not contain the Entry ID. Only if no entry id is
contained in the URL, a DB lookup will be made; thus if people stay with our old
archives/ style links, they will not feel much of a performance impact.



A hard thing to do was that the archiveURL() function now needs the timestamp
value of an entry so that you can build /archives/2005/10/05/title.html.



I have only tested the basic functionality, and it seems to work pretty well.
Please review the attached patch for Serendipity 0.9 SVN - if nobody disagrees
until the next days I will commit the patch to SVN. Feedback is appreciated, of
course.



It currently ONLY works for the entries archive. The Pattern for past archives,
categories and feeds I have not yet touched because it's less important IMHO;
and the funcionality to implement it is all there, it just needs a volunteer.
*g*



But for migrating WordPress articles and leaving the articles Permalink, the
patch is suitable. (You'll need to import your wordpress articles first, and
then change the permalink structure in s9y configuration to the WordPress one)



The patch is online at: http://garv.in/files/permalink.diff (will be removed after a while, backup is here: http://nopaste.php-q.net/134018)





As I checked back with Tom Sommer, we thought about if it's a clever way to have a seperate lookup table for the permalinks. Advantages for this lookup table are:

  • faster performance as it's a smaller table with optimized indices
  • flexible approach as all kinds of categories, feeds, authors etc. permalinks can be handled there as well
  • you can store more than one entry on the same day with the same title
However there are also drawbacks:
  • needs a new table
  • the lookup table needs to be synchronized when updating/creating entries or changing the permalink syntax (the synchronizing is already taken care of in my patch)

Other blog systems do not use a seperate lookup table - so is our uniqueness here clever or are we doing something wrong the others found out about? :-)



[Update: I updated the links above to include a minor bugfix in the .diff file]

Trackbacks

Trackback-URL für diesen Eintrag

Kommentare

Ansicht der Kommentare: (Linear | Verschachtelt)

Fred am um :

For example, Wordpress doesn't use a seperate table. Instead, it uses the "short title" combined with the post's date to determine the correct one post. I never tried two posts with the same title on the same day, but I think the short title will differ somehow, then.

Nonetheless, I like the idea to use a seperate table, depending on the permalink syntax used. It can significantly speed up article search. Tables usually don't hurt.

Kommentar schreiben

Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.

Um maschinelle und automatische Übertragung von Spamkommentaren zu verhindern, bitte die Zeichenfolge im dargestellten Bild in der Eingabemaske eintragen. Nur wenn die Zeichenfolge richtig eingegeben wurde, kann der Kommentar angenommen werden. Bitte beachten Sie, dass Ihr Browser Cookies unterstützen muss, um dieses Verfahren anzuwenden.
CAPTCHA

BBCode-Formatierung erlaubt
Markdown-Formatierung erlaubt