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

giles at dactyl.lonelymoon.com giles
Sun Jun 6 13:10:30 PDT 2004


Author: giles
Date: Sun Jun  6 13:10:30 2004
New Revision: 6808

Modified:
websites-ngen/wrapup.py
websites-ngen/xiph.org/vorbis/Error/404/
Log:
Recommit changes lost in server migration.
original commit (r6808) 2004-06-03 00:22:44 -0400 (Thu, 03 Jun 2004) by comatoast

* 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-06 02:59:04 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)



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




More information about the commits mailing list