Coral CDN support for URLs with non-standard ports
submitted by Lenny Domnitser
This commit is contained in:
parent
cf137aad95
commit
3cd0e7149b
1
THANKS
1
THANKS
@ -13,6 +13,7 @@ Morten Frederiksen - Support WordPress LinkManager OPML
|
||||
Harry Fuecks - default item date to feed date
|
||||
Antonio Cavedoni - Django templates
|
||||
Morten Frederiksen - expungeCache
|
||||
Lenny Domnitser - Coral CDN support for URLs with non-standard ports
|
||||
|
||||
This codebase represents a radical refactoring of Planet 2.0, which lists
|
||||
the following contributors:
|
||||
|
@ -3,14 +3,15 @@ Remap all images to take advantage of the Coral Content Distribution
|
||||
Network <http://www.coralcdn.org/>.
|
||||
"""
|
||||
|
||||
import sys, urlparse, xml.dom.minidom
|
||||
import re, sys, urlparse, xml.dom.minidom
|
||||
|
||||
entry = xml.dom.minidom.parse(sys.stdin).documentElement
|
||||
|
||||
for node in entry.getElementsByTagName('img'):
|
||||
if node.hasAttribute('src'):
|
||||
component = list(urlparse.urlparse(node.getAttribute('src')))
|
||||
if component[0]=='http' and component[1].find(':')<0:
|
||||
if component[0] == 'http':
|
||||
component[1] = re.sub(r':(\d+)$', r'.\1', component[1])
|
||||
component[1] += '.nyud.net:8080'
|
||||
node.setAttribute('src', urlparse.urlunparse(component))
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
<entry xmlns="http://www.w3.org/2005/Atom">
|
||||
<content>
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||
<img src="http://example.com/foo.png"/>
|
||||
Plain old image: <img src="http://example.com/foo.png"/>
|
||||
Host has a non-standard port: <img src="http://example.com:1234/foo.png"/>
|
||||
A non-port colon: <img src="http://u:p@example.com/foo.png"/>
|
||||
Several colons: <img src="http://u:p@example.com:1234/foo.png"/>
|
||||
</div>
|
||||
</content>
|
||||
</entry>
|
||||
|
@ -11,8 +11,11 @@ class FilterTests(unittest.TestCase):
|
||||
|
||||
output = shell.run(filter, open(testfile).read(), mode="filter")
|
||||
dom = xml.dom.minidom.parseString(output)
|
||||
imgsrc = dom.getElementsByTagName('img')[0].getAttribute('src')
|
||||
self.assertEqual('http://example.com.nyud.net:8080/foo.png', imgsrc)
|
||||
imgsrcs = [img.getAttribute('src') for img in dom.getElementsByTagName('img')]
|
||||
self.assertEqual('http://example.com.nyud.net:8080/foo.png', imgsrcs[0])
|
||||
self.assertEqual('http://example.com.1234.nyud.net:8080/foo.png', imgsrcs[1])
|
||||
self.assertEqual('http://u:p@example.com.nyud.net:8080/foo.png', imgsrcs[2])
|
||||
self.assertEqual('http://u:p@example.com.1234.nyud.net:8080/foo.png', imgsrcs[3])
|
||||
|
||||
def test_excerpt_images1(self):
|
||||
config.load('tests/data/filter/excerpt-images.ini')
|
||||
|
Loading…
x
Reference in New Issue
Block a user