Category:Padliography: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "thumb The Padliography is a tool to keep track of our pads. It is built to interact with the MediaWiki API, and it uses ''XPUB & Lens-Based Wiki'''s pages as archive. Find it here: [https://hub.xpub.nl/soupboat/padliography/ Padliography] ''' Features ''' * Multiple archives * Custom categories * Filter by categories * Table Sorting * Create new pad * Interact with the wiki <br> == Quick Start == The Padliography homepage loads by def...")
 
(Blanked the page)
Tag: Blanking
Line 1: Line 1:
[[File:Padliography frog.jpg|thumb]]


The Padliography is a tool to keep track of our pads. It is built to interact with the MediaWiki API, and it uses ''XPUB & Lens-Based Wiki'''s pages as archive. Find it here: [https://hub.xpub.nl/soupboat/padliography/ Padliography]
''' Features '''
* Multiple archives
* Custom categories
* Filter by categories
* Table Sorting
* Create new pad
* Interact with the wiki
<br>
== Quick Start ==
The Padliography homepage loads by default the XPUB2 archive. Just above the pads list it is indicated from where the pads are being fetched, and it is possible to change source by inserting the title of the page in which the other archive is.
To create a brand new archive click on '''Init a new padliography''' and insert a title and a short description to put in the wiki.
''Watch out:'' This action will create a new blank page, so check that there is not already something with the same title in the wiki, or it will be overwritten. Thanks to the wiki's history, it is possible to recover overwritten contents, so the contents are not in total danger.
Use the '''Add a new pad''' form to insert a pad in the archive. The required information are a title, the URL of the document, a short description, a date and some categories. The categories are custom, and are useful to organize pads in themes or context.
The '''Filter Categories''' section loads all the categories from the current archive and uses it to filter the list of pads.
The list of pads is sortable. Click on the headers to order the pad, click twice to invert the order.
At the moment this Padliography instance runs on the [https://hub.xpub.nl/soupboat/ Soupboat]. If you are using it a lot or with a lot of pads, consider to install a new instance on a different environment, in order not to put a strain on the small Raspberry. It should be fine anyway.
== How does it work ==
[[File:Pad Lifecycle.jpg|thumb]]
To have an overview over the lifecycle of the Padliography let’s start from the wiki. The pads are stored in a page with a minimal template, such as the title, a short description and a section named Padliography with the archive. Here they are organized in a table that has the CSS class <code>padliography</code>.
Through the [https://pzwiki.wdka.nl/mediadesign/Special:ApiSandbox MediaWiki API] we can request the contents of this page from somewhere else. This somewhere else is a small Raspberry Pi called Soupboat and installed on the 4th floor of the WdKA.
The Soupboat is a small server, and it runs a [https://flask.palletsprojects.com/en/2.2.x/ Flask] application that interacts with the wiki using the [https://mwclient.readthedocs.io/en/latest/index.html mwclient] python library.
When a user enters the homepage of the padliography, the Flask application returns a [https://vuejs.org/ Vue3] app and through that requests to the wiki API the list of pads.
The response from the MediaWiki API is parsed on the server using [https://www.crummy.com/software/BeautifulSoup/ BeautifulSoup], that tries to find the <code>padliography</code> table with some CSS selectors and then builds a list of pads organized by the properties of the table’s headers. The list of table is sent to the Vue app as JSON message, and used to compile a fancy sortable table and filtering system.
When a user interacts with the form to add a new pad the process is the same, but in the opposite direction: first the Vue app sends the data to the Flask application that in turns tries to add it in the archive wiki page.
== Development ==
=== Local Setup ===
To install the Padliography somewhere else start by cloning this repo.
<pre>git clone https://git.xpub.nl/kamo/pad-bis.git</pre>
Then move to the cloned repository folder and create a python virtual environment.
<pre>cd pad-bis
python3 -m venv venv</pre>
Activate the virtual environment
<pre># on unix
source venv/bin/activate
# on windows
venv\Scripts\activate</pre>
and then install the requirements with pip. The '''.''' here refers to the current working directory, where the '''setup.py''' file can be found. There are specified all the packages the application needs.
<pre>pip install -e .</pre>
Once the installation is completed, launch the application and open it on the default port .
<pre>python pad-bis.py</pre>
If you open <code>localhost:5000</code> on your browser, it will return the padliography stuck in the loading process. This is why before interacting with the MediaWiki API we need to specify the credential for a user to log into the wiki. On your local version you can use your own credentials, but if you plan to put this padliography online it’s better to use a dedicated user, aka a bot.
Remember not to commit your credentials on git, or they will be rendered public! Instead create and <code>.env</code> file, that will not be uploaded on git as specified in the <code>.gitignore</code> file.
Create an <code>.env</code> file in your working directory with the following properties:
<pre>MW_BOT= your username
MW_KEY= your password</pre>
At this step you are up and running, the padliography should be able to fetch the pad from the wiki etc.
== License ==
This Padliography was distilled with the help and within the context of XPUB, 2022.<br />
Copyleft with a difference: This is a collective work, you are invited to copy, distribute, and modify it under the terms of the [https://constantvzw.org/wefts/cc4r.en.html CC4r].

Revision as of 18:18, 18 October 2022

Pages in category "Padliography"

The following 9 pages are in this category, out of 9 total.