fixed encoding error, cleaned script

master
Castro0o 9 years ago
parent a9e5722543
commit de51cb30a1

@ -1,33 +1,11 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2, json, pprint, re
import pprint, re, subprocess, shlex, urllib
import xml.etree.ElementTree as ET
import subprocess, shlex, urllib
from urlparse import urlparse
from mwclient import Site
sid = '1234'
useragent = "Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101"
endpoint = "http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&"
site = Site("pzwiki.wdka.nl", path="/mw-mediadesign/")
# API MODULES
def api_request(action, pagename): #get page: content, metadata, images, imageifnp
pagename = urllib.quote(pagename.encode('utf-8'))
# print pagename
url = endpoint + (action.format(pagename))
# print 'API REQUEST', url
request = urllib2.urlopen(url)
jsonp = json.loads(request.read() )
json_dic= (jsonp.get('query').get('pages'))
# pprint.pprint( json_dic )
page_id = json_dic.keys()[0]
page_content = json_dic.get(page_id)
return page_content
##############################
# CATEGORIES, PAGES AND IMAGES
##############################

@ -3,9 +3,9 @@
import xml.etree.ElementTree as ET
import html5lib, pprint
from mmdc_modules import pandoc2html, parse_work, replace_gallery, replace_video, index_addwork, write_html_file, mw_cats, mw_imgsurl, site, mw_page_text
from mmdc_modules import pandoc2html, parse_work, replace_gallery, replace_video, index_addwork, write_html_file, mw_cats, mw_imgsurl, mw_page_text, site
from argparse import ArgumentParser
from mwclient import Site
p = ArgumentParser()
p.add_argument("--host", default="pzwiki.wdka.nl")
@ -18,30 +18,29 @@ print args
# Index
########
memberpages=mw_cats(site, args)
#memberpages['Ctrl-F Reader','As We Speak']
#memberpages = [ u'The Aesthetics of Ethics']#
print 'memberpages', memberpages
########
# Templates
########
page_template = open("web/page-template.html", "r")
index_file = open('web/index-template.html', 'r')
index_tree = html5lib.parse(index_file, namespaceHTMLElements=False)
index_template = open('web/index-template.html', 'r')
index_tree = html5lib.parse(index_template, namespaceHTMLElements=False)
index_container = index_tree.find(".//div[@class='isotope']") #maybe id is important, to destinguish it
########
# Create Page
########
for member in memberpages:
print ' member', member
workpage_mw = mw_page_text(site, member)#CONTENT
workpage_mw = replace_gallery(workpage_mw)
workpage_mw = replace_video(workpage_mw)
workdict = parse_work(member, workpage_mw) # create dictionary w/ page content
workpage_imgs = mw_imgsurl(site, member)
print ' member', member
# only parse pages with Creator, Title, Thumbnail
if len(workdict['Creator'])>1 and len(workdict['Title'])>1 and len(workdict['Description'])>1 and len(workdict['Thumbnail'])>1:
if len(workdict['Creator'])>1 and len(workdict['Title'])>1 and len(workdict['Thumbnail'])>1: #and len(workdict['Description'])>1
for key in workdict.keys(): # convert Extra, Description, Bio to HTML
if key in ['Extra', 'Description', 'Bio'] and workdict[key]:
workdict[key] = pandoc2html( (workdict[key].decode('utf-8')))
@ -52,16 +51,18 @@ for member in memberpages:
if type(workdict[key]) is unicode:
workdict[key]=workdict[key].encode('utf-8')
# print workdict, type(workdict['Creator'])
# print workdict['Creator']#.decode('utf-8')
# create work page
page_tree = html5lib.parse(page_template, namespaceHTMLElements=False)
page_title = page_tree.find('.//title')
page_title.text=workdict['Title']
page_title.text='Title'#workdict['Title']#.decode('utf-8')
page_creator = page_tree.find('.//h2[@id="creator"]')
page_creator.text=workdict['Creator']
page_creator.text=(workdict['Creator'].decode('utf-8'))
page_title_date = page_tree.find('.//p[@id="title"]')
page_title_date.text="{} {}".format(workdict['Title'], workdict['Date'])
page_description = page_tree.find('.//div[@id="description"]')
page_description_el = ET.fromstring('<div>'+workdict['Description']+'</div>')
page_description_el = ET.fromstring('<div>'+"workdict['Description']"+'</div>')
page_description.extend(page_description_el)
page_bio = page_tree.find('.//div[@id="bio"]')
page_bio_el = ET.fromstring('<div>'+workdict['Bio']+'</div>')
@ -79,18 +80,16 @@ for member in memberpages:
# give work page's imgs full url
imgs = page_tree.findall('.//img')
print 'ALL PAGE IMGS', imgs
for img in imgs:
img_class = img.get('class')
if img_class != 'template':
src =unicode(img.get('src'))
print src
for pair in workpage_imgs:
if src.replace("_", " ") in pair[0]:#if img in html matchs img in workpage_imgs
img.set('src', pair[1])
# save work page
creator = workdict['Creator']#.decode('ascii', 'ignore')
creator = workdict['Creator'].decode('ascii', 'ignore')
creator = creator.replace(' ','_')
work_filename = 'web/{}-{}.html'.format(workdict['Date'], creator)
write_html_file(page_tree, work_filename)
@ -101,8 +100,8 @@ for member in memberpages:
index_addwork( parent=index_container,
workid=key,
href=work_filename.replace('web/',''),
title=workdict['Title'],#.decode('utf-8'),
creator=workdict['Creator'],#.decode('utf-8'),
title="workdict['Title']",#.decode('utf-8'),
creator="workdict['Creator']",#.decode('utf-8'),
date=workdict['Date'],
thumbnail=workdict['Thumbnail']
)

