2021-10-24 23:59:35 +11:00
|
|
|
from . import models
|
2022-02-09 19:59:04 +11:00
|
|
|
from rakka.utils import rerender
|
2021-10-24 23:59:35 +11:00
|
|
|
|
|
|
|
@rerender
|
|
|
|
def index():
|
|
|
|
books=models.Book.objects.all()
|
|
|
|
#Make table I guess, for now just get data up there
|
2021-10-27 19:09:18 +11:00
|
|
|
contents='<br/>\n'.join([f'<a href="/books/{book.url}">{book}</a> - {book.last_updated}' for book in books])
|
|
|
|
return {'title':'Booklist','content':contents+"<br/>\nYou should be able to read books now.",'date':'2021/10/24'}
|
|
|
|
|
|
|
|
@rerender
|
|
|
|
def book(bookurl):
|
|
|
|
book=models.Book.objects.filter(url=bookurl)[0]
|
|
|
|
chapters=models.Chapter.objects.filter(book=book).order_by('added')
|
|
|
|
return {'title':book.title,'content':'<a href="/books/">Top</a><br/>\n'+'<br/>\n'.join([f'<a href="/books/{book.url}/{chap.number}">{chap}</a> - {chap.added}' for chap in chapters]),'date':book.last_updated}
|
|
|
|
|
|
|
|
@rerender
|
|
|
|
def chapter(bookurl,chapnum):
|
|
|
|
book=models.Book.objects.filter(url=bookurl)[0]
|
2022-01-26 19:51:03 +11:00
|
|
|
chapter=models.Chapter.objects.filter(book=book,number=chapnum)[0]
|
2021-10-29 05:53:01 +11:00
|
|
|
text='<p>'+chapter.contents.replace('<','<').replace('>','>').replace('\n\n','</p><p>').replace('\n','<br/>')+'</p>'
|
2021-10-29 05:53:33 +11:00
|
|
|
return {'title':chapter,'content':'<p>Navigation buttons will come later...</p>\n'+text,'date':chapter.added}
|