From bd403e6ab18d5cc7818e86d43c3ca0b15c5e53a1 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Thu, 18 Sep 2025 23:17:24 +0200 Subject: g2h: Add navbar --- g2h/cli.py | 5 +++-- g2h/commit_page.py | 3 ++- g2h/file_page.py | 1 + g2h/log_page.py | 6 ++++-- g2h/overview_page.py | 3 ++- g2h/page_factory.py | 4 ++-- g2h/tree_page.py | 1 + 7 files changed, 15 insertions(+), 8 deletions(-) (limited to 'g2h') diff --git a/g2h/cli.py b/g2h/cli.py index 6ffabb0..3f60b82 100644 --- a/g2h/cli.py +++ b/g2h/cli.py @@ -22,13 +22,14 @@ def main(): branches = sorted(git.get_branches(), key=lambda b: b.commit.committed_date, reverse=True) commits = git.get_commits() + head = git.get_head() # TODO: Fix this for repo_path=(.|~) project_name = args.name if args.name is not None else os.path.basename(args.repo_path) tags = sorted(git.get_tags(), key=lambda t: t.commit.committed_date, reverse=True) factory = PageFactory(args.out_dir, project_name, args.content_subdir) - factory.new_overview(branches, tags, git.get_head()).render() - factory.new_log(commits, branches, tags).render() + factory.new_overview(branches, tags, head).render() + factory.new_log(commits, branches, tags, head).render() for commit in commits: factory.new_commit(commit).render() tree = factory.new_tree(commit, '', git.get_repo()) diff --git a/g2h/commit_page.py b/g2h/commit_page.py index 03d74ab..84374e6 100644 --- a/g2h/commit_page.py +++ b/g2h/commit_page.py @@ -31,5 +31,6 @@ class CommitPage(Page): 'commit': self.commit, 'title': self.name + ': ' + self.commit.hexsha, 'redacted_email': redact_email(self.commit.author.email), - 'content_subdir': self.content_subdir + 'content_subdir': self.content_subdir, + 'this_commit': self.commit } diff --git a/g2h/file_page.py b/g2h/file_page.py index 67ddf6d..a558254 100644 --- a/g2h/file_page.py +++ b/g2h/file_page.py @@ -42,5 +42,6 @@ class FilePage(Page): 'content_subdir': self.content_subdir, 'file_extension': os.path.splitext(self.file_name)[1].lstrip('.'), 'title': self.name + ': ' + self.file_name, + 'this_commit': self.commit, 'type': file_type } diff --git a/g2h/log_page.py b/g2h/log_page.py index 4b8ee10..b8df839 100644 --- a/g2h/log_page.py +++ b/g2h/log_page.py @@ -13,11 +13,12 @@ def ref_names_for_commit(refs, commit_sha): return ref_names class LogPage(Page): - def __init__(self, out_dir, name, commits, branches, tags, content_subdir): + def __init__(self, out_dir, name, commits, branches, tags, content_subdir, latest_commit): super(LogPage, self).__init__('log.md', out_dir, 'l.md', name, content_subdir) self.commits = commits self.branches = branches self.tags = tags + self.latest_commit = latest_commit def _commits_with_refs(self): commits_context = [] @@ -40,6 +41,7 @@ class LogPage(Page): return { 'commits': commits_context, 'content_subdir': self.content_subdir, - 'title': self.name + ': Log' + 'title': self.name + ': Log', + 'this_commit': self.latest_commit } diff --git a/g2h/overview_page.py b/g2h/overview_page.py index 0363494..145a8d7 100644 --- a/g2h/overview_page.py +++ b/g2h/overview_page.py @@ -13,6 +13,7 @@ class OverviewPage(Page): 'content_subdir': self.content_subdir, 'latest_commit_date': self.latest_commit.committed_datetime, 'tags': self.tags, - 'title': self.name + 'title': self.name, + 'this_commit': self.latest_commit } diff --git a/g2h/page_factory.py b/g2h/page_factory.py index 82e2b0f..4a46f14 100644 --- a/g2h/page_factory.py +++ b/g2h/page_factory.py @@ -23,8 +23,8 @@ class PageFactory: def new_overview(self, branches, tags, head): return OverviewPage(self.out_dir, self.name, branches, tags, self.content_subdir, head) - def new_log(self, commits, branches, tags): - return LogPage(self.out_dir, self.name, commits, branches, tags, self.content_subdir) + def new_log(self, commits, branches, tags, head): + return LogPage(self.out_dir, self.name, commits, branches, tags, self.content_subdir, head) def new_tree(self, commit, tree_segment, repo): return TreePage(self.out_dir, self.name, commit, tree_segment, repo, self.content_subdir) diff --git a/g2h/tree_page.py b/g2h/tree_page.py index c36212c..df65a33 100644 --- a/g2h/tree_page.py +++ b/g2h/tree_page.py @@ -46,6 +46,7 @@ class TreePage(Page): 'entries': self._get_entries(), # TODO: Make this fit the rest of the system. 'subdir': '/'.join([self.content_subdir, tree_join(self.commit, self.tree.path)]), + 'this_commit': self.commit, 'title': self.name + ': Tree' } -- cgit v1.2.3