diff options
-rw-r--r-- | app/photos/migrations/0001_initial.py | 137 | ||||
-rw-r--r-- | app/photos/migrations/__init__.py | 0 | ||||
-rw-r--r-- | app/photos/templatetags/__init__.py | 0 | ||||
-rw-r--r-- | app/photos/templatetags/get_image_size.py | 8 | ||||
-rw-r--r-- | app/photos/utils.py | 15 | ||||
-rw-r--r-- | app/resume/migrations/0003_auto_20151211_1925.py | 19 | ||||
-rw-r--r-- | design/templates/details/photo_gallery.html | 62 |
7 files changed, 241 insertions, 0 deletions
diff --git a/app/photos/migrations/0001_initial.py b/app/photos/migrations/0001_initial.py new file mode 100644 index 0000000..a98bc97 --- /dev/null +++ b/app/photos/migrations/0001_initial.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-11 19:33 +from __future__ import unicode_literals + +import django.contrib.gis.db.models.fields +from django.db import migrations, models +import django.db.models.deletion +import photos.models +import taggit.managers + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('taggit', '0002_auto_20150616_2121'), + ('locations', '__first__'), + ] + + operations = [ + migrations.CreateModel( + name='LuxGallery', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(blank=True, max_length=300)), + ('description', models.TextField(blank=True, null=True)), + ('slug', models.CharField(blank=True, max_length=300)), + ('thumb', models.CharField(blank=True, max_length=300)), + ('pub_date', models.DateTimeField(null=True)), + ('point', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)), + ('is_public', models.BooleanField(default=True)), + ], + options={ + 'verbose_name_plural': 'Galleries', + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date', 'id'), + }, + ), + migrations.CreateModel( + name='LuxImage', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image', models.FileField(blank=True, null=True, upload_to=photos.models.get_upload_path)), + ('title', models.CharField(blank=True, max_length=300, null=True)), + ('caption', models.TextField(blank=True, null=True)), + ('pub_date', models.DateTimeField()), + ('exif_raw', models.TextField(blank=True, null=True)), + ('exif_aperture', models.CharField(blank=True, max_length=50, null=True)), + ('exif_make', models.CharField(blank=True, max_length=50, null=True)), + ('exif_model', models.CharField(blank=True, max_length=50, null=True)), + ('exif_exposure', models.CharField(blank=True, max_length=50, null=True)), + ('exif_iso', models.CharField(blank=True, max_length=50, null=True)), + ('exif_focal_length', models.CharField(blank=True, max_length=50, null=True)), + ('exif_lens', models.CharField(blank=True, max_length=50, null=True)), + ('exif_date', models.DateTimeField(blank=True, null=True)), + ('height', models.CharField(blank=True, max_length=6, null=True)), + ('width', models.CharField(blank=True, max_length=6, null=True)), + ('point', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)), + ('is_public', models.BooleanField(default=True)), + ('is_video', models.BooleanField(default=False)), + ('flickr_id', models.CharField(blank=True, max_length=80, null=True)), + ('location', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')), + ], + options={ + 'verbose_name_plural': 'Images', + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date', 'id'), + }, + ), + migrations.CreateModel( + name='Photo', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.TextField(blank=True, null=True)), + ('title', models.CharField(blank=True, max_length=300)), + ('pub_date', models.DateTimeField()), + ('exif_aperture', models.CharField(blank=True, max_length=50, null=True)), + ('exif_make', models.CharField(blank=True, max_length=50, null=True)), + ('exif_model', models.CharField(blank=True, max_length=50, null=True)), + ('exif_exposure', models.CharField(blank=True, max_length=50, null=True)), + ('exif_iso', models.CharField(blank=True, max_length=50, null=True)), + ('exif_focal_length', models.CharField(blank=True, max_length=50, null=True)), + ('exif_lens', models.CharField(blank=True, max_length=50, null=True)), + ('exif_date', models.DateTimeField()), + ('flickr_id', models.CharField(max_length=300)), + ('flickr_owner', models.CharField(max_length=20)), + ('flickr_server', models.IntegerField()), + ('flickr_farm', models.IntegerField()), + ('flickr_secret', models.CharField(max_length=50)), + ('flickr_originalsecret', models.CharField(max_length=50)), + ('lon', models.FloatField(help_text='Longitude of centerpoint', null=True, verbose_name='Longitude')), + ('lat', models.FloatField(help_text='Latitude of centerpoint', null=True, verbose_name='Latitude')), + ('slideshowimage_width', models.CharField(blank=True, max_length=4, null=True)), + ('slideshowimage_height', models.CharField(blank=True, max_length=4, null=True)), + ('slideshowimage_margintop', models.CharField(blank=True, max_length=4, null=True)), + ('slideshowimage_marginleft', models.CharField(blank=True, max_length=4, null=True)), + ('is_public', models.BooleanField(default=True)), + ('location', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')), + ('region', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Region')), + ('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')), + ], + options={ + 'ordering': ('-pub_date',), + }, + ), + migrations.CreateModel( + name='PhotoGallery', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('set_id', models.CharField(blank=True, max_length=300)), + ('set_title', models.CharField(blank=True, max_length=300)), + ('set_desc', models.TextField(blank=True, null=True)), + ('set_slug', models.CharField(blank=True, max_length=300)), + ('primary', models.CharField(blank=True, max_length=300)), + ('pub_date', models.DateTimeField(null=True)), + ('location', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')), + ('photos', models.ManyToManyField(to='photos.Photo')), + ('region', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Region')), + ], + options={ + 'verbose_name_plural': 'Photo Galleries', + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date', 'id'), + }, + ), + migrations.AddField( + model_name='luxgallery', + name='image', + field=models.ManyToManyField(to='photos.LuxImage'), + ), + migrations.AddField( + model_name='luxgallery', + name='location', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location'), + ), + ] diff --git a/app/photos/migrations/__init__.py b/app/photos/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/photos/migrations/__init__.py diff --git a/app/photos/templatetags/__init__.py b/app/photos/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/photos/templatetags/__init__.py diff --git a/app/photos/templatetags/get_image_size.py b/app/photos/templatetags/get_image_size.py new file mode 100644 index 0000000..4ca6c66 --- /dev/null +++ b/app/photos/templatetags/get_image_size.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + +@register.simple_tag +def get_image_size(obj, *args): + method = getattr(obj, "get_image_size") + return method(*args) diff --git a/app/photos/utils.py b/app/photos/utils.py new file mode 100644 index 0000000..6cc64a3 --- /dev/null +++ b/app/photos/utils.py @@ -0,0 +1,15 @@ +import os +from resizeimage import resizeimage + + +def resize_image(img, width=None, height=None, quality=72, base_path="", filename=""): + if width and height: + newimg = resizeimage.resize_cover(img, [width, height]) + if width and not height: + newimg = resizeimage.resize_width(img, width) + if height and not width: + newimg = resizeimage.resize_height(img, height) + if not os.path.isdir(base_path): + os.makedirs(base_path) + path = "%s%s" % (base_path, filename) + newimg.save(path, newimg.format, quality=quality) diff --git a/app/resume/migrations/0003_auto_20151211_1925.py b/app/resume/migrations/0003_auto_20151211_1925.py new file mode 100644 index 0000000..77e3049 --- /dev/null +++ b/app/resume/migrations/0003_auto_20151211_1925.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-11 19:25 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('resume', '0002_auto_20151207_2105'), + ] + + operations = [ + migrations.AlterModelOptions( + name='publisher', + options={'ordering': ('order',)}, + ), + ] diff --git a/design/templates/details/photo_gallery.html b/design/templates/details/photo_gallery.html new file mode 100644 index 0000000..b991ba2 --- /dev/null +++ b/design/templates/details/photo_gallery.html @@ -0,0 +1,62 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load get_image_size %} +{% load number_to_word %} + +{% block pagetitle %}{{object.title}} - Luxagraf, Photos{% endblock %} +{%block htmlclass%}class="black"{%endblock%} + + +{% block metadescription %}{{object.description|truncatewords:30|smartypants|safe}}{% endblock %} + +{% block extrahead %} + <script src="/media/js/leaflet-master/leaflet-mod.js"></script> + <style> + #map-canvas img{ border: none;} + </style> +{% endblock %} +{%block bodyid%}class="image_gallery"{%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><a href="/photos/" title="See all Photos" itemprop="url"><span>Photos</span></a> →</li> + <li>{{object.title}}</li> + </ul> + <p class="directions">Use left/right arrow keys to navigate through photos</p> + <main id="slides" class="image-gallery--wrapper"> + <h1 class="hide">Photos from {{object.title}}</h1>{%for photo in object.image.all reversed %} + <article id="image-{{forloop.counter}}"> + <h6><a href="#image-{{forloop.counter}}" class="permalink" title="link to this image">∞ {{forloop.counter|number_to_word}} ∞</a></h6> + <figure class="fig"> + <img sizes="(max-width: 960px) 100vw" + srcset="{% get_image_size photo "small" %} 720w, + {% get_image_size photo "medium" %} 1140w, + {% get_image_size photo "large" %} 2280w," + src="{% get_image_size photo "medium" %}" alt="{{photo.title}}" {%if photo.is_portait %}class="v"{%endif%} > + <figcaption class="figcaption"> + <div class="caption" id="id-{{photo.id}}"> + <h3 class="figcaption--title">{{photo.title}}</h3> + <time class="figcaption--date" datetime="{{photo.exif_date|date:'c'}}">{{photo.exif_date|date:"M j, Y"}}</time> + {% if object.is_public %}<a class="map-link" href="#" data-latitude="{{photo.lat}}" data-longitude="{{photo.lon}}" data-imgid="id-{{photo.id}}">Map</a>{%endif%} + {%if photo.caption%}<p class="figcaption--desc">{{photo.caption|safe}}</p> {%endif%} + </div> + <div class="photo-options"> + {% if object.is_public %}<p>{% if photo.exif_make == 'Canon'%}{{photo.exif_model}}{%endif%}{% if photo.exif_model == 'DMC-LX2'%}{{photo.exif_make}} {{photo.exif_model}}{%endif%}{%if photo.exif_model == 'DMC-GF1' %}Panasonic GF1 with {%endif%} {%if photo.exif_lens == 'LUMIX G VARIO 14-45/F3.5-5.6' %}Lumix 14-45mm lens{%endif%}{%if photo.exif_lens == 'LUMIX G 20/F1.7' %}Lumix 20mm lens{%endif%}{%if photo.exif_lens == 'LUMIX G VARIO 45-200/F4.0-5.6' %}Lumix 45-200mm lens{%endif%}{%if photo.exif_lens == 'OLYMPUS M.9-18mm F4.0-5.6' %}Olympus 9-18mm lens{%endif%}{%if photo.exif_lens == None %}{%endif%}</p> + <p>{{photo.exif_exposure}} sec at f/{{photo.exif_aperture}}, ISO {{photo.exif_iso}} </p>{% endif %} + <!--<p><a href="{{photo.flickr_link}}" title="View this Photo on Flickr.com">View on Flickr</a></p>--> + <!--<a href="#" class="exif-link" title="{{photo.id}}">Camera</a>--> + </div> + </figcaption> + </figure> + </article> + {% endfor %} + </section> +{%endblock%} + +{% block js %} + <script type="text/javascript" src="/media/js/jquery.js"></script> + <script type="text/javascript" src="/media/js/jquery.scrollTo-1.4.2-min.js"></script> + <script type="text/javascript" src="/media/js/photos.min.js" ></script> +{% endblock%} + + |