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.text import LegimiCategory, Epoch, Kind, Genre, Audience
10 from depot.legimi import legimi
13 class XslView(TemplateView):
14 template_name = 'wlxml/wl2html.xsl'
15 content_type = 'application/xslt+xml'
17 def get_context_data(self):
18 ctx = super().get_context_data()
20 for t in models.Tag.objects.all():
21 tags.setdefault(t.type, []).append(t.name)
24 "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",
25 "http://purl.org/dc/elements/1.1/": "dc",
26 "http://www.w3.org/XML/1998/namespace": "xml",
32 class EditorCSS(ListView):
33 template_name = 'wlxml/editor.css'
34 content_type = 'text/css'
35 queryset = models.Tag.objects.all()
38 class TagsView(ListView):
39 queryset = models.Tag.objects.all()
42 class TagView(DetailView):
43 queryset = models.Tag.objects.all()
50 'options': list(legimi.CATEGORIES.keys()),
54 'source': '/catalogue/terms/epoch/',
59 'source': '/catalogue/terms/kind/',
64 'source': '/catalogue/terms/genre/',
70 class MetaTagsView(View):
71 def get(self, request):
73 for f in BookInfo.FIELDS:
76 'required': f.required,
77 'multiple': f.multiple,
80 'hasLanguage': f.value_type.has_language,
81 'name': f.value_type.__name__,
84 d['value_type'].update(VALUE_TYPES.get(f.value_type, {}))
88 'let META_FIELDS = ' + json.dumps(fields),
89 content_type='text/javascript')