mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 14:17:19 +00:00
* frontend rewrite with vie initial commit * got ComicCard.vue working nice. * got TheComicList.vue working. * added router and basic config * getting jwt stuff working. * login with jwt now working. * implemented browse api call * implemented browse api recievers * jwt token is now updating automatically. * removed code for jwt testing. * enabled browsing * breadcrumbs working * adding django webpack loader * linking up navigation * fixes for ComicCard.vue stying * added thumbnail view * added thumbnail generation and handling. * detached breadcrumbs * fix breadcrumbs * added first stages of reader * reader view is working. * reader is now working with keyboard shortcuts * implemented setting read page. * implemented pagination on comic reader. * hide elements that shouldn't be shown. * fixed the ComicCard.vue to use as little space as possible. * fix navbar browse link * added RecentView.vue and added manual option for breadcrumbs * updated rest api to handle recent comics. * most functionality of recent comics done * modified comicstatus relation to use uuid relation and implemented mark read and unread for batches. * added functions to TheRecentTable.vue * added feed link to TheRecentTable.vue * fixes for comicstatus updates. * added constraints to comicstatus * update to python packages. * some changes for django 4, also removed django-recaptcha2 as it doesnt support django 4. * some fixes and updates to ComicCard.vue * cleaned up generate_directory. fixed bug where pages not visible on first call. * cleaned up generate_directory. fixed bug where pages not visible on first call. * cleaned up generate_directory. fixed bug where pages not visible on first call. * cleaned up generate_directory. * added silk stubs * fix for re-requesting thumbnail after getting it already. * fix for removing stale comics. adding leeway to access token. * mark read and unread * added filtering to comic list. * stored filtering state. * stored filtering state. * added next functionality to login. * cleanup LoginView.vue * bump font-awesome. * working on AccountView.vue * fixed form submission on LoginView.vue * account page should now be working. * hide users option if not superuser. * added pdf support * make pdf resize. * added touch controls to pdf reader * added touch controls to comic reader * beginnings of routing between issues. * fixes for navigating pages. * fixes for navigating pages. * fixes for navigating pages. * renamed HomeView.vue to BrowseView.vue * stubs for users page added. api ready * users page further functinality * fix for notification * fix for notification * moved messages to parent. * form to add users * added error handling * removed console logging * classification in base directory should be lowest * renamed usermisc to classification to be more consistent with what it does. * renamed usermisc to classification to be more consistent with what it does. * added functionality to change classification of directories. * merged rss_id api into account api. * merged breadcrumbs api into browse api. * clears some warnings from console. * fixed read/unread rendering. * added build script and starting lint * fixing lint errors * fixing lint errors * fixing lint errors * fixing lint errors * fixing lint errors * fixing lint errors * fixing lint errors * fixing lint errors * fixing navigation bugs * cleanup and fixes * fixed generated tooltips over calling. * fixed classifications. * initial setup now working * fix navbar branding * fix favicon * added beta build script. * fixes to get ready for production * optimisations for loading new comics. * added loading indicators to TheComicList.vue * lint fixes * made two methods static. may use them elsewhere. * fix for scanning files. * version updates. * fixes for production * fixes for production Co-authored-by: Peter Dwyer <peter.dwyer@clanwilliamhealth.com>
81 lines
3.0 KiB
Python
81 lines
3.0 KiB
Python
import uuid
|
|
|
|
from django.contrib.auth.models import User
|
|
from django.contrib.syndication.views import Feed
|
|
from django.db.models import Case, When, PositiveSmallIntegerField, F
|
|
from django.http import HttpRequest
|
|
from django.shortcuts import get_object_or_404
|
|
from django.urls import reverse
|
|
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
|
|
|
|
from .models import ComicBook, UserMisc, Directory
|
|
|
|
|
|
class RecentComics(Feed):
|
|
title = "CBWebReader Recent Comics"
|
|
link = "/comics/"
|
|
description = "Recently added Comics"
|
|
user: User
|
|
|
|
def get_object(self, request: HttpRequest, user_selector: str, *args, **kwargs) -> UserMisc:
|
|
user_selector = uuid.UUID(bytes=urlsafe_base64_decode(user_selector))
|
|
user_misc = get_object_or_404(UserMisc, feed_id=user_selector)
|
|
self.user = user_misc.user
|
|
return user_misc.user
|
|
|
|
def items(self) -> ComicBook:
|
|
comics = ComicBook.objects.order_by("-date_added")
|
|
comics = comics.annotate(
|
|
classification=Case(
|
|
When(directory__isnull=True, then=Directory.Classification.C_18),
|
|
default=F('directory__classification'),
|
|
output_field=PositiveSmallIntegerField(choices=Directory.Classification.choices)
|
|
)
|
|
)
|
|
comics = comics.filter(classification__lte=self.user.usermisc.allowed_to_read)
|
|
return comics[:10]
|
|
|
|
def item_title(self, item: ComicBook) -> str:
|
|
return item.file_name
|
|
|
|
def item_description(self, item: ComicBook) -> str:
|
|
return item.date_added.strftime("%a, %e %b %Y %H:%M")
|
|
|
|
# item_link is only needed if NewsItem has no get_absolute_url method.
|
|
def item_link(self, item: ComicBook) -> str:
|
|
return reverse('read_comic', args=(urlsafe_base64_encode(item.selector.bytes),))
|
|
|
|
|
|
class RecentComicsAPI(Feed):
|
|
title = "CBWebReader Recent Comics"
|
|
link = "/read/"
|
|
description = "Recently added Comics"
|
|
user: User
|
|
|
|
def get_object(self, request: HttpRequest, user_selector: str, *args, **kwargs) -> UserMisc:
|
|
user_misc = get_object_or_404(UserMisc, feed_id=user_selector)
|
|
self.user = user_misc.user
|
|
return user_misc.user
|
|
|
|
def items(self) -> ComicBook:
|
|
comics = ComicBook.objects.order_by("-date_added")
|
|
comics = comics.annotate(
|
|
classification=Case(
|
|
When(directory__isnull=True, then=Directory.Classification.C_18),
|
|
default=F('directory__classification'),
|
|
output_field=PositiveSmallIntegerField(choices=Directory.Classification.choices)
|
|
)
|
|
)
|
|
comics = comics.filter(classification__lte=self.user.usermisc.allowed_to_read)
|
|
return comics[:10]
|
|
|
|
def item_title(self, item: ComicBook) -> str:
|
|
return item.file_name
|
|
|
|
def item_description(self, item: ComicBook) -> str:
|
|
return item.date_added.strftime("%a, %e %b %Y %H:%M")
|
|
|
|
# item_link is only needed if NewsItem has no get_absolute_url method.
|
|
def item_link(self, item: ComicBook) -> str:
|
|
return f'#/read/{item.selector}/'
|