From 5e0dc9e0d95bca9eba0f02f3ec01681c105ff86d Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Mon, 30 Apr 2018 19:44:04 +0000 Subject: [PATCH] version 2.2.0 - mostly design cleanups --- archive.py | 6 +- envelope.py | 32 +++ nasg.py | 64 ++++- router.py | 4 +- shared.py | 5 +- templates/Category.html | 10 +- templates/Category_article.html | 2 +- templates/Comment.html | 17 +- templates/Singular.html | 113 +++++---- templates/WebImage.html | 2 +- templates/archiveindex.html | 23 -- templates/block_footer.html | 6 +- templates/comment.html | 36 --- templates/page.html | 32 --- templates/style-dark.css | 400 +++++++++++++++++--------------- 15 files changed, 391 insertions(+), 361 deletions(-) delete mode 100644 templates/archiveindex.html delete mode 100644 templates/comment.html delete mode 100644 templates/page.html diff --git a/archive.py b/archive.py index 03f8be9..e69430a 100644 --- a/archive.py +++ b/archive.py @@ -3,11 +3,11 @@ # vim: set fileencoding=utf-8 : __author__ = "Peter Molnar" -__copyright__ = "Copyright 2017, Peter Molnar" +__copyright__ = "Copyright 2018, Peter Molnar" __license__ = "GPLv3" -__version__ = "2.0" +__version__ = "2.2.0" __maintainer__ = "Peter Molnar" -__email__ = "hello@petermolnar.eu" +__email__ = "mail@petermolnar.net" __status__ = "Production" """ diff --git a/envelope.py b/envelope.py index bca89f9..bd73b62 100644 --- a/envelope.py +++ b/envelope.py @@ -1,3 +1,35 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# vim: set fileencoding=utf-8 : + +__author__ = "Peter Molnar" +__copyright__ = "Copyright 2017-2018, Peter Molnar" +__license__ = "GPLv3" +__version__ = "2.1.0" +__maintainer__ = "Peter Molnar" +__email__ = "mail@petermolnar.net" +__status__ = "Production" + +""" + fancy email module of NASG + Copyright (C) 2017-2018 Peter Molnar + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +""" + + from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.image import MIMEImage diff --git a/nasg.py b/nasg.py index b602bd9..859cc82 100644 --- a/nasg.py +++ b/nasg.py @@ -5,9 +5,9 @@ __author__ = "Peter Molnar" __copyright__ = "Copyright 2017-2018, Peter Molnar" __license__ = "GPLv3" -__version__ = "2.1.0" +__version__ = "2.2.0" __maintainer__ = "Peter Molnar" -__email__ = "hello@petermolnar.eu" +__email__ = "mail@petermolnar.net" __status__ = "Production" """ @@ -194,9 +194,10 @@ class Category(NoDupeContainer): pagedir = 'page' taxonomy = 'category' - def __init__(self, name=''): + def __init__(self, name='', is_front=False): self.name = name self.topics = NoDupeContainer() + self.is_front = is_front super().__init__() def append(self, post): @@ -297,6 +298,7 @@ class Category(NoDupeContainer): tmplvars = { 'taxonomy': { + 'add_welcome': self.is_front, 'title': self.title, 'name': self.name, 'lastmod': arrow.get(self.mtime).format( @@ -364,16 +366,23 @@ class Category(NoDupeContainer): fg.updated(arrow.get(self.mtime).to('utc').datetime) for p in reversed(posttmpls): - link = '%s/%s' % (shared.site.get('url'), p.get('slug')) + link = '%s/%s/' % (shared.site.get('url'), p.get('slug')) dt = arrow.get(p.get('pubtime')).to('utc') + content = p.get('html') + if p.get('photo'): + content = "%s\n\n%s" % (p.get('photo'), content) + fe = fg.add_entry() fe.id(link) - fe.link(href='%s/' % (link)) + fe.link(href=link) fe.title(p.get('title')) fe.published(dt.datetime) fe.updated(dt.datetime) - fe.content(content=p.get('html'), type='CDATA') + fe.content( + content, + type='CDATA' + ) fe.rights('%s %s %s' % ( dt.format('YYYY'), shared.site.get('author').get('name'), @@ -383,6 +392,9 @@ class Category(NoDupeContainer): with open(o, 'wb') as f: f.write(fg.atom_str(pretty=True)) + #with open(o.replace('.xml', '.rss'), 'wb') as f: + #f.write(fg.rss_str(pretty=True)) + # ping pubsub r = requests.post( shared.site.get('websub').get('hub'), @@ -397,7 +409,12 @@ class Category(NoDupeContainer): pagination = shared.config.getint('display', 'pagination') pages = ceil(len(self.data) / pagination) page = 1 + + while page <= pages: + add_welcome = False + if (self.is_front and page == 1): + add_welcome = True # list relevant post templates start = int((page - 1) * pagination) end = int(start + pagination) @@ -413,6 +430,7 @@ class Category(NoDupeContainer): # is overcomplicated tmplvars = { 'taxonomy': { + 'add_welcome': add_welcome, 'title': self.title, 'name': self.name, 'page': page, @@ -489,6 +507,8 @@ class Singular(object): wdb.finish() def queue_webmentions(self): + if self.is_future: + return wdb = shared.WebmentionQueue() for target in self.urls_to_ping: if not wdb.exists(self.url, target, self.published): @@ -727,6 +747,10 @@ class Singular(object): return "RE: %s" % self.is_reply return self.published.format(shared.ARROWFORMAT['display']) + @property + def review(self): + return self.meta.get('review', False) + @property def summary(self): s = self.meta.get('summary', '') @@ -785,12 +809,20 @@ class Singular(object): 'reactions': self.reactions, 'syndicate': self.syndicate, 'tags': self.tags, - 'photo': False + 'photo': False, + 'enclosure': False, + 'review': self.review } if self.photo: self._tmplvars.update({ - 'photo': str(self.photo) + 'photo': str(self.photo), + 'enclosure': { + 'mime': self.photo.mime_type, + 'size': self.photo.mime_size, + 'url': self.photo.href + } }) + return self._tmplvars async def render(self): @@ -844,6 +876,16 @@ class WebImage(object): 'tags': list(set(self.meta.get('Subject', []))), } + @property + def mime_type(self): + return str(self.meta.get('MIMEType', 'image/jpeg')) + + @property + def mime_size(self): + if not self.is_downsizeable: + return int(os.path.getsize(self.fpath)) + return int(self.sizes[-1][1]['fsize']) + @property def href(self): if len(self.target): @@ -996,7 +1038,8 @@ class WebImage(object): 'crop', size, fallback=False - ) + ), + 'fsize': os.path.getsize(fpath) } )) return sorted(sizes, reverse=False) @@ -1175,7 +1218,6 @@ class WebImage(object): height ) - @property def tmplvars(self): src_width, src_height = self.src_size @@ -1481,7 +1523,7 @@ def build(): sdb = shared.SearchDB() magic = MagicPHP() - collector_front = Category() + collector_front = Category(is_front=True) collector_categories = NoDupeContainer() sitemap = {} diff --git a/router.py b/router.py index ee989e4..554db49 100644 --- a/router.py +++ b/router.py @@ -5,9 +5,9 @@ __author__ = "Peter Molnar" __copyright__ = "Copyright 2017-2018, Peter Molnar" __license__ = "GPLv3" -__version__ = "2.1.0" +__version__ = "2.2.0" __maintainer__ = "Peter Molnar" -__email__ = "hello@petermolnar.eu" +__email__ = "mail@petermolnar.net" __status__ = "Production" """ diff --git a/shared.py b/shared.py index 6180b48..0ef4399 100644 --- a/shared.py +++ b/shared.py @@ -5,9 +5,9 @@ __author__ = "Peter Molnar" __copyright__ = "Copyright 2017-2018, Peter Molnar" __license__ = "GPLv3" -__version__ = "2.1.0" +__version__ = "2.2.0" __maintainer__ = "Peter Molnar" -__email__ = "hello@petermolnar.eu" +__email__ = "mail@petermolnar.net" __status__ = "Production" """ @@ -431,6 +431,7 @@ class SearchDB(BaseDB): return False def search_by_query(self, query): + logging.info("query is: %s", query) ret = {} cursor = self.db.cursor() cursor.execute('''SELECT diff --git a/templates/Category.html b/templates/Category.html index d08f15e..a8f3111 100644 --- a/templates/Category.html +++ b/templates/Category.html @@ -5,13 +5,21 @@ {% include 'block_header_close.html' %} +{% if taxonomy.add_welcome %} + +{% endif %} +
diff --git a/templates/Category_article.html b/templates/Category_article.html index d2467b0..02bec3b 100644 --- a/templates/Category_article.html +++ b/templates/Category_article.html @@ -11,7 +11,7 @@ - Atom feed + XML feed

