diff --git a/README b/README.md similarity index 100% rename from README rename to README.md diff --git a/mmdc_modules.py b/mmdc_modules.py index 00ee1c4..5cbe30f 100644 --- a/mmdc_modules.py +++ b/mmdc_modules.py @@ -12,11 +12,8 @@ endpoint = "http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&" # API MODULES def api_request(action, pagename): #get page: content, metadata, images, imageifnp - print 'API REQUEST' - print pagename - print 'TEST', action.format(pagename) url = endpoint + (action.format(pagename)) - print 'API REQUEST', url +# print 'API REQUEST', url request = urllib2.urlopen(url) jsonp = json.loads(request.read() ) json_dic= (jsonp.get('query').get('pages')) @@ -76,24 +73,6 @@ def api_pagesincategories(category, year): else: intersectCatMembers = graduation_work_members return intersectCatMembers - # for page in intersectCatMembers: - # title = ((page['title']).encode('utf-8') ).replace(" ", "_") #snakecase for page titles - # pageid = page['pageid'] - # article = api_page(pageid, 'content') - # # print title - # # pprint.pprint(article) - # work = parse_work_page(title, article) - # if work: - # allworks[pageid] = work #dictionary(allworks) entry - # print pprint.pprint( work ) - # # Create work page - # else: - # print 'WORK DOES NOT CONTAIN REQUIRED CONTENT' - # print '-------------' - # print - - - def api_file_url(filename): # get full urls page_content_dict = api_page(filename, 'file') @@ -104,15 +83,9 @@ def api_file_url(filename): # get full urls return None def api_thumb_url(filename): - print '''get thumbnail url of image''' thumburl = api_page(filename, 'imageinfo') thumburl = ((thumburl.get('imageinfo'))[0].get('thumburl')) - print thumburl return thumburl - -# http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&action=query&titles=File:2x2 905.jpg&prop=imageinfo&iiprop=url&iiurlwidth=300 -# http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&action=query&pageids=10603&prop=revisions&rvprop=content -# http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&action=query&titles=Graduation_Website_Braindump&prop=revisions&rvprop=content # PROCESSING MODULES @@ -124,7 +97,6 @@ def write_html_file(html_tree, filename): edited.close() # mw article modules - def parse_work_page(title, content): # content = content.encode('utf-8') if re.match('\{\{\Graduation work', content): @@ -135,9 +107,6 @@ def parse_work_page(title, content): if extra: #append extra extra = ('Extra', extra) keyval.append(extra) #? - -# checkkeys = [keyval[i] for i in range(len(keyval)) if keyval[i][0] in mainkeys and len(keyval[i][1])>3] #list mainkeys present, w/ values, in tuples [(key, val),(key, val)...] - # if len(checkkeys) == 3 : # checkkeys contains all mainkeys and values for pair in keyval: key = pair[0] val = pair[1] @@ -147,7 +116,6 @@ def parse_work_page(title, content): elif 'Thumbnail' in key: thumburl = api_thumb_url(val) work_dict['Thumbnail_url']=thumburl - print 'THUMB:', thumburl work_dict[key]=val return work_dict, extra @@ -155,8 +123,7 @@ def parse_work_page(title, content): # Alternative to parse_work_page def parse_work(title, content): - workdict = {'Title':title, 'Creator':'', 'Date':'', 'Website':'', 'Thumbnail':'', 'Bio':'', 'Description':'', 'Extra':''} - + workdict = {'Title':title, 'Creator':'', 'Date':'', 'Website':'', 'Thumbnail':'', 'Bio':'', 'Description':'', 'Extra':''} if re.match('\{\{\Graduation work', content): template, extra = (re.findall('\{\{Graduation work\n(.*?)\}\}(.*)', content, re.DOTALL))[0] if extra: @@ -217,3 +184,21 @@ def replace_video(content): content = re.sub(youtube_exp, "", content) return content + +# Index Creation +def index_addwork(parent, workid, href, thumbnail, title, creator, date): + child_div = ET.SubElement(parent, 'div', attrib={'class':'item', + 'id':workid, + 'data-title':title, + 'data-creator':creator, + 'data-date':date}) + + grandchild_a = ET.SubElement(child_div, 'a', attrib={'href':href, 'class':'work'}) + grandgrandchild_img = ET.SubElement(grandchild_a, 'img', attrib={'class':'work', 'src':thumbnail}) +# TEXT CONTENT ? +# grandchild_text = ET.SubElement(child_div, 'div', attrib={'class':'work'}) +# grandchild_text.text=creator + + + + # need to add css width to div.item diff --git a/prototype_page.py b/prototype_page.py index 0d63e05..81352cf 100755 --- a/prototype_page.py +++ b/prototype_page.py @@ -17,7 +17,7 @@ import xml.etree.ElementTree as ET import html5lib, re, pprint -from mmdc_modules import api_request, api_page, api_thumb_url, pandoc2html, parse_work, api_file_url, replace_gallery, replace_video, gallery_exp, video_exp, api_pagesincategories +from mmdc_modules import api_request, api_page, api_thumb_url, pandoc2html, parse_work, api_file_url, replace_gallery, replace_video, gallery_exp, video_exp, api_pagesincategories, index_addwork, write_html_file ######## # QUERY API @@ -29,18 +29,27 @@ endpoint = "http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&" ######## # CREATE INDEX ######## -memberpages = api_pagesincategories('Graduation work', '2015') #list, containing dictionary of all page ids. Example: [{u'ns': 0, u'pageid': 15974, u'title': u'Ahhhh'}, {u'ns': 0, u'pageid': 16005, u'title': u'Artyom-graduation-work'}] -#memberpages = [{u'ns': 0, u'pageid': 16005, u'title': u'Artyom-graduation-work'}] +memberpages = api_pagesincategories('Graduation work', '2015') #list, containing dictionary of all pages ids. Example: [{u'ns': 0, u'pageid': 15974, u'title': u'Ahhhh'}, {u'ns': 0, u'pageid': 16005, u'title': u'Artyom-graduation-work'}] +#memberpages = [{u'ns': 0, u'pageid': 15982, u'title': u'The Aesthetics of Ethics'}] +#memberpages = [{u'ns': 0, u'pageid': 16005, u'title': u'Artyom-graduation-work'}] #memberpages = [{u'ns': 0, u'pageid': 16007, u'title': u'U ntitled'}] #memberpages = [{u'ns': 0, u'pageid': 15965, u'title': u'Qq'}] print 'memberpages', memberpages ######## -# CREATE PAGE +# Templates ######## page_template = open("web/page-template.html", "r") page_template = page_template.read() +index_file = 'web/index-template.html' +index_file = open(index_file, 'r') +index_tree = html5lib.parse(index_file, 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 # download mw work page @@ -78,11 +87,8 @@ for member in memberpages: img.set('src', newsrc) website = tree.find('.//p[@class="hightlightSidebar"]/a') - print 'website', ET.tostring(website) - - if not website.get('href'): - #remove empty .//p[@class="hightlightSidebar"]/a - # This can be applied to more fields + if not website.get('href'): # if no website link. + #remove empty .//p[@class="hightlightSidebar"]/a website_parent = tree.find('.//p[@class="hightlightSidebar"]') website_parent.remove(website) @@ -95,4 +101,17 @@ for member in memberpages: work_file.write(workpage_html) work_file.close() + # insert work to index + index_addwork( parent=index_container, + workid=key, + href=work_filename.replace('web/',''), + title=(workdict['Title']).decode('utf-8'), + creator=workdict['Creator'].decode('utf-8'), + date=workdict['Date'], + thumbnail=workdict['Thumbnail'], + ) + +write_html_file(index_tree, 'web/index.html') +print +print diff --git a/web/index-template.html b/web/index-template.html index 44338ba..739dfa7 100644 --- a/web/index-template.html +++ b/web/index-template.html @@ -1,47 +1,139 @@ + + + - Media Design & Communication - Piet Zwart Institute + + + Piet Zwart Institute: Master Media Design & Communication + - - + + + + + + + -
-
+
+
+
+
+
+
+ + +

