diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html | 44 | ||||
-rw-r--r-- | app/fieldnotes/templates/fieldnotes/fieldnote_detail.html | 83 | ||||
-rw-r--r-- | app/fieldnotes/templates/fieldnotes/fieldnote_list.html | 45 | ||||
-rw-r--r-- | app/guides/admin.py | 37 | ||||
-rw-r--r-- | app/guides/guide_urls.py | 18 | ||||
-rw-r--r-- | app/guides/migrations/0002_remove_guide_category.py | 17 | ||||
-rw-r--r-- | app/guides/migrations/0003_guide_category.py | 21 | ||||
-rw-r--r-- | app/guides/migrations/0004_auto_20190914_0646.py | 47 | ||||
-rw-r--r-- | app/guides/migrations/0005_remove_guide_category.py | 17 | ||||
-rw-r--r-- | app/guides/models.py | 80 | ||||
-rw-r--r-- | app/guides/review_urls.py | 18 | ||||
-rw-r--r-- | app/guides/templates/guides/guide_detail.html | 176 | ||||
-rw-r--r-- | app/guides/templates/guides/guide_detail.txt | 8 | ||||
-rw-r--r-- | app/guides/templates/guides/guide_list.html | 40 | ||||
-rw-r--r-- | app/guides/views.py | 11 | ||||
-rw-r--r-- | app/taxonomy/admin.py | 28 |
16 files changed, 662 insertions, 28 deletions
diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html b/app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html new file mode 100644 index 0000000..57bbb69 --- /dev/null +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html @@ -0,0 +1,44 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %} Field Notes | luxagraf {% endblock %} +{% block metadescription %} Rough notes and sketches from the field {% endblock %} +{%block bodyid%}id="field-notes"{%endblock%} + +{% block primary %} + <ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> + <li>{% if month or year %}<a href="{% url 'fieldnotes:list' %}">Field Notes</a> →{%else%}Field Notes{%endif%}</li> + <li>{% if not month %}{{year|date:"Y"}}{%else%}<a href="/field-notes/{{month|date:"Y"}}/">{{month|date:"Y"}}</a> →{%endif%}</li> + {% if month %}<li itemprop="title">{{month|date:"F"}}</li>{% endif %} + </ul> + <main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="essay-intro"> + <h2>Field Notes {% if month or year %}{% if month %} from {{month|date:"F"}} {{month|date:"Y"}}{%else%} from {{year|date:"Y"}}{%endif%}{%endif%}</h2> + <p>Quick notes, sketches and images from the road. This is the semi-orgnized brain dump that comes before the more organized <a href="/jrnl/" title="read the journal">journal entries</a> and <a href="/essays/" title="read essays">essays</a>. If I used social media this is the stuff I'd probably put there, but I prefer to put it here, even if it means a lot few people read it.</p> + </div> + <ul class="fancy-archive-list">{% for object in object_list %}{% if object.slug != 'about' %} + <li class="h-entry hentry" itemscope itemType="http://schema.org/Article"> + <a href="{{object.get_absolute_url}}"> + {% if object.featured_image %}<div class="circle-img-wrapper"><img src="{{object.featured_image.get_thumbnail_url}}" alt="{{object.featured_image.alt}}" /></div>{%endif%} + <span class="date dt-published">{{object.pub_date|date:"F d, Y"}}</span> + <a href="{{object.get_absolute_url}}"> + <h2>{{object.title|safe|smartypants|widont}}</h2> + {% if object.subtitle %}<h3 class="p-summary">{{object.subtitle|safe|smartypants|widont}}</h3>{%endif%} + </a> + {% if object.location %}<h4 class="p-location h-adr post-location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> + <span class="p-locality">{{object.location.name|smartypants|safe}}</span>, + <span class="p-region">{{object.location.state_name}}</span>, + <span class="p-country-name">{{object.location.country_name}}</span> + <data class="p-latitude" value="{{object.latitude}}"></data> + <data class="p-longitude" value="{{object.longitude}}"></data> + </h4>{% endif %} + </li> + {%endif%}{%endfor%}</ul> + </main> + +{% endblock %} + + + diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html new file mode 100644 index 0000000..dc90e16 --- /dev/null +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html @@ -0,0 +1,83 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load month_number_to_name %} +{% block pagetitle %}{{object.title|title|smartypants|safe}} - Luxagraf, Field Notes{% endblock %} + +{% block metadescription %}{{object.body_html|striptags|safe|truncatewords:30}}{% endblock %} +{%block extrahead%} + <link rel="canonical" href="http://luxagraf.net{{object.get_absolute_url}}" /> + <meta name="ICBM" content="{{object.latitude}}, {{object.longitude}}" /> + <meta name="geo.position" content="{{object.latitude}}; {{object.longitude}}" /> + <meta name="geo.placename" content="{% if object.location.country.name == "United States" %}{{object.location.name|smartypants|safe}}, {{object.state.name}}{%else%}{{object.location.name|smartypants|safe}}, {{object.country.name}}{%endif%}"> + <meta name="geo.region" content="{{object.country.iso2}}{%if object.state.code != '' %}-{{object.state.code}}{%endif%}"> +{%endblock%} +{% block bodyid %}class="notes--permalin detail" id="archive-{% if month %}{{month|month_number_to_name}}{%endif%}{{year}}"{%endblock%} + + +{% block primary %}<ul class="bl crumbs" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> + <li><a href="/field-notes/" itemprop="url"><span itemprop="title">Field Notes</span></a> →</li> + <li><a href="/field-notes/{{object.pub_date|date:"Y"}}/">{{object.pub_date|date:"Y"}}</a> →</li> + <li itemprop="title"><a href="/field-notes/{{object.pub_date|date:"Y"}}/{{object.pub_date|date:"m"}}/">{{object.pub_date|date:"F"}}</a></li> + </ul> + <main role="main"> + <article class="h-entry hentry {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %} post--article--double{%endif%}{%endwith%}" itemscope itemType="http://schema.org/BlogPosting"> + <header id="header" class="post-header {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %}post--header--double{%endif%}{%endwith%}"> + <h1 class="p-name entry-title post-title" itemprop="headline">{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|safe}}{%endif%}</h1> + {% if object.subtitle %}<h2 class="post-subtitle">{{object.subtitle|smartypants|safe}}</h2>{%endif%} + <div class="post-linewrapper"> + {% if object.location %}<div class="p-location h-adr adr post-location" itemprop="contentLocation" itemscope itemtype="http://schema.org/Place"> + <h3 class="h-adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">{% if object.location.country_name == "United States" %}<span class="p-locality locality" itemprop="addressLocality">{{object.location.name|smartypants|safe}}</span>, <a class="p-region region" href="/jrnl/united-states/" title="travel writing from the United States">{{object.location.state_name|safe}}</a>, <span class="p-country-name" itemprop="addressCountry">U.S.</span>{%else%}<span class="p-region" itemprop="addressRegion">{{object.location.name|smartypants|safe}}</span>, <a class="p-country-name country-name" href="/jrnl/{{object.location.country_slug}}/" title="travel writing from {{object.location.country_name}}"><span itemprop="addressCountry">{{object.location.country_name|safe}}</span></a>{%endif%}</h3> + – <a href="" onclick="showMap({{object.latitude}}, {{object.longitude}}, { type:'point', lat:'{{object.latitude}}', lon:'{{object.longitude}}'}); return false;" title="see a map">Map</a> + </div>{%endif%} + <time class="dt-published published dt-updated post-date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> + <span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span> + </div> + </header> + <div class="e-content"> + {{object.body_html|safe|smartypants}} + </div> + <span class="p-author h-card"> + <data class="p-name" value="Scott Gilbertson"></data> + <data class="u-url" value="https://luxagraf.net/"></data> + </span> + <footer> + {%comment%}<p class="note--date"> + <a class="u-url" href="{{object.get_absolute_url}}" rel="bookmark"><time class="dt-published" datetime="{{object.pub_date|html5_datetime}}">{{object.pub_date|date:"F j, Y"}}</time></a> + </p>{%endcomment%} + {% comment %} {% if object.twitter_id %} + <ul class="note--actions"> + <li><a rel="syndication" class="u-syndication" href="https://twitter.com/luxagraf/status/{{object.twitter_id}}">View on Twitter</a></li> + <li> + <indie-action do="reply" with="{{SITE_URL}}{{object.get_absolute_url}}"><a href="https://twitter.com/intent/tweet?in_reply_to={{object.twitter_id}}">Reply</a></indie-action> + </li> + <li> + <indie-action do="post" with="{{SITE_URL}}{{object.get_absolute_url}}"> + <a href="https://twitter.com/intent/retweet?tweet_id={{object.twitter_id}}">Retweet</a> + </indie-action> + </li> + <li> + <indie-action do="bookmark" with="{{SITE_URL}}{{object.get_absolute_url}}"> + <a href="https://twitter.com/intent/favorite?tweet_id={{object.twitter_id}}">Favourite</a> + </indie-action> + </li> + </ul>{% endif %}{% endcomment %} + </footer> + + + {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + <nav id="page-navigation"> + <ul>{% if prev%} + <li rel="previous" id="next"><span class="bl">Previous:</span> + <a href="{{ prev.get_absolute_url }}" rel="prev" title=" {{prev.title}}">{{prev.title|safe}}</a> + </li>{%endif%}{% if next%} + <li rel="next" id="prev"><span class="bl">Next:</span> + <a href="{{ next.get_absolute_url }}" rel="next" title=" {{next.title}}">{{next.title|safe}}</a> + </li>{%endif%} + </ul> + </nav>{%endwith%}{%endwith%} + </article> +</main> +{% endblock %} diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html new file mode 100644 index 0000000..c201382 --- /dev/null +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html @@ -0,0 +1,45 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %} Field Notes | luxagraf {% endblock %} +{% block metadescription %}Rough notes and sketches from the field {% endblock %} +{%block bodyid%}id="field-notes"{%endblock%} + +{% block primary %} + <ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> + <li>Field Notes</li> + </ul> + <main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="essay-intro"> + <h2>Field Notes</h2> + <p>Quick notes, sketches and images from the road. This is the semi-orgnized brain dump that comes before the more organized <a href="/jrnl/" title="read the journal">journal entries</a> and <a href="/essays/" title="read essays">essays</a>. If I used social media this is the stuff I'd probably put there, but I prefer to put it here, even if it means a lot fewer people read it.</p> + </div> + {% autopaginate object_list 30 %} + <ul class="fancy-archive-list">{% for object in object_list %}{% if object.slug != 'about' %} + <li class="h-entry hentry" itemscope itemType="http://schema.org/Article"> + <a href="{{object.get_absolute_url}}" class="u-url"> + {% if object.featured_image %}<div class="circle-img-wrapper"><img src="{{object.featured_image.get_thumbnail_url}}" alt="{{object.featured_image.alt}}" class="u-photo" /></div>{%endif%} + <span class="date dt-published">{{object.pub_date|date:"F d, Y"}}</span> + <a href="{{object.get_absolute_url}}"> + <h2>{{object.title|safe|smartypants|widont}}</h2> + {% if object.subtitle %}<h3 class="p-summary">{{object.subtitle|safe|smartypants|widont}}</h3>{%endif%} + </a> + {% if object.location %}<h4 class="p-location h-adr post-location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> + <span class="p-locality">{{object.location.name|smartypants|safe}}</span>, + <span class="p-region">{{object.location.state_name}}</span>, + <span class="p-country-name">{{object.location.country_name}}</span> + <data class="p-latitude" value="{{object.latitude}}"></data> + <data class="p-longitude" value="{{object.longitude}}"></data> + </h4>{% endif %} + </li> + {%endif%}{%endfor%}</ul> + </main> + <nav aria-label="page navigation" class="pagination"> + {% paginate %} + </nav> +{% endblock %} + + + diff --git a/app/guides/admin.py b/app/guides/admin.py index e424385..7895aba 100644 --- a/app/guides/admin.py +++ b/app/guides/admin.py @@ -1,29 +1,34 @@ from django.contrib import admin +from django.contrib.gis.admin import OSMGeoAdmin from utils.widgets import LGEntryForm +from utils.util import get_latlon from .models import Guide + @admin.register(Guide) -class GuideAdmin(admin.ModelAdmin): +class GuideAdmin(OSMGeoAdmin): form = LGEntryForm - list_display = ('title', 'pub_date', 'enable_comments', 'status') + list_display = ('title', 'pub_date', 'enable_comments', 'status', 'post_type') list_filter = ('pub_date', 'enable_comments', 'status') prepopulated_fields = {"slug": ('title',)} fieldsets = ( ('Entry', { 'fields': ( 'title', - ('sub_title', 'category'), + 'sub_title', 'body_markdown', - ('pub_date', 'status'), + ('pub_date', 'status', 'post_type', 'disclaimer'), 'meta_description', + 'featured_image', 'dek', 'tags', - 'preamble_markdown', - 'featured_image', + 'prologue_markdown', + 'epilogue_markdown', 'has_video', ('slug', 'enable_comments'), + 'point', ), 'classes': ( 'show', @@ -33,10 +38,7 @@ class GuideAdmin(admin.ModelAdmin): }), ('meta', { 'fields': ( - 'point', - 'afterword', - ('field_notes', 'books'), - ('essays', 'jrnl'), + ('field_notes', 'books','jrnl'), ), 'classes': ( 'hide', @@ -46,5 +48,20 @@ class GuideAdmin(admin.ModelAdmin): }), ) + # options for OSM map Using custom ESRI topo map + lat, lon = get_latlon() + default_lon = lon + default_lat = lat + default_zoom = 10 + units = True + scrollable = False + map_width = 700 + map_height = 425 + map_template = 'gis/admin/osm.html' + openlayers_url = '/static/admin/js/OpenLayers.js' + class Media: js = ('image-loader.js', 'next-prev-links.js') + css = { + "all": ("my_styles.css",) + } diff --git a/app/guides/guide_urls.py b/app/guides/guide_urls.py new file mode 100644 index 0000000..ad67061 --- /dev/null +++ b/app/guides/guide_urls.py @@ -0,0 +1,18 @@ +from django.urls import path, re_path + +from . import views + +app_name = "guide" + +urlpatterns = [ + path( + r'<str:slug>', + views.GuideDetailView.as_view(), + name="guide-detail" + ), + path( + r'<str:slug>.txt', + views.GuideDetailViewTXT.as_view(), + name="guide-detail-txt" + ), +] diff --git a/app/guides/migrations/0002_remove_guide_category.py b/app/guides/migrations/0002_remove_guide_category.py new file mode 100644 index 0000000..76eefa6 --- /dev/null +++ b/app/guides/migrations/0002_remove_guide_category.py @@ -0,0 +1,17 @@ +# Generated by Django 2.1.7 on 2019-07-04 12:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('guides', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='guide', + name='category', + ), + ] diff --git a/app/guides/migrations/0003_guide_category.py b/app/guides/migrations/0003_guide_category.py new file mode 100644 index 0000000..82d03ac --- /dev/null +++ b/app/guides/migrations/0003_guide_category.py @@ -0,0 +1,21 @@ +# Generated by Django 2.1.7 on 2019-09-08 17:45 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('taxonomy', '0001_initial'), + ('guides', '0002_remove_guide_category'), + ] + + operations = [ + migrations.AddField( + model_name='guide', + name='category', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='taxonomy.Category'), + preserve_default=False, + ), + ] diff --git a/app/guides/migrations/0004_auto_20190914_0646.py b/app/guides/migrations/0004_auto_20190914_0646.py new file mode 100644 index 0000000..ccd79a5 --- /dev/null +++ b/app/guides/migrations/0004_auto_20190914_0646.py @@ -0,0 +1,47 @@ +# Generated by Django 2.1.7 on 2019-09-14 06:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('guides', '0003_guide_category'), + ] + + operations = [ + migrations.RenameField( + model_name='guide', + old_name='afterword', + new_name='epilogue_html', + ), + migrations.RenameField( + model_name='guide', + old_name='afterword_html', + new_name='epilogue_markdown', + ), + migrations.RenameField( + model_name='guide', + old_name='preamble_html', + new_name='prologue_html', + ), + migrations.RenameField( + model_name='guide', + old_name='preamble_markdown', + new_name='prologue_markdown', + ), + migrations.RemoveField( + model_name='guide', + name='essays', + ), + migrations.AddField( + model_name='guide', + name='disclaimer', + field=models.BooleanField(blank=True, default=False), + ), + migrations.AddField( + model_name='guide', + name='post_type', + field=models.IntegerField(choices=[(0, 'guide'), (1, 'review')], default=0), + ), + ] diff --git a/app/guides/migrations/0005_remove_guide_category.py b/app/guides/migrations/0005_remove_guide_category.py new file mode 100644 index 0000000..71d0280 --- /dev/null +++ b/app/guides/migrations/0005_remove_guide_category.py @@ -0,0 +1,17 @@ +# Generated by Django 2.1.7 on 2019-09-14 07:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('guides', '0004_auto_20190914_0646'), + ] + + operations = [ + migrations.RemoveField( + model_name='guide', + name='category', + ), + ] diff --git a/app/guides/models.py b/app/guides/models.py index 1583bee..8704887 100644 --- a/app/guides/models.py +++ b/app/guides/models.py @@ -20,11 +20,13 @@ class Guide(models.Model): title = models.CharField(max_length=200) sub_title = models.CharField(max_length=200, blank=True) dek = models.TextField(blank=True) - preamble_markdown = models.TextField(blank=True) - preamble_html = models.TextField(blank=True) - slug = models.SlugField(unique_for_date='pub_date') - body_html = models.TextField(blank=True) + prologue_markdown = models.TextField(blank=True) + prologue_html = models.TextField(blank=True) body_markdown = models.TextField() + body_html = models.TextField(blank=True) + epilogue_markdown = models.TextField(blank=True) + epilogue_html = models.TextField(blank=True) + slug = models.SlugField(unique_for_date='pub_date') pub_date = models.DateTimeField('Date published') last_updated = models.DateTimeField(auto_now=True) enable_comments = models.BooleanField(default=False) @@ -33,19 +35,21 @@ class Guide(models.Model): (1, 'Published'), ) status = models.IntegerField(choices=PUB_STATUS, default=0) + POST_TYPE = ( + (0, 'guide'), + (1, 'review'), + ) + post_type = models.IntegerField(choices=POST_TYPE, default=0) meta_description = models.CharField(max_length=256, null=True, blank=True) tags = TaggableManager(through=TaggedItems, blank=True, help_text='Topics Covered') - category = models.ForeignKey(Category, on_delete=models.CASCADE) featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) + point = models.PointField(null=True, blank=True) + location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True) has_video = models.BooleanField(blank=True, default=False) + disclaimer = models.BooleanField(blank=True, default=False) field_notes = models.ManyToManyField(FieldNote, blank=True) books = models.ManyToManyField(Book, blank=True) - essays = models.ManyToManyField(Essay, blank=True) jrnl = models.ManyToManyField(Entry, blank=True) - point = models.PointField(null=True, blank=True) - location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True) - afterword = models.TextField(blank=True) - afterword_html = models.TextField(blank=True) class Meta: ordering = ('-pub_date',) @@ -56,7 +60,10 @@ class Guide(models.Model): return self.title def get_absolute_url(self): - return reverse('guides:detail', kwargs={"category": self.category, "slug": self.slug}) + if self.post_type == 0: + return reverse('guide:guide-detail', kwargs={"slug": self.slug}) + if self.post_type == 1: + return reverse('review:review-detail', kwargs={"slug": self.slug}) def comment_period_open(self): return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date @@ -66,14 +73,55 @@ class Guide(models.Model): return self.get_previous_by_pub_date(status__exact=1) @property + def get_previous_admin_url(self): + n = self.get_previous_by_pub_date() + return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] ) + + @property def get_next_published(self): return self.get_next_by_pub_date(status__exact=1) - def save(self): - md = render_images(self.body_markdown) - self.body_html = markdown_to_html(md) - self.afterword_html = markdown_to_html(self.afterword) - super(Guide, self).save() + @property + def get_next_admin_url(self): + model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name) + try: + return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] ) + except model.DoesNotExist: + return '' + + @property + def longitude(self): + '''Get the site's longitude.''' + return self.point.x + + @property + def latitude(self): + '''Get the site's latitude.''' + return self.point.y + + def save(self, *args, **kwargs): + created = self.pk is None + if not created: + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + self.prologue_html = markdown_to_html(self.prologue_markdown) + self.epilogue_html = markdown_to_html(self.epilogue_markdown) + self.has_video = parse_video(self.body_html) + if self.point: + try: + self.location = Location.objects.filter(geometry__contains=self.point).get() + except Location.DoesNotExist: + raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) + if created and not self.featured_image: + self.featured_image = LuxImage.objects.latest() + old = type(self).objects.get(pk=self.pk) if self.pk else None + if old and old.featured_image != self.featured_image: # Field has changed + s = LuxImageSize.objects.get(name="featured_jrnl") + ss = LuxImageSize.objects.get(name="picwide-med") + self.featured_image.sizes.add(s) + self.featured_image.sizes.add(ss) + self.featured_image.save() + super(Guide, self).save(*args, **kwargs) class GuideSitemap(Sitemap): diff --git a/app/guides/review_urls.py b/app/guides/review_urls.py new file mode 100644 index 0000000..7048065 --- /dev/null +++ b/app/guides/review_urls.py @@ -0,0 +1,18 @@ +from django.urls import path, re_path + +from . import views + +app_name = "review" + +urlpatterns = [ + path( + r'<str:slug>', + views.GuideDetailView.as_view(), + name="review-detail" + ), + path( + r'<str:slug>.txt', + views.GuideDetailViewTXT.as_view(), + name="review-detail-txt" + ), +] diff --git a/app/guides/templates/guides/guide_detail.html b/app/guides/templates/guides/guide_detail.html new file mode 100644 index 0000000..1ef602a --- /dev/null +++ b/app/guides/templates/guides/guide_detail.html @@ -0,0 +1,176 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} +{%block htmlclass%}class="detail single"{%endblock%} +{% block pagetitle %}{{object.title|title|smartypants|safe}} - by Scott Gilbertson{% endblock %} + +{% block metadescription %}{% autoescape on %}{{object.meta_description|striptags|safe}}{% endautoescape %}{% endblock %} +{%block extrahead%} +{% if object.has_code %} + <link rel="stylesheet" href="/media/src/solarized.css" type="text/css" media="screen"/> +{%endif %} + <link rel="canonical" href="https://luxagraf.net{{object.get_absolute_url}}" /> + <meta property="og:type" content="article" /> + <meta property="og:title" content="{{object.title|safe}}" /> + <meta property="og:url" content="https://luxagraf.net{{object.get_absolute_url}}" /> + <meta property="og:description" content="{% if object.meta_description %}{{object.meta_description}}{%else%}{{object.sub_title}}{%endif%}" /> + <meta property="article:published_time" content="{{object.pub_date|date:'c'}}" /> + <meta property="article:author" content="Scott Gilbertson" /> + <meta property="og:site_name" content="Luxagraf" /> + <meta property="og:image" content="{{self.get_featured_image}}" /> + <meta property="og:locale" content="en_US" /> + <meta name="twitter:card" content="summary_large_image"/> + <meta name="twitter:description" content="{% if object.meta_description %}{{object.meta_description}}{%else%}{{object.sub_title}}{%endif%}"/> + <meta name="twitter:title" content="{{object.title|safe}}"/> + <meta name="twitter:site" content="@luxagraf"/> + <meta name="twitter:domain" content="luxagraf"/>{% if object.featured_image %} + <meta name="twitter:image:src" content="{{object.featured_image.get_image_url}}"/>{%endif%} + <meta name="twitter:creator" content="@luxagraf"/> +{%endblock%} + +{%block bodyid %}{% if object.get_post_type_display == 'tools' %}class="src"{% endif %}{%endblock%} + +{% block primary %} + <main> + <article class="h-entry hentry {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %} post--article--double{%endif%}{%endwith%}" itemscope itemType="http://schema.org/Article"> + <header id="header" class="post-header {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %}post--header--double{%endif%}{%endwith%}"> + <h1 class="p-name entry-title post-title" itemprop="headline">{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|safe}}{%endif%}</h1> + <h2 class="post-subtitle">{{object.sub_title|smartypants|safe}}</h2> + <div class="post-linewrapper"> + {% if object.originally_published_by %}<h4 class="post-source">Originally Published By: <a href="{{object.originally_published_by_url}}" title="View {{object.title}} on {{object.originally_published_by}}">{{object.originally_published_by}}</a></h4>{%endif%} + {% if object.location %}<div class="p-location h-adr adr post-location" itemprop="contentLocation" itemscope itemtype="http://schema.org/Place"> + <h3 class="h-adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">{% if object.location.country_name == "United States" %}<span class="p-locality locality" itemprop="addressLocality">{{object.location.name|smartypants|safe}}</span>, <a class="p-region region" href="/jrnl/united-states/" title="travel writing from the United States">{{object.location.state_name|safe}}</a>, <span class="p-country-name" itemprop="addressCountry">U.S.</span>{%else%}<span class="p-region" itemprop="addressRegion">{{object.location.name|smartypants|safe}}</span>, <a class="p-country-name country-name" href="/jrnl/{{object.location.country_slug}}/" title="travel writing from {{object.location.country_name}}"><span itemprop="addressCountry">{{object.location.country_name|safe}}</span></a>{%endif%}</h3> + – <a href="" onclick="showMap({{object.latitude}}, {{object.longitude}}, { type:'point', lat:'{{object.latitude}}', lon:'{{object.longitude}}'}); return false;" title="see a map">Map</a> + </div>{%endif%} + <time class="dt-published published dt-updated post-date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> + <span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span> + </div> + </header> + <div id="article" class="e-content entry-content post--body post--body--{% with object.template_name as t %}{%if t == 0 or t == 2 %}single{%endif%}{%if t == 1 or t == 3 %}double{%endif%}{%endwith%} post-essay" itemprop="articleBody"> + {% if object.preamble %}<div class="afterward"> + {{object.preamble_html|smartypants|safe}} + </div>{%endif%} + {{object.body_html|safe|smartypants}} + </div> + {% if object.afterword_html %}<div class="afterward"> + <h4>Afterward</h4> + {{object.afterword_html|smartypants|safe}} + </div>{%endif%} + {%if wildlife or object.field_notes.all or object.books.all %}<div class="entry-footer">{%if wildlife %} + <aside id="wildlife"> + <h3>Fauna and Flora</h3> + {% regroup wildlife by ap.apclass.get_kind_display as wildlife_list %} + <ul> + {% for object_list in wildlife_list %} + <li class="grouper">{{object_list.grouper}}<ul> + {% for object in object_list.list %} + <li>{%if object.ap.body_markdown%}<a href="{% url 'sightings:detail' object.ap.slug %}">{{object}}</a>{%else%}{{object}}{%endif%} </li> + {% endfor %}</ul> + {% endfor %}</ul> + </aside> + {% endif %}{%if object.field_notes.all %} + <aside {% if wildlife %}class="margin-left-none" {%endif%}id="field_notes"> + <h3>Field Notes</h3> + <ul>{% for obj in object.field_notes.all %} + <li><a href="{% url 'fieldnotes:detail' year=obj.pub_date.year month=obj.pub_date|date:"m" slug=obj.slug %}">{{obj}}</a></li> + {% endfor %}</ul> + </aside>{% endif %} + {%if object.books.all %} + <aside id="recommended-reading" {%if object.field_notes.all and wildlife %}class="rr-clear{%endif%}" > + <h3>Recommended Reading</h3> + <ul>{% for obj in object.books.all %} + <li><a href="{% url 'books:detail' slug=obj.slug %}"><img src="{{obj.get_small_image_url}}" /></a></li> + {% endfor %}</ul> + </aside>{% endif %} + </div>{%endif%} + </article> + + {% comment %} <div class="mailing-list--wrapper"> + <h5>If you enjoyed this, you should join the mailing list…</h5> + {% include 'mailing_list.html' %} + </div> {% endcomment %} + </main> + {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} +<p class="comments--header">{{comment_count}} Comment{{ comment_count|pluralize }}</p> +{% render_comment_list for object %} +{%endif%} +{% render_comment_form for object %} +{% else %} +<p class="comments--header" style="text-align: center">Sorry, comments have been disabled for this post.</p> +{%endif%} +{% endblock %} +{% block js %} +<script type="text/javascript"> +document.addEventListener("DOMContentLoaded", function(event) { + var leaflet = document.createElement('script'); + leaflet.src = "/media/js/leaflet-master/leaflet-mod.js"; + document.body.appendChild(leaflet); + var lightbox = document.createElement('script'); + lightbox.src = "/media/js/lightbox.js"; + document.body.appendChild(lightbox); + leaflet.onload = function(){ + var detail = document.createElement('script'); + detail.src = "/media/js/detail.min.js"; + document.body.appendChild(detail); + {% with object.get_template_name_display as t %}{%if t == "single" or t == "single-dark" %} + detail.onload = function(){ + createMap(); + var open = false; + } + {%endif%}{%endwith%} + } + + lightbox.onload = function() { + var opts= { + //nextOnClick: false, + captions: true, + onload: function(){ + var im = document.getElementById("jslghtbx-contentwrapper"); + var link = im.appendChild(document.createElement('a')) + link.href = im.firstChild.src; + link.innerHTML= "open "; + link.target = "_blank"; + link.setAttribute('class', 'p-link'); + im.appendChild(link); + } + }; + var lightbox = new Lightbox(); + lightbox.load(opts); + } + {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} + //delay loading of gravatar images using noscript data-hash attribute + dataattr = document.getElementsByClassName("datahashloader"); + for(var i=0; i<dataattr.length; i++) { + var c = dataattr[i].parentNode; + var img = document.createElement("img"); + img.src = 'https://images.luxagraf.net/gravcache/' + dataattr[i].getAttribute('data-hash') + '.jpg'; + img.className += "gravatar"; + c.insertBefore(img, c.childNodes[3]); + } +{%endif%} +{%endif%} +{% if object.has_video %} +var tester = document.getElementsByClassName("vidauto"); +var wrapper = document.getElementById('wrapper'); +var dist = 100; + +window.onscroll = function() { + for (var i=0; i<tester.length; i++) { + checkVisible(tester[i]) ? tester[i].play() : tester[i].pause(); + } +}; + +function checkVisible(elm) { + var rect = elm.getBoundingClientRect(); + var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); + return !(rect.bottom < 0 || rect.top - viewHeight >= 0); +} +{%endif%} + +}); +</script> +{%endblock%} diff --git a/app/guides/templates/guides/guide_detail.txt b/app/guides/templates/guides/guide_detail.txt new file mode 100644 index 0000000..547ce79 --- /dev/null +++ b/app/guides/templates/guides/guide_detail.txt @@ -0,0 +1,8 @@ +{{object.title|safe}} +{% for letter in object.title %}={%endfor%} + + by Scott Gilbertson + <{{SITE_URL}}{{object.get_absolute_url}}> + {{object.pub_date|date:"l, d F Y"}} + +{{object.body_markdown|safe}} diff --git a/app/guides/templates/guides/guide_list.html b/app/guides/templates/guides/guide_list.html new file mode 100644 index 0000000..a264a11 --- /dev/null +++ b/app/guides/templates/guides/guide_list.html @@ -0,0 +1,40 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %}Guides for the Perplexed{% endblock %} +{% block metadescription %}Guides for fellow travelers: tools, tips, and tricks to make life on the road easier.{% endblock %} + +{% block primary %}<ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> + <li>Essays</li> + </ul> + <main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="essay-intro"> + <h2>Guides for fellow travelers</h2> + <p>The less stuff you travel with the better off you will be, up to a point. But where is that point? What's enough? What's too much? That point is what I'm trying to discover here. </p> + <p>What do you really need? What's worth having? What's not?</p> + <p>Topics include {% for topic in topic_list %}{{topic}}, {% endfor %}travel, cooking, photography, writing, simplicity, and once, coffee.</p> + </div> + <h1 class="topic-hed">Guides</h1> + {% autopaginate object_list 30 %} + <ul class="fancy-archive-list">{% for object in object_list %} + <li class="h-entry hentry" itemscope itemType="http://schema.org/Article"> + <a href="{{object.get_absolute_url}}" class="u-url"> + <div class="circle-img-wrapper"><img src="{{object.featured_image.get_thumbnail_url}}" alt="{{object.featured_image.alt}}" class="u-photo" /></div> + <span class="date dt-published">{{object.pub_date|date:"F d, Y"}}</span> + <a href="{{object.get_absolute_url}}"> + <h2>{{object.title|safe|smartypants|widont}}</h2> + {% if object.subtitle %}<h3 class="p-summary">{{object.subtitle|safe|smartypants|widont}}</h3>{%endif%} + </a> + {% if object.location %}<h4 class="p-location h-adr post-location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> + <span class="p-locality">{{object.location.name|smartypants|safe}}</span>, + <span class="p-region">{{object.location.state_name}}</span>, + <span class="p-country-name">{{object.location.country_name}}</span> + <data class="p-latitude" value="{{object.latitude}}"></data> + <data class="p-longitude" value="{{object.longitude}}"></data> + </h4>{% endif %} + </li> + {%endfor%}</ul> + </main> +{%endblock%} diff --git a/app/guides/views.py b/app/guides/views.py index 8b5aeaa..01dc974 100644 --- a/app/guides/views.py +++ b/app/guides/views.py @@ -14,12 +14,19 @@ class GuideListView(PaginatedListView): qs = Guide.objects.filter(status=1) return qs -class GuideCatListView(PaginatedListView): + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(GuideListView, self).get_context_data(**kwargs) + context['topic_list'] = Guide.tags.all() + return context + + +class GuideCatListView(GuideListView): model = Guide def get_queryset(self, **kwargs): cat = Category.objects.get(slug=self.kwargs['slug']) - qs = Guide.objects.filter(status=1, category=cat) + qs = Guide.objects.filter(status=1, tags=cat) return qs class GuideDetailView(DetailView): diff --git a/app/taxonomy/admin.py b/app/taxonomy/admin.py new file mode 100644 index 0000000..cc48fac --- /dev/null +++ b/app/taxonomy/admin.py @@ -0,0 +1,28 @@ +from django.contrib import admin +from .models import Category + + +@admin.register(Category) +class CategoryAdmin(admin.ModelAdmin): + list_display = ( + 'name', + 'color_rgb', + ) + fieldsets = ( + ('Item', { + 'fields': ( + 'name', + 'color_rgb', + 'slug', + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + } + ), + ) + + class Media: + js = ('image-loader.js', 'next-prev-links.js') |