blob: e3820b5c461eb96e7ae551c8e993fb5603abad2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from django.shortcuts import redirect, render
from read.utils import get_chapter_pages, get_manga_data
# Create your views here.
def index(request):
return redirect("home:index")
def read(request, manga_id, chapter_id):
manga = get_manga_data(manga_id)
pages = get_chapter_pages(chapter_id)
chapters = manga["chapters"]
current_chapter_index = next((i for i, chapter in enumerate(chapters) if chapter["id"] == chapter_id), None)
next_chapter = chapters[current_chapter_index + 1] if current_chapter_index is not None and current_chapter_index + 1 < len(chapters) else None
prev_chapter = chapters[current_chapter_index - 1] if current_chapter_index is not None and current_chapter_index - 1 >= 0 else None
context = {
"pages": pages,
"manga": manga,
"chapter_id": chapter_id,
"next_chapter": next_chapter,
"prev_chapter": prev_chapter,
}
return render(request, "read/read.html", context)
|