@ -1,2 +1,2 @@
#!/bin/sh
python mmdc_wiki2web.py --category Graduation_work 2015
python mmdc_wiki2web.py --category Graduation_work --category 2015

@ -1,12 +1,12 @@
<html><head>
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport" />
<!DOCTYPE HTML><html><head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>Title</title>
<link href="./css/style.css" rel="stylesheet" />
<link href="./css/style_projectpage.css" rel="stylesheet" />
<link href="./fonts/fontstylesheet01.css" rel="stylesheet" />
<link href="./css/fixedsticky.css" rel="stylesheet" />
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">
<link href="./css/fixedsticky.css" rel="stylesheet">
</head>
<body>
@ -15,24 +15,25 @@
<div id="sidebarInner">
<div id="sideBarDesc">
<div id="sideBarDescInfo">
<a class="hoverBackA" href="index.html"><img src="./img/arrowBack.svg" /></a><p>Tempted by Tomorrow</p>
<a class="hoverBackA" href="index.html"><img class="template" src="./img/arrowBack.svg"></a><p>Tempted by Tomorrow</p>
</div>
<div id="sideBarDescInner">
<!-- we used h2's and p's instead of divs here, moved 2015 and deleted http://pzwiki.wdka.nl/mw-mediadesign/images/b/bd/Collage_007_thumbnail.jpg -->
<!-- we used h2's and p's instead of divs here, moved date and deleted thumbnail -->
<h2 id="creator">Ana Lu&#237;sa Moura</h2>
<h2 id="creator">Ana Luísa Moura</h2>
<p id="title">Title 2015</p>
<p id="title">The Aesthetics of Ethics 2015</p><!--{title} {date} -->
<!-- moved up desc -->
<!-- moved up description -->
<div id="description">desc</div>
<div id="description"></div>
<div id="bio" />
<div id="bio"><p>Ana Luísa Moura (PT) has a background in Architecture / Urban Planning and is currently exploring means of visual storytelling and strategic illustration. Her research focuses on photographical protocols within media imagery, regarding in particular the instrumentalization of vulnerability and personal exposure.</p>
</div>
<p class="hightlightSidebar" />
<p class="hightlightSidebar"><a href="" target="_blank"></a></p><!-- {website} -->
<!-- // -->
@ -40,34 +41,36 @@
</div>
</div>
<div id="logoWrap"><img id="logo" src="./img/black_PZI_logo_p.svg" /></div>
<div id="logoWrap"><img class="template" id="logo" src="./img/black_PZI_logo_p.svg"></div>
</div>
<div class="zwartArea zwartAreaWhite sidebarBorderLeft" id="section02">
<div class="fixedsticky" id="filter" style="top:0;">
<div class="themes" id="sortArea">
<a class="hoverBackB" href="index.html"><img src="./img/arrowBack.svg" /></a><p>Title</p><a class="closeSidebar"><img src="./img/arrowUpW.svg" /></a>
<a class="hoverBackB" href="index.html">
<img class="template" src="./img/arrowBack.svg">
</a>
<p>The Aesthetics of Ethics</p><!--{title}-->
<a class="closeSidebar"><img class="template" src="./img/arrowUpW.svg"></a>
</div>
</div>
<!-- extra -->
<div class="project" id="extra">
<img id="thumnail" src="http://pzwiki.wdka.nl/mw-mediadesign/images/b/bd/Collage_007_thumbnail.jpg" />
extra
</div>
<img id="thumbnail" src="http://pzwiki.wdka.nl/mw-mediadesign/images/b/bd/Collage_007_thumbnail.jpg">
<p>The Aesthetics of Ethics is a reflection on the way social documentary photography shapes ethical concern. The aesthetics of these photographs map out a set of emotional reactions to social issues, tailoring a form of political consciousness. The project associated with the theoretical research, an illustration exercise, unfolds and explores the visual grammar of the genre. Attention to details of a manufactured informality allows the understanding of the images as an encoded language, detaching it from the objectivity and authority of the photographical medium (...)</p>
</div>
<!---->
</div>
</div>
<script src="./js/jquery-2.1.3.min.js" />
<script src="./js/fixedfixed.js" />
<script src="./js/fixedsticky.js" />
<script src="./js/isotope.pkgd.min.js" />
<script src="./js/imagesloaded.pkgd.min.js" />
<script src="./js/mainScripts_single.js" />
<script src="./js/jquery-2.1.3.min.js"></script>
<script src="./js/fixedfixed.js"></script>
<script src="./js/fixedsticky.js"></script>
<script src="./js/mainScripts_single.js"></script>

