OpenLayers OpenLayers

Changeset 2256

Show
Ignore:
Timestamp:
02/21/07 17:32:31 (2 years ago)
Author:
crschmidt
Message:

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!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js

    r2029 r2256  
    131131            catch (e) { description="No description."; } 
    132132 
    133             try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { }  
     133            /* If no link URL is found in the first child node, try the 
     134               href attribute */ 
     135            try { 
     136              var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; 
     137            }  
     138            catch (e) { 
     139              try { 
     140                var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].getAttribute("href"); 
     141              } 
     142              catch (e) {} 
     143            } 
     144 
    134145            data.icon = OpenLayers.Marker.defaultIcon(); 
    135146            data.popupSize = new OpenLayers.Size(250, 120); 
  • trunk/openlayers/tests/test_Layer_GeoRSS.html

    r1424 r2256  
    1919        } ); 
    2020    } 
     21     
     22    function test_01_Layer_GeoRSS_AtomParsing (t) { 
     23        t.plan( 6 ); 
     24        layer = new OpenLayers.Layer.GeoRSS('Test Layer', "./atom-1.0.xml" ); 
     25        t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" ); 
     26        t.eq( layer.location, "./atom-1.0.xml", "layer.location is correct" ); 
     27        var markers; 
     28        t.delay_call( 1, function() {   
     29            t.eq( layer.markers.length, 2, "marker length is correct" ); 
     30            var ll = new OpenLayers.LonLat(29.9805, 36.7702); 
     31            t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" ); 
     32            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."); 
     33            t.eq( layer.name, "tumulus", "Layer name is correct." ); 
     34        } ); 
     35    } 
     36 
    2137    function test_02_Layer_GeoRSS_draw (t) {  
    2238//        t.plan(5);