Use Jinja2 template system to build static pages with Flask integration
Project description
Almoststatic
Almoststatic is a Python library useful to build static html content from yaml files and markdown files.
It is roughly inspired by hugo static site generator, but it differs in many ways.
Almoststatic has a great integration with Flask web micro framework. But can be used even without it.
Yaml files and media data are stored in a content
folder and pages are built
combining yaml files with jinja2 templates,
the same used by default on Flask.
When your site is done, you can continue to serve it with Flask, or you can write it as static site composed by plain html pages, easy to deliver everywhere in the web.
Why Almoststatic?
-
It's perfect for pythonist. If you are pythonist, it's the right choice for you, because uses jinja2 that is one of the most used template's engine written in Python so you have to learn it only once and there is no need to learn others systems and templates.
-
It's easy! In fact the rules are very few and this mean few things to learn, but also more flexibility.
-
It's versatile. It's engine has a powerful recursive system for embedding and including contents. This helps to build rich contents and also to split the contents in small pieces called "widgets" easier to maintain.
-
You can deliver static and dynamic contents at same time. Under Flask you can build your dynamic content and then use the Almoststatic system to render the rest of page or render with it the whole page if it is full static.
-
Write static sites. Static sites are composed only by text files and media contents. They are easy to deliver on the web, are secure by design, require less maintenance and resources and are faster. If you have no need of dynamic contents, with Almoststatic you can write all static pages ready to be delivered.
-
Not only for pythonists. To use Almoststatic You need to know very few thinks of Python, the mot part of your time is spent writing contents in Yaml or Markdown and writing widgets in html and Jinja2. So, learn some Python basics or search for little help and go on.
Quick start
The simplest way to see if Almoststatic is right for you, is to try the sample provided with source code package and examinate source code.
The following tutorial is tested on Linux Ubuntu, but it's easy to port on other platforms such other Linux flavours, Windows or Mac.
You need git and python3, install them with:
$ sudo apt install git python3
python3 should be already installed because it is in all modern Linux distributions but be sure your version is at least 3.6 with:
$ python3 --version
then goto in your development environment, download source code of Almoststatic and enter into directory:
$ git clone https://gitlab.com/claudio.driussi/almoststatic.git
$ cd almoststatic
now you can setup you development environment with virtualenv and install the package:
$ python3 -m venv myvenv
$ source myvenv/bin/activate
$ pip install almoststatic
Done! Now you can try the sample:
$ cd sample/
$ python flaskapp.py
This launch a Flask app with the demo site which illustrates the
Almoststatic functionality. Goto in your browser and navigate to:
http://127.0.0.1:5000/
you will see some sample pages.
When you are done, exit from server pressing CTRL-C and write a static site and see the result files with:
$ python write_static.py
$ ls -l ../_static_site/
As you can see, your pages are written as *.html files, but this is not enough to get a really static site, to do this you have to tune writing parameters and copy media files on appropriate location. When you are done the site can be published as static site.
If you wish, you can run tests:
$ cd ../test
$ python as_test.py
This do some tests and write a simpler static site.
Now if you decide that Almoststatic is right for you, you can dig into source code of sample and tests and read the documentation.
Donate
If you appreciate Almoststatic, you can make a donation via PayPal
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file almoststatic-0.7.0.tar.gz
.
File metadata
- Download URL: almoststatic-0.7.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4739f5fd916cc9a2ecb2e3a12ff6bf7853c30e550c0334bcd5e8104bf81ada8 |
|
MD5 | 7ed107b5c326559b04be3743c06e8405 |
|
BLAKE2b-256 | 85361c307d749845c1c17f68af7855c7948e4e2991562d7d0d16442a7c972257 |
Provenance
File details
Details for the file almoststatic-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: almoststatic-0.7.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e54198880edc450be0bae7e3270b0c58b3a36d0cd415428b4f92fc27912ec3f0 |
|
MD5 | 14d5e1036bad77ef78534c9a4664c2ce |
|
BLAKE2b-256 | dd89604296984a501df51e7035fb8802c60107923c613e696d766a9c02e511bf |