From 818e007157317f31f87a25a170f7856fdbf0c4f2 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Sun, 31 May 2015 16:02:46 +0200 Subject: [PATCH] merging scripts --- ...index-template.html => index-template.html | 0 mmdc_modules.py | 137 ++++++++++-------- web/page-template.html => page-template.html | 0 web/2015-Ana_Lusa_Moura.html | 77 ---------- web/2015-Artyom.html | 79 ---------- web/2015-Henk-Jelle_de_Groot.html | 77 ---------- web/2015-Joseph_Knierzinger.html | 76 ---------- web/2015-Lucia_Dossin.html | 81 ----------- web/2015-Luther_Blisset.html | 86 ----------- web/2015-Max_Dovey.html | 81 ----------- 10 files changed, 76 insertions(+), 618 deletions(-) rename web/index-template.html => index-template.html (100%) rename web/page-template.html => page-template.html (100%) delete mode 100644 web/2015-Ana_Lusa_Moura.html delete mode 100644 web/2015-Artyom.html delete mode 100644 web/2015-Henk-Jelle_de_Groot.html delete mode 100644 web/2015-Joseph_Knierzinger.html delete mode 100644 web/2015-Lucia_Dossin.html delete mode 100644 web/2015-Luther_Blisset.html delete mode 100644 web/2015-Max_Dovey.html diff --git a/web/index-template.html b/index-template.html similarity index 100% rename from web/index-template.html rename to index-template.html diff --git a/mmdc_modules.py b/mmdc_modules.py index f04e168..a3fba24 100644 --- a/mmdc_modules.py +++ b/mmdc_modules.py @@ -1,20 +1,19 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- -import pprint, re, subprocess, shlex, urllib +import pprint, re, subprocess, shlex import xml.etree.ElementTree as ET from mwclient import Site -site = Site("pzwiki.wdka.nl", path="/mw-mediadesign/") -############################## -# CATEGORIES, PAGES AND IMAGES -############################## -def mw_page_text(site, page): - page = site.Pages[page] - text = page.text() - return text -def mw_cats(site, args): +######### +# Site Level +######### +def mwsite(host, path): #returns wiki site object + site = Site(host, path) + return site + +def mw_cats(site, args): #returns pages member of args(categories) last_names = None for cats in args.category: for ci, cname in enumerate(cats): @@ -30,21 +29,42 @@ def mw_cats(site, args): results = list(results) return [p.name for p in results] -def mw_singelimg_url(site, img): #find full of an img - if 'File:' not in img: - img = 'File:'+img - img_page=site.Pages[img] - img_url = (img_page.imageinfo)['url'] - return img_url + -def mw_imgsurl(site, page): #all the imgs in a page #return: list of tuples (img.name, img.fullurl) +############################## +# CATEGORIES, PAGES AND IMAGES +############################## +def mw_page(site, page): page = site.Pages[page] + return page + +def mw_page_text(site, page): + text = page.text() + return text + +def mw_page_cats(site, page): + cats_list = list(page.categories()) + cats = [cat.name for cat in cats_list if cat.name != u'Category:04 Publish Me'] + return cats + + +def mw_page_imgsurl(site, page): + #all the imgs in a page + #returns list of tuples (img.name, img.fullurl) imgs = page.images() imgs = list(imgs) - urls = [((img.name),(img.imageinfo)['url']) for img in imgs] + urls = { img.name: (img.imageinfo)['url'] for img in imgs} return urls +def mw_img_url(site, img): #find full of an img + if 'File:' not in img: + img = 'File:'+img + img_page=site.Pages[img] + img_url = (img_page.imageinfo)['url'] + return img_url + + # PROCESSING MODULES @@ -56,43 +76,39 @@ def write_html_file(html_tree, filename): edited.write(html) edited.close() -def parse_work(title, content): - workdict = {'Title':title, 'Creator':u'', 'Date':u'', 'Website':u'', 'Thumbnail':u'', 'Bio':u'', 'Description':u'', 'Extra':u''} - if re.match(u'\{\{\Graduation work', content): - template, extra = (re.findall(u'\{\{Graduation work\n(.*?)\}\}(.*)', content, re.DOTALL))[0] - if extra: - workdict['Extra'] = extra - # template's key/value pair - # Note:Extra value is NOT CAPTURED by this regex - keyval = re.findall(u'\|(.*?)\=(.*?\n)', template, re.DOTALL) - for pair in keyval: - key = pair[0] - val = (pair[1]).replace('\n', '') - if 'Creator' in key: - val = val.replace(u', ', u'') - elif 'Thumbnail' in key: - val = mw_singelimg_url(site, val)#api_thumb_url(val) - elif 'Website' in key: - val = urllib.unquote( val) - workdict[key]=val -# pprint.pprint(workdict) - return workdict - def pandoc2html(mw_content): '''convert individual mw sections to html''' mw_content = mw_content.encode('utf-8') - # convert from mw to html - args_echo =shlex.split( ('echo "{}"'.format(mw_content)) ) - args_pandoc = shlex.split( 'pandoc -f mediawiki -t html5' ) - p1 = subprocess.Popen(args_echo, stdout=subprocess.PIPE) - p2 = subprocess.Popen(args_pandoc, stdin=p1.stdout, stdout=subprocess.PIPE) - html = (p2.communicate())[0] + tmpfile = open('tmp_content.mw', 'w') + tmpfile.write(mw_content) + tmpfile.close() + args_pandoc = shlex.split( 'pandoc -f mediawiki -t html5 tmp_content.mw' ) + pandoc = subprocess.Popen(args_pandoc, stdout=subprocess.PIPE) + html = pandoc.communicate()[0] html = html.decode("utf-8") return html - + +author_exp = re.compile('^Authors?\: ?(.*?)\\n') +cat_exp = re.compile('\[\[Category\:.*?\]\]') gallery_exp=re.compile('(.*?)', re.S) imgfile_exp=re.compile('(File:(.*?)\.(gif|jpg|jpeg|png))') +def find_authors(content): + authors = re.findall(author_exp, content[0:100]) #search only in 1st lines + if authors: + #replace authors in content + content = re.sub(author_exp, '', content) + authors = authors[0] + else: + content = content + authors = None + return (authors, content) + +def remove_cats(content): + content = re.sub(cat_exp, '', content) + return content + print 'NO CATS', content + def replace_gallery(content): content = re.sub(imgfile_exp, '[[\g<1>]]', content) #add [[ ]] to File:.*? content = re.sub(gallery_exp, '\g<1>', content) #remove gallery wrapper @@ -107,19 +123,18 @@ def replace_video(content): content = re.sub(youtube_exp, "", content) return content +img_exp=re.compile('^.*?\.(?:jpg|jpeg|JPG|JPEG|png|gif)') -# 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}) +def replace_img_a_tag(img_anchor): + # TO DO: remove - requires finding the img_anchor + href = img_anchor.get('href') + if re.match(img_exp, href): + img_anchor.clear() + figure = ET.SubElement(img_anchor, 'figure') + img = ET.SubElement(figure, 'img', attrib={'src': href}) +# figcaption = ET.SubElement(figure, 'figcaption') +# figcaption.text = href - 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/web/page-template.html b/page-template.html similarity index 100% rename from web/page-template.html rename to page-template.html diff --git a/web/2015-Ana_Lusa_Moura.html b/web/2015-Ana_Lusa_Moura.html deleted file mode 100644 index 9f0e10c..0000000 --- a/web/2015-Ana_Lusa_Moura.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

