Update /photography.

This commit is contained in:
voussoir 2022-10-04 19:58:52 -07:00
parent 12a874b9ae
commit 93e1e2b6b0
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -1,5 +1,6 @@
import PIL.Image
import jinja2 import jinja2
import PIL.Image
import sys
from voussoirkit import dotdict from voussoirkit import dotdict
from voussoirkit import imagetools from voussoirkit import imagetools
@ -9,6 +10,7 @@ from voussoirkit import spinal
PHOTOGRAPHY_ROOTDIR = pathclass.Path(__file__).parent PHOTOGRAPHY_ROOTDIR = pathclass.Path(__file__).parent
DOMAIN_ROOTDIR = PHOTOGRAPHY_ROOTDIR.parent DOMAIN_ROOTDIR = PHOTOGRAPHY_ROOTDIR.parent
CSS_CONTENT = PHOTOGRAPHY_ROOTDIR.with_child('dark.css').read('r', encoding='utf-8') CSS_CONTENT = PHOTOGRAPHY_ROOTDIR.with_child('dark.css').read('r', encoding='utf-8')
DOMAIN_WEBROOT = ('file:///' + DOMAIN_ROOTDIR.absolute_path) if '--test' in sys.argv else 'https://voussoir.net'
class Photo: class Photo:
def __init__(self, filepath): def __init__(self, filepath):
@ -23,17 +25,17 @@ class Photo:
thumb = self.thumbnail.relative_to(DOMAIN_ROOTDIR, simple=True).replace('\\', '/') thumb = self.thumbnail.relative_to(DOMAIN_ROOTDIR, simple=True).replace('\\', '/')
return f''' return f'''
<article id="{self.article_id}" class="photograph"> <article id="{self.article_id}" class="photograph">
<a href="https://voussoir.net/{href}" target="_blank"><img src="/{thumb}" loading="lazy"/></a> <a href="{DOMAIN_WEBROOT}/{href}" target="_blank"><img src="{DOMAIN_WEBROOT}/{thumb}" loading="lazy"/></a>
</article> </article>
''' '''
def render_atom(self): def render_atom(self):
href = f'https://voussoir.net/photography{self.anchor}' href = f'{DOMAIN_WEBROOT}/photography{self.anchor}'
imgsrc = 'https://voussoir.net/' + self.thumbnail.relative_to(DOMAIN_ROOTDIR, simple=True) imgsrc = f'{DOMAIN_WEBROOT}/' + self.thumbnail.relative_to(DOMAIN_ROOTDIR, simple=True)
return f''' return f'''
<id>{self.article_id}</id> <id>{self.article_id}</id>
<title>{self.article_id}</title> <title>{self.article_id}</title>
<link rel="alternate" type="text/html" href="https://voussoir.net/photography{self.anchor}"/> <link rel="alternate" type="text/html" href="{DOMAIN_WEBROOT}/photography{self.anchor}"/>
<updated>{self.published.isoformat()}</updated> <updated>{self.published.isoformat()}</updated>
<content type="html"> <content type="html">
<![CDATA[ <![CDATA[
@ -89,8 +91,8 @@ class Album:
def render_atom(self): def render_atom(self):
photos = [] photos = []
for photo in self.photos: for photo in self.photos:
href = 'https://voussoir.net/photography/' + photo.filepath.relative_to(PHOTOGRAPHY_ROOTDIR, simple=True) href = f'{DOMAIN_WEBROOT}/photography/' + photo.filepath.relative_to(PHOTOGRAPHY_ROOTDIR, simple=True)
imgsrc = 'https://voussoir.net/photography/' + photo.thumbnail.relative_to(PHOTOGRAPHY_ROOTDIR, simple=True) imgsrc = f'{DOMAIN_WEBROOT}/photography/' + photo.thumbnail.relative_to(PHOTOGRAPHY_ROOTDIR, simple=True)
line = f'<article><a href="{href}"><img src="{imgsrc}"/></a>'.replace('\\', '/') line = f'<article><a href="{href}"><img src="{imgsrc}"/></a>'.replace('\\', '/')
photos.append(line) photos.append(line)
photos = '\n'.join(photos) photos = '\n'.join(photos)
@ -98,7 +100,7 @@ class Album:
return f''' return f'''
<id>{self.article_id}</id> <id>{self.article_id}</id>
<title>{self.article_id}</title> <title>{self.article_id}</title>
<link rel="alternate" type="text/html" href="https://voussoir.net/photography{self.link}"/> <link rel="alternate" type="text/html" href="{DOMAIN_WEBROOT}/photography{self.link}"/>
<updated>{self.published.isoformat()}</updated> <updated>{self.published.isoformat()}</updated>
<content type="html"> <content type="html">
<![CDATA[ <![CDATA[
@ -319,7 +321,7 @@ def write_atom(items):
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<title>voussoir.net/photography</title> <title>voussoir.net/photography</title>
<link href="https://voussoir.net/photography"/> <link href="{DOMAIN_WEBROOT}/photography"/>
<id>voussoir.net/photography</id> <id>voussoir.net/photography</id>
{% for item in items %} {% for item in items %}