forked from mirrors/bookwyrm
Merge branch 'main' into production
This commit is contained in:
commit
cbfa99a95b
7 changed files with 22 additions and 1 deletions
|
@ -222,6 +222,7 @@ USER_AGENT = f"{agent} (BookWyrm/{VERSION}; +https://{DOMAIN}/)"
|
||||||
# Imagekit generated thumbnails
|
# Imagekit generated thumbnails
|
||||||
ENABLE_THUMBNAIL_GENERATION = env.bool("ENABLE_THUMBNAIL_GENERATION", False)
|
ENABLE_THUMBNAIL_GENERATION = env.bool("ENABLE_THUMBNAIL_GENERATION", False)
|
||||||
IMAGEKIT_CACHEFILE_DIR = "thumbnails"
|
IMAGEKIT_CACHEFILE_DIR = "thumbnails"
|
||||||
|
IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY = "bookwyrm.thumbnail_generation.Strategy"
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||||
|
|
20
bookwyrm/thumbnail_generation.py
Normal file
20
bookwyrm/thumbnail_generation.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
"""thumbnail generation strategy for django-imagekit"""
|
||||||
|
|
||||||
|
|
||||||
|
class Strategy:
|
||||||
|
"""
|
||||||
|
A strategy that generates the image on source saved (Optimistic),
|
||||||
|
but also on demand, for old images (JustInTime).
|
||||||
|
"""
|
||||||
|
|
||||||
|
def on_source_saved(self, file): # pylint: disable=no-self-use
|
||||||
|
"""What happens on source saved"""
|
||||||
|
file.generate()
|
||||||
|
|
||||||
|
def on_existence_required(self, file): # pylint: disable=no-self-use
|
||||||
|
"""What happens on existence required"""
|
||||||
|
file.generate()
|
||||||
|
|
||||||
|
def on_content_required(self, file): # pylint: disable=no-self-use
|
||||||
|
"""What happens on content required"""
|
||||||
|
file.generate()
|
Binary file not shown.
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 0.0.1\n"
|
"Project-Id-Version: 0.0.1\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2022-01-09 19:01+0000\n"
|
"POT-Creation-Date: 2022-01-09 19:19+0000\n"
|
||||||
"PO-Revision-Date: 2021-02-28 17:19-0800\n"
|
"PO-Revision-Date: 2021-02-28 17:19-0800\n"
|
||||||
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
|
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
|
||||||
"Language-Team: English <LL@li.org>\n"
|
"Language-Team: English <LL@li.org>\n"
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue