for post in tree.findall('//row[@PostTypeId="1"]'):
title = post.get('Title')
post_id = int(post.get('Id'))
- url = "https://security.stackexchange.com/questions/{}/".format(post_id)
+ url = "https://stackoverflow.com/questions/{}/".format(post_id)
questions_table[post_id] = dict(title=title, post_id=post_id, url=url)
if parent_post in post_index:
rfcs_table[rfc_id].append(parent_post)
+ # Dedupe.
+ for rfc in rfcs_table:
+ rfcs_table[rfc] = list(set(rfcs_table[rfc]))
+
return rfcs_table
+# The post index is big. Only keep posts which are related to an RFC.
+def optimize_post_index(rfc_index, post_index):
+ posts = [item for sublist in rfc_index.values() for item in sublist]
+ optimized_index = dict()
+
+ for post in posts:
+ if post in post_index:
+ optimized_index[post] = post_index[post]
+
+ return optimized_index
+
+
def main():
if len(sys.argv) != 2:
print "usage: build-index Posts.xml"
+ print "Building tree"
tree = load_posts_file(sys.argv[1])
+
+ print "Building post index"
post_index = build_post_index(tree)
+
+ print "Building RFC index"
rfc_index = build_rfc_index(tree, post_index)
+ print "Building optimized index"
+ optimized_index = optimize_post_index(rfc_index, post_index)
+
+
with open('post_index.json', 'w+') as fd:
- json.dump(post_index, fd, indent=4)
+ json.dump(optimized_index, fd, indent=4)
with open('rfc_index.json', 'w+') as fd:
json.dump(rfc_index, fd, indent=4)
data = lvl2_title_rx.sub(r'\t<a name="section-\1.\2"><h3>\1.\2 \3</h3></a>', data)
lvl1_title_rx = re.compile(r"^(\d+)\.*(.*)$", re.MULTILINE)
- data = lvl1_title_rx.sub(r"""\t<a name="section-\1"><h2>\1. \2 <a href="https://tools.ietf.org/html/{}#section-\1">(raw)</a></h2></a>
+ data = lvl1_title_rx.sub(r"""\t<a name="section-\1"><h2>\1. \2</h2></a>
""".format(html_name), data)
return data
In no specific order, thanks to the IETF, Stackoverflow and their contributors and Jeremy Ashkenas, who created the two column theme I'm using.
</p>
- <h5>Comments, remarks, insults?</h5>
+ <h5>Comments, remarks?</h5>
<p>
- If you've noticed that your favorite RFC isn't rendering correctly, or if you have general remarks,
- don't hesitate to send me an email to karim@rfcspot.com!
+ If you've noticed that your favorite RFC isn't rendering correctly, please open a ticker on the <a href="https://github.com/khamidou/rfcspot/issues">Github repo</a>
+ If you have general remarks, don't hesitate to send me an email to karim@rfcspot.com!
</p>
<p>Copyright {{ date.year }} <a href="http://khamidou.com">Karim Hamidou</a>.</p>