User:Alexander Roidl/database

From XPUB & Lens-Based wiki

Database

Screen Shot 2018-03-07 at 23.09.09.png
Reader 2018
DSC5741.jpg

I printed the whole database of our collection of book we gathered during the making of SI5 in zotero.

I dumped it with zotero into a pdf and printed it at the american book center.

Asking the questions:

  • Does it turn into a narrative again?
  • What does this data say (especially when put into context)
  • How can you read this?
  • exploring database structures

Creating process

  • 5000 pages version: http://pzwart1.wdka.hro.nl/~aroidl/all5000.pdf
    • including all the content of the zotero database including pdf and html content text
  • decided to only use metadata
  • decided to put it into the context of whatsapp and mediwiki (see realations, get context, see patterns in timeline)


Content

It reveals 3 sides of the zoterodatabase

1 --- all books

2 --- trash

3 --- the added titles in the context of the mediawiki and whatsappgroup


Source Code

This is the source code of the database to print. The API and python is the only interface to the database. DATABASE > Python > BOOK

import reportlab.rl_config
reportlab.rl_config.TTFSearchPath.append('/Users/alexroidl/Library/Fonts/')
from reportlab.platypus import BaseDocTemplate, Frame, Paragraph, PageBreak, PageTemplate, NextPageTemplate, KeepTogether
from reportlab.pdfgen import canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import A5
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.pdfmetrics import registerFontFamily
from  reportlab.platypus.tableofcontents import TableOfContents
from reportlab.graphics.shapes import Drawing, Rect, Line
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.colors import (
    black,
    purple,
    white,
    yellow
)
import random
from pyzotero import zotero
import pdfkit
import pprint
import textract
from sys import stdin
import re
import time
from datetime import datetime
import mwclient
from bs4 import BeautifulSoup
from mwclient import Site
from time import mktime
from datetime import datetime, timedelta
site = mwclient.Site('pzwiki.wdka.nl', path='/mw-mediadesign/')

mediawiki = []


class MyDocTemplate(BaseDocTemplate):
     def __init__(self, filename, **kw):
         self.allowSplitting = 0
         BaseDocTemplate.__init__(self, filename, **kw)

# Entries to the table of contents can be done either manually by
# calling the addEntry method on the TableOfContents object or automatically
# by sending a 'TOCEntry' notification in the afterFlowable method of
# the DocTemplate you are using. The data to be passed to notify is a list
# of three or four items countaining a level number, the entry text, the page
# number and an optional destination key which the entry should point to.
# This list will usually be created in a document template's method like
# afterFlowable(), making notification calls using the notify() method
# with appropriate data.

     def afterFlowable(self, flowable):
         "Registers TOC entries."
         if flowable.__class__.__name__ == 'Paragraph':
             text = flowable.getPlainText()
             style = flowable.style.name
             if style == 'styleChapter':
                 self.notify('TOCEntry', (0, text, self.page))
             if style == 'styleSubChapter':
                 self.notify('TOCEntry', (1, text, self.page))

# MEDIAWIKI
def getallrecentchanges():
	#get all recent changes
	for revision in site.recentchanges():
		entry = {}
		text = ""
		for revision in site.revisions([revision['revid']]):
			dt = datetime.fromtimestamp(mktime(revision['timestamp']))
			time_between_insertion = datetime.now() - dt
			userlist = ['Alexander Roidl', 'Michael Murtaugh', 'Angeliki', 'Tash', 'Alice', 'Joca', 'Steve Rushton', 'Delphine Bedel', 'Zalán Szakács', 'Andre Castro','Aymeric Mansoux']

			if  time_between_insertion.days>65:
				return

			elif revision['user'] in userlist:
				try:
					html = revision['diff']['*']
					#print(revision['diff']['*'])
	
					soupAll = BeautifulSoup(html, "lxml")
					
					soupElements = soupAll.find_all("ins", class_= "diffchange")
					
					# get text
					for soup in soupElements:
						text = "\n".join((text, soup.get_text()))
						
				except:
					text = ""
	
	
				user = revision['user']
				comment = revision['comment']
				time = dt
				
				entry['type'] = 'mediawiki'
				entry['date'] = time
				entry['user'] = user
				if text == "" or comment =="":
					if comment == "":
						entry['change'] = text	
					if text == "":
						entry['change'] = comment	
				else:
					entry['change'] = ", ".join((comment, text))

				
				mediawiki.append(entry)
				
