diff --git a/mmdc_modules.py b/mmdc_modules.py index 79c47e5..4e61b44 100644 --- a/mmdc_modules.py +++ b/mmdc_modules.py @@ -79,8 +79,10 @@ def api_thumb_url(filename): # PROCESSING MODULES def write_html_file(html_tree, filename): + print 'WRITE HTML FILE' doctype = "" - html = doctype + ET.tostring(html_tree, encoding='utf-8', method='html') + print 'TREE', type(html_tree) + html = doctype + ET.tostring(html_tree, method='html', encoding='utf-8', ) edited = open(filename, 'w') #write edited.write(html) edited.close() @@ -121,7 +123,7 @@ def pandoc2html(mw_content): gallery_exp=re.compile('(.*?)', re.S) -imgfile_exp=re.compile('(File:(.*?)\.(gif|jpg|jpeg|png|svg))') +imgfile_exp=re.compile('(File:(.*?)\.(gif|jpg|jpeg|png))') def replace_gallery(content): content = re.sub(imgfile_exp, '[[\g<1>]]', content) #add [[ ]] to File:.*? @@ -146,6 +148,10 @@ def index_addwork(parent, workid, href, thumbnail, title, creator, date): '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}) + grandchild_a = ET.SubElement(child_div, 'a', attrib={'href':href, 'class':'work'}) + if thumbnail is '': + grandgrandchild_h3 = ET.SubElement(grandchild_a, 'h3', attrib={'class':'work', 'id':'thumbnail_replacement'}) + grandgrandchild_h3.text=title + else: + grandgrandchild_img = ET.SubElement(grandchild_a, 'img', attrib={'class':'work', 'src':thumbnail}) # need to add css width to div.item diff --git a/mmdc_wiki2web.py b/mmdc_wiki2web.py index 46f2b8c..9b83229 100755 --- a/mmdc_wiki2web.py +++ b/mmdc_wiki2web.py @@ -37,15 +37,9 @@ endpoint = "http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&" # CREATE INDEX ######## memberpages=mw_cats(args) +#memberpages['Ctrl-F Reader','As We Speak'] print 'memberpages', memberpages -#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'}] -## output: memberpages [{u'ns': 0, u'pageid': 15982, u'title': u'The Aesthetics of Ethics'}] - ######## # Templates @@ -72,27 +66,35 @@ for member in memberpages: workpage_mw = replace_gallery(workpage_mw) workpage_mw = replace_video(workpage_mw) workdict = parse_work(member, workpage_mw) # create dictionary workpage_mw template + if len(workdict['Creator'])>1 and len(workdict['Title'])>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'))) + elif key in ['Creator']: + workdict[key] = workdict[key].replace(',','' ) #remove comma + + #replace empty dict values with ' ' # to avoid empty tags + for key in workdict.keys(): + if workdict[key] is '' and key is not 'Thumbnail': + workdict[key] = ' ' + elif key is 'Thumbnail' and workdict[key]: + img = ''.format(workdict[key]) + # append img to text + workdict[key] = workdict[key] # + img + print 'THUMB', workdict[key] - 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')) ) - - - - print 'EXTRA', type (workdict['Extra']), workdict['Extra'] - # fill template with dictionary/mw_page values - pprint.pprint(workdict) - - if len(workdict['Creator'])>1 and len(workdict['Creator'])>1: + if type(workdict[key]) is unicode: + workdict[key]=workdict[key].encode('utf-8') + # print workdict[key] - workpage_html = page_template.format(title=('Title'),#workdict['Title']), - creator=(workdict['Creator']), + workpage_html = page_template.format(title=workdict['Title'], + creator=workdict['Creator'], date=workdict['Date'], website=workdict['Website'], thumbnail=workdict['Thumbnail'], - bio=(workdict['Bio']), - description=(workdict['Description']), - extra=( workdict['Extra'] ) + bio=workdict['Bio'], + description=workdict['Description'], + extra=workdict['Extra'] ) # parse workpage_html # process html: img full url @@ -105,33 +107,31 @@ for member in memberpages: if newsrc: img.set('src', newsrc) - website = tree.find('.//p[@class="hightlightSidebar"]/a') - 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) - + ####### + # INDEX + ####### # save workpage_html workpage_html = ET.tostring(tree) - creator = workdict['Creator'].decode('ascii', 'ignore') + creator = workdict['Creator']#.decode('ascii', 'ignore') creator = creator.replace(' ','_') work_filename = 'web/{}-{}.html'.format(workdict['Date'], creator) work_file = open(work_filename, "w") work_file.write(workpage_html) work_file.close() - - - print 'DICT', type(workdict['Title']) - # insert work to index + + # 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'), + title=workdict['Title'],#.decode('utf-8'), + creator=workdict['Creator'],#.decode('utf-8'), date=workdict['Date'], - thumbnail=workdict['Thumbnail'], + thumbnail=workdict['Thumbnail'] ) - + # print '----', workdict['Title'] + # print ET.tostring(tree) + +print index_tree, type(index_tree) write_html_file(index_tree, 'web/index.html') print print diff --git a/web/2015-Artyom.html b/web/2015-Artyom.html index 5e5d50e..9492786 100644 --- a/web/2015-Artyom.html +++ b/web/2015-Artyom.html @@ -2,7 +2,7 @@ - Title + Artyom-graduation-work @@ -20,19 +20,19 @@
- +

