![]() |
![]() |
| View unanswered posts | View active topics |
|
All times are UTC - 5 hours [ DST ] |
|
|
Page 1 of 1 |
[ 4 posts ] | Print view | | Previous topic | Next topic |
|
Joined: Wed Oct 19, 2011 5:22 pm Posts: 2 |
Hello,
Does anybody ever attempt to rewrite story urls of a particular feed? For example from something like http://actus.gregit.com/actus/url?sa=t& ... ng-renamed to http://www.citytv.com/toronto/citynews/ ... ng-renamed Any help would be appreciated Thx |
| Thu Oct 20, 2011 11:31 am |
|
|
Site Admin Joined: Fri Feb 07, 2003 8:48 am Posts: 2883 Location: Melbourne, Australia |
manuel wrote: Does anybody ever attempt to rewrite story urls of a particular feed? You can do it using XSL (kevotheclone is better at this stuff than I am and he'll probably chime in with info on how to do it), or you can write a little plugin to do it. Look at the online help for info on how to do this - it's pretty simple. If you define a parameter called DownloadUrl, Awasu will download the specified URL for you (more info here). Your plugin can then read it in, fix up all the URL's, then print out the adjusted feed for Awasu to read. |
| Sat Oct 22, 2011 10:56 pm |
|
|
Joined: Mon Sep 08, 2008 3:16 pm Posts: 222 Location: Elk Grove, California |
Great idea! Wish I'd thought of it
Google News feeds do this same type of thing where all links are first routed to Google so they can track your clicks. (I'm no expert, but...) The XSLT file below should work for the example URLs that you (manuel) provided as well Google News feeds since both prefix the actual URL with a url= named parameter. If needed you can change the value of <xsl:variable name="UrlPrefix">url=</xsl:variable> to process other feeds that use a different prefix before the actual URL. Once again this kind of processing only exists within the Wonderful World Of Awasu! Code: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:variable name="UrlPrefix">url=</xsl:variable> <!-- Matches everything not specified elseware; copies it to the output. --> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <!-- Matches the root node and "gets the party started". --> <xsl:template match="/"> <xsl:apply-templates></xsl:apply-templates> </xsl:template> <!-- Matches RSS <link> elements. --> <xsl:template match="/rss/channel/item/link"> <xsl:element name="{name(.)}"> <xsl:choose> <xsl:when test="contains(., $UrlPrefix)"> <xsl:value-of select="substring-after(., $UrlPrefix)"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:element> </xsl:template> <!-- Matches Atom <link> elements. --> <xsl:template match="/atom:feed/atom:entry/atom:link/@href"> <xsl:choose> <xsl:when test="contains(., $UrlPrefix)"> <xsl:value-of select="substring-after(., $UrlPrefix)"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> |
| Sun Oct 23, 2011 3:10 am |
|
|
Joined: Wed Oct 19, 2011 5:22 pm Posts: 2 |
Thank you for your straightforward answers and ready to use solution. Definitively a wonderfull world!
|
| Tue Oct 25, 2011 12:38 pm |
|
|
|
Page 1 of 1 |
[ 4 posts ] | Print view | | Previous topic | Next topic |
|
All times are UTC - 5 hours [ DST ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |