How to install wiki-to-print?
Source code
https://git.vvvvvvaria.org/CC/wiki-to-print.git
Requirements
- mediawiki
- localsettings: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.LocalSettings.php.example
- common.css: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.Common.css.example
- common.js: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.Common.js.example
- php-fpm
- mysql/mariadb
- nginx
- config: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.nginx.example
- extensions: https://cc.vvvvvvaria.org/wiki/Special:Version
- web app
- flask
- nginx config: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.nginx.example
- beautifulsoup
- (gunicorn) -- (only if you want to configure your url as a subdirectory, for example: https://cc.practices.tools/wiki-to-print/ and not as a subdomain, like: https://wiki-to-print.practices.tools)
- pandoc
- service file: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.service.example
Preparations
Make a wikitoprint system user
We will make an “wikitoprint” user on the server to run wiki-to-print with this user. In this way we can restrict the access of this user to the rest of the server.
Make a system user called “wikitoprint”.
# useradd --system --no-create-home --shell=/sbin/nologin wikitoprint
Give read and write access + ownership to the /opt/wiki-to-print folder to the wikitoprint user.
# chown -R wikitoprint:wikitoprint /opt/wiki-to-print
# chmod -R u+rw /opt/wiki-to-print
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.practices.tools/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/CC/wiki-to-print/src/branch/master/wiki-to-print.nginx.example
- add the following to your
LocalSettings.phpfile: 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. After making it, run:systemctl daemon-reload, thensystemctl enable wiki-to-printandsystemctl start wiki-to-print.
A more messy but way much longer installation log can be found here.
Flask application
The Flask application is based around the following URLs/routes:
| button | URL/route | Flask action |
|---|---|---|
| Unfolded | Pdf:Test | - |
| CSS! | https://cc.practices.tools/wiki-to-print/static/Test.css | renders PdfCSS:Test as CSS stylesheet |
| Preview HTML | https://cc.practices.tools/wiki-to-print/html/Test | renders Pdf:Test as HTML page, using PdfCSS:Test as CSS stylesheet |
| Preview PDF | https://cc.practices.tools/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.