diff options
author | luxagraf <sng@luxagraf.net> | 2019-02-22 20:44:24 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-02-22 20:44:24 -0600 |
commit | 5813a02145c8f95c04a2fedfd9555b402d443e6b (patch) | |
tree | c41dfa15aa4d4e50b928c514526216f84c9921cc /app/books/models.py | |
parent | 24e0c4ee694c694db2a6d038e5b509aed8e66b13 (diff) |
added essays and books to sitemap, moved books to read
Diffstat (limited to 'app/books/models.py')
-rw-r--r-- | app/books/models.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/books/models.py b/app/books/models.py index 8e381ef..5df74f1 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -2,6 +2,7 @@ import os from PIL import Image from django.db import models from django.db.models.signals import post_save +from django.contrib.sitemaps import Sitemap from django.dispatch import receiver from django.urls import reverse from django.apps import apps @@ -23,7 +24,7 @@ class Book(models.Model): slug = models.CharField(max_length=50) read_date = models.DateTimeField() isbn = models.CharField(max_length=100, blank=True, null=True) - body_markdown = models.TextField(null=True, blank=True) + body_markdown = models.TextField(blank=True) body_html = models.TextField(null=True, blank=True) read_in = models.TextField(null=True, blank=True) url = models.CharField(max_length=200, blank=True, null=True) @@ -114,3 +115,15 @@ class BookHighlight(models.Model): def body_html(self): return markdown_to_html(self.body_markdown) + + +class BookSitemap(Sitemap): + changefreq = "never" + priority = 0.7 + protocol = "https" + + def items(self): + return Book.objects.filter(is_public=True).exclude(body_markdown='') + + def lastmod(self, obj): + return obj.read_date |