Skip to main content

Use Jinja2 template system to build static pages with Flask integration

Project description

Almoststatic

Almoststatic is a static sites and web pages generator engine written in Python which uses the Jinja2 template system to render pages. It can be integrated with Flask apps to serve static contents on dynamic sites or used only for static sites development.

Pages are declared in yaml files and rendered with Jinja2 template files, the html contents can be written in markdown markup language or in plain html. "content" folder contains all data needed to do the job, the "config.yaml" is used to share global parameters and to setup configuration.

It is roughly inspired by hugo static site generator, but it differs in many ways.

Why Almoststatic?

There are many static site generators such as Next.js, Hugo or Jekyll, but you can prefer Almostatic because:

  • It's perfect for pythonist. It uses Jinja2 and Flask which are widely used by python community, so you don't need to learn other programming languages or template engines.
  • It's easy! In fact the rules are very few and this mean few things to learn and great flexibility.
  • It's versatile. It's engine has a powerful recursive system for embedding and including contents. This helps you to build rich contents and also to split them in small pieces called "widgets" easier to maintain.
  • You can deliver static and dynamic contents at same time. With Flask you can build your dynamic content and let Almoststatic to render the rest of page or 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 for dynamic contents, with Almoststatic you can write all pages as static.
  • Not only for pythonists. Basic knowledge of python is needed, but once your developer environment is ready, Almoststatic lets you to focus on writing yaml and karkdown's contents and to create your own widgets in html and Jinja2.

Quick start

The simplest way to see if Almoststatic is what you're looking for, is to try the sample provided with source code package and explore the source code.

The following tutorial is tested on Linux Ubuntu, but it's easy to port on other platforms such other Linux distros, Windows or Mac.

You need git and python3, install them with:

$ sudo apt install git python3

Last linux's releases comes with python3 already installed and you have only to check if your version is 3.6 or higher:

$ python3 --version

Now clone Almoststatic with git and enter into the directory:

$ git clone https://gitlab.com/claudio.driussi/almoststatic.git
$ cd almoststatic

It's common in python using virtualenv for development, to do so and to install Almoststatic, write:

$ python3 -m venv myvenv
$ source myvenv/bin/activate
$ pip install almoststatic
$ pip install pyftpsync

Done! Now you can try the sample, cd into sample directory and run flaskapp.py:

$ cd sample/
$ python flaskapp.py

A local host Flask App instance server is executed and you can test Almoststatic features.

Open your browser and copy and paste the following URL: http://127.0.0.1:5000/ or localhost:5000

You will be redirected to the static site showing some widgets and feature of Almostatic, you can navigate to see some examples.

You can always exit from server pressing CTRL-C on your terminal.

To build static site run:

$ 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 at: https://almoststatic.readthedocs.io

Status of project

Almoststatic is now in beta. It should be stable enough to produce right results, but it wasn't used enough to put him in stable status.

Almoststatic is a young project, so at the moment there are no themes ready to use but we are developing a theme with some beautiful widgets ready to production. See Fullstep theme and follow the tutorial.

Donate

If you appreciate Almoststatic, you can make a donation via PayPal

paypal

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

almoststatic-0.7.7.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

almoststatic-0.7.7-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file almoststatic-0.7.7.tar.gz.

File metadata

  • Download URL: almoststatic-0.7.7.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.61.2 importlib-metadata/4.6.1 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for almoststatic-0.7.7.tar.gz
Algorithm Hash digest
SHA256 701a292e75e8af88e745cb7073051fde98ca7f4b15ca46b7544dd4f637363aa0
MD5 541562ba5c461f61dbeb6e50888b40b9
BLAKE2b-256 799e8c90ce349c2209817fb20596f0e0c4af48313950525d85ffd2cf4212de3f

See more details on using hashes here.

Provenance

File details

Details for the file almoststatic-0.7.7-py3-none-any.whl.

File metadata

  • Download URL: almoststatic-0.7.7-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.61.2 importlib-metadata/4.6.1 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for almoststatic-0.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d33823d344f72b0858d2e7bd745784806e269488aa8e5789d9b7bfd334fa6b52
MD5 5bb575c2ffab11a46e26e15930603ffc
BLAKE2b-256 c15882ba546a651dc7a8198e30061727c901c4dafc033688b5d05e29065cf5b5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page