diff --git a/timesearch/offline_reading.py b/timesearch/offline_reading.py
index 968074b..62d1470 100644
--- a/timesearch/offline_reading.py
+++ b/timesearch/offline_reading.py
@@ -5,6 +5,71 @@ from . import common
from . import tsdb
+HTML_HEADER = '''
+
+
+
+
+
+
+
+
+'''.strip()
+HTML_FOOTER = '\n'
+
+HTML_COMMENT = '''
+
+'''.strip()
+
+HTML_SUBMISSION = '''
+
+ {usernamelink}
+
| {score} points
+
| {human}
+
+
+
{title}
+
{url_or_text}
+
+
+ {permalink}
+
+
+{{children}}
+'''.strip()
+
+
class DBEntry:
def __init__(self, fetch):
if fetch[1].startswith('t3_'):
@@ -101,64 +166,18 @@ class TreeNode:
yield from child.walk(customsort=customsort)
def html_format_comment(comment):
- text = '''
-
- '''.format(
+ text = HTML_COMMENT.format(
id=comment.idstr,
body=sanitize_braces(render_markdown(comment.body)),
usernamelink=html_helper_userlink(comment),
score=comment.score,
human=common.human(comment.created),
permalink=html_helper_permalink(comment),
- children='{children}',
)
return text
def html_format_submission(submission):
- text = '''
-
-
-
- {usernamelink}
- | {score} points
- | {human}
-
-
-
{title}
-
{url_or_text}
-
-
- {permalink}
-
-
- {children}
- '''.format(
+ text = HTML_SUBMISSION.format(
id=submission.idstr,
title=sanitize_braces(submission.title),
usernamelink=html_helper_userlink(submission),
@@ -166,7 +185,6 @@ def html_format_submission(submission):
human=common.human(submission.created),
permalink=html_helper_permalink(submission),
url_or_text=html_helper_urlortext(submission),
- children='{children}',
)
return text
@@ -193,9 +211,9 @@ def html_from_database(subreddit=None, username=None, specific_submission=None):
html_basename = '%s.html' % submission_tree.identifier
html_filepath = database.offline_reading_dir.with_child(html_basename)
html_handle = open(html_filepath.absolute_path, 'w', encoding='utf-8')
- html_handle.write('')
+ html_handle.write(HTML_HEADER)
html_handle.write(page)
- html_handle.write('')
+ html_handle.write(HTML_FOOTER)
html_handle.close()
print('Wrote', html_filepath.relative_path)
{body}
+ ++ {permalink} +
+{{children}} +