02-04-2006, 10:58 AM | #1 |
Zealot
Posts: 129
Karma: 60
Join Date: Feb 2003
Location: London England
Device: Palm Tungsten T3
|
Link rewriting - request for help
I'd be grateful for some advice on how to write a script to do link rewriting for the Open Democracy website. I'm afraid that I have no knowledge of scripts at all, so it would have to be an idiot's guide.
I'm using the RSS feed as the starting page: http://www.opendemocracy.net/xml/rss/home/index.xml The links in the RSS feed look like this: http://www.opendemocracy.net/debates...articleId=3239 Open Democracy is divided into a large number of different themes and debates. The links include both a Debate ID and an Article ID. However, the links to the print versions don't include a Debate ID and look like this: http://www.opendemocracy.net/article...articleId=3239 If some kind person could show me how to write a script to handle this, I'd be most grateful. Some explanation of how it works would be useful too. Or maybe you could direct me to a website with a dummy's guide. Finally, Sunrise XP evidently handles link rewriting differently, but I can't find an explanation anywhere. I presume that's because the help pages haven't been written yet? (Afternote: I've now discovered that if I'd used the Plain Text version of the website, I could get the same results without any link rewriting - though there wouldn't be any images included. However, it would be nice to learn how to do this ) |
02-04-2006, 02:44 PM | #2 |
Jah Blessed
Posts: 1,295
Karma: 1373
Join Date: Apr 2003
Location: The Netherlands
Device: iPod Touch
|
There is no documentation or web site yet. As of the latest alpha release, link rewriting rules can be specified in the interface. You no longer need separate scripts.
Link rewriting uses Perl-style regular expressions. Non-programmers might find it difficult to get to grips with regular expressions, though. You'll have to Google around if you really want to dive into it. Attached you'll find a predefined SXL for site you mention. |
Advert | |
|
02-04-2006, 06:44 PM | #3 | |
Zealot
Posts: 129
Karma: 60
Join Date: Feb 2003
Location: London England
Device: Palm Tungsten T3
|
Quote:
|
|
02-05-2006, 06:03 AM | #4 |
Jah Blessed
Posts: 1,295
Karma: 1373
Join Date: Apr 2003
Location: The Netherlands
Device: iPod Touch
|
Link Rewriting In a NutShell (TM)
The key to link rewriting is using so-called "marked subexpressions".
The regular expression for matching article URLs is fairly straightforward: http://.*\.?opendemocracy\.net/.*/article\.jsp\?id=\d*.*articleId=\d*.* What you want to do is extract certains parts of a matching URL to construct a handheld-friendly URL. You can do this by marking these parts as subexpressions by putting them between parentheses: (http://.*\.?opendemocracy\.net)/.*/article\.jsp\?id=(\d*).*articleId=(\d*).* Each subexpression in a matching link is assigned a number. You have to put a dollar sign in front of them when rewriting the link. In this case there are three submatches: $1, $2 and $3. Once you have understand this and have this working, rewriting the link becomes very simple: $1/articles/ViewPopUpArticle.jsp?id=$2&articleId=$3 There's far more to regexp, but you don't need to know everything to use link rewriting. |
07-05-2007, 05:49 AM | #5 |
Junior Member
Posts: 1
Karma: 10
Join Date: Jul 2007
Device: p910i
|
openDemocracy new site
Hi,
I'm the website developer at openDemocracy. We've just moved to a new site, and unfortunately this technique will no longer work. We will be introducing new mobile RSS feeds on the site shortly, however, so in future it won't be necessary to go through this process. Thanks to everyone for your interest in our content! Felix |
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What's with the Wiki link? | eGeezer | Feedback | 2 | 10-28-2009 08:05 PM |
New link to jkOnTheRun? | RCR | Feedback | 1 | 02-05-2009 03:31 AM |