python-docx==0.8.11
Wikidata==0.7
-librarian==2.6
+librarian==23.07
## Django
Django==4.1.9
path("book/<slug:slug>/", views.BookView.as_view(), name="catalogue_book"),
path("book/<slug:slug>.json", views.BookAPIView.as_view(), name="catalogue_book_api"),
+ path('terms/audience/', views.AudienceTerms.as_view()),
path('terms/epoch/', views.EpochTerms.as_view()),
path('terms/kind/', views.KindTerms.as_view()),
path('terms/genre/', views.GenreTerms.as_view()),
path('terms/book_title/', views.BookTitleTerms.as_view()),
path('terms/author/', views.AuthorTerms.as_view()),
path('terms/thema/', views.ThemaTerms.as_view()),
+ path('terms/thema-main/', views.MainThemaTerms.as_view()),
path('terms/editor/', views.EditorTerms.as_view()),
label = serializers.CharField(source='name')
+class AudienceTerms(Terms):
+ queryset = models.Audience.objects.all()
+ search_fields = ['code', 'name', 'description']
+
+ class serializer_class(serializers.Serializer):
+ label = serializers.CharField(source='code')
+ name = serializers.CharField()
+ description = serializers.CharField()
+
class EpochTerms(Terms):
queryset = models.Epoch.objects.all()
class KindTerms(Terms):
name = serializers.CharField()
description = serializers.CharField()
+class MainThemaTerms(ThemaTerms):
+ queryset = models.Thema.objects.filter(usable=True, hidden=False, usable_as_main=True)
+
class WikidataView(APIView):
permission_classes = [IsAdminUser]
base_url='file://' + book.gallery_path() + '/'
).build(wlbook).get_file()
+ thema = []
+ if meta.thema_main:
+ thema.append(meta.thema_main)
+ thema.extend(meta.thema)
+
book_data = {
"Title": meta.title,
"Author": ", ".join(p.readable() for p in meta.authors),
"Year": str(date.today().year),
'GenreId': str(self.get_genre(wlbook)),
- 'themaCategories': ';'.join(meta.thema),
+ 'themaCategories': ';'.join(thema),
'thema-search': '',
'Isbn': '',
'LanguageLocale': lang_code_3to2(meta.language),
for p in wlbook.meta.genres
) + '</p>'
- if wlbook.meta.audience:
+ # TODO: Move away from using audiences for this.
+ if wlbook.meta.audience in ('L', 'SP1', 'SP2', 'SP3', 'SP4'):
description += '<p><em>{}</em> to lektura szkolna.'.format(wlbook.meta.title)
if wlbook.tree.find('//pe') is not None:
description += '<br>Ebook <em>{title}</em> zawiera przypisy opracowane specjalnie dla uczennic i uczniów {school}.'.format(
title=wlbook.meta.title,
- school='szkoły podstawowej' if wlbook.meta.audience == 'SP' else 'liceum i technikum'
+ school='szkoły podstawowej' if wlbook.meta.audience.startswith('SP') else 'liceum i technikum'
)
description += '</p>'
return description
{% if perms.depot.add_legimibookpublish %}
<hr>
- {% with thema=doc.book_info.thema %}
- {% if thema %}
+ {% with thema_main=doc.book_info.thema_main thema=doc.book_info.thema %}
+ {% if thema_main or thema %}
<form method="post" action="{% url 'depot_legimi_publish' book.pk %}">
{% csrf_token %}
<button class="btn btn-primary" type="submit">
Opublikuj na Legimi<br><small>w kategorii:
+ {% if thema_main %}
+ <tt>{{ thema_main }}</tt>
+ {% endif %}
{% for t in thema %}
+ {% if forloop.first and thema_main %}oraz: {% endif %}
<tt>{{ t }}</tt>
{% if not forloop.last %}, {% endif %}
{% endfor %}
+ {% if not thema_main %}
+ <span class="badge badge-secondary" title="Nie ustalono głównej kategorii Thema"> * </small>
+ {% endif %}
</small></button>
{% with llp=book.last_legimi_publish %}
{% if llp %}
{% endwith %}
</form>
{% else %}
- <div class="alert alert-warning">Nie można opublikować na Legimi, ponieważ nie ustaiono kategorii Thema.</div>
+ <div class="alert alert-warning">Nie można opublikować na Legimi, ponieważ nie ustalono kategorii Thema.</div>
{% endif %}
{% endwith %}
{% endif %}
return HttpResponseForbidden("Not authorized.")
# TODO: move to celery
- doc = book.wldocument()
+ doc = book.wldocument(librarian2=True)
# TODO: error handling
- #### Problemas: images in children.
- epub = doc.as_epub(base_url='file://' + book.gallery_path() + '/').get_bytes()
+ from librarian.builders import EpubBuilder
+ epub = EpubBuilder(
+ base_url='file://' + book.gallery_path() + '/'
+ ).build(doc).get_bytes()
response = HttpResponse(content_type='application/epub+zip')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
response.write(epub)
return HttpResponseForbidden("Not authorized.")
# TODO: move to celery
- doc = book.wldocument()
+ doc = book.wldocument(librarian2=True)
# TODO: error handling
- mobi = doc.as_mobi(base_url='file://' + book.gallery_path() + '/').get_bytes()
+ from librarian.builders import MobiBuilder
+ mobi = MobiBuilder(
+ base_url='file://' + book.gallery_path() + '/'
+ ).build(doc).get_bytes()
response = HttpResponse(content_type='application/x-mobipocket-ebook')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.mobi'
response.write(mobi)
self.$pane.on('click', '.meta-delete', function() {
let $fg = $(this).closest('.form-group');
- $('input', $fg).data('edited').remove();
+ let $ig = $(this).closest('.input-group');
+ $('input', $ig).data('edited').remove();
self.displayMetaProperty($fg);
$.wiki.perspectives.VisualPerspective.flush();
return false;
from librarian.document import WLDocument
from librarian.builders import StandaloneHtmlBuilder
from librarian.meta.types.wluri import WLURI
-from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience, ThemaCategory
+from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience, ThemaCategory, MainThemaCategory
from depot.legimi import legimi
'widget': 'select',
'options': [''] + list(legimi.CATEGORIES.keys()),
},
+ Audience: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/audience/',
+ }
+ },
ThemaCategory: {
'autocomplete': {
'source': '/catalogue/terms/thema/',
}
},
+ ThemaCategory: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/thema-main/',
+ }
+ },
Epoch: {
'autocomplete': {
'source': '/catalogue/terms/epoch/',