Piet Zwart Institute: Master Media Design & Communication

+ +

+ The Piet Zwart Institute, Master in Media Design is an intensive project-based research degree that will equip you to create a distinctive voice as an artist/designer in the contemporary media landscape.

+

+ Our programme encourages students to explore the new possibilities released by the friction between media forms, critically working across the historical gaps between photography, cinema, animation, mobile media, information systems and technological networks. This course does not believe in old media and new media, nor in the pattern of media extinctions that punctuate traditional media histories: we believe in the cross fertilisation of a thriving media ecology.

+

+ Digital media can be thought of as a field in which radically different materialities of software, interface and human behaviour are being brought together for the first time. This is often experienced as tensions between computer code and the images that this code generates but does not explain; a tension between abstract symbols and concrete models, between concept and sensation. This course does not try to resolve these tensions but uses them to stimulate new ways to think about how we might live with information today.

+ +

Graduation 2015: Tempted by Tomorrow

+

+ Exhibitions, programming, conferences and publications are a means of expanding our research beyond the confines of academia, while simultaneously valuing the very necessary speculative space for reflection and knowledge-building that is only made possible through an academic framework like the Piet Zwart Institute. +

+
+
-
-
-

Media Design & Communication - Piet Zwart Institute

-

Graduation 2012

+ + + -
-
- - +
+ + + +
+

User:Joak/graduation/catalog1

+

Joseph Knierzinger

+

2015

+
+
+
+ + + +
+

User:Max Dovey/maxgradbio

+

Max Dovey

+

2015

+
+
+
+ + + +
+

Ahhhh

+

JOK

+

2015

+
+
+
+ + + +
+

The Aesthetics of Ethics

+

Ana Luísa Moura

+

2015

+
+
+
+ + + +
+

Qq

+

Luther Blisset

+

2015

+
+
+
- + - \ No newline at end of file +