[xiph-cvs] r6808 - in websites-ngen: . xiph.org/vorbis/Error/404

comatoast at xiph.org comatoast at xiph.org
Wed Jun 2 21:22:44 PDT 2004



Author: comatoast
Date: 2004-06-03 00:22:44 -0400 (Thu, 03 Jun 2004)
New Revision: 6808

Modified:
   websites-ngen/wrapup.py
   websites-ngen/xiph.org/vorbis/Error/404/
Log:
* Added in top-level support for the news posts where the number is limited to 15 posts at a time. It still needs some formatting work, though.
* Generated HTML files: It's about suppression.

Modified: websites-ngen/wrapup.py
===================================================================
--- websites-ngen/wrapup.py	2004-06-02 19:34:14 UTC (rev 6807)
+++ websites-ngen/wrapup.py	2004-06-03 04:22:44 UTC (rev 6808)
@@ -413,7 +413,6 @@
         def formatOne(self, newsItem): pass
 
 class HTMLNewsFormatter(NewsFormatter):
-	""" This is just one HTML news formatter of possibly many, really."""
         def __init__(self, newsItems, dateFormat="%A, %B %d, %Y"):
                 NewsFormatter.__init__(self, newsItems)
                 self.newsItems = newsItems
@@ -453,20 +452,32 @@
                 
                 
         def formatOne(self, newsItem, headingLevel=1):
+		reg = re.compile(r'^http://www.xiph.org(.*)$')
+		m = reg.match(newsItem.url)
+		url = m.groups(1)
+
                 ret =  "<div class='newsEntry'>\n"
                 ret += " <h%s>%s</h%s>\n" % (headingLevel, newsItem.title, headingLevel)
                 ret +=  newsItem.post[:]
                 ret += " <div class='postInfo'>Posted %s (<a href='%s'>permalink</a>)</div>\n" % \
-			    (time.strftime(self.dateFormat, newsItem.dateIssued), newsItem.url)
+			    (time.strftime(self.dateFormat, newsItem.dateIssued), url)
                 ret += "</div>\n\n"
 
                 return ret
         
-	def format(self):
+	def format(self, howMany=0):
+		"""Formats all in the series if howMany is 0; formats and returns that many otherwise."""
                 ret = ''
-		for ni in self.newsItems:
-			ret += self.formatOne(ni)
-		return ret
+		items = self.dispenser.items()
+		# lame way of coding, but what the hey
+		if howMany == 0:
+			for ni in items:
+				ret += self.formatOne(ni)
+			return ret
+		else:
+			for ni in items[:min(howMany, len(items))]:
+				ret += self.formatOne(ni)
+			return ret
 
 class AtomNewsFormatter(NewsFormatter):
         def __init__(self, newsItems):
@@ -707,7 +718,17 @@
                                         fh.close()
 
                 def toplevel(formatter):
-			pass
+			howManyOnFrontPage = len(formatter.dispenser.items())
+			if howManyOnFrontPage > 5:
+				howManyOnFrontPage = 5
+			for item in formatter.dispenser.items()[:howManyOnFrontPage]:
+				destPath = os.path.join('xiph.org', 'news', 'index.markdown')
+				fh = open(destPath, 'w')
+				try:
+					fh.write(formatter.format(howManyOnFrontPage))
+				finally:
+					fh.close()
+				
 
                 formatter = HTMLNewsFormatter(newsDispenser)
                 

<p>Property changes on: websites-ngen/xiph.org/vorbis/Error/404
___________________________________________________________________
Name: svn:ignore
   + index.html

<p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list