@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>Artyom-graduation-work</title>
<title>Title</title>
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">
@ -28,8 +28,7 @@
<!-- moved up description -->
<div id="description"><p>Artyoms work entitled “New Image” is a series of images of that have been made using Google Image search results. In his work Artyom explores the relations between images and the technology that is responsible for their production and distribution. Namely how technological endeavors came to affect the dynamics within image culture.</p>
</div>
<div id="description"></div>
<div id="bio"><p>Artyom Kocharyan (AM) is visual artist based in Rotterdam. His work explores the contemporary visual culture, namely the culture of images that increasingly dominate the world of communication. Artyoms work is concerned with the representation aspect of images and their ability to determine our vision of the world. Artyom is engaged with the representation apparatus that is peculiar to current digital and online culture.</p>
</div>

@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>U ntitled</title>
<title>Title</title>
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">
@ -28,8 +28,7 @@
<!-- moved up description -->
<div id="description"><p>Untitled is a work about visualizing non audible and non visual acoustic properties of a space. Every space has a certain acoustic reverberation, a property that can't be heard or seen on it's own. With this project I aim to visualize that property trough data visualization. Untitled contains a (few) examples of spaces that have been mapped and visualized in a new form and material. These sculptures are presented in a way that the viewer may contextualize on it's own what the nature of the sculpture is</p>
</div>
<div id="description"></div>
<div id="bio"><p>Henk-Jelle de Groot is a Rotterdam based sound designer and musician. After graduating with an Audio / Visual design bachelor Henk-Jelle setup a sound studio in Rotterdam to work in the Audio / Visual industry. After 7 years of working he returned to the Piet Zwart Institute to graduate in a Master of comm design something something. In addition to working in the Audio / Visual industry, he is muscian and builder of electronic instruments.</p>
</div>

@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>User:Joak/graduation/catalog1</title>
<title>Title</title>
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">

@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>Mina</title>
<title>Title</title>
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">
@ -28,8 +28,7 @@
<!-- moved up description -->
<div id="description"><p>Mina is a smart chat bot, a commercial project designed by a promising startup to fulfill humans' need of talking to someone else in a world where communication has become almost completely mediated by social media services. To keep the illusion alive, the software aims to be invisible.</p>
</div>
<div id="description"></div>
<div id="bio"><p>The bio is coming soon.</p>
</div>

