summaryrefslogtreecommitdiff
path: root/app/books
diff options
context:
space:
mode:
Diffstat (limited to 'app/books')
-rw-r--r--app/books/templates/books/book_detail.html62
-rw-r--r--app/books/templates/books/book_list.html53
-rw-r--r--app/books/views.py7
3 files changed, 118 insertions, 4 deletions
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 %}<main itemprop="mainEntity" itemscope itemtype="http://schema.org/Book">
+ <header class="tight">
+ <h1 class="post-title book-title" itemprop="name">{{object.title|smartypants|widont|safe}}</h1>
+ <h2 class="post-subtitle" itemprop="author" itemscope itemtype="http://schema.org/Person">
+ <meta itemprop="name" content="{{object.author_name}}"/>by {{object.author_name}}</h2>
+
+
+ </header>
+ <div class="book-cover-wrapper">
+ <img src="{{object.get_image_url}}" alt="{{object.title}} cover" />
+ </div>
+ <div class="meta-cover">
+ <dl class="book-metadata">
+
+ {% if object.rating %}<dt>Rating</dt><dd class="book-stars">
+ {% for i in object.ratings_range %}{% if i <= object.get_rating%}&#9733;{%else%}&#9734;{%endif%}{%endfor%}</span></dd>{%endif%}
+ {% if object.read_in %}<dt>Read</dt>
+ <dd>{{object.read_in}}</dd>{%endif%}
+ {% if object.pages %}<dt>Pages</dt>
+ <dd itemprop="numberOfPages">{{object.pages}}</dd>{%endif%}
+ {% if object.publish_date %}<dt>Published</dt>
+ <dd>{%if object.publish_place%}{{object.publish_place}}, {%endif%}{{object.publish_date}}</dd>{%endif%}
+ {% if object.isbn %}<dt>ISBN</dt>
+ <dd>{{object.isbn}}</dd>{%endif%}
+ </dl>
+ <div class="buy-btn-wrapper">
+ {% if object.isbn %}<a class="buy-btn" href="http://worldcat.org/isbn/{{object.isbn}}" title="find {{object.title}} in your local library">Borrow</a>{%endif%}
+ {% if object.afflink %}<a class="buy-btn" href="{{object.afflink}}" title="buy {{object.title}} at Amazon">Buy</a>{%endif%}
+ </div>
+ </div>{%if object.body_html%}
+ <div class="thoughts" itemprop="review" itemscope itemtype="http://schema.org/Review">
+ <h5>Notes</h5>
+ <span class="hide" itemprop="reviewRating">{{object.rating}}</span>
+ <meta itemprop="author" content="Scott Gilbertson" />
+ <meta itemprop="datePublished" content="{{object.read_date|date:"c"}}">
+ <div itemprop="reviewBody">{{object.body_html|safe|smartypants|widont}}</div>
+ </div>{%endif%}
+ {% if object.bookhighlight_set.all %}
+ <div class="highlights">
+ <h4>Highlights:</h4>
+ {% for object in object.bookhighlight_set.all %}
+ <div class="h-entry hentry post--article book">
+ <a class="highlink" id="h{{forloop.counter}}-page-{{object.page}}" href="#h{{forloop.counter}}-page-{{object.page}}">&para;</a>
+ <div class="book-highlight">
+ {{object.body_html|safe|amp|smartypants}}
+ </div>
+ <p class="foot">&ndash; Page: {{object.page}} {% if object.location %}(Kindle location: {{object.location|cut:"["|cut:"]"}}){%endif%}</p>
+ </div>
+ {% endfor %}
+ </div>
+ {%endif%}
+ </main>
+{% endblock %}
+{% block disclaimer %}
+<div class="highlights">
+ <p class="dis"><em>When you buy a book using the link above, I may earn a small affiliate commission.</em></p>
+</div>
+{% 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 %}<main>{% autopaginate object_list 24 %}
+ <h1 class="hide">Books</h1>
+ <div class="intro">
+ <p>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.</p>
+ <p>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.</p>
+ </div>
+ <nav class="pagination">{% paginate %}
+ </nav>
+ <div class="archive-grid book-grid"> {% for object in object_list %}
+ <article class="archive-card" itemscope itemtype="http://schema.org/Book">
+ {% if object.image %}<div class="img-wrapper"><a href="{{object.get_absolute_url}}"><img itemprop="image" src="{{object.get_image_url}}" alt="cover art for {{object.title}} by {{object.author_name}}"/></a></div>{%endif%}
+ <h2 class="post-title" itemprop="name"><a href="{{object.get_absolute_url}}">{{object.title|amp|smartypants|widont|safe}}</a></h2>
+ <h4 class="author" itemprop="author">{{object.author_name}}</h4>
+ <div class="post-summary" itemprop="review" itemscope itemtype="http://schema.org/Review">
+ {% if object.rating %}<span class="book-stars" itemprop="reviewRating">{% for i in object.ratings_range %}{% if i <= object.get_rating%}&#9733;{%else%}&#9734;{%endif%}{%endfor%}</span>{%endif%}
+ <span class="hide" itemprop="author">Scott Gilbertson</span>
+ <meta itemprop="datePublished" content="{{object.read_date|date:'F Y'}}"><span class="read-in">Read in: {{object.read_date|date:"F Y"}}</span></div>
+ </article>
+ {% endfor %}</div>
+ <nav aria-label="page navigation" class="pagination">{% paginate %}
+ </nav>
+ </main>
+{% 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"