[OpenLayers-Commits] r2256 - in trunk/openlayers: lib/OpenLayers/Layer tests
commits at openlayers.org
commits at openlayers.org
Wed Feb 21 17:32:32 EST 2007
Author: crschmidt
Date: 2007-02-21 17:32:31 -0500 (Wed, 21 Feb 2007)
New Revision: 2256
Added:
trunk/openlayers/tests/atom-1.0.xml
Modified:
trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js
trunk/openlayers/tests/test_Layer_GeoRSS.html
Log:
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!
Modified: trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js 2007-02-21 21:24:03 UTC (rev 2255)
+++ trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js 2007-02-21 22:32:31 UTC (rev 2256)
@@ -130,7 +130,18 @@
}
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)) {
Added: trunk/openlayers/tests/atom-1.0.xml
===================================================================
--- trunk/openlayers/tests/atom-1.0.xml (rev 0)
+++ trunk/openlayers/tests/atom-1.0.xml 2007-02-21 22:32:31 UTC (rev 2256)
@@ -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>
+
Modified: trunk/openlayers/tests/test_Layer_GeoRSS.html
===================================================================
--- trunk/openlayers/tests/test_Layer_GeoRSS.html 2007-02-21 21:24:03 UTC (rev 2255)
+++ trunk/openlayers/tests/test_Layer_GeoRSS.html 2007-02-21 22:32:31 UTC (rev 2256)
@@ -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 );
More information about the Commits
mailing list