OpenLayers OpenLayers

Changeset 7127

Show
Ignore:
Timestamp:
05/09/08 15:20:06 (2 months ago)
Author:
tschaub
Message:

the example parser now also kicks out a basic atom feed, example list page links to this feed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/example-list.html

    r7125 r7127  
    22<html> 
    33    <head> 
    4         <title>OpenLayers Examples</title>         
     4        <title>OpenLayers Examples</title> 
     5        <link rel="alternate" href="example-list.xml" type="application/atom+xml" /> 
    56        <link rel="stylesheet" href="style.css" type="text/css" /> 
    67        <style type="text/css"> 
  • trunk/openlayers/tools/exampleparser.py

    r7126 r7127  
    55import re 
    66import urllib2 
     7from xml.dom.minidom import Document 
    78 
    89missing_deps = False 
     
    8283    return d 
    8384     
     85def createFeed(examples): 
     86    doc = Document() 
     87    feed = doc.createElementNS("http://www.w3.org/2005/Atom", "feed") 
     88    for example in examples: 
     89        entry = doc.createElementNS("http://www.w3.org/2005/Atom", "entry") 
     90         
     91        title = doc.createElementNS("http://www.w3.org/2005/Atom", "title") 
     92        title.appendChild(doc.createTextNode(example["title"] or example["example"])) 
     93        entry.appendChild(title) 
     94         
     95        link = doc.createElementNS("http://www.w3.org/2005/Atom", "link") 
     96        link.setAttribute("href", example["example"]) 
     97        entry.appendChild(link) 
     98     
     99        summary = doc.createElementNS("http://www.w3.org/2005/Atom", "summary") 
     100        summary.appendChild(doc.createTextNode(example["shortdesc"] or example["example"])) 
     101        entry.appendChild(summary) 
     102         
     103        feed.appendChild(entry) 
     104 
     105    doc.appendChild(feed) 
     106    return doc 
     107 
     108def createEntry(doc, example): 
     109     
     110    return entry 
     111     
     112     
    84113def wordIndex(examples): 
    85114    """ 
     
    139168        exampleList.append(tagvalues) 
    140169         
     170    print 
     171     
    141172    exampleList.sort(key=lambda x:x['example'].lower()) 
    142173     
     
    148179    outFile.write(json) 
    149180    outFile.close() 
     181 
     182    print "writing feed to ../examples/example-list.xml " 
     183    atom = open('../examples/example-list.xml','w') 
     184    doc = createFeed(exampleList) 
     185    atom.write(doc.toprettyxml("    ")) 
     186    atom.close() 
     187 
     188 
    150189    print 'complete' 
    151190