2 from librarian import RDFNS, DCNS
4 from datetime import date
6 from django.conf import settings
9 def build_document_texts(book_source):
11 for builder in text_builders:
12 root = etree.Element('utwor')
14 add_rdf(root, book_source)
17 master = etree.SubElement(root, 'powiesc')
19 for page in book_source.get_ocr_files():
22 texts.append(etree.tostring(root, encoding='unicode', pretty_print=True))
27 ocr.add_page_to_master,
28 ocr.add_page_to_master_as_stanzas,
29 ocr.add_page_to_master_as_p,
33 def add_rdf(root, book_source):
34 book = book_source.book
37 rdf = etree.SubElement(root, RDFNS('RDF'))
38 desc = etree.SubElement(rdf, RDFNS('Description'), **{})
41 for author in book.authors.all():
42 etree.SubElement(desc, DCNS('creator')).text = f'{author.last_name_pl}, {author.first_name_pl}'
44 for tr in book.translators.all():
45 etree.SubElement(desc, DCNS('contributor.translator')).text = f'{tr.last_name_pl}, {tr.first_name_pl}'
47 etree.SubElement(desc, DCNS('title')).text = book.title
49 etree.SubElement(desc, DCNS('date')).text = date.today().isoformat()
51 etree.SubElement(desc, DCNS('date.pd')).text = str(book.pd_year)
53 etree.SubElement(desc, DCNS('publisher')). text = 'Fundacja Wolne Lektury'
55 etree.SubElement(desc, DCNS('language')).text = book.language # 3to2?
58 etree.SubElement(desc, DCNS('source')).text = book_source.source.name
60 etree.SubElement(desc, DCNS('identifier.url')).text = f'https://wolnelektury.pl/katalog/lektura/{book.slug}/'
63 etree.SubElement(desc, DCNS('rights')).text = ''
65 for tag in book.epochs.all():
66 etree.SubElement(desc, DCNS('subject.period')).text = tag.name
68 for tag in book.kinds.all():
69 etree.SubElement(desc, DCNS('subject.type')).text = tag.name
71 for tag in book.genres.all():
72 etree.SubElement(desc, DCNS('subject.genre')).text = tag.name