sorl-thumbnail==12.10.0
# home-brewed & dependencies
-librarian==24.5.6
+librarian==24.5.7
# celery tasks
celery[redis]==5.4.0
'isbn_pdf', 'isbn_epub', 'isbn_mobi',
]
+class BookSerializer11Labs(serializers.ModelSerializer):
+ url = AbsoluteURLField()
+ href = AbsoluteURLField(view_name='catalogue_api_book', view_args=['slug'])
+ html = EmbargoURLField(source='html_nonotes_url')
+
+ authors = AuthorItemSerializer(many=True)
+ translators = AuthorItemSerializer(many=True)
+ epochs = EpochItemSerializer(many=True)
+ genres = GenreItemSerializer(many=True)
+ kinds = KindItemSerializer(many=True)
+ parent = serializers.HyperlinkedRelatedField(
+ read_only=True,
+ view_name='catalogue_api_book',
+ lookup_field='slug'
+ )
+
+ class Meta:
+ model = Book
+ fields = [
+ 'slug', 'title', 'full_sort_key',
+ 'href', 'url', 'language',
+ 'authors', 'translators',
+ 'epochs', 'genres', 'kinds',
+ #'children',
+ 'parent', 'preview',
+ 'html',
+ 'cover_thumb', 'cover',
+ 'isbn_pdf', 'isbn_epub', 'isbn_mobi',
+ ]
+
+
class BookSerializer(LegacyMixin, serializers.ModelSerializer):
author = serializers.CharField(source='author_unicode')
kind = serializers.CharField(source='kind_unicode')
piwik_track_view(views.BookList2.as_view()),
name='catalogue_api_book_list'
),
+ path('11labs/books/',
+ piwik_track_view(views.BookList11Labs.as_view()),
+ name='catalogue_api_book_list'
+ ),
path('books/<slug:slug>/',
piwik_track_view(views.BookDetail2.as_view()),
name='catalogue_api_book'
return books
+class BookList11Labs(BookList2):
+ serializer_class = serializers.BookSerializer11Labs
+
+ def get_queryset(self):
+ books = Book.objects.all()
+ books = books.filter(findable=True)
+ books = books.filter(license='')
+ books = order_books(books, True)
+
+ return books
+
+
@vary_on_auth # Because of 'liked'.
class BookDetail(RetrieveAPIView):
queryset = Book.objects.all()
return wldoc.as_html(gallery_path=gal_path, gallery_url=gal_url, base_url=absolute_url(gal_url))
+class HtmlNonotesField(EbookField):
+ ext = 'html'
+ for_parents = False
+ directory = 'html_nonotes'
+
+ @staticmethod
+ def transform(wldoc, book):
+ # ugly, but we can't use wldoc.book_info here
+ from librarian import DCNS
+ url_elem = wldoc.edoc.getroot().find('.//' + DCNS('identifier.url'))
+ if url_elem is None:
+ gal_url = ''
+ gal_path = ''
+ else:
+ slug = url_elem.text.rstrip('/').rsplit('/', 1)[1]
+ gal_url = gallery_url(slug=slug)
+ gal_path = gallery_path(slug=slug)
+ return wldoc.as_html(gallery_path=gal_path, gallery_url=gal_url, base_url=absolute_url(gal_url), flags=['nonotes'])
+
+
class CoverField(EbookField):
ext = 'jpg'
directory = 'cover'
--- /dev/null
+# Generated by Django 4.0.8 on 2025-02-26 14:46
+
+import catalogue.fields
+from django.db import migrations, models
+import fnpdjango.storage
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalogue', '0048_remove_collection_kind_remove_tag_for_books_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='book',
+ name='html_nonotes_file',
+ field=catalogue.fields.HtmlNonotesField(etag_field_name='html_nonotes_file_etag', storage=fnpdjango.storage.BofhFileSystemStorage()),
+ ),
+ migrations.AddField(
+ model_name='book',
+ name='html_nonotes_file_etag',
+ field=models.CharField(db_index=True, default='', editable=False, max_length=255),
+ ),
+ migrations.AddField(
+ model_name='book',
+ name='license',
+ field=models.CharField(blank=True, db_index=True, max_length=255, verbose_name='licencja'),
+ ),
+ ]
common_slug = models.SlugField('wspólny slug', max_length=120, db_index=True)
language = models.CharField('kod języka', max_length=3, db_index=True, default=app_settings.DEFAULT_LANGUAGE)
description = models.TextField('opis', blank=True)
+ license = models.CharField('licencja', max_length=255, blank=True, db_index=True)
abstract = models.TextField('abstrakt', blank=True)
toc = models.TextField('spis treści', blank=True)
created_at = models.DateTimeField('data utworzenia', auto_now_add=True, db_index=True)
# files generated during publication
xml_file = fields.XmlField(storage=bofh_storage, with_etag=False)
html_file = fields.HtmlField(storage=bofh_storage)
+ html_nonotes_file = fields.HtmlNonotesField(storage=bofh_storage)
fb2_file = fields.Fb2Field(storage=bofh_storage)
txt_file = fields.TxtField(storage=bofh_storage)
epub_file = fields.EpubField(storage=bofh_storage)
'okładka dla Ebookpoint')
ebook_formats = constants.EBOOK_FORMATS
- formats = ebook_formats + ['html', 'xml']
+ formats = ebook_formats + ['html', 'xml', 'html_nonotes']
parent = models.ForeignKey('self', models.CASCADE, blank=True, null=True, related_name='children')
ancestor = models.ManyToManyField('self', blank=True, editable=False, related_name='descendant', symmetrical=False)
def html_url(self):
return self.media_url('html')
+ def html_nonotes_url(self):
+ return self.media_url('html_nonotes')
+
def pdf_url(self):
return self.media_url('pdf')
book.findable = findable
book.language = book_info.language
book.title = book_info.title
+ book.license = book_info.license
if book_info.variant_of:
book.common_slug = book_info.variant_of.slug
else:
for format_ in constants.EBOOK_FORMATS_WITH_CHILDREN:
if format_ not in dont_build:
getattr(book, '%s_file' % format_).build_delay()
+ book.html_nonotes_file.build_delay()
if not settings.NO_SEARCH_INDEX and search_index and findable:
tasks.index_book.delay(book.id)