From 6e8b62d8c38f6ca366f240ea45ad738ebfd62943 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 27 Jan 2020 20:37:10 -0500 Subject: abstracted breadcrumbs into seperate template --- app/books/templates/books/book_detail.html | 62 ++++++++++++++++++++++++++++++ app/books/templates/books/book_list.html | 53 +++++++++++++++++++++++++ app/books/views.py | 7 ++-- 3 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 app/books/templates/books/book_detail.html create mode 100644 app/books/templates/books/book_list.html (limited to 'app/books') diff --git a/app/books/templates/books/book_detail.html b/app/books/templates/books/book_detail.html new file mode 100644 index 0000000..99d5b9d --- /dev/null +++ b/app/books/templates/books/book_detail.html @@ -0,0 +1,62 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{%block bodyid%}class="detail"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs_detail.html" with breadcrumbs=breadcrumbs %}{% endblock %} + {% block primary %}
+
+

{{object.title|smartypants|widont|safe}}

+ + + +
+
+ {{object.title}} cover +
+
+ +
+ {% if object.isbn %}Borrow{%endif%} + {% if object.afflink %}Buy{%endif%} +
+
{%if object.body_html%} +
+
Notes
+ {{object.rating}} + + +
{{object.body_html|safe|smartypants|widont}}
+
{%endif%} + {% if object.bookhighlight_set.all %} +
+

Highlights:

+ {% for object in object.bookhighlight_set.all %} +
+ +
+ {{object.body_html|safe|amp|smartypants}} +
+

– Page: {{object.page}} {% if object.location %}(Kindle location: {{object.location|cut:"["|cut:"]"}}){%endif%}

+
+ {% endfor %} +
+ {%endif%} +
+{% endblock %} +{% block disclaimer %} +
+

When you buy a book using the link above, I may earn a small affiliate commission.

+
+{% endblock %} diff --git a/app/books/templates/books/book_list.html b/app/books/templates/books/book_list.html new file mode 100644 index 0000000..96d4d1b --- /dev/null +++ b/app/books/templates/books/book_list.html @@ -0,0 +1,53 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %} Books | luxagraf {% endblock %} +{% block metadescription %}Books I've read and thoughts on them. {% endblock %} +{%block bodyid%}class="archive" id="books-archive"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}
{% autopaginate object_list 24 %} +

Books

+
+

I wear glasses because as a child I would stay up late, covers pulled over my head, reading by the dim light of a dying flashlight. At least that's what an eye doctor told me when I was younger. Probably a load of crap, but I still love reading and I still often do it by poor light far later in the night than is reasonable.

+

I've always taken notes while reading, usually with a pen and paper, but sometimes as highlights in the Kindle. And of course since I have all this stuff in text files I thought might as well put it online. So here you have it, books I've read and things I've thought about them.

+
+ +
{% for object in object_list %} +
+ {% if object.image %}
cover art for {{object.title}} by {{object.author_name}}
{%endif%} +

{{object.title|amp|smartypants|widont|safe}}

+ +
+ {% if object.rating %}{% for i in object.ratings_range %}{% if i <= object.get_rating%}★{%else%}☆{%endif%}{%endfor%}{%endif%} + + Read in: {{object.read_date|date:"F Y"}}
+
+ {% endfor %}
+ +
+{% endblock %} + + + title = models.CharField(max_length=200) + author_name = models.CharField(max_length=200) + slug = models.CharField(max_length=50) + year_pub = models.CharField(max_length=4, blank=True, null=True) + read_date = models.DateTimeField() + isbn = models.CharField(max_length=100, blank=True, null=True) + body_html = models.TextField(null=True, blank=True) + url = models.CharField(max_length=200, blank=True, null=True) + tags = TaggableManager() + RATINGS = ( + ('1', "1 Star"), + ('2', "2 Stars"), + ('3', "3 Stars"), + ('4', "4 Stars"), + ('5', "5 Stars"), + ) + rating = models.CharField(max_length=1, choices=RATINGS, null=True) + enable_comments = models.BooleanField(default=False) + image = models.FileField(upload_to='book-covers/', null=True, blank=True) + diff --git a/app/books/views.py b/app/books/views.py index e829476..bf09996 100644 --- a/app/books/views.py +++ b/app/books/views.py @@ -1,17 +1,16 @@ from django.views.generic.detail import DetailView -from utils.views import PaginatedListView +from utils.views import PaginatedListView, LuxDetailView from .models import Book class BookListView(PaginatedListView): - template_name = 'archives/books.html' + model = Book def get_queryset(self): return Book.objects.filter(is_public=True).order_by('-read_date').select_related() -class BookDetailView(DetailView): +class BookDetailView(LuxDetailView): model = Book - template_name = "details/book.html" slug_field = "slug" -- cgit v1.2.3-70-g09d2