print('collecting mediawiki')				
getallrecentchanges()


#WHATSAPP
file = open("_chat.txt") 
text = file.read()

lines = text.split("\n")

conversations = []

print('collecting whatsapp')
for line in lines:
	try:
		match = re.search(r'\[\d{2}.\d{2}.\d{2}, \d{2}:\d{2}:\d{2}\] ', line)
		found = match.group()
		newLine = line.replace(found, '')
		date = datetime.strptime(found, '[%d.%m.%y, %H:%M:%S] ')
		user = newLine[0:newLine.find(':')]
		newLine = newLine.replace('{}: '.format(user), '')
		newLine = newLine.replace(' <‎attached>', '')
		message = {}
		message['date'] = date
		message['user'] = user
		message['text'] = newLine
		message['type'] = 'whatsapp'
		conversations.append(message)
	except:
		print("–––––––TEXTMESSAGES FAILED")
	#text = text.replace(match.group(), '')
	#date = datetime.strptime(match.group(), '%d.%m.%Y').date()



pdfmetrics.registerFont(TTFont('MyFont', 'ITCGaramondStd-BkCond.ttf'))
pdfmetrics.registerFont(TTFont('MyFontItalic', 'ITCGaramondStd-BkCondIta.ttf'))
pdfmetrics.registerFont(TTFont('MyFontBold', 'ITCGaramondStd-BdCond.ttf'))
pdfmetrics.registerFont(TTFont('MyFontBoldItalic', 'ITCGaramondStd-BdCondIta.ttf'))
    
registerFontFamily('MyFont',normal='MyFont',bold='MyFontBold',italic='MyFontItalic',boldItalic='MyFontBoldItalic')

    
style = ParagraphStyle(
			name='Normal',
    		fontName='MyFont',
            fontSize=9,
            leading=12,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
    
)
styleHeader = ParagraphStyle(
			name='styleHeader',
    		fontName='MyFont',
            fontSize=30,
            leading=40,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=-10,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
    
)
styleChapter = ParagraphStyle(
			name='styleChapter',
    		fontName='MyFont',
            fontSize=30,
            leading=40,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=10,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)
styleSubChapter = ParagraphStyle(
			name='styleSubChapter',
    		fontName='MyFont',
            fontSize=13,
            leading=14,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)
styleBig = ParagraphStyle(
			name='styleBig',
    		fontName='MyFont',
            fontSize=13,
            leading=14,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)
styleDate = ParagraphStyle(
			name='Normal',
    		fontName='MyFont',
            fontSize=13,
            leading=15,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)
style1= ParagraphStyle(
			name='Normal',
    		fontName='MyFont',
            fontSize=9,
            leading=12,
            leftIndent=0,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)
style2= ParagraphStyle(
			name='Normal',
    		fontName='MyFont',
            fontSize=9,
            leading=12,
            leftIndent=20,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)
style3= ParagraphStyle(
			name='Normal',
    		fontName='MyFont',
            fontSize=9,
            leading=12,
            leftIndent=40,
            rightIndent=0,
            firstLineIndent=0,
            alignment=TA_LEFT,
            spaceBefore=0,
            spaceAfter=0,
            bulletFontName='Times-Roman',
            bulletFontSize=10,
            bulletIndent=0,
            textColor= black,
            backColor=None,
            wordWrap=None,
            borderWidth= 0,
            borderPadding= 0,
            borderColor= None,
            borderRadius= None,
            allowWidows= 0,
            allowOrphans= 0,
            textTransform=None,  # 'uppercase' | 'lowercase' | None
            endDots=None,         
            splitLongWords=1,
)


