Commits

Anonymous committed e1d6b5c

added all missing fields

  • Participants
  • Parent commits 24b7986

Comments (0)

Files changed (1)

File nom/plugins/rss/__init__.py

         fh = open(output)
         content = fh.read()
         fh.close()
+        # PyRSS2Gen escapes everything, no CDATA needed
         # return '<![CDATA[%s]]>' % (content,)
         return content
 
 
-    def _gen_feed(self, env, patterns):
+    def _gen_feed(self, env, conf):
         items = []
+        pat = conf.get('feed', 'match')
+        patterns = [re.compile(fnmatch.translate(pat))]
+
         for src,item in self._iter_sources(env, patterns):
             url = nom.config.base_url + item['output']
                 
                 pubDate = datetime.datetime.fromtimestamp(item['timestamp']),
             ))
 
+        title = conf.get('feed', 'title')
+        description = conf.get('feed', 'description')
+
+        try:
+            link = conf.get('feed', 'link')
+        except ConfigParser.NoOptionError:
+            # This is a guess at the output link.  Short of a
+            # specialized writer that tweaks the XML content, this is
+            # the best we can do as long as the mapping/tracker stuff
+            # is in a handler and not some kind of service.
+            from os.path import splitext
+            outfile = splitext(env['input-filename'][len(env['input-dir']):])[0]
+            link = ''.join((nom.config.base_url, outfile, '.rss'))
+
         rss = rssgen.RSS2(
-            title = "XXX TODO needs a title in config",
-            link = "XXX TODO generate self-link",
-            description = "XXX TODO needs description in config",
+            title = title, link = link, description = description,
             lastBuildDate = datetime.datetime.now(),
             items = items
             )
         conf = ConfigParser.ConfigParser()
         conf.readfp(fp)
 
-        pat = conf.get('feed', 'match')
-        patterns = [re.compile(fnmatch.translate(pat))]
-        
-        string = self._gen_feed(env,patterns)
+        string = self._gen_feed(env,conf)
         
         env['content-type'] = 'application/rss+xml'
         return (string, env)