svn commit: samba-web r334 - in trunk: . scripts

deryck at samba.org deryck at samba.org
Wed Sep 15 21:02:00 GMT 2004


Author: deryck
Date: 2004-09-15 21:01:59 +0000 (Wed, 15 Sep 2004)
New Revision: 334

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba-web&path=/trunk&rev=334&nolog=1

Log:

Now the script for updating news.samba.org writes
the last ten headlines to <headlines.html>, which 
can then be included in the latest news section 
on the samba.org homepage.

The other file is just a test file for me to be
able to tell when the script runs again, so I'll
know when it's safe to include the headlines file.

--deryck 


Added:
   trunk/headlines_test.html
Modified:
   trunk/scripts/updateNews.py


Changeset:
Added: trunk/headlines_test.html
===================================================================
--- trunk/headlines_test.html	2004-09-14 16:32:31 UTC (rev 333)
+++ trunk/headlines_test.html	2004-09-15 21:01:59 UTC (rev 334)
@@ -0,0 +1,8 @@
+<!--#include virtual="/samba/header.html" --> 
+  <title>Testing headlines</title>
+<!--#include virtual="/samba/header2.html" -->
+
+<!--#include virtual="/samba/news/headlines.html" -->
+
+
+<!--#include virtual="/samba/footer.html" -->


Property changes on: trunk/headlines_test.html
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/scripts/updateNews.py
===================================================================
--- trunk/scripts/updateNews.py	2004-09-14 16:32:31 UTC (rev 333)
+++ trunk/scripts/updateNews.py	2004-09-15 21:01:59 UTC (rev 334)
@@ -12,7 +12,7 @@
 # calendar dir, so calendar updates are not read as news items.
 #
 
-import os, time
+import os, time, re
 from stat import ST_MTIME
 
 top_dir = '/data/httpd/html/samba/news'      # set to news directory path
@@ -136,3 +136,23 @@
 
 for topic in topics_files.keys():
     archive(topic, topics_files[topic])
+
+    
+# Create headlines for samba.org from last ten news items
+headlines = open('headlines.html', 'w')
+headlines.write('<ul class="news">\n')
+
+for line in open('index.html', 'r').readlines():
+        if '<h3>' in line and len(open('headlines.html', 'r').readlines()) < 10:
+            # Search for text between quotes
+            link = re.search('(?<=\")\S+(?=\")', line)
+            # Search for text between > and </a
+            title = re.search('(?<=\"\>).+(?=\<\/a)', line)
+            headlines = open('headlines.html', 'a')
+            headlines.write('<li><a href="/samba/news/#' + link.group(0) + '">' + title.group(0) + '</a></li>\n')
+        else:
+            continue
+            
+
+headlines = open('headlines.html', 'a')
+headlines.write('</ul>\n')



More information about the samba-cvs mailing list