Skip to content
Snippets Groups Projects
Commit 665bb3a0 authored by Josh Borrow's avatar Josh Borrow
Browse files

Added markdown compilation for individual templates

parent 23f68b32
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ from distutils.dir_util import copy_tree
import jinja2
import yaml
import pypandoc
def get_from_filesystem(template_names, template_dir=".", data_dir="../data"):
......@@ -26,22 +27,35 @@ def get_from_filesystem(template_names, template_dir=".", data_dir="../data"):
def get_associated_data(template_names, data_dir="../data"):
""" Grabs the data from yaml files within the data directory if they exist,
and if not returns an empty dictionary for that item. """
""" Grabs the data from yaml/md files within the data directory if they
exist, and if not returns an empty dictionary for that item. """
data = []
for template in template_names:
# swap that .html for a .yaml
# swap that .html for a .yaml and a .md
stub = template.split(".")[0]
filename = f"{data_dir}/{stub}.yaml"
this_data = {} # we will start with empty and add to it.
# YAML Search
try:
with open(filename, "r") as handle:
data.append(yaml.load(handle))
with open(f"{data_dir}/{stub}.yaml", "r") as handle:
this_data = dict(yaml.load(handle), **this_data)
except FileNotFoundError:
data.append({})
pass
# Markdown Search
try:
with open(f"{data_dir}/{stub}.md", "r") as handle:
markdown = pypandoc.convert_text(handle.read(), 'html', 'md')
this_data["markdown_content"] = markdown
except FileNotFoundError:
pass
data.append(this_data)
return data
......@@ -131,6 +145,7 @@ if __name__ == "__main__":
"pubs.html",
"talks.html",
"about.html",
"contact.html"
]
STATIC = [
......
## Contact Us
Hello there! You can contact us using the form below (that goes out to a third party where you'll have to use a capatcha).
<form action="https://formspree.io/your@email.com"
method="POST">
<input type="text" name="name">
<input type="email" name="_replyto">
<textarea>Your message here...</textarea>
<input type="submit" value="Send">
</form>
If you would prefer to contact us through the post, you can do that at the following address:
The SWIFT Team <br/>
Institute for Computational Cosmology <br/>
Ogden Centre for Fundamental Physics - West <br/>
Department of Physics <br/>
Durham University <br/>
South Road <br/>
Durham DH1 3LE <br/>
\ No newline at end of file
people: [
Dr. Pedro Gonnet,
Dr. Matthieu Schaller,
Mr. Aidan Chalk,
Mr. James S. Willis,
Mr. Angus Lepper,
Dr. John A. Regan,
Mr. Stefan Arridge,
Pr. Tom Theuns,
Pr. Richard G. Bower,
Dr. Peter Draper,
Dr. Lydia Heck,
Dr. Tobias Weinzierl,
Dr. Stephen McGough,
Pr. Georgios Theodoropoulos,
Mr. Joshua Borrow,
]
\ No newline at end of file
{% extends "base.html" %}
{% import "helpers.html" as helper %}
{% block title %}Contact Us{% endblock %}
{% block content %}
{{ helper.wide_header() }}
<div class="container">
{{ helper.navbar(navbar, link) }}
<div class="content">
<div class="text">
{{ markdown_content }}
</div>
<div class="sidebar">
<h2>People</h2>
<p>The following people are involved in SWIFT:</p>
<ul>
{% for person in people %}
<li>{{ person }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment