List Info

Thread: absolute_img_paths.py filter




absolute_img_paths.py filter
user name
2007-06-01 19:08:29
I would be surprised if someone hasn't done one of these
already, but
I've written a filter that looks out for images with
relative file
paths and turns them in to absolute file paths using a
protocol and
domain extracted from the Atom link element:

http://simonwillison.net/static/2007/absolute_img_
paths.py.txt

One problem: I'm ending up with HTML that looks like this:

<p><img src="http://www.hicksdesign.co.uk/images/txp/267.gif"
alt="Mahalo" height="162"
title="Mahalo"
width="360"></img></p>

What's the standard Planet/Venus solution for killing that
closing </img> tag?

Cheers,

Simon
-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

Re: absolute_img_paths.py filter
user name
2007-06-01 20:54:42
On 6/1/07, Simon Willison <simonsimonwillison.net>
wrote:
> I would be surprised if someone hasn't done one of
these already, but
> I've written a filter that looks out for images with
relative file
> paths and turns them in to absolute file paths using a
protocol and
> domain extracted from the Atom link element:
>
> http://simonwillison.net/static/2007/absolute_img_
paths.py.txt
>
> One problem: I'm ending up with HTML that looks like
this:
>
> <p><img src="http://www.hicksdesign.co.uk/images/txp/267.gif"
> alt="Mahalo" height="162"
title="Mahalo"
width="360"></img></p>
>
> What's the standard Planet/Venus solution for killing
that closing </img> tag?

I'm confused.  The feedparser should already resolve all
relative
links.  Can you provide an example where this does not
occur?  You
might find the following to be a handy way to see how venus
normalizes
any given feed:

python tests/reconstitute.py http://feeds.
feedburner.com/hicksdesign

- Sam Ruby
-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

Re: absolute_img_paths.py filter
user name
2007-06-02 01:56:57
On 6/2/07, Sam Ruby <rubysintertwingly.net>
wrote:
> I'm confused.  The feedparser should already resolve
all relative
> links.  Can you provide an example where this does not
occur?  You
> might find the following to be a handy way to see how
venus normalizes
> any given feed:
>
> python tests/reconstitute.py http://feeds.
feedburner.com/hicksdesign

This is very strange - that command shows me resolved image
links, but
my own planet install wasn't resolving them (the test suite
ran fine).

Here's the output without my filter (illustrating the
error):

htt
p://planet.oxfordgeeks.net/without-img-filter/

That's using this config file:

[Planet]
name = Planet Oxford Geeks
link = http://planet.oxfordge
eks.net/
owner_name = Simon Willison
owner_email = simon+planetoxfordgeeks...

# filters = absolute_img_paths.py

cache_directory = /home/simon/sites/oxfordgeeks.net/cache
log_level = ERROR
feed_timeout = 20

# output_theme: "theme" of the output
# output_dir: Directory to place output files
# items_per_page: How many items to put on each page
output_theme = classic_fancy
output_dir =
/home/simon/sites/planet.oxfordgeeks.net/htdocs/without-img-
filter
items_per_page = 60

# additional files to copy (note the wildcards!)
bill_of_materials:
  thumbshots/#

# Options placed in the [DEFAULT] section provide defaults
for the feed
# sections.  Placing a default here means you only need to
override the
# special cases later.
[DEFAULT]
# Hackergotchi default size.
# If we want to put a face alongside a feed, and it's this
size, we
# can omit these variables.
facewidth = 160
faceheight = 120

[http://
feeds.simonwillison.net/swn-everything]
name = Simon Willison
face = simonwillison.jpg

[http://feeds.feedb
urner.com/natbat]
name = Natalie Downe
face = natbat.jpg

[http://gag
ravarr.livejournal.com/data/atom]
name = Nick Burch
face = gagravarr.jpg

[http://www.thr
owingbeans.org/index.rdf]
name = Tom Dyson
face = throwingbeans.jpg

[http://www.jpstac
ey.info/blog/feed/]
name = JP Stacey
face = jpstacey.jpg

[http://blog.victori
ac.net/rss.xml]
name = Victoria Chan
face = victoriac.jpg

[http://feeds.
feedburner.com/hicksdesign]
name = Jon Hicks
face = hicksdesign.jpg

[http://matt.west.co.tt/f
eed/]
name = Matthew Westcott
face = westcott.jpg

[http://jonathan
leighton.com/feed/blog]
name = Jonathan Leighton
face = jonathanleighton.jpg

[http://polytechnic.c
o.uk/rss.xml]
name = Garrett Coakley
face = polytechnic.jpg
-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

Re: absolute_img_paths.py filter
country flaguser name
United States
2007-06-02 06:16:16
Simon Willison wrote:
> On 6/2/07, Sam Ruby <rubysintertwingly.net>
wrote:
>> I'm confused.  The feedparser should already
resolve all relative
>> links.  Can you provide an example where this does
not occur?  You
>> might find the following to be a handy way to see
how venus normalizes
>> any given feed:
>>
>> python tests/reconstitute.py http://feeds.
feedburner.com/hicksdesign
> 
> This is very strange - that command shows me resolved
image links, but
> my own planet install wasn't resolving them (the test
suite ran fine).
> 
> Here's the output without my filter (illustrating the
error):
> 
> htt
p://planet.oxfordgeeks.net/without-img-filter/

Here are the (sorted, unique) img src's I find in the page:

  src="http://farm1.static.flickr.com/192/516391703_f1
83a4605b.jpg"
  src="http://feeds.feedburner.com/~f/natbat?i=1hiBhKVW"

  src="http://feeds.feedburner.com/~f/natbat?i=20O1BT75"

  src="http://feeds.feedburner.com/~f/natbat?i=8e5q8bN5"

  src="http://feeds.feedburner.com/~f/natbat?i=EuRf2Z27"

  src="http://feeds.feedburner.com/~f/natbat?i=G1tG4wHi"

  src="http://feeds.feedburner.com/~f/natbat?i=HCdwlxrp"

  src="http://feeds.feedburner.com/~f/natbat?i=Wl7o5l3c"

  src="http://feeds.feedburner.com/~f/natbat?i=Zsb83kTk"

  src="http://feeds.feedburner.com/~f/natbat?i=btFfvgyO"

  src="http://feeds.feedburner.com/~f/natbat?i=mwjxVDOG"

  src="http://www.hicksdesign.co.uk/images/txp/261.jpg"
  src="http://www.hicksdesign.co.uk/images/txp/264.jpg"
  src="http://www.hicksdesign.co.uk/images/txp/266.png"
  src="http://www.hicksdesign.co.uk/images/txp/267.gif"
  src="images/feed-icon-10x10.png"
  src="thumbshots/gagravarr.jpg"
  src="thumbshots/hicksdesign.jpg"
  src="thumbshots/jonathanleighton.jpg"
  src="thumbshots/natbat.jpg"
  src="thumbshots/polytechnic.jpg"
  src="thumbshots/simonwillison.jpg"
  src="thumbshots/throwingbeans.jpg"
  src="thumbshots/victoriac.jpg"
  src="thumbshots/westcott.jpg"

Which ones illustrate the problem?

- Sam Ruby
-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )