summaryrefslogtreecommitdiffstats
path: root/g2h/commit_page.py
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-09-19 19:21:11 +0200
committerChristoph Schlosser <christoph@linux.com>2025-09-19 19:21:11 +0200
commita3324b7e71ec48daab81981e7d85967a590d4f79 (patch)
treedef4a8d901d9a56047a0e63f5f3d93803c93ee87 /g2h/commit_page.py
parentbd403e6ab18d5cc7818e86d43c3ca0b15c5e53a1 (diff)
downloadgit2hugo-a3324b7e71ec48daab81981e7d85967a590d4f79.tar.gz
g2h: Add utility script
Also move the sources into the more conventional src/g2h dir
Diffstat (limited to 'g2h/commit_page.py')
-rw-r--r--g2h/commit_page.py36
1 files changed, 0 insertions, 36 deletions
diff --git a/g2h/commit_page.py b/g2h/commit_page.py
deleted file mode 100644
index 84374e6..0000000
--- a/g2h/commit_page.py
+++ /dev/null
@@ -1,36 +0,0 @@
-import os
-
-from .page import Page
-
-def _redact_local_segment(local_segment):
- if len(local_segment) == 0:
- return ''
- if len(local_segment) < 6:
- return local_segment[0] + '...'
- return local_segment[:2] + '...'
-
-def redact_email(email):
- if email is None or len(email) == 0:
- return ''
-
- if '@' not in email:
- return _redact_local_segment(email)
-
- local, domain = email.split('@')
- redacted_local = _redact_local_segment(local)
-
- return redacted_local + '@' + domain
-
-class CommitPage(Page):
- def __init__(self, out_dir, name, commit, content_subdir):
- super(CommitPage, self).__init__('commit.md', out_dir, os.path.join(commit.hexsha, '_index.md'), name, content_subdir)
- self.commit = commit
-
- def context(self):
- return {
- 'commit': self.commit,
- 'title': self.name + ': ' + self.commit.hexsha,
- 'redacted_email': redact_email(self.commit.author.email),
- 'content_subdir': self.content_subdir,
- 'this_commit': self.commit
- }