diff options
-rw-r--r-- | app/sightings/migrations/0004_ap_main_image.py | 18 | ||||
-rw-r--r-- | app/sightings/migrations/0005_auto_20180516_1759.py | 24 | ||||
-rw-r--r-- | app/sightings/models.py | 13 | ||||
-rw-r--r-- | design/sass/_birds.scss | 47 | ||||
-rw-r--r-- | design/sass/_writing_details.scss | 6 | ||||
-rw-r--r-- | design/templates/archives/sightings.html | 14 | ||||
-rw-r--r-- | design/templates/details/sighting.html | 11 |
7 files changed, 116 insertions, 17 deletions
diff --git a/app/sightings/migrations/0004_ap_main_image.py b/app/sightings/migrations/0004_ap_main_image.py new file mode 100644 index 0000000..70e1937 --- /dev/null +++ b/app/sightings/migrations/0004_ap_main_image.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.1 on 2018-05-16 17:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sightings', '0003_auto_20180209_1037'), + ] + + operations = [ + migrations.AddField( + model_name='ap', + name='main_image', + field=models.CharField(max_length=200, null=True), + ), + ] diff --git a/app/sightings/migrations/0005_auto_20180516_1759.py b/app/sightings/migrations/0005_auto_20180516_1759.py new file mode 100644 index 0000000..301c0d9 --- /dev/null +++ b/app/sightings/migrations/0005_auto_20180516_1759.py @@ -0,0 +1,24 @@ +# Generated by Django 2.0.1 on 2018-05-16 17:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0018_auto_20161130_1218'), + ('sightings', '0004_ap_main_image'), + ] + + operations = [ + migrations.RemoveField( + model_name='ap', + name='main_image', + ), + migrations.AddField( + model_name='ap', + name='image', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='photos.LuxImage'), + ), + ] diff --git a/app/sightings/models.py b/app/sightings/models.py index 8531772..8673d4b 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -9,9 +9,11 @@ from django.utils import timezone from django import forms from django.conf import settings +from bs4 import BeautifulSoup # from photos.models import LuxImage from locations.models import Location +from photos.models import LuxImage from utils.widgets import parse_image from utils.widgets import markdown_to_html from utils.next_prev import next_in_order, prev_in_order @@ -22,6 +24,12 @@ def render_images(s): return s +def extract_main_image(s): + soup = BeautifulSoup(s, 'html.parser') + image = soup.find_all('img')[0]['id'] + return image.split('image-')[1] + + def get_upload_path(self, filename): return "images/sightings-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) @@ -67,6 +75,7 @@ class AP(models.Model): apclass = models.ForeignKey(APClass, on_delete=models.CASCADE) body_html = models.TextField(null=True, blank=True) body_markdown = models.TextField(null=True, blank=True) + image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True) # image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px") # image_credit = models.CharField(max_length=200, blank=True, null=True) @@ -115,6 +124,10 @@ class AP(models.Model): if self.pk: md = render_images(self.body_markdown) self.body_html = markdown_to_html(md) + try: + self.image = LuxImage.objects.get(pk=extract_main_image(self.body_markdown)) + except TypeError: + pass self.slug = slugify(self.common_name[:50]) super(AP, self).save(*args, **kwargs) diff --git a/design/sass/_birds.scss b/design/sass/_birds.scss index 81149ff..d491f1d 100644 --- a/design/sass/_birds.scss +++ b/design/sass/_birds.scss @@ -79,16 +79,57 @@ .map { margin: 0 auto; width: 99%; - height: 200px; - @include constrain_wide; + height: 400px; @include breakpoint(beta) { @include constrain_narrow; } } #endnode { + @include breakpoint(beta) { + text-align: left; + } @include fancy-sans; @include fontsize(14); - margin-top: 2em; + margin-top: 4rem; + h5 { + @include fontsize(14); + @include smcaps; + @include fancy_sans; + margin-bottom: 1rem; + margin-top: 2rem; + } + ul { + margin-bottom: 2em; + li { + color: lighten($body_font, 30); + &:before { + content: "\2022"; + color: lighten($body_font, 30); + margin-right: .35rem; + } + } + } + a { + text-decoration: none; + color: lighten($body_font, 10); + } + &:before { + @include faded_line_after; + } + } + #detail-map-canvas { + width: 100vw; + @include constrain_wide; + position: relative; + @include breakpoint(gamma) { + left: calc(-20%); + } + @include breakpoint(delta) { + left: calc(-38%); + } + @include breakpoint(epsilon) { + left: calc(-45%); + } } } diff --git a/design/sass/_writing_details.scss b/design/sass/_writing_details.scss index 9dec803..27f73b9 100644 --- a/design/sass/_writing_details.scss +++ b/design/sass/_writing_details.scss @@ -780,6 +780,12 @@ figure.picwide img.picwide { text-decoration: none; color: lighten($body_font, 20); } + #wildlife li ul li { + color: lighten($body_font, 40); + a { + color: lighten($body_font, 10); + } + } @include breakpoint(beta) { margin-bottom: 4em; #wildlife { diff --git a/design/templates/archives/sightings.html b/design/templates/archives/sightings.html index e9d4610..413ec44 100644 --- a/design/templates/archives/sightings.html +++ b/design/templates/archives/sightings.html @@ -18,14 +18,12 @@ <article class="{% cycle 'odd' 'even' %} {% cycle 'first' 'second' 'third' %}"> <div class="post--image"> {% load get_image_by_size %} -{% load get_image_width %} +{% load get_image_width %}{% if object.ap.image%} <figure> <a href="{{object.ap.get_absolute_url}}" title="{{object.ap}}"> -<img class="picfull" sizes="(max-width: 680px) 100vw, (min-width: 681) 680px" srcset="{% for size in object.image.sizes.all%}{% get_image_by_size object.image size.name %} {{size.width}}w{% if forloop.last%}"{%else%}, {%endif%}{%endfor%} - {% for size in object.image.sizes.all%}{%if forloop.first %} src="{% get_image_by_size object.image size.name %}"{%endif%}{%endfor%} alt="{{object.image.alt}} photographed by {% if object.image.photo_credit_source %}{{object.image.photo_credit_source}}{%else%}luxagraf{%endif%}" > + <img src="{% get_image_by_size object.ap.image 'pic5' %}" /> </a> -{% if object.image.photo_credit_source %}<figcaption>photo by <a href="{{object.image.photo_credit_url}}">{{object.image.photo_credit_source}}</a></figcaption>{%endif%} -</figure> +</figure>{%endif%} </div> <h3 class="post--title"><a href="{{object.ap.get_absolute_url}}" title="{%if object.title_keywords%}{{object.title_keywords}}{%else%}{{object.ap}}{%endif%}">{{object.ap|safe|smartypants|widont}}</a> (<span class="sci">{{object.ap.scientific_name}}</span>)</h3> <time class="post--date" datetime="{{object.pub_date|date:'c'}}">Seen: {{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> @@ -38,12 +36,6 @@ </span> </span> </p> - <div class="audio-figure">{% for recording in object.ap.recordings.all %} - <audio controls="controls"> - <source src="/media/{{recording.audio}}" /> - </audio> - <small>Audio recorded by {{recording.recorder}} on {{recording.pub_date|date:"F j, Y"}} in {{recording.location}}. <a href="{{recording.link}}">© {{recording.copyright}}</a></small> - </div>{% endfor %} </article> {% endfor %} </main> <nav class="pagination"> diff --git a/design/templates/details/sighting.html b/design/templates/details/sighting.html index fd060f7..718583f 100644 --- a/design/templates/details/sighting.html +++ b/design/templates/details/sighting.html @@ -26,9 +26,14 @@ <small>Audio recorded by {{recording.recorder}} on {{recording.pub_date|date:"F j, Y"}} in {{recording.location}}. <a href="{{recording.link}}">© {{recording.copyright}}</a></small> </div> {%endif%} -<p id="endnode">Seen at {%for sight in sighting %}{{sight.location}}, {{sight.location.comma_name}} in {{sight.pub_date|date:"M Y"}} {%comment%}by {% for person in sight.seen_by.all %}<a href="{% url 'sightings:list_by_person' person %}">{% if person.username == "luxagraf"%}Scott{%else%}{{person.username|capfirst}}{%endif%}</a>{%if forloop.last %}. {%else%}{% if forloop.revcounter == 2 %}, and {%else%}, {%endif%}{%endif%}{%endfor%}{%endcomment%}{%endfor%} </p> -{% if recording.audio %} -{%endif%} +<div id="endnode"> + <aside id="locations"> + <h5>Seen at</h5> + <ul>{%for sight in sighting %} + <li><a href="{{sight.location.get_absolute_url}}">{{sight.location}}</a>, {{sight.location.comma_name}}, {{sight.pub_date|date:"M Y"}}</li> + {%endfor%}</ul> + </aside> +</div> </article> </main> {% endblock %} |