Photography site generator.

This commit is contained in:
voussoir 2023-12-17 12:45:25 -08:00
parent c513e38a93
commit 57dc749fa2
3 changed files with 26 additions and 11 deletions

View file

@ -3,6 +3,7 @@ import io
import jinja2 import jinja2
import PIL.Image import PIL.Image
import sys import sys
import textwrap
import urllib.parse import urllib.parse
import etiquette import etiquette
@ -68,6 +69,7 @@ class Photo:
self.tiny_url = f'{S3_WEBROOT}/{self.tiny_key}' self.tiny_url = f'{S3_WEBROOT}/{self.tiny_key}'
self.anchor_url = f'{DOMAIN_WEBROOT}/{parent_key}#{self.article_id}' self.anchor_url = f'{DOMAIN_WEBROOT}/{parent_key}#{self.article_id}'
self.published = imagetools.get_exif_datetime(self.etq_photo.real_path) self.published = imagetools.get_exif_datetime(self.etq_photo.real_path)
self.exposure_time = imagetools.exifread(self.etq_photo.real_path)['EXIF ExposureTime'].values[0].decimal()
def prepare(self): def prepare(self):
if not self.s3_exists: if not self.s3_exists:
@ -129,6 +131,7 @@ class Album:
# self.link = webpath(path) # self.link = webpath(path)
self.web_url = f'{PHOTOGRAPHY_WEBROOT}/{self.article_id}' self.web_url = f'{PHOTOGRAPHY_WEBROOT}/{self.article_id}'
self.published = self.photos[0].published self.published = self.photos[0].published
self.exposure_time = sum(p.exposure_time for p in self.photos)
def prepare(self): def prepare(self):
for photo in self.photos: for photo in self.photos:
@ -141,15 +144,15 @@ class Album:
<article id="{{article_id}}" class="album"> <article id="{{article_id}}" class="album">
<h1><a href="{{web_url}}">{{article_id}}</a></h1> <h1><a href="{{web_url}}">{{article_id}}</a></h1>
<div class="albumphotos"> <div class="albumphotos">
{% for photo in headliners %} {% for photo in headliners %}
{{photo.render_web()}} {{photo.render_web()}}
{% endfor %} {% endfor %}
<div class="album_tinies"> <div class="album_tinies">
{% for photo in photos %} {% for photo in photos %}
<a class="tiny_thumbnail {{photo.color_class}}" href="{{photo.anchor_url}}"><img src="{{photo.tiny_url}}" loading="lazy"/></a> <a class="tiny_thumbnail {{photo.color_class}}" href="{{photo.anchor_url}}"><img src="{{photo.tiny_url}}" loading="lazy"/></a>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</article> </article>
''').render( ''').render(
@ -259,6 +262,12 @@ def make_webpage(items, is_root, doctitle):
grid-auto-flow: row; grid-auto-flow: row;
grid-row-gap: 12vh; grid-row-gap: 12vh;
} }
footer
{
display: grid;
grid-auto-flow: row;
grid-row-gap: 8px;
}
body.noscrollbar::-webkit-scrollbar body.noscrollbar::-webkit-scrollbar
{ {
display: none; display: none;
@ -449,14 +458,13 @@ def make_webpage(items, is_root, doctitle):
{{item.render_web(index=loop.index, totalcount=none if is_root else (items|length))}} {{item.render_web(index=loop.index, totalcount=none if is_root else (items|length))}}
{% endfor %} {% endfor %}
<footer> <footer>
<p>Ethan Dalool</p> <p>Ethan Dalool</p>
<p>Contact me: photography@voussoir.net</p> <p>Contact me: photography@voussoir.net</p>
<p>These photos took {{items|sum(attribute='exposure_time')|round(4)}} seconds to make.</p>
<p><button id="new_perspective_button" onclick="return new_perspective_button_onclick(event);">👁 Try a different perspective</button></p>
</footer> </footer>
<p><button id="new_perspective_button" onclick="return new_perspective_button_onclick(event);">👁 Try a different perspective</button></p>
<form id="a_new_perspective" class="hidden"> <form id="a_new_perspective" class="hidden">
<div><label>Background color: <input type="color" value="#1b1c18" oninput="return backgroundcolor_onchange(event);"/></label></div> <div><label>Background color: <input type="color" value="#1b1c18" oninput="return backgroundcolor_onchange(event);"/></label></div>
<div><label>Border radius: <input type="range" min="0" value="16" max="500" oninput="return border_radius_onchange(event);"/></label> <span id="border_radius_value">16px</span></div> <div><label>Border radius: <input type="range" min="0" value="16" max="500" oninput="return border_radius_onchange(event);"/></label> <span id="border_radius_value">16px</span></div>
@ -717,6 +725,7 @@ def make_webpage(items, is_root, doctitle):
back_link=back_link, back_link=back_link,
items=items, items=items,
) )
html = textwrap.dedent(html)
return html return html
def write_atom(items): def write_atom(items):
@ -734,6 +743,7 @@ def write_atom(items):
{% endfor %} {% endfor %}
</feed> </feed>
'''.strip()).render(items=items) '''.strip()).render(items=items)
atom = textwrap.dedent(atom)
write(ATOM_FILE, atom) write(ATOM_FILE, atom)
# write_directory_index(PHOTOGRAPHY_ROOTDIR) # write_directory_index(PHOTOGRAPHY_ROOTDIR)

View file

@ -0,0 +1 @@
winscp /console /script=upload.winscp

View file

@ -0,0 +1,4 @@
open voussoir@ovh
put *.html voussoir.net/voussoir.net/photography/
put *.atom voussoir.net/voussoir.net/photography/
exit