Overview
This is the implementation of the WhakerKit library. WhakerKit is a versatile toolkit for building websites with both static and dynamic HTML pages. It was developed by Brigitte Bigi, CNRS.
WhakerKit is a seamless toolkit for managing dynamic websites and shared documents.
Use cases
WhakerKit is the ideal toolkit if you want to:
- create a dynamic website with a few static pages,
- share documents easily without having to manage a database,
- restrict access to parts of your website using an existing LDAP directory,
- keep full control of your HTML content without the overhead of a heavy framework like Django.
It’s designed for developers who want a lightweight, flexible solution with minimal configuration.
It’s easy to deploy, easy to understand, and highly adaptable.
WhakerKit provides easy management of public and authenticated access and simplifies document sharing in collaborative environments. It is based on the following technologies:
- Python >= 3.9
- (optional) PyJWT and ldap3 for authentication (install with pip)
- WhakerPy >= 1.0: https://whakerpy.sourceforge.io (install with pip)
- WhintPy >= 1.1: https://whintpy.sourceforge.io (install with pip)
- Whakerexa >= 0.7: https://whakerexa.sourceforge.io (download and unzip)
- HTML5, CSS4, and JavaScript technologies
Technical approach
The Apache server uses uWSGI to run a Python application, handled by
the local wsgi.py
file. The WSGI server looks for an
application(environ, start_response)
function, which is called whenever a
request is received (via POST, GET, or any other method). This file defines
a function that is an instance of the WSGIApplication
class. It is
instantiated with the following parameters:
- The default page name is
index.html
- Page descriptions are stored in a
.json
file
Pages are dynamically generated using the WhakerPy
library and are returned
as either HTML or JSON, depending on the request. The dynamic HTML pages fall
into two categories:
- Fully dynamically generated pages
- Partially dynamically generated pages
Partially dynamic pages are described in the JSON configuration file. The <head>
,
header, menu, and footer of these HTML pages are automatically added to a static
HTML body located in the html
folder. The dynamic parts are generated by Python
classes.
Authors and contributors
See the accompanying file AUTHORS.md
.
Get and install WhakerKit
Get it from its repository https://sourceforge.net/projects/whakerkit/, and get documentation https://whakerkit.sourceforge.io.
Download the latest ".zip" from the web page and unpack it:
> unzip WhakerKit-xxx.zip
Alternatively, you can clone the repository with git
:
> git clone https://git.code.sf.net/p/whakerkit/code whakerkit-code
> python -m pip install .
Creating a Custom Website
Starting a New Project
Required contents:
pyproject.toml
: Python configuration file used to install dependencieswhakerkit
: Contains the JavaScript package and the Python source code that handles requests, including headers, status codes, and contentwhakerexa
: CSS and JS
Optional content:
whintpy_add.py
: Script to add documents to theuploads
folder
Get it:
- Create a working directory
- Download and unzip WhakerKit
- Download and unzip Whakerexa
- Create a virtual environment:
python -m venv .venv
- Activate the virtual environment
- Run:
python -m pip install .
— this readspyproject.toml
and installs dependencies
Files and folders required to launch the sample:
wsgi.py
: entry point for the applicationwhakerkit/whakerkit.json
: General configuration file for any websitesample
: folder with python source codesample/sample.json
: list of dynamic pages for the samplesample/statics
: Contains static files such as icons, images, and CSS for the samplesample/html
: Contains all static components of the HTML pages of the samplesample/uploads
: Contains the document database. This folder should never be modified manually.
Editing Existing Files
All the sample files are well-commented to help developers understand and adapt the logic to their own use case.
Starts by editing the whakerkit.json
to configure your project.
The whakerkit
package also includes an error
folder containing HTML error pages.
Edit these files to customize error messages. The package also includes default icons
that can be replaced as long as the file names remain the same.
Editing the Sample
WhakerKit comes with a sample
directory to help you get started.
bakery.py
This file contains the CustomWebData
class, which inherits from WebSiteData
.
It parses sample.json
, stores data, and manages the "bakery" system — a concept
from WhakerPy used to dynamically generate page content.
pages_resp.py
This file implements the CustomPagesResponse
class. It is invoked when a
requested page name is listed in sample.json
. It reuses the same head, header,
navigation bar, and footer, while changing only the main content, which is
defined in a static HTML file.
head_node.py
Allows adding content to the <head>
tag of dynamically created HTML files.
You can include <meta>
, <link>
, or <script>
elements.
nav_node.py
Allows defining the entire <nav>
content of dynamically created HTML files.
Development and Debugging
Edit the file wsgi.py
to adapt it to your project content.
To enable debugging, modify the logging configuration, i.e. comment/uncomment
the following lines:
LOG_LEVEL = 1 # Debug level
# LOG_LEVEL = 15 # Info level
Launch locally
Under any linux version or macOS, launch locally the application with:
> # install required external libraries:
> python3 -m pip install pycryptodome --break-system-packages
> python -m pip install uwsgi
> # launch with uwsgi service:
> uwsgi --http :9090 --wsgi-file wsgi.py
Then open http://localhost:9090/
Live projects built with WhakerKit
- The intranet of "Laboratoire Parole et Langage", Aix-en-Provence, France
- https://auto-cuedspeech.org/
- https://sppas.org/