You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.9 KiB
Markdown

## Technic Stack
The platform is used as web-container for a series of remix/alternative display of our archive's assets.
You will see boxes, each box is created by a resident.
You will be able to generate pdf to print! You will check the checkboxes beside each box to select which one to queue and then click PRINT.
For this platform2print has been used:
* Flask
* Plain JavaScript
* Paged.js for the print-layout
* HTML
* CSS
As rudimental CMS has been used our NextCloud instance.
NextCloud, as it sounds, it's a self-hosted open-source cloud. You can store files, share them, do shared calendars and todo lists, etc...
The People from [MEGASTUDIO ](https://habitattt.it/wiki/index.php?title=MEGASTUDIO)recidency could then upload in their shared folders the contents of this publication.
Flask reads the path of all the folders that the users uploaded in our server to create a JSON file, a dictionary.
![json.png](./static/json.png)
If in the platform you open the "TREE", you will see the structure of the folders: the JSON file contains that, and Flask reads it after compiling it to create the HTML page.
### Wait, what is and why Flask?
First of all, who programmed this platform really likes Python (Flask is made of it) and never really tried Flask. So why not?
[Flask](https://en.wikipedia.org/wiki/Flask_(web_framework)) is a web framework, so it's used to develop and deploy web stuff. \
You install it in the server via python (see below)
You can make flask perform only in the server and serves to the user static files: it is Server Side Rendering.
It is definitely more ecological then make Javascript runs everything in the device of each user.
So, Python compiles with Jinja a html template:
Jinja is an engine to make templates, for to facilitate the compiling with Python. It comes with Flask.
### What happens when you click "PRINT"?
"Paged.js is a free and open source JavaScript library that paginates content in the browser to create PDF output from any HTML content. This means you can design works for print (eg. books) using HTML and CSS!"
So yep, after you select which boxes you want to print (and which layout you want to use, with the sliders) and click print, Flask compiles another HTML based on Paged.js
### wheres code
You will see the magic in the file *app.py*
The code is in our GIT [git.habitattt.it/ministro/MEGASTUDIO_platform](https://git.habitattt.it/ministro/MEGASTUDIO_platform)
### how to set it up?
So, you have to install Python
Then you create a folder, and from the terminal you go there (if you don't know what I'm talkin about, first have a look to basic commands in Terminal).
Create a virtual environment with:
python3 -m venv .
And activate it
source bin/activate
And then install flask
pip3 install flask
To run:
flask run
### Bonus
The files are compressed in CLI (Command Line Interface, the terminal, directly in the server) with ImageMagick.