Skip to content

Instantly share code, notes, and snippets.

@DeusFigendi
Created October 26, 2016 08:08
Show Gist options
  • Save DeusFigendi/8985e7c9cc7e94cdda812d4be017957f to your computer and use it in GitHub Desktop.
Save DeusFigendi/8985e7c9cc7e94cdda812d4be017957f to your computer and use it in GitHub Desktop.
import json
import sys
import mistune
import re
origin_text = open(sys.argv[1],"r").read()
origin_json = json.loads(origin_text)
users_podurl = 'https://'+re.findall('@([^@]+)',origin_json['user']['profile']['diaspora_handle'])[0]
#generate style.css
outputstring = ""
outputstring += "\n.profile .profileimage {"
outputstring += "\n max-width:10em;"
outputstring += "\n display:block;"
outputstring += "\n float:left;"
outputstring += "\n}"
outputstring += "\n.profile .userslanguage {"
outputstring += "\n border:groove;"
outputstring += "\n font-size:2em;"
outputstring += "\n position:relative;"
outputstring += "\n top:-1em;"
outputstring += "\n background-color:white;"
outputstring += "\n}"
outputstring += "\n.profile .username {"
outputstring += "\n display:list-item;"
outputstring += "\n}"
outputstring += "\n.profile .username:before {"
outputstring += '\n content:"Handle: ";'
outputstring += '\n font-weight:bold;'
outputstring += "\n}"
outputstring += "\n.profile .usersemail {"
outputstring += "\n display:list-item;"
outputstring += "\n}"
outputstring += "\n.profile .usersemail:before {"
outputstring += '\n content:"E-Mail: ";'
outputstring += '\n font-weight:bold;'
outputstring += "\n}"
outputstring += "\n.profile .usersgender {"
outputstring += "\n display:list-item;"
outputstring += "\n}"
outputstring += "\n.profile .usersgender:before {"
outputstring += '\n content:"Gender: ";'
outputstring += '\n font-weight:bold;'
outputstring += "\n}"
outputstring += "\n.profile .userslocation {"
outputstring += "\n display:list-item;"
outputstring += "\n}"
outputstring += "\n.profile .userslocation:before {"
outputstring += '\n content:"Location: ";'
outputstring += '\n font-weight:bold;'
outputstring += "\n}"
outputstring += "\n#aspect_contact_crossing {"
outputstring += "\n border-collapse:collapse;"
outputstring += "\n}"
outputstring += "\n#aspect_contact_crossing th .usersname {"
outputstring += "\n display:block;"
outputstring += "\n}"
outputstring += "\n#aspect_contact_crossing th .usershandle {"
outputstring += "\n font-size:0.5em;"
outputstring += "\n}"
outputstring += "\n#aspect_contact_crossing td {"
outputstring += "\n font-size:2em;"
outputstring += "\n text-align:center;"
outputstring += "\n}"
outputstring += "\n#aspect_contact_crossing td, #aspect_contact_crossing th {"
outputstring += "\n border:solid;"
outputstring += "\n}"
outputstring += "\n.col_headline {"
outputstring += "\n height:10em;"
outputstring += "\n}"
outputstring += "\n.col_headline th {"
outputstring += "\n max-width:2em;"
outputstring += "\n position:relative;"
outputstring += "\n top:3em;"
#outputstring += "\n transform-origin: left bottom;"
outputstring += "\n transform: rotate(-90deg);"
outputstring += "\n}"
outputstring += "\n.posting_information li {"
outputstring += "\n display:inline-block;"
outputstring += "\n}"
outputstring += "\n.posting_container {"
outputstring += "\n padding:2em;"
outputstring += "\n margin-right:12em;"
outputstring += "\n border:solid;"
outputstring += "\n}"
outputstring += "\n.comments_table td {"
outputstring += "\n border:solid;"
outputstring += "\n}"
outputstring += "\n.comments_table {"
outputstring += "\n border-collapse: collapse;"
outputstring += "\n}"
outputstring += "\n.comments_table img {"
outputstring += "\n max-width:20em; "
outputstring += "\n}"
outputstring += "\n.comments_table pre {"
outputstring += "\n max-width: 15em;"
outputstring += "\n overflow: scroll;"
outputstring += "\n}"
open('./style.css',"w").write(outputstring)
#generate self.html
outputstring = "<!DOCTYPE html>"
outputstring += "\n<html>"
outputstring += "\n <head>"
outputstring += '\n <meta charset="utf-8">'
outputstring += "\n <title>"+origin_json['user']['name']+"</title>"
outputstring += '\n <link rel="stylesheet" type="text/css" href="style.css">'
outputstring += "\n </head>"
outputstring += "\n <body>"
outputstring += '\n <div class="profile self">'
outputstring += '\n <h1 class="displayname"><span class="first_name">'+origin_json['user']['profile']['first_name']+'</span><span class="last_name">'+origin_json['user']['profile']['last_name']+'</span></h1>'
outputstring += '\n <div>'
outputstring += '\n <span class="userslanguage">'+origin_json['user']['language']+'</span>'
outputstring += '\n <span class="username">'+origin_json['user']['profile']['diaspora_handle']+'</span>'
outputstring += '\n <span class="usersemail">'+origin_json['user']['email']+'</span>'
outputstring += '\n <span class="usersgender">'+origin_json['user']['profile']['gender']+'</span>'
outputstring += '\n <span class="userslocation">'+origin_json['user']['profile']['location']+'</span>'
outputstring += '\n </div>'
outputstring += '\n <img class="profileimage" src="'+origin_json['user']['profile']['image_url']+'" />'
outputstring += '\n <p class="usersbio">'+mistune.markdown(origin_json['user']['profile']['bio'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</p>'
outputstring += '\n </div>'
outputstring += '\n </body>'
outputstring += '\n</html>'
open('./self.html',"w").write(outputstring)
#generating contacts-aspects-table.html
outputstring = "<!DOCTYPE html>"
outputstring += "\n<html>"
outputstring += "\n <head>"
outputstring += '\n <meta charset="utf-8">'
outputstring += "\n <title>Contacts and aspects</title>"
outputstring += '\n <link rel="stylesheet" type="text/css" href="style.css">'
outputstring += "\n </head>"
outputstring += "\n <body>"
outputstring += '\n <table id="aspect_contact_crossing">'
outputstring += '\n <tr class="col_headline">'
outputstring += "\n <th>Name</th>"
outputstring += "\n <th>→</th>"
outputstring += "\n <th>←</th>"
for this_aspect in origin_json['user']['aspects']:
outputstring += "\n <th><span>"+this_aspect['name']+"</span></th>"
outputstring += "\n </tr>"
for this_contact in origin_json['user']['contacts']:
outputstring += "\n <tr>"
outputstring += '\n <th class="row_headline"><span class="usersname">'+this_contact['person_name']+'</span><span class="usershandle">'+this_contact['person_diaspora_handle']+"</span></th>"
if this_contact['sharing']:
outputstring += "\n <td>✔</td>"
else:
outputstring += "\n <td></td>"
if this_contact['receiving']:
outputstring += "\n <td>✔</td>"
else:
outputstring += "\n <td></td>"
if this_contact['receiving']:
for this_aspect1 in origin_json['user']['aspects']:
hookthis = False
for this_aspect2 in this_contact['aspects']:
if this_aspect1['name'] == this_aspect2['name']:
hookthis = True
if hookthis:
outputstring += "\n <td>✔</td>"
else:
outputstring += "\n <td></td>"
outputstring += "\n </tr>"
outputstring += "\n </table>"
outputstring += "\n </body>"
outputstring += "\n</html>"
open('./contacts-aspects-table.html',"w").write(outputstring)
#generate postings.html
temp_list = sorted(origin_json['user']['posts'], key=lambda k: k['created_at'])
origin_json['user']['posts'] = temp_list
if len(origin_json['user']['posts']) < 200:
outputstring = "<!DOCTYPE html>"
outputstring += "\n<html>"
outputstring += "\n <head>"
outputstring += '\n <meta charset="utf-8">'
outputstring += "\n <title>Postings</title>"
outputstring += '\n <link rel="stylesheet" type="text/css" href="style.css">'
outputstring += "\n </head>"
outputstring += "\n <body>"
for this_posting in origin_json['user']['posts']:
outputstring += '\n <div class="posting_container">'
outputstring += '\n <ul class="posting_information">'
outputstring += '\n <li class="likes_count">'+str(this_posting['likes_count'])+'</li>'
outputstring += '\n <li class="comments_count">'+str(this_posting['comments_count'])+'</li>'
outputstring += '\n <li class="reshares_count">'+str(this_posting['reshares_count'])+'</li>'
if this_posting['public']:
outputstring += '\n <li class="public_post">♁</li>'
else:
outputstring += '\n <li class="restricted_post">✗</li>'
if this_posting['type'] == 'Reshare':
outputstring += '\n <li class="reshare_post">₪</li>'
elif this_posting['type'] == 'StatusMessage':
outputstring += '\n <li class="statusmessage_post">☞</li>'
outputstring += '\n </ul>'
outputstring += '\n <div class="creation_date">'+this_posting['created_at']+'</div>'
outputstring += '\n <div class="post_content">'
outputstring += '\n\n\n\n\n\n\n'
outputstring += mistune.markdown(this_posting['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))
outputstring += '\n\n\n\n\n\n\n'
outputstring += '\n </div>'
outputstring += '\n </div>'
outputstring += '\n </body>'
outputstring += '\n</html>'
open('./postings.html',"w").write(outputstring)
else:
post_counter = 0
first_date = 0
last_date = 0
meta_outputstring = '<!DOCTYPE html>\n<html>\n <head>\n <meta charset="utf-8">\n <title>Postings</title>\n <link rel="stylesheet" type="text/css" href="style.css">\n </head>\n <body>\n <ul>'
for this_posting in origin_json['user']['posts']:
if post_counter == 0:
first_date = this_posting['created_at']
outputstring = "<!DOCTYPE html>"
outputstring += "\n<html>"
outputstring += "\n <head>"
outputstring += '\n <meta charset="utf-8">'
outputstring += "\n <title>Postings</title>"
outputstring += '\n <link rel="stylesheet" type="text/css" href="style.css">'
outputstring += "\n </head>"
outputstring += "\n <body>"
outputstring += '\n <div class="posting_container">'
outputstring += '\n <ul class="posting_information">'
outputstring += '\n <li class="likes_count">'+str(this_posting['likes_count'])+'</li>'
outputstring += '\n <li class="comments_count">'+str(this_posting['comments_count'])+'</li>'
outputstring += '\n <li class="reshares_count">'+str(this_posting['reshares_count'])+'</li>'
if this_posting['public']:
outputstring += '\n <li class="public_post">♁</li>'
else:
outputstring += '\n <li class="restricted_post">✗</li>'
if this_posting['type'] == 'Reshare':
outputstring += '\n <li class="reshare_post">₪</li>'
elif this_posting['type'] == 'StatusMessage':
outputstring += '\n <li class="statusmessage_post">☞</li>'
outputstring += '\n </ul>'
outputstring += '\n <div class="creation_date">'+this_posting['created_at']+'</div>'
outputstring += '\n <div class="post_content">'
outputstring += '\n\n\n\n\n\n\n'
outputstring += mistune.markdown(this_posting['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))
outputstring += '\n\n\n\n\n\n\n'
outputstring += '\n </div>'
outputstring += '\n </div>'
post_counter += 1
if post_counter >= 100:
last_date = this_posting['created_at']
post_counter = 0
outputstring += '\n </body>\n</html>'
open('./postings'+this_posting['guid']+'.html',"w").write(outputstring)
meta_outputstring += '\n <li><a href="./postings'+this_posting['guid']+'.html"><span class="start_date">'+first_date+'</span> - <span class="last_date">'+last_date+'</span></li>'
meta_outputstring += '\n </ul>\n </body>\n</html>'
open('./postings.html',"w").write(meta_outputstring)
#generate comments.html
temp_list = sorted(origin_json['user']['comments'], key=lambda k: k['post_guid'])
origin_json['user']['comments'] = temp_list
temp_list = []
last_post_id = "blah"
temp_list2 = []
for this_comment in origin_json['user']['comments']:
if this_comment['post_guid'] != last_post_id:
temp_list.append(temp_list2)
temp_list2 = []
last_post_id = this_comment['post_guid']
temp_list2.append(this_comment)
outputstring = "<!DOCTYPE html>"
outputstring += "\n<html>"
outputstring += "\n <head>"
outputstring += '\n <meta charset="utf-8">'
outputstring += "\n <title>Comments</title>"
outputstring += '\n <link rel="stylesheet" type="text/css" href="style.css">'
outputstring += "\n </head>"
outputstring += "\n <body>"
outputstring += '\n <table class="comments_table">'
for comment_group in temp_list:
if len(comment_group) >= 1:
outputstring += "\n <tr>"
outputstring += '\n <th><a href="'+users_podurl+'/posts/'+comment_group[0]['post_guid']+'">p o s t</a></th>'
if len(comment_group) == 1:
outputstring += '\n <td colspan="12">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 2:
outputstring += '\n <td colspan="6">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="6">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 3:
outputstring += '\n <td colspan="4">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="4">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="4">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 4:
outputstring += '\n <td colspan="3">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="3">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="3">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="3">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 5:
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="3">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="3">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 6:
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 7:
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[6]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) == 8:
outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[6]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[7]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# elif len(comment_group) == 9:
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[6]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[7]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[8]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# elif len(comment_group) == 10:
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[6]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[7]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[8]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[9]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# elif len(comment_group) == 11:
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="2">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[6]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[7]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[8]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[9]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[10]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# elif len(comment_group) == 12:
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[0]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[1]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[2]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[3]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[4]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[5]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[6]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[7]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[8]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[9]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[10]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
# outputstring += '\n <td colspan="1">'+mistune.markdown(comment_group[11]['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))+'</td>'
elif len(comment_group) > 8:
outputstring += '\n <td colspan="12">'
for this_comment in comment_group:
outputstring += '\n <div class="too_many_comments">'
outputstring += '\n\n\n\n\n'
outputstring += mistune.markdown(this_comment['text'].replace('\n#','\n\\#').replace('\n\\# ','\n# ').replace('\n\\## ','\n## ').replace('\n\\### ','\n### ').replace('\n\\#### ','\n#### '))
outputstring += '\n\n\n\n\n'
outputstring += '\n <div>'
outputstring += '\n </td>'
if len(comment_group) >= 1:
outputstring += '\n </tr>'
if len(comment_group) >= 7:
outputstring += '\n </table>'
outputstring += '\n <table class="comments_table">'
outputstring += "\n </table>"
outputstring += '\n </body>'
outputstring += '\n</html>'
open('./comments.html',"w").write(outputstring)
#and some kind of table of content…
outputstring = "<!DOCTYPE html>"
outputstring += "\n<html>"
outputstring += "\n <head>"
outputstring += '\n <meta charset="utf-8">'
outputstring += "\n <title>"+origin_json['user']['name']+"</title>"
outputstring += '\n <link rel="stylesheet" type="text/css" href="style.css">'
outputstring += "\n </head>"
outputstring += "\n <body>"
outputstring += "\n <h1>Table of Content</h1>"
outputstring += "\n <ul>"
outputstring += '\n <li><a href="./self.html">'+origin_json['user']['profile']['first_name']+'s Profile</a></li>'
outputstring += '\n <li><a href="./contacts-aspects-table.html">Contacts and Aspects</a></li>'
outputstring += '\n <li><a href="./postings.html">Postings</a></li>'
outputstring += '\n <li><a href="./comments.html">All Comments '+origin_json['user']['name']+' ever wrote.</a></li>'
outputstring += "\n </ul>"
outputstring += "\n </body>"
outputstring += "\n</html>"
open('./index.html',"w").write(outputstring)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment