diff --git a/www/conservancy/static/projects/policies/publish-travel-policy.py b/www/conservancy/static/projects/policies/publish-policy.py similarity index 94% rename from www/conservancy/static/projects/policies/publish-travel-policy.py rename to www/conservancy/static/projects/policies/publish-policy.py index 0aabd11c684c71b0618baf5d39ee5787f6916a80..05d2abf3ca49cc963a5555d9a814e7b8aa90a120 100755 --- a/www/conservancy/static/projects/policies/publish-travel-policy.py +++ b/www/conservancy/static/projects/policies/publish-policy.py @@ -24,7 +24,7 @@ except ImportError: markdown_import_success = False TEMPLATE_HEADER = """{% extends "base_projects.html" %} -{% block subtitle %}Travel and Reimburseable Expense Policy - {% endblock %} +{% block subtitle %}{% endblock %} {% block submenuselection %}Policies{% endblock %} {% block content %} @@ -181,7 +181,7 @@ Setting any flag will always override the default behavior. ) add_parser_flag( parser, 'commit', - help="Commit changes to the travel policy", + help="Commit changes to the website repository", ) parser.add_argument( '-m', dest='commit_message', @@ -194,7 +194,7 @@ Setting any flag will always override the default behavior. ) parser.add_argument( 'input_path', type=pathlib.Path, - help="Path to the Conservancy travel policy Markdown source", + help="Path to the Conservancy policy Markdown source", ) parser.add_argument( 'output_path', type=pathlib.Path, @@ -221,7 +221,7 @@ Try `apt install python3-markdown` or `python3 -m pip install --user Markdown`." pass if args.revision is None: 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)) return args @@ -299,7 +299,17 @@ def write_output(args): ], output_format='html5', ) + 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()) with tempfile.NamedTemporaryFile( 'w', @@ -309,7 +319,7 @@ def write_output(args): delete=False, ) as tmp_out: try: - tmp_out.write(TEMPLATE_HEADER) + tmp_out.write(header) tmp_out.write(body) tmp_out.write(TEMPLATE_FOOTER) tmp_out.flush()