Anonymous avatar Anonymous committed e1d6b5c

added all missing fields

Comments (0)

Files changed (1)

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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.