Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > Miscellaneous > Archive > Sunrise

Notices

 
 
Thread Tools Search this Thread
Old 02-04-2006, 11:58 AM   #1
BasilC
Zealot
BasilC is on a distinguished road
 
BasilC's Avatar
 
Posts: 129
Karma: 60
Join Date: Feb 2003
Location: London England
Device: Palm Tungsten T3
Question 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 )
BasilC is offline  
Old 02-04-2006, 03:44 PM   #2
Laurens
Jah Blessed
Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.
 
Laurens's Avatar
 
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.
Attached Files
File Type: sxl opendemocracy.sxl (1.1 KB, 476 views)
Laurens is offline  
Advert
Old 02-04-2006, 07:44 PM   #3
BasilC
Zealot
BasilC is on a distinguished road
 
BasilC's Avatar
 
Posts: 129
Karma: 60
Join Date: Feb 2003
Location: London England
Device: Palm Tungsten T3
Quote:
Originally Posted by Laurens
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.
Laurens, that's most kind of you. I'll use it and also try to deconstruct it and learn some lessons. I have used regular expressions a bit in iSiloX, but only extremely simple stuff.
BasilC is offline  
Old 02-05-2006, 07:03 AM   #4
Laurens
Jah Blessed
Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.Laurens is no ebook tyro.
 
Laurens's Avatar
 
Posts: 1,295
Karma: 1373
Join Date: Apr 2003
Location: The Netherlands
Device: iPod Touch
Smile 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.
Laurens is offline  
Old 07-05-2007, 06:49 AM   #5
felix_cohen
Junior Member
felix_cohen began at the beginning.
 
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
felix_cohen is offline  
Advert
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What's with the Wiki link? eGeezer Feedback 2 10-28-2009 09:05 PM
New link to jkOnTheRun? RCR Feedback 1 02-05-2009 04:31 AM


All times are GMT -4. The time now is 01:02 AM.


MobileRead.com is a privately owned, operated and funded community.