BottleMD is a static website generator (CMS) for simple non-interactive websites, based on the projects Bottle and python-markdown. The greater idea behind developing BottleMD is that all websites should be low in bandwidth and easily accessible and built on a fast platform. It will therefore always provide also the Markdown files on which it has been built. In the long run, an online UI to edit the website shall be provided, and maybe added further functionality to extend the idea of having a simple personal broadcasting hub.
You need a basic Python 3 installation (including the packages sys
, re
, urllib
, os
, getopt
, shutil
) and the packages bottle
and python-markdown
, which you can install from pip: pip install bottle markdown
BottleMD is a single Python file. To generate a website, call the Python file: ./bottlemd.py
BottleMD will traverse the files, starting with the startfile.
The startfile is by default index.md
if not otherwise given with the -i
flag.
All files that are given in the navigation of the startfile are checked out as well, as well as their navigation elements, etc.
The directory from which the source files are taken (as the startfile) is the current working directory. It can be changed with the -s
flag.
The website will be output to the directory website
. If it does not exist, it will be generated. You can change the target directory with the -t
flag.
BottleMD uses the web framework Bottle for its templating engine.
Two templates are expected: bottlemd_site.tpl
which describes the whole website template and bottlemd_navigation.tpl
which describes one single navigation menu entry (which are added together and inserted into the website).
Note that none of the arguments as documented below must be included.
If one of the fields (e.g., the title or the header) do not exist, they are left out.
Examples for bottlemd_navigation.tpl and bottlemd_site.tpl as used for this website.
bottlemd_navigation.tpl is the template that describes one single entry in the navigation. This comprises a name for the link and its target URL. These can be given by:
!{{!bottlemd_url}}
-- the URL for the link!{{!bottlemd_name}}
-- the name for the linkbottlemd_site.tpl is the template that describes the framework of every site. It can include the following options:
!{{!bottlemd_title}}
-- will be filled by the page title. Should be in the \<title> tags in the header.!{{!bottlemd_header}}
-- should be inside the \<head> tags to add additional header elements (e.g., style files or Javascript scripts).!{{!bottlemd_navigation}}
-- the placeholder to insert the navigation.!{{!bottlemd_sitetext}}
-- the actual site content, as rendered by BottleMD.A BottleMD source file contains a header (with sections) and the actual file content.
Every file scanned will be scanned for header elements. The first element that is not considered a header element indicated the beginning of the file content.
A header element is separated by a preceding horizontal ruler (---
) as well as a trailing one (which can be used as the preceding horizontal ruler for the next element).
The first line of a header element contains the keyword. A keyword always starts with bottlemd_
and indicates the meaning of the rest of the file. After the keyword, a newline is expected.
The keywords are described below.
Indicates the title, as is inserted in the template with the bottlemd_title
(described above).
If no title is given, the first header element (if existing) found is used as the page title.
Describes all elements that are to be linked or attached to this page, given as a list o flinks. There are three types of links you can give:
Indicates the lines that are inserted in the template as the bottlemd_header
(described above).