Artyom

-

Title 2015

+

Artyom-graduation-work 2015

- +

Artyom’s 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.

-
+

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. Artyom’s 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.

+

www.artyomkocharyan.com

@@ -48,7 +48,7 @@
-

Title

+

Artyom-graduation-work

@@ -66,12 +66,10 @@
- + + + diff --git a/web/2015-Henk-Jelle_de_Groot.html b/web/2015-Henk-Jelle_de_Groot.html index 4f980f1..eb690a0 100644 --- a/web/2015-Henk-Jelle_de_Groot.html +++ b/web/2015-Henk-Jelle_de_Groot.html @@ -2,7 +2,7 @@ - Title + U ntitled @@ -20,21 +20,21 @@
- +

Henk-Jelle de Groot

-

Title 2015

+

U ntitled 2015

- +

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

-
+

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.

+
-

+

@@ -48,7 +48,7 @@
-

Title

+

U ntitled

@@ -56,7 +56,7 @@
- +
@@ -64,12 +64,10 @@
- + + + diff --git a/web/2015-Lucia_Dossin.html b/web/2015-Lucia_Dossin.html index 59d05cd..eb62720 100644 --- a/web/2015-Lucia_Dossin.html +++ b/web/2015-Lucia_Dossin.html @@ -2,7 +2,7 @@ - Title + Mina @@ -20,19 +20,19 @@
- +

Lucia Dossin

-

Title 2015

+

Mina 2015

- +

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.

-
hoi
+

The bio is coming soon.

+

www.example.com

@@ -48,7 +48,7 @@
-

Title

+

Mina

@@ -71,13 +71,11 @@
- + + + - \ No newline at end of file + diff --git a/web/2015-Luther_Blisset.html b/web/2015-Luther_Blisset.html index d03906b..2f03cbb 100644 --- a/web/2015-Luther_Blisset.html +++ b/web/2015-Luther_Blisset.html @@ -2,7 +2,7 @@ - Title + Qq @@ -20,19 +20,19 @@
- +

Luther Blisset

-

Title 2015

+

Qq 2015

- +

The novel Q 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.

-
Oh
+

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.

+

https://en.wikipedia.org/wiki/Luther_Blissett_(nom_de_plume)

@@ -48,7 +48,7 @@
-

Title

+

Qq

@@ -76,7 +76,8 @@ - + + - \ No newline at end of file + diff --git a/web/2015-Max_Dovey.html b/web/2015-Max_Dovey.html index c4618f9..39564b9 100644 --- a/web/2015-Max_Dovey.html +++ b/web/2015-Max_Dovey.html @@ -2,7 +2,7 @@ - Title + User:Max Dovey/maxgradbio @@ -20,19 +20,19 @@
- +

Max Dovey

-

Title 2015

+

User:Max Dovey/maxgradbio 2015

- +

How to be more or less human.

-
+

My Bio

+

http://maxdovey.com

@@ -48,7 +48,7 @@
-

Title

+

User:Max Dovey/maxgradbio

@@ -65,12 +65,10 @@
- + + + diff --git a/web/index.html b/web/index.html index 50d992a..7751cba 100644 --- a/web/index.html +++ b/web/index.html @@ -1,8 +1,8 @@ - - - + + + Piet Zwart Institute: Master Media Design & Communication @@ -70,7 +70,7 @@
- +
@@ -102,7 +102,7 @@ <div class="item video flash"><img src="img/project_roel2.png"></div> <div class="item narrative"><img src="img/project_andre.jpeg"></div--> -
+
diff --git a/web/page-template.html b/web/page-template.html index fc9b2c9..cc8ea6d 100644 --- a/web/page-template.html +++ b/web/page-template.html @@ -22,13 +22,13 @@
- +

{creator}

{title} {date}

- +
{description}
@@ -64,10 +64,10 @@
- - - - + + + +