-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config option on whether to enable Jekyll output. #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
md_index = None | ||
last_updated_dir = None | ||
last_updated_file = None | ||
jekyll_output = True | ||
|
||
def read_config(): | ||
global client | ||
|
@@ -58,8 +59,9 @@ def read_config(): | |
global md_index | ||
global last_updated_dir | ||
global last_updated_file | ||
global jekyll_output | ||
|
||
def get_config(section: str, key: str, default_value: Optional[str]=None) -> Optional[str]: | ||
def get_config(section: str, key: str, default_value: Optional[str] = None) -> Optional[str]: | ||
if config_file.has_option(section, key): | ||
return config_file.get(section, key) | ||
return default_value | ||
|
@@ -107,6 +109,9 @@ def get_config(section: str, key: str, default_value: Optional[str]=None) -> Opt | |
last_updated_dir = Path("_includes") # directory to store update timestamp | ||
last_updated_file = Path("archive_update.html") # filename for update timestamp | ||
|
||
# Whether to emit output in Jekyll format | ||
if config_file.has_option('archive', 'jekyll_output'): | ||
jekyll_output = config_file.getboolean('archive', 'jekyll_output') | ||
|
||
## Customizable display functions. | ||
|
||
|
@@ -141,7 +146,8 @@ def write_stream_index(streams): | |
sanitize_stream(s, streams[s]['id']), | ||
num_topics, | ||
'' if num_topics == 1 else 's')) | ||
outfile.write('\n{% include ' + str(last_updated_file) + ' %}') | ||
if jekyll_output: | ||
outfile.write('\n{% include ' + str(last_updated_file) + ' %}') | ||
outfile.close() | ||
|
||
# writes the Jekyll header info for the index page for a given stream. | ||
|
@@ -171,7 +177,8 @@ def write_topic_index(stream_name, stream): | |
datetime.utcfromtimestamp(t['latest_date']).strftime('%b %d %Y at %H:%M'), | ||
'' if t['size'] == 1 else 's' | ||
)) | ||
outfile.write('\n{% include ' + str(last_updated_file) + ' %}') | ||
if jekyll_output: | ||
outfile.write('\n{% include ' + str(last_updated_file) + ' %}') | ||
outfile.close() | ||
|
||
# formats the header for a topic page. | ||
|
@@ -230,10 +237,12 @@ def write_topic(stream_name, stream, topic_name): | |
f.close() | ||
o = open_outfile(md_root / Path(sanitize_stream(stream_name, stream['id'])), Path(sanitize_topic(topic_name) + '.html'), 'w+') | ||
write_topic_header(o, stream_name, stream['id'], topic_name) | ||
o.write('\n{% raw %}\n') | ||
if jekyll_output: | ||
o.write('\n{% raw %}\n') | ||
write_topic_body(messages, stream_name, stream['id'], topic_name, o) | ||
o.write('\n{% endraw %}\n') | ||
o.write('\n{% include ' + str(last_updated_file) + ' %}') | ||
if jekyll_output: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mark-Simulacrum is this what you wanted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer that in non-Jekyll mode we literally include the contents instead of via an include statement. That does mean that all of the files will change on each run, but that's true if you render through jekyll to a static site anyway. |
||
o.write('\n{% endraw %}\n') | ||
o.write('\n{% include ' + str(last_updated_file) + ' %}') | ||
o.close() | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mark-Simulacrum what you want is for the
{%include ... %}
directive to be removed, right? Do you still want thelast_updated_file
info be in the output somehow?