diff --git a/compiler.py b/compiler.py index f5d4cc928eaec747dcb631dc412ca81200c20476..56af2333a99018445c685b2433a75498d6d09b0d 100644 --- a/compiler.py +++ b/compiler.py @@ -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 = [ diff --git a/data/contact.md b/data/contact.md new file mode 100644 index 0000000000000000000000000000000000000000..30d694e1e7258d392d8d7454b82bf99d79c70623 --- /dev/null +++ b/data/contact.md @@ -0,0 +1,21 @@ +## 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 diff --git a/data/contact.yaml b/data/contact.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5d011d8a2fb1b2cc550c4983a10d2974f1b25005 --- /dev/null +++ b/data/contact.yaml @@ -0,0 +1,17 @@ +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 diff --git a/templates/contact.html b/templates/contact.html new file mode 100644 index 0000000000000000000000000000000000000000..8856eeed22a4bbd9a80b7c368b96d6ec4d88a01d --- /dev/null +++ b/templates/contact.html @@ -0,0 +1,26 @@ +{% 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