@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>Qq</title>
<title>Title</title>
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">
@ -28,8 +28,7 @@
<!-- moved up description -->
<div id="description"><p>The novel <strong>Q</strong> was written by four Bologna-based members of the LBP, as a final contribution to the project, and published in Italy in 1999. So far, it has been translated into English (British and American), Spanish, German, Dutch, French, Portuguese (Brazilian), Danish, Polish, Greek, Czech, Russian, Turkish, Basque and Korean. In August 2003 the book was nominated for the Guardian First Book Prize.</p>
</div>
<div id="description"></div>
<div id="bio"><p>Luther Blissett is a multiple-use name, an open pop star informally adopted and shared by hundreds of artists and activists all over Europe and the Americas since 1994. The pseudonym first appeared in Bologna, Italy, in mid-1994, when a number of cultural activists began using it for staging a series of urban and media pranks and to experiment with new forms of authorship and identity. From Bologna the multiple-use name spread to other European cities, such as Rome and London, as well as countries such as Germany, Spain, and Slovenia.[1] Sporadic appearances of Luther Blissett have been also noted in Canada, the United States, and Brazil.</p>
</div>

@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>User:Max Dovey/maxgradbio</title>
<title>Title</title>
<link href="./css/style.css" rel="stylesheet">
<link href="./css/style_projectpage.css" rel="stylesheet">
<link href="./fonts/fontstylesheet01.css" rel="stylesheet">
@ -28,8 +28,7 @@
<!-- moved up description -->
<div id="description"><p>How to be more or less human.</p>
</div>
<div id="description"></div>
<div id="bio"><p>My Bio</p>
</div>

@ -81,7 +81,7 @@
<div class="isotope"> <!-- Maybe sould aslo have have-->
<div class="grid-sizer"></div>
<div class="item" data-creator="Max Dovey" data-date="2015" data-title="User:Max Dovey/maxgradbio" id="Extra"><a class="work" href="2015-Max_Dovey.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/1/16/Pointer.gif"></a></div><div class="item" data-creator="Luther Blisset" data-date="2015" data-title="Qq" id="Extra"><a class="work" href="2015-Luther_Blisset.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/8/85/Luther-blissett-300.jpg"></a></div><div class="item" data-creator="Artyom" data-date="2015" data-title="Artyom-graduation-work" id="Extra"><a class="work" href="2015-Artyom.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/6/6a/Screen_Shot_2014-10-26_at_16.10.08.jpg"></a></div><div class="item" data-creator="Lucia Dossin" data-date="2015" data-title="Mina" id="Extra"><a class="work" href="2015-Lucia_Dossin.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/5/59/3legs.jpg"></a></div><div class="item" data-creator="Henk-Jelle de Groot" data-date="2015" data-title="U ntitled" id="Extra"><a class="work" href="2015-Henk-Jelle_de_Groot.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/e/e7/9m4MBqRM1w-6.png"></a></div></div>
<div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Max_Dovey.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/1/16/Pointer.gif"></a></div><div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Luther_Blisset.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/8/85/Luther-blissett-300.jpg"></a></div><div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Artyom.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/6/6a/Screen_Shot_2014-10-26_at_16.10.08.jpg"></a></div><div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Joseph_Knierzinger.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/1/16/Pointer.gif"></a></div><div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Ana_Lusa_Moura.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/b/bd/Collage_007_thumbnail.jpg"></a></div><div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Lucia_Dossin.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/5/59/3legs.jpg"></a></div><div class="item" data-creator="workdict['Creator']" data-date="2015" data-title="workdict['Title']" id="Extra"><a class="work" href="2015-Henk-Jelle_de_Groot.html"><img class="work" src="http://pzwiki.wdka.nl/mw-mediadesign/images/e/e7/9m4MBqRM1w-6.png"></a></div></div>
</div>
<div class="sidebarBorderLeft zwartArea" id="section03">
<div class="zwartAreaFull zwartColophon">

Loading…
Cancel
Save