diff options
Diffstat (limited to 'g2h')
| -rw-r--r-- | g2h/cli.py | 3 | ||||
| -rw-r--r-- | g2h/commit_page.py | 4 | ||||
| -rw-r--r-- | g2h/log_page.py | 4 | ||||
| -rw-r--r-- | g2h/overview_page.py | 4 | ||||
| -rw-r--r-- | g2h/page.py | 3 | ||||
| -rw-r--r-- | g2h/page_factory.py | 9 |
6 files changed, 15 insertions, 12 deletions
@@ -12,6 +12,7 @@ def parse_args(): parser.add_argument('repo_path', help='Path to the root of git repository') parser.add_argument('out_dir', help='Path to where the generated files should be stored') parser.add_argument('--name', help='Name of the project. Default: directory name of repo') + parser.add_argument('--content-subdir', help='Subdir(s) where the page will be served from. Default: None', default='') return parser.parse_args() @@ -25,7 +26,7 @@ def main(): 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) + factory = PageFactory(args.out_dir, project_name, args.content_subdir) factory.new_overview(branches, tags).render() factory.new_log(commits, branches, tags).render() for commit in commits: diff --git a/g2h/commit_page.py b/g2h/commit_page.py index 325df85..716a4f8 100644 --- a/g2h/commit_page.py +++ b/g2h/commit_page.py @@ -3,8 +3,8 @@ import os from .page import Page class CommitPage(Page): - def __init__(self, out_dir, name, commit): - super(CommitPage, self).__init__('commit.md', out_dir, os.path.join(commit.hexsha, 'index.md'), name) + 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): diff --git a/g2h/log_page.py b/g2h/log_page.py index 684a758..9a3d64f 100644 --- a/g2h/log_page.py +++ b/g2h/log_page.py @@ -13,8 +13,8 @@ def ref_names_for_commit(refs, commit_sha): return ref_names class LogPage(Page): - def __init__(self, out_dir, name, commits, branches, tags): - super(LogPage, self).__init__('log.md', out_dir, 'l.md', name) + def __init__(self, out_dir, name, commits, branches, tags, content_subdir): + super(LogPage, self).__init__('log.md', out_dir, 'l.md', name, content_subdir) self.commits = commits self.branches = branches self.tags = tags diff --git a/g2h/overview_page.py b/g2h/overview_page.py index 1693b9a..8c7a69c 100644 --- a/g2h/overview_page.py +++ b/g2h/overview_page.py @@ -1,8 +1,8 @@ from .page import Page class OverviewPage(Page): - def __init__(self, out_dir, name, branches, tags): - super(OverviewPage, self).__init__('overview.md', out_dir, '_index.md', name) + def __init__(self, out_dir, name, branches, tags, content_subdir): + super(OverviewPage, self).__init__('overview.md', out_dir, '_index.md', name, content_subdir) self.branches = branches self.tags = tags diff --git a/g2h/page.py b/g2h/page.py index 44f97ee..a708f2b 100644 --- a/g2h/page.py +++ b/g2h/page.py @@ -2,9 +2,10 @@ from jinja2 import Environment, FileSystemLoader import os class Page: - def __init__(self, template_file, out_dir, out_file, name): + def __init__(self, template_file, out_dir, out_file, name, content_subdir): self.out_file_path = os.path.join(out_dir, out_file) self.name = name + self.content_subdir = content_subdir template_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'templates')) self.template = Environment(loader=FileSystemLoader(template_dir)).get_template(template_file) diff --git a/g2h/page_factory.py b/g2h/page_factory.py index f946e7a..43a48ae 100644 --- a/g2h/page_factory.py +++ b/g2h/page_factory.py @@ -3,15 +3,16 @@ from .overview_page import OverviewPage from .log_page import LogPage class PageFactory: - def __init__(self, out_dir, name): + 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) + return CommitPage(self.out_dir, self.name, commit, self.content_subdir) def new_overview(self, branches, tags): - return OverviewPage(self.out_dir, self.name, branches, tags) + return OverviewPage(self.out_dir, self.name, branches, tags, self.content_subdir) def new_log(self, commits, branches, tags): - return LogPage(self.out_dir, self.name, commits, branches, tags) + return LogPage(self.out_dir, self.name, commits, branches, tags, self.content_subdir) |