Elements=[]


innerMargin = 40

#Footer (pages)
def foot(canvas,doc):
    canvas.saveState()
    canvas.setFont('MyFont',13)
    canvas.drawRightString(doc.width+doc.leftMargin, 0.5 * cm, "%d" % doc.page)
    canvas.restoreState()

def foot2(canvas,doc):
    canvas.saveState()
    canvas.setFont('MyFont',13)
    canvas.drawString(doc.width-4*cm, 0.5 * cm, "%d" % doc.page)
    canvas.restoreState()
    
def showProgress(pageNo):
    print('Creating page: %d' % pageNo)
    

doc = MyDocTemplate('layout.pdf',showBoundary=0, pagesize=A5, leftMargin=0.7*cm, bottomMargin=1.5*cm, topMargin=0.7*cm, rightMargin=0.7*cm)
doc.setPageCallBack(showProgress)

#Two Columns

frame1r = Frame(doc.leftMargin+innerMargin, doc.bottomMargin, (doc.width-innerMargin)/2-6, doc.height, leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0,id='col1')
frame2r = Frame(doc.leftMargin+innerMargin+(doc.width-innerMargin)/2+6, doc.bottomMargin, (doc.width-innerMargin)/2-6, doc.height,leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0, id='col2')
#Two Columns
frame1v = Frame(doc.leftMargin, doc.bottomMargin, (doc.width-innerMargin)/2-6, doc.height,  leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0,id='col1')
frame2v = Frame(doc.leftMargin+(doc.width-innerMargin)/2+6, doc.bottomMargin, (doc.width-innerMargin)/2-6, doc.height, leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0,id='col2')
#Single Columns
frameSingle1 = Frame(doc.leftMargin+innerMargin, doc.bottomMargin, doc.width-innerMargin, doc.height , leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0,id='single')
frameSingle2 = Frame(doc.leftMargin, doc.bottomMargin, doc.width-innerMargin, doc.height ,leftPadding=0, rightPadding=0, topPadding=0, bottomPadding=0, id='single')

doc.addPageTemplates([PageTemplate(id='SingelCol2',frames=[frameSingle2], onPage=foot2), PageTemplate(id='SingelCol1',frames=[frameSingle1], onPage=foot2)])
doc.addPageTemplates([PageTemplate(id='TwoCol1',frames=[frame1r,frame2r], onPage=foot2),PageTemplate(id='TwoCol2',frames=[frame1v,frame2v], onPage=foot2) ])


Elements.append(Paragraph("Reader 2018",styleHeader))

#Elements.append(NextPageTemplate(['SingelCol1','SingelCol2']))

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())

introduction = '''Content'''

Elements.append(Paragraph(introduction,styleChapter))

toc = TableOfContents()
toc.levelStyles = [
    ParagraphStyle(fontName='MyFont', fontSize=13, name='TOCHeading1', leftIndent=0, firstLineIndent=-0, spaceBefore=10, leading=16),
    ParagraphStyle(fontName='MyFont', fontSize=9, name='TOCHeading2', leftIndent=20, firstLineIndent=-0, spaceBefore=0, leading=10),
]
Elements.append(toc)

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())

chapterTitle = '''Introduction'''
introduction = '''This is a printed database. The database converts into a narrative by printing. The zotero-database »Reader 2018« was created for Special Issue 5. It’s a research about scanning culture using feminist methodologies.'''

Elements.append(Paragraph(chapterTitle,styleChapter))
Elements.append(Paragraph(introduction,styleBig))

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
chapterTitle = '''Entries, sorted by alphabeth.'''

Elements.append(Paragraph(chapterTitle,styleChapter))


Elements.append(NextPageTemplate(['TwoCol2']))
Elements.append(PageBreak())
chapterTitle = '''Reader 2018 Collection'''
Elements.append(Paragraph(chapterTitle,styleSubChapter))
Elements.append(Paragraph("<br/><br/>",style))	


