summaryrefslogtreecommitdiffstats
path: root/src/g2h/page_factory.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 /src/g2h/page_factory.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 'src/g2h/page_factory.py')
-rw-r--r--src/g2h/page_factory.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/g2h/page_factory.py b/src/g2h/page_factory.py
new file mode 100644
index 0000000..4a46f14
--- /dev/null
+++ b/src/g2h/page_factory.py
@@ -0,0 +1,30 @@
+import os
+
+from .commit_page import CommitPage
+from .file_page import FilePage
+from .overview_page import OverviewPage
+from .log_page import LogPage
+from .tree_page import TreePage
+
+class PageFactory:
+ def __init__(self, out_dir, name, content_subdir):
+ self.out_dir = out_dir
+ self.name = name
+ self.content_subdir = content_subdir
+
+ def new_commit(self, commit):
+ return CommitPage(self.out_dir, self.name, commit, self.content_subdir)
+
+ def new_file(self, commit, path):
+ filename = os.path.basename(path)
+ dir = os.path.dirname(path)
+ return FilePage(self.out_dir, self.name, commit, filename, dir, self.content_subdir)
+
+ 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, 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)