diff --git a/voussoir.net/writing/dark.css b/voussoir.net/writing/dark.css index 8510a63..b44d17c 100644 --- a/voussoir.net/writing/dark.css +++ b/voussoir.net/writing/dark.css @@ -44,6 +44,10 @@ article padding: 16px; background-color: var(--color_bodybg); } +article address +{ + font-style: normal; +} @media not print { article @@ -252,7 +256,7 @@ https://github.com/richleland/pygments-css .highlight .nf { color: var(--color_monokai_green) } /* Name.Function */ .highlight .nl { color: var(--color_monokai_white) } /* Name.Label */ .highlight .nn { color: var(--color_monokai_white) } /* Name.Namespace */ -.highlight .nx { color: var(--color_monokai_green) } /* Name.Other */ +.highlight .nx { color: var(--color_monokai_white) } /* Name.Other */ .highlight .py { color: var(--color_monokai_white) } /* Name.Property */ .highlight .nt { color: var(--color_monokai_pink) } /* Name.Tag */ .highlight .nv { color: var(--color_monokai_white) } /* Name.Variable */ diff --git a/voussoir.net/writing/generate_site.py b/voussoir.net/writing/generate_site.py index b9b51cb..c0b8ef3 100644 --- a/voussoir.net/writing/generate_site.py +++ b/voussoir.net/writing/generate_site.py @@ -10,6 +10,7 @@ import re import subprocess import vmarkdown +from voussoirkit import dotdict from voussoirkit import pathclass from voussoirkit import spinal from voussoirkit import winwhich @@ -20,20 +21,6 @@ WRITING_ROOTDIR = pathclass.Path(__file__).parent GIT = winwhich.which('git') -ARTICLE_TEMPLATE = ''' -[Back to writing](/writing) - -{body} - ---- - -[View this document's history]({github_history}) - -{commits} - -Contact me: writing@voussoir.net -''' - # HELPERS ################################################################################ def check_output(command): @@ -87,7 +74,7 @@ def git_file_edited_date(path) -> datetime.datetime: date = check_output(command) if date: date = dateutil.parser.parse(date) - date = date.astimezone(datetime.timezone.utc) + # date = date.astimezone(datetime.timezone.utc) return date else: return datetime.datetime.now(datetime.timezone.utc) @@ -107,16 +94,24 @@ def git_file_commit_history(path): '-C', repo.absolute_path, 'log', '--follow', - '--pretty=format:%H %ad %s', - '--date=short', + '--pretty=format:%H///%ad///%s', + '--date=iso', '--', path, ] output = check_output(command) lines = [line for line in output.splitlines() if line.strip()] #'*' in line] - lines = [re.sub(r'([\*\_\[\]\(\)\^])', r'\\\1', line) for line in lines] - lines = [line.split(' ', 1) for line in lines] - return lines + lines = [line.split('///', 2) for line in lines] + commits = [] + for (commit_hash, date, title) in lines: + commit = dotdict.DotDict({ + 'hash': commit_hash, + 'date': dateutil.parser.parse(date), + 'title': title, + }) + commits.append(commit) + commits.sort(key=lambda commit: commit.date, reverse=True) + return commits def git_file_published_date(path) -> datetime.datetime: ''' @@ -139,7 +134,7 @@ def git_file_published_date(path) -> datetime.datetime: date = check_output(command) if date: date = dateutil.parser.parse(date) - date = date.astimezone(datetime.timezone.utc) + # date = date.astimezone(datetime.timezone.utc) return date else: return datetime.datetime.now(datetime.timezone.utc) @@ -221,25 +216,33 @@ class Article: github_history = f'https://github.com/voussoir/voussoir.net/commits/master/{relative_path}' commits = git_file_commit_history(self.md_file) - self.publication_id = f'{commits[-1][0]}/{self.md_file.parent.basename}' if commits else None + self.publication_id = f'{commits[-1].hash}/{self.md_file.parent.basename}' if commits else None - commits = [ - f'- [{html.escape(line)}](https://github.com/voussoir/voussoir.net/commit/{hash})' - for (hash, line) in commits - ] - commits = '\n'.join(commits) - - md = vmarkdown.cat_file(self.md_file.absolute_path) - md = ARTICLE_TEMPLATE.format( - body=md, - github_history=github_history, - commits=commits, - ) self.soup = vmarkdown.markdown( - md, + self.md_file.read('r', encoding='utf-8'), css=WRITING_ROOTDIR.with_child('dark.css').absolute_path, return_soup=True, ) + header = jinja2.Template(''' +
+ ''').render() + footer = jinja2.Template(''' +