How is wiki-to-print made?: Difference between revisions

From creative crowd wiki
Jump to navigation Jump to search
Line 10: Line 10:
The git repository contains the following files and folders:
The git repository contains the following files and folders:


├── static/
├── templates/
  ├── Makefile
  ├── Makefile
├── README.md
  ├── api.py
  ├── api.py
  ├── plugins
  ├── config.json
  ├── readme.md
  ├── config.py
  ├── requirements.txt
  ├── requirements.txt
├── static
├── templates
  └── web-interface.py
  └── web-interface.py


* <code>static/</code>: folder for static files used by flask (eg. css and js scripts)
* <code>templates/</code>: folder for jinja templates used by flask
* <code>Makefile</code>: script you can use to install or run the flask application
* <code>Makefile</code>: script you can use to install or run the flask application
* <code>api.py</code>: script with all the functions that are used by the flask application
* <code>api.py</code>: script with all the functions that are used by the flask application
* <code>config.json</code>: config script for your wiki-to-print installation
* <code>config.py</code>: script that binds config.json with web-interface.py
* <code>requirements.txt</code>: list of software dependencies for wiki-to-print
* <code>web-interface.py</code>: the flask application
* <code>web-interface.py</code>: the flask application



Revision as of 15:15, 21 August 2023

Technically seen, wiki-to-print is a web application made with Flask, that can be installed on the same server as where the MediaWiki is installed.

In practice, it's a DIY configuration that glues different things together: it takes a wiki page and a CSS stylesheet as input sources and renders them into a HTML page and a PDF preview page.

Code

The source code 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 flask
  • Makefile: script you can use to install or run the flask application
  • api.py: script with all the functions that are used by the flask application
  • config.json: config script for your wiki-to-print installation
  • config.py: script that binds config.json with web-interface.py
  • requirements.txt: list of software dependencies for wiki-to-print
  • web-interface.py: the flask application

To install wiki-to-print

  • make setup: makes a virtual environment and installs all the requirements
  • edit config.json

To run wiki-to-print

  • make local: runs the Flask application locally
  • make server: runs the Flask application remotely with Gunicorn, which we used to work with a subdirectory (we use https://cc.vvvvvvaria.org/wiki-to-print/ as the root of this Flask application)

Flask application

The Flask application is based around the following URLs/routes:

button URL/route Flask action
CSS https://cc.vvvvvvaria.org/wiki-to-print/static/Test.css renders PdfCSS:Test as CSS stylesheet
HTML https://cc.vvvvvvaria.org/wiki-to-print/html/Test renders Pdf:Test as HTML page, using PdfCSS:Test as CSS stylesheet
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
Update text https://cc.vvvvvvaria.org/wiki-to-print/update/Test downloads all the text from Pdf:Test using the Mediawiki API and saves it to Test.json (in HTML)
Update Media https://cc.vvvvvvaria.org/wiki-to-print/update/Test?full=true downloads all the text + images from Pdf:Test using the Mediawiki API and saves them to ./static/images/