diff --git a/templates/Comment.html b/templates/Comment.html index cd2e9a7..e3d1aa8 100644 --- a/templates/Comment.html +++ b/templates/Comment.html @@ -1,9 +1,12 @@
  • - - +{% if 'webmention' != comment.type %} + + {{ comment.type }} +{% endif %} + from {% if comment.author.url %} @@ -12,7 +15,7 @@ {% else %} {{ comment.author.name }} {% endif %} - +
    {% if 'webmention' == comment.type %} @@ -20,9 +23,5 @@
    {{ comment.source }} -{% else %} - - {{ comment.type }} - {% endif %}
  • diff --git a/templates/Singular.html b/templates/Singular.html index 1b53143..d0e3ea5 100644 --- a/templates/Singular.html +++ b/templates/Singular.html @@ -17,6 +17,23 @@

    {% include 'Singular_title.html' %}

    +{% if post.review %} +
    +

    Review summary

    +

    + {{ post.review.title }} +

    +

    + + {{ post.review.rating }} + out of + 5 + +

    +

    {{ post.review.summary }}

    +
    +{% endif %} + {% if post.summary %}
    {{ post.summary }} @@ -34,66 +51,72 @@
    -

    - -

    -
    - {% include 'block_author.html' %} -
    -

    - -

    -

    +

    +
    Published
    +
    + +
    +
    Author
    +
    + {% include 'block_author.html' %} +
    +
    Entry URL
    +
    + {{ site.url}}/{{ post.slug }}/ +
    +
    License
    +
    {% if post.licence.text == 'CC BY 4.0' %} - CC BY 4.0 + CC BY 4.0 - +
    Licensed under Creative Commons Attribution 4.0 International. You are free to share or republish, even if modified, if you link back here and indicate the modifications, even for commercial use. {% elif post.licence.text == 'CC BY-NC 4.0' %} - CC BY-NC 4.0 + CC BY-NC 4.0 - +
    Licensed under Creative Commons Attribution-NonCommercial 4.0 International. You are free to share or republish, even if modified, if you link back here and indicate the modifications, for non commercial use. For commercial use please contact the author. {% else %} - CC BY-NC-ND 4.0 + CC BY-NC-ND 4.0 - +
    Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International. You are free to share if you link back here for non commercial use, but you can't publish any altered versions of it. For commercial use please contact the author. {% endif %} -

    +
    +
    Leave a tip
    +
    +

    + {% if post.category == 'photo' %} + Did you like this photo?
    Leave a tip! If you're interested in prints, please get in touch. + {% elif post.category == 'article' %} + Did you find this article useful?
    Support me, so I can write more like this.
    If you want my help for your project, get in touch. + {% elif post.category == 'journal' %} + Did you like this entry?
    Encourage me to write more of them. + {% else %} + Did you like what you read?
    Leave a tip! + {% endif %} +

    + +
    - {% if post.syndicate|length %}