Changeset - 637ca012b778
[Not reviewed]
1 0 1
Brett Smith (brett) - 6 years ago 2018-05-04 20:05:32
brett@sfconservancy.org
policies: Extend publication script to handle any Conservancy policy.
1 file changed with 15 insertions and 5 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/projects/policies/publish-policy.py
Show inline comments
 
file renamed from www/conservancy/static/projects/policies/publish-travel-policy.py to www/conservancy/static/projects/policies/publish-policy.py
...
 
@@ -26,3 +26,3 @@ except ImportError:
 
TEMPLATE_HEADER = """{% extends "base_projects.html" %}
 
{% block subtitle %}Travel and Reimburseable Expense Policy - {% endblock %}
 
{% block subtitle %}{% endblock %}
 
{% block submenuselection %}Policies{% endblock %}
...
 
@@ -183,3 +183,3 @@ Setting any flag will always override the default behavior.
 
        parser, 'commit',
 
        help="Commit changes to the travel policy",
 
        help="Commit changes to the website repository",
 
    )
...
 
@@ -196,3 +196,3 @@ Setting any flag will always override the default behavior.
 
        'input_path', type=pathlib.Path,
 
        help="Path to the Conservancy travel policy Markdown source",
 
        help="Path to the Conservancy policy Markdown source",
 
    )
...
 
@@ -223,3 +223,3 @@ Try `apt install python3-markdown` or `python3 -m pip install --user Markdown`."
 
            parser.error("no --revision specified and not found from input path")
 
    args.output_link_path = args.git_output.dir_path / 'conservancy-travel-policy.html'
 
    args.output_link_path = args.git_output.dir_path / args.input_path.with_suffix('.html').name
 
    args.output_file_path = args.output_link_path.with_suffix('.{}.html'.format(args.revision))
...
 
@@ -301,3 +301,13 @@ def write_output(args):
 
    )
 
    header = TEMPLATE_HEADER
 
    with args.input_path.open(encoding=args.encoding) as src_file:
 
        for line in src_file:
 
            if line.startswith('# '):
 
                subtitle = line[2:].replace('Software Freedom Conservancy', '').strip()
 
                header = header.replace(
 
                    '{% block subtitle %}',
 
                    '{{% block subtitle %}}{} - '.format(subtitle),
 
                )
 
                break
 
        src_file.seek(0)
 
        body = converter.convert(src_file.read())
...
 
@@ -311,3 +321,3 @@ def write_output(args):
 
        try:
 
            tmp_out.write(TEMPLATE_HEADER)
 
            tmp_out.write(header)
 
            tmp_out.write(body)
0 comments (0 inline, 0 general)