Website for H&D, Amsterdam.
The wiki and the backend are running on MediaWiki, acting as open-door cms, workshop space, archive for projects and knowledge.
A wiki comes with no predetermined hierarchy, which lets you create your own logic for a navigation. On the the H&D wiki we work with Forms and Templates for a better editing experience; Semantic MediaWiki for organising all bits of data and metadata on each page and Concepts to create sections and the navigation for the frontend website.
The front-end is built in Python 3.6 with:
- Werkzeug to wrap the website inside an app and put it on the internet through the
WSGIinterface - Requests to fetch all
jsonfrom the MediaWiki backend - Beautiful Soup to parse and clean up wiki’s extra markup, and to add atomic, functional
cssclasses tohtmltags - Jinja to build the templates (works hand in hand w/ Werkzeug)
Requirements
- terminal basics (introduction)
- Python (introduction)
pipPython package manager (instructions)- venv to setup a Python environment (check this for instructions)
- git!
Then
- open terminal
- clone the repository:
git clone git@github.com:hackersanddesigners/had-py.git - setup a new Python 3.6 environment inside the repo folder:
python3.6 -m venv env. To activate it, type:source env/bin/activate - type:
python had.py - you will be asked to install a bunch of dependencies using Python’s
pippackage manager. Dopip install name-of-packageand keep runningpython had.pyuntil everything is installed - type:
python had.pyagain, the Python app should start and print something likehttp://127.0.0.1:5000, copy that in your browser to see the H&D’s frontend website ☺︎
Improving and organising the MediaWiki demanded a good reading of the extensive (at times confusing) documentation, installing some plugins (in particular PageForms on top of Semantic MediaWiki) and manage the data through the MediaWiki interface. The most challenging part was to understand how Mediawiki actually treated data, and to decide how much complexity adding to the existing wiki. Overall, the aim was to be able to create new articles and to edit them in a pleasant manner but not limited the editing activities too much.
The wiki is fully able to parse different syntaxes whenever you need to embed an image, a video, an audio clip, an etherpad, etc, and it supports your writing and mark-up. One instance is the token autocompletion: for example some fields suggest you already used words (tokens) while you are typing.
Check Page Forms:Input types for an overview of what’s available.
Currently, the Event page receives data with this template
{{{for template|Event}}}
{| class="formtable"
! Name
| {{{field|Name}}}
|-
! Location
| {{{field|Location|input type=combobox}}}
|-
! Date
| {{{field|Date}}}
|-
! Time
| {{{field|Time}}}
|-
! PeopleOrganisations
| {{{field|PeopleOrganisations}}}
|-
! Type
| {{{field|Type|input type=combobox}}}
|-
! Web
| {{{field|Web|input type=checkbox}}}
|-
! Print
| {{{field|Print|input type=checkbox}}}
|}
{{{end template}}}
'''Text'''
{{{standard input|free text|rows=15|editor=wikieditor}}}
The combobox input type (see) looks up what has been already saved in that particular field from all the previous pages, and suggests possible completion.
± ± ±
Working with the frontend instead, requires to have / get some knowledge of:
- restful APIs (ref)
- how to handle page request, setup page routing, serve the app to the web, etc. — in this case with Python
- how to use a templating library
As we decided not to use a framework, the second point in particular gives you the chance to manually fiddle with stuff than if you mostly use a (php-based) cms, usually you can avoid or don’t have to touch at all.
Working with a restful API introduces you to the powerful world of json (intro), a very flexible data format able to convert anything into anything else—and back.
When working with Python, there are two very useful commands that let you inspect a json dataset:
type(data), egprint(type(data))— to check if the current object is a dict, or a lists, a string and so forthdata.keys(), egprint(data.keys())— to check the object’s keys (which is howjsonstructures data)
Alternatively, you can access to a pretty-printed version of the json request you made to MediaWiki, by visiting that url, eg
https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json
and adding fm after format=json, like format=jsonfm (see docs) to have an indented, more readable version
https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=jsonfm
This double approach lets you inspect better what’s going on in case you are unsure which data you are working with.
± ± ±
Once you get acquainted with MediaWiki’s design language (Forms, Templates, etc), json data structures and some basic Python, you can play around with the website.
± ± ±
/mediawiki/resources/src/mediawiki.action/mediawiki.action.history.styles.css
this add more padding and take out list styles to the revision list
#pagehistory {
margin-left: 0;
padding-top: 0.25rem;
}
#pagehistory li {
list-style: none;
padding: 0.5rem;
margin-bottom: 0.25rem;
}
#pagehistory li:hover {
background-color: #f8f9fa;
border: 1px dashed #a2a9b1;
}
/mediawiki/resources/src/mediawiki.action/mediawiki.action.history.css
this set the ‘compare selected revisions’ to the bottom-right, always at reach and more prominent (before there were two buttons at the top and bottom of the revision list, very much buried amongst the rest of the text)
.historysubmit {
position: fixed;
bottom: 0.5rem;
right: 1rem;
padding: 0.5rem;
font-size: 100%;
}
.historysubmit:hover, .historysubmit:active {
background-color: yellow;
cursor: pointer;
}

