Swift Website
This is the website for the SWIFT project. You can build the website by doing the following:
- Have python 3.6 or more recent and pip 3.6.
- Create a virtual environment (
virtualenv3 env
orvirtualenv env
) and ensure that it ispython3
. - Activate it (
source env/bin/activate
) [note to deactivate you want to use thedeactivate
keyword in your shell] - Use that virtual environment to install the required packages (
pip install -r requirements.txt
) - If
pandoc
is installed on your machine, I would recommend also installingpypandoc
. If not, then the system will use themistune
python-only renderer. - You can then compile the website by running
python3 compiler.py
from this directory. The conpiled files will be placed in./compiled
, and they can then simply be uploaded to a webserver. It is a fully static website so no need to worry about installing anything!
Adding to the Website
TODO: This section.
Templates
To add a new page altogether, you will need to create a template.
The templates in the SWIFT website are based on the jinja2
templating system which is thankfully pretty well documented.
These templates are then processed by compiler.py
that just uses the jinja
api to stick a bunch of data files into them.
The exception to this rule is the About page (see below for more information on that) which uses some markdown files that are also stored in the data directory, along with a separate compiler in about.py
that is automatically called when the compilation process is begun.
It should be fairly self-explanatory how to add a 'regular' page (the Contact page should be a good starter for you if you just want to add a page that's full of text).
The program, in general, flows like this
- Templates are loaded from the filesystem
- YAML files are loaded from the filesystem into dictionaries that are passed to the templates who expose these as template variables that are accessible in the template itself
- Some minor processing happens on the template side, such as sticking things between heading tags, etc.
- A HTML page is saved to the filesystem
- We do a bunch of copying around of static files into the compiled directory so everything lives side-by-side and can be referenced as if it has been in the same directory all along.
About Page
The about page is created from four files, via a single YAML file, with
-
data/about_meta.yaml
describing meta information about the other files and containing the information about the 'cards' at the top of the page, -
data/public.md
a Markdown file containing the information for the public, -
data/astro.md
a Markdown file containing the information for astronomers, -
data/cd.md
a Markdown file containing the information for computer scientists.
These are them compiled by about.py
to a single YAML file, about.yaml
which is read in by compiler.py
when dealing with the templates and fed to templates/about.html
as variables.
So, if you want to edit the information on the about page you only need to edit one of the four above files and re-run the compiler.
The markdown syntax is available here.
It should hopefully be at least somehwat familiar (it's the same one that is used on GitLab).
To add images stick the image file into images
and then you can reference them by filename in the markdown file, for example:
- I have a file called
test.png
that I want to display in the Public section. - I should place this file into
images
, i.e.images/test.png
- I should edit
data/public.md
, and place in
- I should now run
python3 compiler.py
(see the top-level information for how to compile correctly) and everything will be copied such that the images live in the same directory as the final HTML files.
Adding Talks/Publications
Adding talks or publications is as simple as editing a YAML file in the data
directory.
To add a publication, you need to add the following data structure to data/pubs.yaml
,
- title:
date:
img:
link:
Please place the image file into /images
.
I would not recommend adding a publication without an image, even if it is possible.
To add a talk, you need to add the following data structure to data/talks.yaml
,
- meeting:
location:
date:
title:
author:
abstract:
links:
- href:
name:
and recompile the website with compiler.py
.
You can place slides, etc. in the /talks
directory and reference them here with href: filename
with no need to worry about the directory -- again, these are all copied automatically.