print('collecting zotero')
zot = zotero.Zotero('2084415', 'group', 'qecU14ukJLNELvVZ5Bq8xtvo')
zot.add_parameters(sort='title', direction='asc', limit=10)
top_level_collection =  zot.everything(zot.items())
#top_level_collection =  zot.top()
#trash_collection =  zot.trash()

i = 1
books = []
alltags = []
for item in top_level_collection:
	content = []
	book = {}
	print('item number {}'.format(i))
	i=i+1
	
	title = "";
	note = "";
	#get one level elements of item
	#elements = ['title', 'abstractNote', 'itemType', 'language', 'pages','url', 'volume', 'date', 'dateAdded', 'creators']
	for element in item['meta']:
		if 'createdByUser' in element:
			get_node = item['meta'][element]
			for key, value in get_node.items():
				if (type(value) == dict) or (type(value) == list):
					print('exclude this list')
				else:
					if 'username' in str(key):
						content.append('added to library by {1}'.format(str(key), str(value)))
						book['username'] = str(value)
	
	for element in item['data']:
		#check if element is in JSNO – and not empty and excluders
		if 'tags' not in element and item['data'][element]:
			#find out if element is a list
			get_node = item['data'][element]
			if type(get_node) == list: 
				content.append('{0}'.format(str(element)))
				for node in get_node:
					if type(node)==dict:
						print(len(node))
						for key, value in node.items():
							content.append('{0}: {1} '.format(str(key), str(value)))
							print('>>> {} added to content'.format(str(key)))
					else:
						element_content = str(node)
						content.append('{0}: {1} '.format(node, element_content))
						print('>>> {} added to content'.format(node))
			else:
				element_content = str(get_node)
				if 'title' in element:
					title = element_content
					content.insert(0,'<b>{1}</b>; <br/>'.format(element, element_content))
					book['title'] = element_content
					book['type'] = 'zotero'
				elif 'abstractNote' in element:
					note = element_content
					content.insert(2,'<br/>{1}'.format(element, element_content))
					book['abstractNote'] = element_content
					book['type'] = 'zotero'
				elif 'dateAdded' in element:
					note = element_content
					content.append('{0}: {1} '.format(element, element_content))
					date = datetime.strptime(element_content, '%Y-%m-%dT%H:%M:%SZ')
					book['date'] = date
					book['type'] = 'zotero'
				else:
					content.append('<br/><i>{0}</i> {1} '.format(element, element_content))
					print('>>> {} added to content'.format(element))
					book['type'] = 'zotero'
			#if it has content
			if 'contentType' in element:
				element_content = str(get_node)
			#if it is PDF
				if 'image/jpeg' in element_content:
					img_url = str('{0}/file'.format(item['links']['alternate']['href']))
					#content.append('{0}'.format(img_url))
					#content.append('<img src="{0}" valign="top"/>'.format(img_url))
					print("++++++++++++++++++++++++++++ NEW CONTENTTYPE {0}".format(element_content))
				if 'text/html' in element_content:
					#img_url = str('{0}/file'.format(item['links']['alternate']['href']))
					#content.append('{0}'.format(img_url))
					try:
						text = zot.fulltext_item(item['library']['id'])
						content.append('{0} '.format(text))
						print("++++++++++++++++++++++++++++ NEW CONTENTTYPE {0}".format(element_content))
					except:
						print('not inluded html')
		else:
			print('--- {} not included'.format(element))
	content.append('<br/>')
	myText = ''.join(content)
	try:
		Elements.append(KeepTogether([Paragraph(myText,style)]))
		print("/////////////////////ZOTERO APPENDED TO CONTENT")
	except:
		print('Not appended error 1')
	#get tags if item
	tagsList = zot.item_tags(item['key'])
	for tag in tagsList:
		alltags.append(tag)
	tags = ', '.join(tagsList) 
	if not tags:
		print('--- tags not included')
		Elements.append(Paragraph('No Tags',styleBig))
	else:
		Elements.append(Paragraph('{0}'.format(tags),styleBig))
		print('>>> tags added to content')
		
	#content.append('<br/><br/>')
	Elements.append(Paragraph("<br/><br/>",style))	
	books.append(book)	