The Aesthetics of Ethics

- -
-
- - - -
- -
- - - -
-
- - - - - - - - - \ No newline at end of file diff --git a/web/2015-Artyom.html b/web/2015-Artyom.html deleted file mode 100644 index 124f3b9..0000000 --- a/web/2015-Artyom.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

Artyom-graduation-work

- -
-
- - - -
- -

Photography, shortly after its invention, took on itself the responsibility of documenting history and giving us images of our world that was previously granted to painting. Photography was the first image of the kind, one that is conceived through technologies – camera, that were products of modern science. Photography democratized the image making proses allowing anyone to produce an image with a click of a button. As well us taking images out from the realm of aesthetics and art which was peculiar to painting, and making them relevant to almost every aspect of culture. As technology developed giving us television and the general media establishment, the bigger part of our world became to be seen through those images than by our own eyes. In today’s online world images function as distinct communication medium and seem do be a better fit to the quick and accumulated online culture where they serve as windows through which we can access the world far beyond our reach.

-

Photography as an image is known for its ability to give an objective representation of the world – it shows the world ‘as it is’. This notion although has been disproved by number of studies, is till excepted by the wider culture. Because of it scientific nature, namely the fact that the subject prescribes itself on the film without the involvement of human hand – without human subjectivity, photography came to gain its objective status. This notion went as far as making photography an image that can stand as a ‘proof’ for something. Similarly Google Images established itself as an agency that gives a precise and accurate representation of a subject. Its algorithms that developed in such way to display the most relevant and the most popular images of the subject. So its objective notion seems to rely again on its scientific factor, namely on the algorithmic analysis that automatically choose the content and arranging them by their on the page by their relevance.

-
- - - -
-
- - - - - - - - - \ No newline at end of file diff --git a/web/2015-Henk-Jelle_de_Groot.html b/web/2015-Henk-Jelle_de_Groot.html deleted file mode 100644 index 4bdf36e..0000000 --- a/web/2015-Henk-Jelle_de_Groot.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

U ntitled

