summaryrefslogtreecommitdiffstats
path: root/g2h
diff options
context:
space:
mode:
Diffstat (limited to 'g2h')
-rw-r--r--g2h/page.py2
-rw-r--r--g2h/tree_page.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/g2h/page.py b/g2h/page.py
index a708f2b..b829a88 100644
--- a/g2h/page.py
+++ b/g2h/page.py
@@ -10,6 +10,8 @@ class Page:
self.template = Environment(loader=FileSystemLoader(template_dir)).get_template(template_file)
def context(self):
+ # TODO: Probably better to delegate to a method here so name and subdir don't have to be
+ # passed around as much.
raise NotImplementedError("Must override context")
def render(self):
diff --git a/g2h/tree_page.py b/g2h/tree_page.py
index 22e563a..977e981 100644
--- a/g2h/tree_page.py
+++ b/g2h/tree_page.py
@@ -2,9 +2,12 @@ import os
from .page import Page
+def tree_prefix(sha, tree):
+ return os.path.join(sha, 't', tree)
+
class TreePage(Page):
def __init__(self, out_dir, name, commit, sub_tree, repo, content_subdir):
- super(TreePage, self).__init__('tree.md', out_dir, os.path.join(commit.hexsha, 't', sub_tree, 'index.md'), name, content_subdir)
+ super(TreePage, self).__init__('tree.md', out_dir, os.path.join(tree_prefix(commit.hexsha, sub_tree), 'index.md'), name, content_subdir)
self.tree = commit.tree.join(sub_tree) if sub_tree else commit.tree
self.repo = repo
self.commit = commit
@@ -30,7 +33,9 @@ class TreePage(Page):
def context(self):
return {
+ 'content_subdir': self.content_subdir,
'entries': self._get_entries(),
+ 'subdir': '/'.join([self.content_subdir, tree_prefix(self.commit.hexsha, self.tree.path)]),
'title': self.name + ': Tree'
}