Elements.append(NextPageTemplate(['TwoCol2']))
Elements.append(PageBreak())
Elements.append(NextPageTemplate(['TwoCol2']))
Elements.append(PageBreak())
chapterTitle = '''Trash'''
Elements.append(Paragraph(chapterTitle,styleSubChapter))
Elements.append(Paragraph("<br/><br/>",style))	



trash_collection =  zot.trash()

i = 1
for item in top_level_collection:
	content = []
	book = {}
	print('item number {}'.format(i))
	i=i+1
	
	title = "";
	note = "";
	#get one level elements of item
	#elements = ['title', 'abstractNote', 'itemType', 'language', 'pages','url', 'volume', 'date', 'dateAdded', 'creators']
	for element in item['meta']:
		if 'createdByUser' in element:
			get_node = item['meta'][element]
			for key, value in get_node.items():
				if (type(value) == dict) or (type(value) == list):
					print('exclude this list')
				else:
					if 'username' in str(key):
						content.append('added to library by {1}'.format(str(key), str(value)))
						book['username'] = str(value)
	
	for element in item['data']:
		#check if element is in JSNO – and not empty and excluders
		if 'tags' not in element and item['data'][element]:
			#find out if element is a list
			get_node = item['data'][element]
			if type(get_node) == list: 
				content.append('{0}'.format(str(element)))
				for node in get_node:
					if type(node)==dict:
						print(len(node))
						for key, value in node.items():
							content.append('{0}: {1} '.format(str(key), str(value)))
							print('>>> {} added to content'.format(str(key)))
					else:
						element_content = str(node)
						content.append('{0}: {1} '.format(node, element_content))
						print('>>> {} added to content'.format(node))
			else:
				element_content = str(get_node)
				if 'title' in element:
					title = element_content
					content.insert(0,'<strike><b>{1}</b>; <br/></strike>'.format(element, element_content))
					book['title'] = element_content
					book['type'] = 'zotero'
				elif 'abstractNote' in element:
					note = element_content
					content.insert(2,'<br/>{1}'.format(element, element_content))
					book['abstractNote'] = element_content
					book['type'] = 'zotero'
				elif 'dateAdded' in element:
					note = element_content
					content.append('{0}: {1} '.format(element, element_content))
					date = datetime.strptime(element_content, '%Y-%m-%dT%H:%M:%SZ')
					book['date'] = date
					book['type'] = 'zotero'
				else:
					content.append('<br/><i>{0}</i> {1} '.format(element, element_content))
					print('>>> {} added to content'.format(element))
					book['type'] = 'zotero'
			#if it has content
			if 'contentType' in element:
				element_content = str(get_node)
			#if it is PDF
				if 'image/jpeg' in element_content:
					img_url = str('{0}/file'.format(item['links']['alternate']['href']))
					#content.append('{0}'.format(img_url))
					#content.append('<img src="{0}" valign="top"/>'.format(img_url))
					print("++++++++++++++++++++++++++++ NEW CONTENTTYPE {0}".format(element_content))
				if 'text/html' in element_content:
					#img_url = str('{0}/file'.format(item['links']['alternate']['href']))
					#content.append('{0}'.format(img_url))
					try:
						text = zot.fulltext_item(item['library']['id'])
						content.append('{0} '.format(text))
						print("++++++++++++++++++++++++++++ NEW CONTENTTYPE {0}".format(element_content))
					except:
						print('not inluded html')
		else:
			print('--- {} not included'.format(element))
	
	content.append('<br/>')
	myText = ''.join(content)
	try:
		Elements.append(KeepTogether([Paragraph(myText,style)]))
		print("/////////////////////ZOTERO APPENDED TO CONTENT")
	except:
		print('Not appended error 1')
	#get tags if item
	tagsList = zot.item_tags(item['key'])
	tags = ', '.join(tagsList) 
	if not tags:
		print('--- tags not included')
		Elements.append(Paragraph('No Tags',styleBig))
	else:
		Elements.append(Paragraph('{0}'.format(tags),styleBig))
		print('>>> tags added to content')
		
	#content.append('<br/><br/>')
	Elements.append(Paragraph("<br/><br/>",style))		

























