Skip to content. | Skip to navigation

Sections
Personal tools

validating Quills Atomfeed

This version actually validates - there is one nasty hack left, though: the timezone for the modification date is hardcoded to -01:00 (European time). Change that if necessary. Search for w3cdate in the source ;-)

atom.xml.pt — HTML, 4Kb

File contents

<tal:block
  tal:define="dummy python:context.REQUEST.RESPONSE.setHeader('Content-Type', 'application/xml')"
  tal:replace='structure string:<?xml version="1.0" encoding="${context/portal_properties/site_properties/default_charset}"?>'/>
<tal:block
  tal:replace='structure string:<?xml-stylesheet href="${context/portal_url}/atom.css" type="text/css"?>'/>

<feed xmlns="http://purl.org/atom/ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  version="0.3"
  xml:base=""
  xml:lang="en"
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  xmlns:tal="http://xml.zope.org/namespaces/tal"
  tal:attributes="xml:base here/portal_url"
  tal:define="results python:container.portal_catalog(
    portal_type=['WeblogEntry','WeblogPhoto'],
    sort_on='effective',
    sort_order='reverse',
    review_state='published');
    results python:[r for r in results[:15] if r.getObject()];
    Batch python:modules['Products.CMFPlone'].Batch;
    b_start python:request.get('b_start',0);
    portal_discussion nocall:here/portal_discussion;
    date python:results[0].ModificationDate;
    w3cdate python:date[0:10] + 'T' + date[11:19] + '-01:00'"
  i18n:domain="quills">

  <info mode="xml" type="text/html">
    <div xmlns="http://www.w3.org/1999/xhtml">
      <a xmlns="http://www.w3.org/1999/xhtml" 
        href="" 
        tal:attributes="href string:http://www.atomenabled.org/feedvalidator/check.cgi?url=${here/absolute_url}/atom.xml">
        <img title="Validate my Atom feed" width="88" height="31" 
          alt="[Valid Atom]" border="0px" i18n:attributes="alt;title;src string:${here/absolute_url}/valid-atom-png"/>
      </a>
      <p i18n:translate="atom_description">
        This is an Atom formatted XML site feed. It is intended to be viewed in
        a Newsreader or syndicated to another site. Please visit the 
        <a href="http://www.atomenabled.org/"
          i18n:translate="atom_enabled">Atom Enabled</a><span 
          i18n:translate="atom_more_info"> for more info.</span>
      </p>
    </div>
  </info>

  <title type="text/html" 
      mode="escaped"
      tal:define="portal_title here/portal_properties/title;
      published here/effective;
      here_title here/title_or_id;
      template_title template/title_or_id;
      here_title python:test(portal_title != here_title, here_title, template_title)"
      tal:content="string:$portal_title - $here_title">Title of page</title>

  <tagline tal:content="here/Description"></tagline>

  <!-- FIXME: all dates need to be 2002-10-02T10:00:00-05:00 -->
  <!-- FIXME: Feed needs a modified date -->
  <!-- FIXME: added manual hack to beat the format into submission -->
  <modified tal:content="w3cdate">
    2002-10-02T10:00:00-05:00
  </modified>

  <link href="" tal:attributes="href here/absolute_url" rel="alternate" type="text/html" />

  <tal:comment condition="nothing">
    The atom:id is defined as follows:

    The "atom:id" element's content conveys a permanent, globally unique
    identifier for the feed. It MUST NOT change over time, even if the feed is
    relocated. atom:feed elements MAY contain an atom:id element, but MUST NOT
    contain more than one. The content of this element, when present, MUST be a
    URI.
  </tal:comment>

  <id tal:define="path python:here.portal_url().replace('http://','');
                  year python: w3cdate[0:4]"
    tal:content="string:tag:${path},${year}:${here/id}"></id>

  <generator url="http://developer.etria.com/projects/quills"
    version="0.9">Quills</generator>

  <tal:define define="max_items here/getEntriesPerPage">
    <tal:repeat repeat="res results">
      <tal:define define="item python:res.getObject()">
        <entry>
          <title tal:content="item/Title"></title>
          <link rel="alternate" type="text/html" href=""
            tal:attributes="href item/absolute_url" />
          <!-- FIXME: Need a unique ID here -->
          <id tal:define="path python:here.portal_url().replace('http://',''); 
                          date python:DateTime(item.EffectiveDate()).strftime('%Y-%m-%d')" 
            tal:content="string:tag:${path},${date}:${item/UID}"></id>
          <content mode="escaped" 
            type="text/html" 
            xml:base="" 
            xml:lang="en-US" 
            xml:space="preserve"
            tal:attributes="xml:base item/portal_url"
            tal:content="string: <blockquote>${item/Description}</blockquote>${item/getText}">
          </content>

          <author>
            <name tal:content="item/Creator"></name>
          </author>
          <issued tal:content="python: DateTime(item.EffectiveDate()).strftime('%Y-%m-%dT%H:%M+00:00')"></issued>
          <modified tal:content="python: DateTime(str(item.modified())).strftime('%Y-%m-%dT%H:%M+00:00')"></modified>
        </entry>
      </tal:define>
    </tal:repeat>
  </tal:define>
</feed>
Outdated Information
Please note that most of the information contained in this section is several years old and while most of it is still useful, hardly none of it applies directly to current versions of the software discussed. Proceed with caution, your mileage may vary etc. pp. ;-)