|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83183 - in website/public_html/live: . site-tools/boost_site
From: dnljms_at_[hidden]
Date: 2013-02-27 04:08:56
Author: danieljames
Date: 2013-02-27 04:08:55 EST (Wed, 27 Feb 2013)
New Revision: 83183
URL: http://svn.boost.org/trac/boost/changeset/83183
Log:
Website: Merge second part of rss change.
Properties modified:
website/public_html/live/ (props changed)
Text files modified:
website/public_html/live/site-tools/boost_site/pages.py | 37 -----------------
website/public_html/live/site-tools/boost_site/site_tools.py | 1
website/public_html/live/site-tools/boost_site/upgrade.py | 82 ++-------------------------------------
3 files changed, 8 insertions(+), 112 deletions(-)
Modified: website/public_html/live/site-tools/boost_site/pages.py
==============================================================================
--- website/public_html/live/site-tools/boost_site/pages.py (original)
+++ website/public_html/live/site-tools/boost_site/pages.py 2013-02-27 04:08:55 EST (Wed, 27 Feb 2013)
@@ -10,7 +10,7 @@
""" Tracks which items in an rss feed have been updated.
Stores meta data about the quickbook file, including the signature
- of the quickbook file and the rss item.
+ of the quickbook file.
"""
def __init__(self, hash_file):
self.hash_file = hash_file
@@ -18,16 +18,11 @@
# Map of quickbook filename to Page
self.pages = {}
- # Map of rss hash to quickbook filename
- self.rss_hashes = {}
-
if(os.path.isfile(hash_file)):
hashes = boost_site.state.load(hash_file)
for qbk_file in hashes:
record = hashes[qbk_file]
self.pages[qbk_file] = Page(qbk_file, record)
- if(record.get('rss_hash')):
- self.rss_hashes[record['rss_hash']] = qbk_file
def save(self):
save_hashes = {}
@@ -68,32 +63,6 @@
if record.type not in ['release', 'page']:
throw ("Unknown record type: " + record.type)
- # You might be wondering why I didn't just save the rss items - would
- # be able to save all the items not just the ones in the feed.
- # I mostly wanted to minimise the amount of stuff that was checked in
- # to subversion with each change.
- def load_rss(self, rss_file, xml_doc):
- rss_items = {}
-
- if(os.path.isfile(rss_file)):
- rss = xml.dom.minidom.parse(rss_file)
- for item in rss.getElementsByTagName('item'):
- hashed = hash_dom_node(item)
- if hashed in self.rss_hashes:
- rss_items[self.rss_hashes[hashed]] = {
- 'quickbook': self.rss_hashes[hashed],
- 'item': xml_doc.importNode(item, True),
- 'last_modified': self.pages[self.rss_hashes[hashed]].last_modified
- }
- else:
- print("Unable to find quickbook file for rss item:")
- print(hashed)
-
- return rss_items
-
- def add_rss_item(self, item):
- self.pages[item['quickbook']].rss_hash = hash_dom_node(item['item'])
-
def convert_quickbook_pages(self, refresh = False):
try:
subprocess.check_call(['quickbook', '--version'])
@@ -197,7 +166,6 @@
self.download_item = attrs.get('download')
self.documentation = attrs.get('documentation')
self.qbk_hash = attrs.get('qbk_hash')
- self.rss_hash = attrs.get('rss_hash')
self.loaded = False
@@ -239,8 +207,7 @@
'pub_date': self.pub_date,
'download': self.download_item,
'documentation': self.documentation,
- 'qbk_hash': self.qbk_hash,
- 'rss_hash': self.rss_hash
+ 'qbk_hash': self.qbk_hash
}
def load(self, values, refresh = False):
Modified: website/public_html/live/site-tools/boost_site/site_tools.py
==============================================================================
--- website/public_html/live/site-tools/boost_site/site_tools.py (original)
+++ website/public_html/live/site-tools/boost_site/site_tools.py 2013-02-27 04:08:55 EST (Wed, 27 Feb 2013)
@@ -77,7 +77,6 @@
if qbk_page.loaded:
item = generate_rss_item(qbk_page.qbk_file, qbk_page)
- pages.add_rss_item(item)
item['item'] = item['item'].toxml('utf-8').decode('utf-8')
rss_items[qbk_page.qbk_file] = item
Modified: website/public_html/live/site-tools/boost_site/upgrade.py
==============================================================================
--- website/public_html/live/site-tools/boost_site/upgrade.py (original)
+++ website/public_html/live/site-tools/boost_site/upgrade.py 2013-02-27 04:08:55 EST (Wed, 27 Feb 2013)
@@ -9,82 +9,12 @@
# Upgrades
#
-def upgrade1():
- pages = boost_site.site_tools.load_pages()
- for qbk_file in pages.pages:
- page = pages.pages[qbk_file]
- if re.match('users/(download|history)', page.location) and \
- page.pub_date != 'In Progress':
- page.flags.add('released')
- pages.save()
- return True
-
-def upgrade2():
- pages = boost_site.site_tools.load_pages()
- for qbk_file in pages.pages:
- page = pages.pages[qbk_file]
- if re.match('users/(download|history)', page.location) and \
- page.pub_date != 'In Progress':
- page.type = 'release'
- else:
- page.type = 'page'
- pages.save()
- return True
-
-def upgrade3():
- pages_raw = boost_site.state.load('generated/state/feed-pages.txt')
- for page in pages_raw:
- page_details = pages_raw[page]
- flags = page_details['flags']
- flags = set(page_details['flags'].split(','))
- if '' in flags:
- flags.remove('')
- type = page_details['type']
- if type == 'release':
- if 'released' in flags:
- page_details['release_status'] = 'released'
- flags.remove('released')
- elif 'beta' in flags:
- page_details['release_status'] = 'beta'
- flags.remove('beta')
- else:
- page_details['release_status'] = None
- if len(flags) != 0:
- raise Exception("Unexpected flags: " + str(flags))
- del page_details['flags']
- boost_site.state.save(pages_raw, 'generated/state/feed-pages.txt')
- return True
-
-def upgrade4():
- """
- Save all the rss entries to a state file.
- Will remove the rss hashes soon, which should improve some the
- rss handling a bit.
- """
- import xml.dom.minidom
- from boost_site.settings import settings
-
- pages = boost_site.site_tools.load_pages()
-
- # Load RSS items from feeds.
- old_rss_items_doc = xml.dom.minidom.parseString('''<items></items>''')
- old_rss_items = {}
- for feed_file in settings['feeds']:
- old_rss_items.update(pages.load_rss(feed_file, old_rss_items_doc))
-
- # Convert items to text (TODO: Should I support XML in state files?)
- for file in old_rss_items:
- old_rss_items[file]['item'] = old_rss_items[file]['item'].toxml('utf-8').decode('utf-8')
-
- boost_site.state.save(old_rss_items, 'generated/state/rss-items.txt')
- return True
-
-versions = [
- upgrade1,
- upgrade2,
- upgrade3,
- upgrade4
- ]
+def upgrade_old():
+ print "Old, unsupported data version."
+ return False
+
+versions = [upgrade_old] * 4
+versions.extend([])
#
# Implementation
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk