3 from django.http import HttpResponse
4 from django.views.generic import TemplateView, ListView, DetailView, View
6 from librarian.dcparser import BookInfo
7 from librarian.document import WLDocument
8 from librarian.builders import StandaloneHtmlBuilder
9 from librarian.meta.types.wluri import WLURI
10 from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience, ThemaCategory, MainThemaCategory
11 from depot.publishers.legimi import Legimi
14 class XslView(TemplateView):
15 template_name = 'wlxml/wl2html.xsl'
16 content_type = 'application/xslt+xml'
18 def get_context_data(self):
19 ctx = super().get_context_data()
21 for t in models.Tag.objects.all():
22 tags.setdefault(t.type, []).append(t.name)
25 "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",
26 "http://purl.org/dc/elements/1.1/": "dc",
27 "http://www.w3.org/XML/1998/namespace": "xml",
33 class EditorCSS(ListView):
34 template_name = 'wlxml/editor.css'
35 content_type = 'text/css'
36 queryset = models.Tag.objects.all()
39 class TagsView(ListView):
40 queryset = models.Tag.objects.all()
43 class TagView(DetailView):
44 queryset = models.Tag.objects.all()
51 'options': [''] + list(Legimi.CATEGORIES.keys()),
55 'source': '/catalogue/terms/audience/',
60 'source': '/catalogue/terms/thema/',
63 'source': '/catalogue/chooser/thema/',
68 'source': '/catalogue/terms/thema-main/',
71 'source': '/catalogue/chooser/thema-main/',
76 'source': '/catalogue/terms/epoch/',
81 'source': '/catalogue/terms/kind/',
86 'source': '/catalogue/terms/genre/',
91 "source": "/catalogue/terms/wluri/",
96 "source": "/catalogue/terms/author/",
101 "source": "/catalogue/terms/author/",
106 "source": "/catalogue/terms/editor/",
109 "technical_editors": {
111 "source": "/catalogue/terms/editor/",
121 "source": "/catalogue/terms/book_title/",
138 "source": ["Fundacja Wolne Lektury"]
146 class MetaTagsView(View):
147 def get(self, request):
149 for f in BookInfo.FIELDS:
152 'required': f.required,
153 'multiple': f.multiple,
156 'hasLanguage': f.value_type.has_language,
157 'name': f.value_type.__name__,
160 d['value_type'].update(
169 if d['name'] == 'thema':
172 d['filter'] = {'not': {'startswith': ['1', '3']}}
173 d_loc['filter'] = {'startswith': ['1']}
174 d_loc['name'] += ' (miejsca)'
175 d_time['filter'] = {'startswith': ['3']}
176 d_time['name'] += ' (czas)'
177 fields.extend([d, d_loc, d_time])
182 'let META_FIELDS = ' + json.dumps(fields),
183 content_type='text/javascript')