- -
-
- - - -
- -
- - - -
-
- - - - - - - - - \ No newline at end of file diff --git a/web/2015-Joseph_Knierzinger.html b/web/2015-Joseph_Knierzinger.html deleted file mode 100644 index 7b02f1a..0000000 --- a/web/2015-Joseph_Knierzinger.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

RRTRN

- -
-
- - - -
- -

my free text

-
- - - -
-
- - - - - - - - - \ No newline at end of file diff --git a/web/2015-Lucia_Dossin.html b/web/2015-Lucia_Dossin.html deleted file mode 100644 index 800fe6a..0000000 --- a/web/2015-Lucia_Dossin.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

Mina

- -
-
- - - -
- -

free text

-

In a future not so far away, most humans are deprived from communicating with other humans through voice. Increased intolerance to raw subjective matters combined to a competitive labour market forcing every adult to work 12 to 16 hours every day resulted in most of human communication happening through written text messages or images using social media services. As a side effect, the complexity of human conversation decreases to a level in which machines and humans can understand each other reasonably well (an issue of Artificial Intelligence solved in an unexpectedly simple way, after many decades and much money spent on Natural Language research). Children are trained from early age to perform well in this environment. However, a parcel of the population still has the need to engage in conversation using their voices. Within this group, a few actually meet other humans to talk. Others do not manage to find time or energy, despite their longings. Aiming at this target group, a promising startup company designed Mina, a chatterbot that manages to fulfill this need for voice interaction remarkably well. Marketed as high technology, as a product of years of research done by the brightest minds in the tech world, Mina is in fact a very old program, written in the infancy of digital electronic computing. Interaction with Mina is possible through a monthly subscription fee.

-

Mina manages natural language in a quite rudimentary fashion. When the program is initiated, it loads a script. This script contains a specific set of instructions for a conversation. It is able to identify some language patterns and according to these patterns, it chooses a response that will sound plausible. But in order for the program to have the desired effect, the responses in these scripts have to be changed on a regular basis. These changes will help keep alive the illusion of talking to another human being. Without them, subscribers would probably notice they are talking to a robot and would cancel their subscriptions. Also, scripts are changed according to the calendar and the news - and can count on social media profile data to increase the (sanitized) subjectivity rate of the conversation.

-

From time to time, the words database used to feed the scripts is attacked and the connections between words are switched or corrupted. That causes the script to reply using weird language constructs, and in many cases Mina's talk will not only unmask the robot but can also ignite a self-reflection process in the subscriber. Some subscribers use this wake-up chance to try to find a way of having actual voice-based human contact back in their lives, others instead sue the company and ask the subscription fee back. Nobody never found out if the ones responsible for these attacks are hackers or a business competitor.

-
- - - -
-
- - - - - - - - - \ No newline at end of file diff --git a/web/2015-Luther_Blisset.html b/web/2015-Luther_Blisset.html deleted file mode 100644 index 10580d1..0000000 --- a/web/2015-Luther_Blisset.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

Qq

- -
-
- - - -
- -

While the folk heroes of the early-modern period and the nineteenth century served a variety of social and political purposes, the Luther Blissett Project (LBP) were able to utilize the media and communication strategies unavailable to their predecessors. According to Marco Deseriis, the main purpose of the LBP was to create a folk hero of the information society whereby knowledge workers and immaterial workers could organize and recognize themselves.[5] Thus, rather than being understood only as a media prankster and culture jammer, Luther Blissett became a positive mythic figure that was supposed to embody the very process of community and cross-media storytelling. Roberto Bui—one of the co-founders of the LBP and Wu Ming—explains the function of Luther Blissett and other radical folk heroes as mythmaking or mythopoesis

-

-

- -

WWWonopoly_Board.png Mb-WordNet-tour-version2-08.png Labanotation1.jpg

-

other radical folk

-

Are you the radical folk?

-

-

-
- - - -
-
- - - - - - - - - \ No newline at end of file diff --git a/web/2015-Max_Dovey.html b/web/2015-Max_Dovey.html deleted file mode 100644 index c5ce813..0000000 --- a/web/2015-Max_Dovey.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Title - - - - - - - -
- - -
-
-
- - - -

How To Be More Or Less Human

- -
-
- - - -
- -

Abstract (longer)

-

How To Be More Or Less Human is a performance investigating how humans are identified by computer vision software. Looking specifically at how the human subject is identified and classified by image recognition software, a representation of the human body is formed. The living presence of a human being cannot be sensed by computer vision, so the human subject becomes a quantifiable data object with a set of attributes and characteristics. Seeing ourselves in this digital mirror allows us to reflect on other models of perception and develop an understanding of how the human subject is ‘seen’ by the machinic ‘other’. Looking at ourselves through the automated perception of image recognition can highlight how gender, race and ethnicity have been processed into a mathematical model. The algorithm is trained to ‘see’ certain things forcing the human subject to identify themselves within the frame of computer vision.

-

Images

-

Video

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