svn commit: samba-web r752 - in trunk/scripts: .

deryck at samba.org deryck at samba.org
Thu Jul 21 22:18:57 GMT 2005


Author: deryck
Date: 2005-07-21 22:18:57 +0000 (Thu, 21 Jul 2005)
New Revision: 752

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba-web&rev=752

Log:
A better RSS feed for news -- include the entire story and wrap
in CDATA brackets so HTML works in a reader.

deryck

Modified:
   trunk/scripts/updateNews.py


Changeset:
Modified: trunk/scripts/updateNews.py
===================================================================
--- trunk/scripts/updateNews.py	2005-07-21 19:56:13 UTC (rev 751)
+++ trunk/scripts/updateNews.py	2005-07-21 22:18:57 UTC (rev 752)
@@ -214,27 +214,22 @@
 count = 10
 for date in post_dates:
     item_text = all_stories[date]
-    # Encode *all* ampersands
-    if '&' in item_text:
-            item_text = item_text.replace('&', '&')
-                
+
     if count > 0:
         title = re.search('(?<=\"\>).+(?=\<\/a)', item_text)
+        text =  re.search('<div class=\"article\"\>(\s|.)*?</div>', item_text)
         link = re.search('(?<=\<div class=\"reference\">Link: \<a href=\"/samba/news/).+(?=\"\>)', item_text)
 
-        # Index by <p> to find first paragraph, but 
-        # leave out the tags for XML
-        begin = item_text.find('<p>') + 3
-        end = item_text.find('</p>') 
-        descrip = item_text[begin:end]
-        # Remove links to avoid malformed XML
-        atags = re.compile('<a href="(.*)">|</a>|<a>|<a|href="(.*)">')
-        descrip = atags.sub('', descrip)
+        # Drop end tag unless nested divs were used
+        if '<div' in text.group()[21:]:
+            description = text.group()[21:]
+        else:
+            description =  text.group()[21:-6]
 
         feed.write('<item>\n')
-        feed.write('<title>' + title.group(0) + '</title>\n')
-        feed.write('<description>' + descrip + '</description>\n')
-        feed.write('<link>http://news.samba.org/' + link.group(0) + '</link>\n')
+        feed.write('<title><![CDATA[' + title.group() + ']]></title>\n')
+        feed.write('<description><![CDATA[' + description + ']]></description>\n')
+        feed.write('<link>http://news.samba.org/' + link.group() + '</link>\n')
         feed.write('</item>\n\n')
         count = count - 1
 



More information about the samba-cvs mailing list