User:Tash/grad prototyping3

From XPUB & Lens-Based wiki

Prototyping 09 April

Guilded Youth, text-based adventure game
Guilded Youth, text-based adventure game

Takeaways from last assessment:

  • important to build context & urgency
  • installation at exhibition should situate the game within warnet culture
  • cards may not be the most suitable format?

  • option 1: game manual / player's handbook
    • print element, places it again within copyshop / warnet context
    • physical element, to counterbalance online aspect of the game
    • references the tactical handbook (military, troll handbooks, counterculture manuals etc)

  • option 2: text-based browser game
    • brings it into the realm of videogames
    • more immersive gameplay
    • technically difficult (how to do multiplayer? how to incorporate into wiki?

  • questions:
    • how to keep the tension between chance vs choice ?
    • roles of different project elements: wiki as rabbithole and input point, handbook / cards / text-based prompts as tools and the game as performance


  • April: finalize formats & develop game
  • April - May: 2 more play sessions (with Marlies / shayan / jacintha?)
  • June: final documentation and production

Wiki sitemap


Wiki development: 27 March

Screen Shot 2019-03-27 at 14.02.56.png
Screen Shot 2019-03-27 at 14.04.03.png

To-do (Test play 2)

  • Finalize Plan A and Plan B for test location and time
  • Test archiving script over at least 10 mins of activity
  • Gameplay: prepare at least 4 email addresses
  • Gameplay: prepare cards & print
  • Gameplay: make handbook version & print
  • Wiki: make & populate all action / tactic pages
  • Wiki: make at least 3 characters to choose from
  • Buy papers & stationery

Prototyping 06 May

Debugging Mediawiki

  • problem: mediawiki categories were not saving onto database
  • running the maintenance script rebuildall.php was a temp solution
  • more research: turns out there seems to a be a problem in the php extension settings, and errors with looking up certain shared database files
  • working on it with Andre: perhaps the sqlite database is creating errors
  • solution: reinstall wiki with mysql database, move content to new wiki
  • export using backupDump.php --current --output dump.xml
  • sudo php importDump.php < /home/pi/dump.xml
  • with the new database, jobs seem to run smoothly, categories are updating!

Wiki to print pipelines

Code: Import wiki content & save images

#! /usr/bin/env python
# -*- coding: utf-8 -*-

from mwclient import Site
from urllib.parse import urlparse
from argparse import ArgumentParser
import time
from datetime import datetime
import os
from urllib.request import urlopen
from urllib.request import quote
from bs4 import BeautifulSoup

# Arguments
p = ArgumentParser()
p.add_argument("--host", default="")
p.add_argument("--path", default="/warnet/", help="nb: should end with /")
p.add_argument("--category", "-c", nargs="*", default=[["Tactics"]], action="append", help="category to query")
p.add_argument("--download", "-d", default="htmlpages", help="What you want to download: htmlpages; images; wikipages")

args = p.parse_args()
#print args

# defs
def mwsite(host, path): #returns wiki site object
    site = Site(('http',host), path)
    return site

def mw_cats(site, categories): #returns pages member of categories
    last_names = None
    for cat in categories:
            for ci, cname in enumerate(cat):
                    cat = site.Categories[cname]
                    pages = list(cat.members())
                    if last_names == None:
                            results = pages
                            results = [p for p in pages if in last_names]                
                    last_names = set([ for p in pages])
            results = list(results)
    return [  for p in results]

def mw_page(site, page):
    page = site.Pages[page]
    return page

def mw_page_imgsurl(site, page, imgdir):
    #all the imgs in a page
    #returns dict {"imagename":{'img_url':..., 'timestamp':... }} 
    imgs = page.images() #images in page
    imgs = list(imgs) 
    imgs_dict = {}
    if len(imgs) > 0:
        for img in imgs:
            if 'url' in img.imageinfo.keys(): #prevent empty images
                imagename =
                imagename = (imagename.capitalize()).replace(' ','_')
                imageinfo = img.imageinfo
                imageurl = imageinfo['url']
                timestamp = imageinfo['timestamp'] ## is .isoformat() 
                imgs_dict[imagename]={'img_url': imageurl,
                                    'img_timestamp': timestamp } 
                os.system('wget {} -N --directory-prefix {}'.format(imageurl, imgdir))
                # wget - preserves timestamps of file
                # -N the decision as to download a newer copy of a file depends on the local and remote timestamp and size of the file.                  
        return imgs_dict
        return None

def write_plain_file(content, filename):
    edited = open(filename, 'w') #write

# ------- Action: Import HTML -------

site = mwsite(, args.path)

memberpages=mw_cats(site, args.category)
print (memberpages)

for pagename in memberpages:
    if == 'htmlpages':
        url = u""+quote(pagename)

        response = urlopen(url) 
        print ('Download html source from', pagename)
        htmlsrc =
        pagename = (pagename.replace(" ", "_"))
        write_plain_file(htmlsrc, "{}/{}.html".format(html_dir, pagename.replace('/','_')) )

        print ('Download images from', pagename)
        page = mw_page(site, pagename)
        page_imgs = mw_page_imgsurl(site, page, img_dir)


# ------- Action: Modify HTML using BeautifulSoup -------

path = './htmls/'

for filename in os.listdir(path):
    if filename.endswith(".html"):
        print (filename)
        htmlsrc = open('./htmls/{0}'.format(filename), "rb")
        soup = BeautifulSoup(htmlsrc, "html5lib")

        for el in soup.find_all(class_='thumb tright'):

        counter = 0
        for el in soup.find_all('p'):
            counter= counter+1
            if counter > 0:

        for el in soup.find_all(class_='button'):

        for el in soup.find_all('h3'):

        for el in soup.find_all('table'):

        for el in soup.find_all('hr'):

        for el in soup.find_all(attrs={"title": "Tactics"}):

        new = soup.prettify()
        filename = filename.replace('.html', '')

        with open("./htmls/edits/{0}.html".format(filename), 'w') as edited:


Code: Make PDFs for cards using Weasyprint

from weasyprint import HTML, CSS
import os

## Make pdfs ##
path = './htmls/edits/'
for filename in os.listdir(path):
	title = filename.replace('.html', '')

	if filename.endswith(".html"):

Wiki development: 16 May

Screen Shot 2019-05-16 at 01.00.54.png
Screen Shot 2019-05-16 at 01.01.00.png
Screen Shot 2019-05-16 at 01.01.04.png

Wiki development: 7 June

Screen Shot 2019-06-05 at 17.52.22.png
Screen Shot 2019-06-05 at 17.57.59.png
Screen Shot 2019-06-05 at 17.58.20.png