]> khamidou — GitHub mirrors - rfcspot.git/commitdiff
general wording.
authorKarim Hamidou <khamidou@gmail.com>
Sun, 20 Mar 2016 19:53:05 +0000 (12:53 -0700)
committerKarim Hamidou <khamidou@gmail.com>
Sun, 20 Mar 2016 19:53:05 +0000 (12:53 -0700)
requirements.txt
src/build-index.py
src/render_rfc.py
templates/index.html

index da9da8b620210ef808baac67441e1f0a6c0ee522..54d123979fabd95981fa70cd8a8aacc8f779d95e 100644 (file)
@@ -2,3 +2,4 @@ jinja2==2.8
 flask==0.10.1
 gevent==1.1.0
 gunicorn==19.4.5
+lxml==3.6.0
index fef824fab7efc79bea5fb15865c5ae17997f93e3..18ae75f7ad5c86c68975bd5912423ef5eacef5b5 100644 (file)
@@ -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)
index 167ea4f910da714f64abbff5707fb0b0bbfdf40c..ef3c3356ac5d6f063dcd351235787961a041507c 100644 (file)
@@ -134,7 +134,7 @@ def anchor_titles(data, **kwargs):
     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
index 5ceb396754d543c0fa5ed0cfd7999a4aa3a24ea1..61d5f056376027e5cfd13309081e0d5c7172831a 100644 (file)
             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>