[xiph-cvs] r6748 - in websites-ngen: . news xiph.org
comatoast at xiph.org
comatoast at xiph.org
Sun May 23 21:25:32 PDT 2004
Author: comatoast
Date: 2004-05-24 00:25:31 -0400 (Mon, 24 May 2004)
New Revision: 6748
Added:
websites-ngen/xiph.org/feeds/
Modified:
websites-ngen/news/options.ini
websites-ngen/todo.txt
websites-ngen/wrapup.py
Log:
More progress on the news front. The Atom feed goes to /feeds/atom.xml. Said feed hides fewer bugs.
<p>Modified: websites-ngen/news/options.ini
===================================================================
--- websites-ngen/news/options.ini 2004-05-23 09:48:17 UTC (rev 6747)
+++ websites-ngen/news/options.ini 2004-05-24 04:25:31 UTC (rev 6748)
@@ -1,6 +1,4 @@
-; [Template]
-;; the authorâs first name
-; Author: Nathan
+;[Template]
;; One or more of the following in a space-separated list:
;; general
@@ -8,16 +6,25 @@
;; flac
;; theora
;; icecast
-; Sections: general hidden
+; required:
+; Title
+; Tag Suffix
+;
+;
+
[on2004-04-21at0000]
-Title: Speex 1.1.5 Released
-Author: Nathan
-Sections: speex
+Title = Speex 1.1.5 Released
+Tag Suffix = Speex115
+Sections = speex
+Issued = 2004-05-21T04:09:33Z
+; Modified = (optional)
+Summary = The 1.1.x branch of Speex now has a 1.0.x-compatible API and ABI.
[on2004-04-19at0149]
-Title: Vorbis-Tools Released (fake post)
-Author: Nathan
-Sections: vorbis flac
+Title = Vorbis-Tools Released (fake post)
+Tag Suffix = VorbisToolsReleased
+Sections = vorbis flac
+Summary = A new version of vorbis-tools was released; oggenc now has a FLAC input.
Modified: websites-ngen/todo.txt
===================================================================
--- websites-ngen/todo.txt 2004-05-23 09:48:17 UTC (rev 6747)
+++ websites-ngen/todo.txt 2004-05-24 04:25:31 UTC (rev 6748)
@@ -6,8 +6,7 @@
* Make a new essay (series) for /about/. Or do something other than an essay.
-* Fix the Atom compliance bugs. Make sure that thereâs no way someone could accidentally
- screw up the id element.
+* Finish the news backend.
* What sorts of things should go in Ogg Traffic? The news feed(s)? Press releases?
Iâd say that PRs and OTs should be announced in the news feeds, but should the OTs
@@ -53,10 +52,14 @@
* /about/ (and a new one, please; the current one is dated)
* /donate/
* /subversion/
+ * test with some complete Subversion newbies (including Windows-using people) to make
+ sure the instructions are usable
+ * drop shadows (optional)
+* /colophon/ (URL subject to change; perhaps /about/website/ ?)
* /contact/
* /ogg/ (not much, just spec stuff)
* /vorbis/ (both from xiph.org and vorbis.com)
-* /speex/
+* /speex/ (this one can go in much more easily since I administer it)
* /lists/ (mailing lists)
* /paranoia/ (possibly with much less filler than it has)
* Documentation for the CMS Iâve cobbled together.
Modified: websites-ngen/wrapup.py
===================================================================
--- websites-ngen/wrapup.py 2004-05-23 09:48:17 UTC (rev 6747)
+++ websites-ngen/wrapup.py 2004-05-24 04:25:31 UTC (rev 6748)
@@ -20,13 +20,23 @@
# 3. This notice may not be removed or altered from any source distribution.
import os, re, sys, glob, os.path, time, datetime
+from time import strftime, strptime
import pdb
from ConfigParser import SafeConfigParser
+from sets import Set
MARKDOWN_COMMAND = "perl Markdown.pl" # could also be "perl Markdown.pl"
TITLE_REGEX = re.compile(r"<h1.*>(.*)</h1>")
LANGUAGE_EXTRACTOR = re.compile(r"^.*\.(.{2,5})\..*$") # anything from â.es.â to â.zh-TW.â
+class MissingOptionError(Exception):
+ def __init__(self, option, section):
+ self.option = option
+ self.section = section
+
+ def __str__(self):
+ return "Must define a '%s' in section %s" % (self.option, self.section)
+
class MarkdownWrapper(object):
"""
Important attributes:
@@ -334,15 +344,21 @@
else: return ""
class NewsItem(object):
- def __init__(self, post='', title='', author='', date=None, sections=None):
- self.post = post
- self.title = title
- self.author = author
- self.date = date
- self.sections = sections
+ def __init__(self):
+ self.post = ''
+ self.title = ''
+ self.summary = ''
+ self.tag = ''
+ self.dateCreated = None
+ self.dateIssued = None
+ self.dateModified = None
+ self.sections = Set()
def __cmp__(self, other):
- return cmp(self.date)
+ return cmp(self.dateCreated, other.dateCreated)
+
+def reverser(lhs, rhs): # primarily to sort NewsItems newest-first
+ return -cmp(lhs, rhs)
class NewsDispenser(object):
@@ -352,24 +368,53 @@
config.read(os.path.join("news", "options.ini"))
FILENAME_DATE_FORMAT = "on%Y-%m-%dat%H%M"
+ USUAL_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
self.newsItems = []
-
+ # strftime: format as string; strptime: parse string and get a struct_time
# okay, now we want to go through the sections and associate each with their newspost.
for section in config.sections(): # section is string
ni = NewsItem()
- ni.date = time.strptime(section, FILENAME_DATE_FORMAT)
+ ni.dateCreated = time.strptime(section, FILENAME_DATE_FORMAT)
+ #ni.dateModified = ni.dateIssued = ni.dateCreated #XXX
for key, value in config.items(section):
- if key == 'author':
- ni.author = value
- if key == 'sections':
- ni.sections = value.split()
if key == 'title':
ni.title = value
+
+ if key == 'summary':
+ ni.summary = value
+
+ if key == 'tag suffix':
+ ni.tag = 'tag:xiph.org,%s:%s' % \
+ (time.strftime('%Y-%m-%d', ni.dateCreated), value)
+
+ if key == 'sections':
+ ni.sections = Set(value.split())
+
+ if key == 'issued':
+ ni.dateIssued = time.strptime(value, USUAL_TIME_FORMAT)
+
+ if key == 'modified':
+ ni.dateModified = time.strptime(value, USUAL_TIME_FORMAT)
+
+
+ # now for some error checkingâ¦
+ if not ni.title: raise MissingOptionError('Title', section)
+ if not ni.summary: raise MissingOptionError('Summary', section)
+
+
+ if not ni.tag: raise MissingOptionError('Tag Suffix', section)
+
+ # â¦and some error coveringâ¦
+ if not ni.dateModified:
+ ni.dateModified = ni.dateCreated
+ if not ni.dateIssued:
+ ni.dateIssued = ni.dateCreated
filename = os.path.join('news', section + '.txt')
s = markdown(filename)
ni.post = s
self.newsItems.append(ni)
+ self.newsItems.sort(reverser)
def dump(self):
return self.newsItems[:]
@@ -416,24 +461,30 @@
def formatOne(self, newsItem, index=0):
ret = "<entry>\n"
ret += "<title>" + newsItem.title + "</title>\n"
- # these next two lines are so wrong.
- ret += "<issued>%s</issued>\n" % time.strftime(self.dateFormat, newsItem.date)
- ret += "<modified>%s</modified>\n" % time.strftime(self.dateFormat, newsItem.date)
- ret += "<id>tag:xiph.org,%s:%s</id>" % (time.strftime("%Y", newsItem.date), index)
- ret += "<link rel='alternate' type='text/html' href='http://www.xiph.org/news/'/>\n"
- ret += "<content type='text/html' mode='escaped'><![CDATA["
- ret += newsItem.post
- ret += "]]></content>\n"
- ret += "</entry>"
+ if newsItem.dateCreated:
+ ret += "<created>%s</created>\n" % strftime(self.dateFormat, newsItem.dateCreated)
+ if newsItem.dateIssued:
+ ret += "<issued>%s</issued>\n" % strftime(self.dateFormat, newsItem.dateIssued)
+ if newsItem.dateModified:
+ ret += "<modified>%s</modified>\n" % strftime(self.dateFormat, newsItem.dateModified)
+ ret += "<id>%s</id>\n" % newsItem.tag
+ ret += "<link rel='alternate' type='text/html' href='http://www.xiph.org/news/'/>\n"
+ ret += "<content type='text/html' mode='escaped'><![CDATA["
+ ret += newsItem.post
+ ret += "]]></content>\n"
+ ret += "</entry>"
return ret
def formatAll(self):
ret = ''
ret += "<?xml version='1.0' encoding='utf-8'?>\n" \
- "<feed version='0.3' xmlns='http://purl.org/atom/ns#'>\n" \
- " <title>Xiph.Org News</title>\n" \
- " <link rel='alternate' type='text/html' href='http://www.xiph.org/news/'/>\n" \
- " <modified>2003-12-13T18:30:02Z</modified>\n"
- ret += "<author><name>Xiph.Org Foundation</name></author>"
+ "<feed version='0.3' xmlns='http://purl.org/atom/ns#' xml:lang='en-US'>\n" \
+ "<title>Xiph.Org News</title>\n" \
+ "<link rel='alternate' type='text/html' href='http://www.xiph.org/news/'/>\n" \
+ "<modified>%s</modified>\n" % \
+ strftime(self.dateFormat, self.newsItems[0].dateModified)
+ ret += "<generator>Wrapup</generator>\n" \
+ "<copyright>© %s Xiph.Org Foundation</copyright>\n" % time.gmtime()[0] + \
+ "<author><name>Xiph.Org Foundation</name></author>\n\n"
for index, newsItem in enumerate(self.newsItems):
ret += self.formatOne(newsItem, index) + "\n\n"
@@ -457,9 +508,10 @@
nd = NewsDispenser(os.path.join('news', 'options.ini'))
#print HTMLNewsFormatter(nd.dump()).formatAll()
s = AtomNewsFormatter(nd.dump()).formatAll()
- fh = open('xiph.org\\atom.xml', 'w')
+ fh = open(os.path.join('xiph.org', 'feeds', 'atom.xml'), 'w')
fh.write(s)
fh.close()
if __name__ == '__main__':
+ doNews()
doSite()
<p>Property changes on: websites-ngen/wrapup.py
___________________________________________________________________
Name: svn:mime-type
+ text/plain; charset=UTF-8
--- >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