diff --git a/annotated-reader/.DS_Store b/annotated-reader/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/annotated-reader/.DS_Store differ diff --git a/annotated-reader/README.md b/annotated-reader/README.md new file mode 100644 index 0000000..e69de29 diff --git a/annotated-reader/annotated-reader.py b/annotated-reader/annotated-reader.py new file mode 100644 index 0000000..be2750b --- /dev/null +++ b/annotated-reader/annotated-reader.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python3 + +import logging +from getpass import getpass +from argparse import ArgumentParser + +import slixmpp +import ssl, os, requests, urllib +from bs4 import BeautifulSoup + +from urllib.parse import quote as urlquote, unquote as urlunquote + + +def make_numbered_text(input_text,output_html): + if not os.path.exists(output_html): + + text = open(input_text, 'r') # open the txt file + lines = text.readlines() # to divide the text into lines + x = 1 + + with open(output_html, 'w') as new_html: # open the output_html with writing only as new_html + new_html.write('') + new_html.write('
') + for line in lines: + new_html.write('

{} {}

'.format(x, x, x, x, x, line)) + x = x + 1 + + new_html.write('
') + print('I wrote a new file!', output_html) + + +def insert_comment_at_line(output_html,comment,line_number): + with open (output_html,'r') as f: + text = f.read() + html = BeautifulSoup(text,'html.parser') + div_id = 'linenum-{}'.format(line_number) + line = html.find('div',{'id' : div_id}) + print(line,comment,'#'+str(line_number)+'#') + print(div_id) + + if line: + with open (output_html,'w') as f: + new_comment = html.new_tag("comment") + new_comment.string = comment + line.append(new_comment) + f.write(html.decode()) + +def insert_media_at_line(output_html,mediafile,line_number): + with open (output_html,'r') as f: + text = f.read() + html = BeautifulSoup(text,'html.parser') + div_id = 'linenum-{}'.format(line_number) + line = html.find('div',{'id' : div_id}) + + if line: + #notes to self write function to the detect media type + with open (output_html,'w') as f: + new_image = html.new_tag("img", src = mediafile) + line.append(new_image) + f.write(html.decode()) + +class MUCBot(slixmpp.ClientXMPP): + def __init__(self, jid, password, room, nick, output): + + slixmpp.ClientXMPP.__init__(self, jid, password) + + self.room = room + self.nick = nick + self.output = output + self.current_line = 0 + + self.add_event_handler("session_start", self.start) # moment that it logs on + self.add_event_handler("groupchat_message", self.muc_message) # moment that someone start speaking someone + + output = self.output + if not os.path.exists(output): + os.mkdir(output) + + make_numbered_text('text.txt','annotated-reader.html') + + + def start(self, event): + + self.get_roster() + self.send_presence() + + # https://xmpp.org/extensions/xep-0045.html + self.plugin['xep_0045'].join_muc(self.room, + self.nick, + # If a room password is needed, use: + # password=the_room_password, + wait=True) + + def muc_message(self, msg): + + # Always check that a message is not the bot itself, otherwise you will create an infinite loop responding to your own messages. + if msg['mucnick'] != self.nick: + + # Check if an OOB URL is included in the stanza (which is how an image is sent) + # (OOB object - https://xmpp.org/extensions/xep-0066.html#x-oob) + if len(msg['oob']['url']) > 0: + # UPLOADED IMAGE + # Send a reply + self.send_message(mto=msg['from'].bare, + mbody="Really? Oke. I'll add your photo for you, {}.".format(msg['mucnick']), + mtype='groupchat') + + # Save the image to the output folder + url = msg['oob']['url'] # grep the url in the message + # urlunquote is like url to filename + filename = os.path.basename(urlunquote(url)) # grep the filename in the url + output = self.output + # if not os.path.exists(output): + # os.mkdir(output) + output_path = os.path.join(output, filename) + + u = urllib.request.urlopen(url) # read the image data + new_html = open(output_path, 'wb') # open the output file + new_html.write(u.read()) # write image to file + new_html.close() # close the output file + + # Add image to stream + img = output_path + insert_media_at_line('annotated-reader.html',img,self.current_line) + + else: + # TEXT MESSAGE + for word in msg['body'].split(): + if word.startswith("#line"): + self.current_line = int(word[5:]) + self.send_message(mto=msg['from'].bare, + mbody="I've set the current line number to {}.".format(self.current_line), + mtype='groupchat') + + elif word == "#comment": + self.send_message(mto=msg['from'].bare, + mbody="Really? Oke. I'll add your comment that for you, {}.".format(msg['mucnick']), + mtype='groupchat') + + insert_comment_at_line('annotated-reader.html',msg['body'], self.current_line) + + +if __name__ == '__main__': + # Setup the command line arguments. + parser = ArgumentParser() # making your own command line - ArgumentParser. + + # output verbosity options. + parser.add_argument("-q", "--quiet", help="set logging to ERROR", + action="store_const", dest="loglevel", + const=logging.ERROR, default=logging.INFO) + parser.add_argument("-d", "--debug", help="set logging to DEBUG", + action="store_const", dest="loglevel", + const=logging.DEBUG, default=logging.INFO) + + # JID and password options. + parser.add_argument("-j", "--jid", dest="jid", # jid = user + help="JID to use") + parser.add_argument("-p", "--password", dest="password", + help="password to use") + parser.add_argument("-r", "--room", dest="room", + help="MUC room to join") + parser.add_argument("-n", "--nick", dest="nick", + help="MUC nickname") # MUC = multi user chat + + # output folder for images + parser.add_argument("-o", "--output", dest="output", + help="output folder, this is where the files are stored", + default="./output/", type=str) + + args = parser.parse_args() + + # Setup logging. + logging.basicConfig(level=args.loglevel, + format='%(levelname)-8s %(message)s') + + if args.jid is None: + args.jid = input("User: ") + if args.password is None: + args.password = getpass("Password: ") + if args.room is None: + args.room = input("MUC room: ") + if args.nick is None: + args.nick = input("MUC nickname: ") + if args.output is None: + args.output = input("Output folder: ") + + # Setup the MUCBot and register plugins. Note that while plugins may + # have interdependencies, the order in which you register them does + # not matter. + xmpp = MUCBot(args.jid, args.password, args.room, args.nick, args.output) + xmpp.register_plugin('xep_0030') # Service Discovery + xmpp.register_plugin('xep_0045') # Multi-User Chat + xmpp.register_plugin('xep_0199') # XMPP Ping + xmpp.register_plugin('xep_0066') # Process URI's (files, images) + + # Connect to the XMPP server and start processing XMPP stanzas. + xmpp.connect() + xmpp.process() + diff --git a/annotated-reader/output/.DS_Store b/annotated-reader/output/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/annotated-reader/output/.DS_Store differ diff --git a/annotated-reader/style.css b/annotated-reader/style.css new file mode 100644 index 0000000..0d7dbc9 --- /dev/null +++ b/annotated-reader/style.css @@ -0,0 +1,33 @@ +*{ + font-family: Arial, Helvetica, sans-serif; + +} + +linenumber{ + margin-right: 1em; +} + +body{ + font-size: 20px; + line-height: 1.5em +} + +#linenum-:before { + width: 50%; +} +comment{ + background-color: black; + color:white; + float: right; + +} + +img{ + max-width: 30%; + float: right; + +} + +img:hover{ +max-width: 400px; +} \ No newline at end of file diff --git a/annotated-reader/test.py b/annotated-reader/test.py new file mode 100644 index 0000000..31da93a --- /dev/null +++ b/annotated-reader/test.py @@ -0,0 +1,17 @@ +text = open('text.txt', 'r') # open the txt file +lines = text.readlines() # to divide the text into lines +lines_noempty = [ ] +x = 1 + +new_html = open('annotated-reader.html', 'a+') + + +for line in lines: + if line is not "\n": # if line is not empty, + outputfile = open('text_num.txt', 'a+') + outputfile.write('{0} {1} '.format(x, line)) + new_html.write('
{}{}
'.format(x, x, line)) + + x = x + 1 + +new_html.close() \ No newline at end of file diff --git a/annotated-reader/text.txt b/annotated-reader/text.txt new file mode 100644 index 0000000..20f7a68 --- /dev/null +++ b/annotated-reader/text.txt @@ -0,0 +1,18 @@ +INTRODUCTION: SUBCULTURE AND STYLE + +I managed to get about twenty photographs, and with bits of chewed bread I pasted them on the back of the cardboard sheet of regulations that hangs on the wall. Some are pinned up with bits of brass wire which the foreman brings me and on which I have to string coloured glass beads. Using the same beads with which the prisoners next door make funeral wreaths, I have made star-shaped frames for the most purely criminal. In the evening, as you open your window to the street, I turn the back of the regulation sheet towards me. Smiles and sneers, alike inexorable, enter me by all the holes I offer.... They watch over my little routines. (Genet, 1966a) + +IN the opening pages of The Thief’s Journal, Jean Genet describes how a tube of vaseline, found in his possession, is confiscated by the Spanish police during a raid. This ‘dirty, wretched object’, proclaiming his homosexuality to the world, becomes for Genet a kind of guarantee – ‘the sign of a secret grace which was soon to save me from contempt’. The discovery of the vaseline is greeted. + +2 SUBCULTURE: THE MEANING OF STYLE + +with laughter in the record-office of the station, and the police ‘smelling of garlic, sweat and oil, but... strong in their moral assurance’ subject Genet to a tirade of hostile innuendo. The author joins in the laughter too (‘though painfully’) but later, in his cell, ‘the image of the tube of vaseline never left me’. +I was sure that this puny and most humble object would hold its own against them; by its mere presence it would be able to exasperate all the police in the world; it would draw down upon itself contempt, hatred, white and dumb rages. (Genet, 1967) +I have chosen to begin with these extracts from Genet because he more than most has explored in both his life and his art the subversive implications of style. I shall be returning again and again to Genet’s major themes: the status and meaning of revolt, the idea of style as a form of Refusal, the elevation of crime into art (even though, in our case, the ‘crimes’ are only broken codes). Like Genet, we are interested in subculture – in the expressive forms and rituals of those subordinate groups – the teddy boys and mods and rockers, the skinheads and the punks – who are alternately dismissed, denounced and canonized; treated at different times as threats to public order and as harmless buffoons. Like Genet also, we are intrigued by the most mundane objects – a safety pin, a pointed shoe, a motor cycle – which, none the less, like the tube of vaseline, take on a symbolic dimension, becoming a form of stigmata, tokens of a self-imposed exile. Finally, like Genet, we must seek to recreate the dialectic between action and reaction which renders these objects meaningful. For, just as the conflict between Genet’s ‘unnatural’ sexuality and the policemen’s ‘legitimate’ outrage can be encapsulated in a single object, so the tensions between dominant and subordinate groups can be +found reflected in the surfaces of subculture – in the + +INTRODUCTION: SUBCULTURE AND STYLE 3 + +styles made up of mundane objects which have a double meaning. On the one hand, they warn the ‘straight’ world in advance of a sinister presence – the presence of difference – and draw down upon themselves vague suspicions, uneasy laughter, ‘white and dumb rages’. On the other hand, for those who erect them into icons, who use them as words or as curses, these objects become signs of forbidden identity, sources of value. Recalling his humiliation at the hands of the police, Genet finds consolation in the tube of vaseline. It becomes a symbol of his ‘triumph’ – ‘I would indeeed rather have shed blood than repudiate that silly object’ (Genet, 1967). +The meaning of subculture is, then, always in dispute, and style is the area in which the opposing definitions clash with most dramatic force. Much of the available space in this book will therefore be taken up with a description of the process whereby objects are made to mean and mean again as ‘style’ in subculture. As in Genet’s novels, this process begins with a crime against the natural order, though in this case the deviation may seem slight indeed – the cultivation of a quiff, the acquisition of a scooter or a record or a certain type of suit. But it ends in the construction of a style, in a gesture of defiance or contempt, in a smile or a sneer. It signals a Refusal. I would like to think that this Refusal is worth making, that these gestures have a meaning, that the smiles and the sneers have some subversive value, even if, in the final analysis, they are, like Genet’s gangster pin-ups, just the darker side of sets of regulations, just so much graffiti on a prison wall. +Even so, graffiti can make fascinating reading. They draw attention to themselves. They are an expression both of impotence and a kind of power – the power to disfigure (Norman Mailer calls graffiti – ‘Your presence on their Presence... hanging your alias on their scene’ (Mailer, 1974)). In this book I shall attempt to decipher the graffiti. diff --git a/archive-bot/.DS_Store b/archive-bot/.DS_Store index cfbb977..5e3a412 100644 Binary files a/archive-bot/.DS_Store and b/archive-bot/.DS_Store differ