From: Karim Hamidou
Date: Sun, 20 Mar 2016 19:53:05 +0000 (-0700)
Subject: general wording.
X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=f667908e0a4764ceb04c97e111b951385b29d13a;p=rfcspot.git
general wording.
---
diff --git a/requirements.txt b/requirements.txt
index da9da8b6..54d12397 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,3 +2,4 @@ jinja2==2.8
flask==0.10.1
gevent==1.1.0
gunicorn==19.4.5
+lxml==3.6.0
diff --git a/src/build-index.py b/src/build-index.py
index fef824fa..18ae75f7 100644
--- a/src/build-index.py
+++ b/src/build-index.py
@@ -26,7 +26,7 @@ def build_post_index(tree):
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)
@@ -51,19 +51,44 @@ def build_rfc_index(tree, post_index):
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)
diff --git a/src/render_rfc.py b/src/render_rfc.py
index 167ea4f9..ef3c3356 100644
--- a/src/render_rfc.py
+++ b/src/render_rfc.py
@@ -134,7 +134,7 @@ def anchor_titles(data, **kwargs):
data = lvl2_title_rx.sub(r'\t\1.\2 \3
', data)
lvl1_title_rx = re.compile(r"^(\d+)\.*(.*)$", re.MULTILINE)
- data = lvl1_title_rx.sub(r"""\t
+ data = lvl1_title_rx.sub(r"""\t\1. \2
""".format(html_name), data)
return data
diff --git a/templates/index.html b/templates/index.html
index 5ceb3967..61d5f056 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -49,10 +49,10 @@
In no specific order, thanks to the IETF, Stackoverflow and their contributors and Jeremy Ashkenas, who created the two column theme I'm using.
- Comments, remarks, insults?
+ Comments, remarks?
- 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 Github repo
+ If you have general remarks, don't hesitate to send me an email to karim@rfcspot.com!
Copyright {{ date.year }} Karim Hamidou.