alltags = ', '.join(alltags) 

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
chapterTitle = '''History of added titles. In the context of the mediawiki and whatsapp.'''

Elements.append(Paragraph(chapterTitle,styleChapter))

#HISTORY
Elements.append(NextPageTemplate(['TwoCol2']))
Elements.append(PageBreak())

all = mediawiki
all.extend(conversations)
all.extend(books)
all.sort(key=lambda item:item['date'], reverse=False)

day = all[0]['date'].day
Elements.append(Paragraph("zotero",style1))
Elements.append(Paragraph("whatsapp",style3))
Elements.append(Paragraph("mediawiki",style2))
Elements.append(Paragraph("<br/><br/>",style))
for item in all:
	thisDay = item['date'].day
	if thisDay > day:
		Elements.append(Paragraph("{0}".format(str(item['date'].strftime('%A, %d %B %Y'))),styleDate))	
		day = item['date'].day
	if 'zotero' in item['type']:
		try:
			Elements.append(Paragraph("<b>{0}</b> added <i>{1}</i>".format(str(item['username']),str(item['title'])),style1))
		except:
			print('')
	if 'whatsapp' in item['type']:
		Elements.append(Paragraph("<b>{0}</b>: {1}".format(str(item['user']),str(item['text'])),style3))
	if 'mediawiki' in item['type']:
		try:
			soup = BeautifulSoup(str(item['change']), "lxml")	
			Elements.append(Paragraph("<b>{0}</b>: {1}".format(str(item['user']),str(soup.text)),style2))
		except:
			print("bip")
#Elements.append(Paragraph(str(conversation),style))
#need to draw shapes?
#d = Drawing(400,200)
#d.add(Rect(0,0,300,100, fillColor=yellow))
#Elements.append(d)


Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
chapterTitle = '''Used tags'''

Elements.append(Paragraph(chapterTitle,styleChapter))

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
content = alltags
Elements.append(Paragraph(content,styleBig))

#Imprint

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
chapterTitle = '''Imprint'''

Elements.append(Paragraph(chapterTitle,styleChapter))

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())
content = '''Reader 5, <br/>
Scanning the Database<br/>
On feminism, bias in data and classification<br/>
Editing, design and Production <br/>
Alexander Roidl<br/>
Printed at the American Book Center Amsterdam<br/>
<br/>
Open Source Typeface: <br/>
Lusitana  by Ana Paula Megda <br/>
<br/>
Collection<br/>
REFLECTIONS ON BOOK SCANNING: <br/>
A FEMINIST READER<br/>
<br/>
XPUB Special Issue 05, March 2018<br/>
https://issue.xpub.nl/05<br/>
The XPUB Triannual<br/>
<br/>
Team: Delphine Bedel, Natasha Berting, André Castro, Angeliki Diakrousi, Aymeric Mansoux, Michael Murtaugh, Alexander Roidl, Steve Rushton, Alice Strete, Zalán Szakács and Joca van der Horst. Main partner: WORM / Pirate Bay. Special guests: Manetta Berends & Cristina Cochior (Algolit group). Thanks to Leslie Robbins, Simon Pummell and Frederic Van de Velde.
<br/><br/>
Experimental Publishing Study Path at Master Media Design and Communication, Piet Zwart Institute, Willem de Kooning Academy, Rotterdam 
<br/><br/>
Publisher XPUB, Rotterdam'''
Elements.append(Paragraph(content,styleBig))

Elements.append(NextPageTemplate(['SingelCol2']))
Elements.append(PageBreak())

#start the construction of the pdf
doc.multiBuild(Elements)