Add support for Atom 1.0 to Layer.GeoRSS. Patch from Sean Gillies provided
in #506: tests are included to test that the links are properly created for Atom 1.0 content (with a data sample provided in the patch). Thanks, Sean! git-svn-id: http://svn.openlayers.org/trunk/openlayers@2256 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -130,7 +130,18 @@ OpenLayers.Layer.GeoRSS.prototype =
|
||||
}
|
||||
catch (e) { description="No description."; }
|
||||
|
||||
try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { }
|
||||
/* If no link URL is found in the first child node, try the
|
||||
href attribute */
|
||||
try {
|
||||
var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue;
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].getAttribute("href");
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
|
||||
data.icon = OpenLayers.Marker.defaultIcon();
|
||||
data.popupSize = new OpenLayers.Size(250, 120);
|
||||
if ((title != null) && (description != null)) {
|
||||
|
||||
34
tests/atom-1.0.xml
Normal file
34
tests/atom-1.0.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom"
|
||||
xmlns:georss="http://www.georss.org/georss">
|
||||
|
||||
<title>tumulus</title>
|
||||
<link rel="self"
|
||||
href="http://pleiades.stoa.org/places/tumulus"/>
|
||||
<updated/>
|
||||
<author/>
|
||||
<id>http://pleiades.stoa.org/places/tumulus</id>
|
||||
|
||||
<entry>
|
||||
<title>Unnamed Tumulus</title>
|
||||
<link rel="alternate"
|
||||
href="http://pleiades.stoa.org/places/638896"
|
||||
/>
|
||||
<id>http://pleiades.stoa.org/places/638896</id>
|
||||
<updated/>
|
||||
<summary>An ancient tumulus, attested during the Classical period (modern location: Karaburun). Its ancient name is not known.</summary>
|
||||
<georss:point>36.7702 29.9805</georss:point>
|
||||
</entry>
|
||||
<entry>
|
||||
<title>Unnamed Tumulus</title>
|
||||
<link rel="alternate"
|
||||
href="http://pleiades.stoa.org/places/638924"
|
||||
/>
|
||||
<id>http://pleiades.stoa.org/places/638924</id>
|
||||
<updated/>
|
||||
<summary>An ancient tumulus, attested during the Classical period (modern location: Kızılbel). Its ancient name is not known.</summary>
|
||||
<georss:point>36.7263 29.8619</georss:point>
|
||||
</entry>
|
||||
|
||||
</feed>
|
||||
|
||||
@@ -18,6 +18,22 @@
|
||||
t.eq( layer.name, "Crschmidt's Places At Platial", "Layer name is correct." );
|
||||
} );
|
||||
}
|
||||
|
||||
function test_01_Layer_GeoRSS_AtomParsing (t) {
|
||||
t.plan( 6 );
|
||||
layer = new OpenLayers.Layer.GeoRSS('Test Layer', "./atom-1.0.xml" );
|
||||
t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
|
||||
t.eq( layer.location, "./atom-1.0.xml", "layer.location is correct" );
|
||||
var markers;
|
||||
t.delay_call( 1, function() {
|
||||
t.eq( layer.markers.length, 2, "marker length is correct" );
|
||||
var ll = new OpenLayers.LonLat(29.9805, 36.7702);
|
||||
t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
|
||||
t.like( layer.features[0].data['popupContentHTML'], '<a class="link" href="http://pleiades.stoa.org/places/638896" target="_blank">Unnamed Tumulus</a>', "Link is correct.");
|
||||
t.eq( layer.name, "tumulus", "Layer name is correct." );
|
||||
} );
|
||||
}
|
||||
|
||||
function test_02_Layer_GeoRSS_draw (t) {
|
||||
// t.plan(5);
|
||||
t.plan( 2 );
|
||||
|
||||
Reference in New Issue
Block a user