(→Fonts) |
(→Code) |
||
Line 6: | Line 6: | ||
==Code== | ==Code== | ||
The source code of the wiki-to-print version that is installed | The source code of the wiki-to-print version that is installed here can be found at: https://git.vvvvvvaria.org/varia/wiki-to-print/. | ||
The git repository contains the following files and folders: | The git repository contains the following files and folders: |
Latest revision as of 13:50, 21 December 2023
Technically seen, wiki-to-print is a web application made in Python with Flask, that can be installed on the same server as where the MediaWiki is installed, or on any other server that you can access with sudo rights.
In practice, it's a version of a DIY configuration and that glues different things together: it takes a wiki page and a stylesheet as input sources (using Python) and renders them into a HTML page (using Pandoc) and a PDF preview page (using Paged.js).
Code
The source code of the wiki-to-print version that is installed here can be found at: https://git.vvvvvvaria.org/varia/wiki-to-print/.
The git repository contains the following files and folders:
├── static/ ├── templates/ ├── Makefile ├── README.md ├── api.py ├── config.json ├── config.py ├── requirements.txt └── web-interface.py
static/
: folder for static files used by Flask (eg. css and js scripts)templates/
: folder for Jinja templates used by FlaskMakefile
: script you can use to install or run the Flask applicationapi.py
: script with all the functions that are used by the Flask applicationconfig.json
: config script for your wiki-to-print installationconfig.py
: script that bindsconfig.json
withweb-interface.py
requirements.txt
: list of software dependencies for wiki-to-printweb-interface.py
: the Flask application
Other versions and variants of this wiki workflow can be found here:
- https://gitlab.constantvzw.org/osp/work.diversions
- https://git.vvvvvvaria.org/mb/volumetric-regimes-book
- https://gitlab.constantvzw.org/titipi/wiki-to-pdf
- https://github.com/hackersanddesigners/wiki2print
To install wiki-to-print
make setup
: make a virtual environment and install all the requirements- edit
config.json
: to configure the Flask application - run the Flask application
- on your computer:
make local
- on a server:
make server
(it uses Gunicorn, as we work with a subdirectory in the wiki-to-print URL on CC, with https://cc.vvvvvvaria.org/wiki-to-print/ as the root of the Flask application)
- on your computer:
- add a proxy_pass to your webserver configuration, to bind web requests with Gunicorn, here is an example: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.nginx.example
- add the following to your
LocalSettings.php
file: wiki-to-print.LocalSettings.php.example - add the following code to the MediaWiki:Common.js page: wiki-to-print.Common.js.example
- add the following code to the MediaWiki:Common.css page: wiki-to-print.Common.css.example
- you can create a systemd service file in the
/etc/systemd/system/
folder, to run wiki-to-print in the background as a service; here is an example: wiki-to-print.service.example and you can find more details on this page: Running wiki-to-print on the server
Flask application
The Flask application is based around the following URLs/routes:
button | URL/route | Flask action |
---|---|---|
Unfolded | Pdf:Test | - |
CSS! | https://cc.vvvvvvaria.org/wiki-to-print/static/Test.css | renders PdfCSS:Test as CSS stylesheet |
Preview HTML | https://cc.vvvvvvaria.org/wiki-to-print/html/Test | renders Pdf:Test as HTML page, using PdfCSS:Test as CSS stylesheet |
Preview PDF | https://cc.vvvvvvaria.org/wiki-to-print/pdf/Test | renders Pdf:Test as PDF preview page (using Paged.js), using PdfCSS:Test as CSS stylesheet |
For a more detailed description of how to work with these buttons, see: How to work with wiki-to-print?
Special namespaces
Wiki-to-print uses the Pdf
and PdfCSS
namespaces to customize the navigation bar.
This means that all wiki-to-print Unfolded pages start with Pdf:
and all CSS pages start with PdfCSS:
.
The wiki-to-print buttons are added and adjusted with Javascript, using MediaWiki:Common.js. MediaWiki:Common.css is used to style the buttons.
Fonts
If you want to use custom fonts, the fonts files need to be hosted somewhere, and the wiki is not really a place where you would usually do that.
It's probably best to use the same domain name to avoid cross-origin errors, or you need to configure your server in such a way that cross-origin links are allowed.