diff --git a/nasg.py b/nasg.py index c3b8f45..f8e7d50 100644 --- a/nasg.py +++ b/nasg.py @@ -68,6 +68,15 @@ RE_PRECODE = re.compile( r'
'
 )
 
+#def relurl(url, base=settings.site.get('url')):
+    #return url
+    ##out = os.path.relpath(url, base)
+    ##if not re.match(r'.*\.[a-z]{2,4}', out):
+        ##out = "%s/index.html" % out
+    ##return out
+
+#J2.filters['relurl'] = relurl
+
 def utfyamldump(data):
     return yaml.dump(
         data,
@@ -648,7 +657,7 @@ class Singular(MarkdownDoc):
             'summary': self.summary,
             'html_summary': self.html_summary,
             'html_content': self.html_content,
-            'mtime': self.mtime,
+            'mtime': self.dt,
             'pubtime': self.published.format(settings.dateformat.get('iso')),
             'pubdate': self.published.format(settings.dateformat.get('display')),
             'year': int(self.published.format('YYYY')),
@@ -748,8 +757,10 @@ class Singular(MarkdownDoc):
             return
         logger.info("rendering %s", self.name)
         r = J2.get_template(self.template).render({
+            #'baseurl': self.url,
             'post': self.tmplvars,
             'site': settings.site,
+            'menu': settings.menu,
             'author': settings.author,
             'meta': settings.meta,
             'licence': settings.licence,
@@ -777,13 +788,23 @@ class Home(Singular):
             'index.html'
         )
 
+    @property
+    def dt(self):
+        maybe = super().dt
+        for cat, post in self.elements:
+            if post['mtime'] > maybe:
+                maybe = post['mtime']
+        return maybe
+
     async def render(self):
         if self.exists:
             return
         logger.info("rendering %s", self.name)
         r = J2.get_template(self.template).render({
+            #'baseurl': settings.site.get('url'),
             'post': self.tmplvars,
             'site': settings.site,
+            'menu': settings.menu,
             'author': settings.author,
             'meta': settings.meta,
             'licence': settings.licence,
@@ -1266,8 +1287,10 @@ class Search(PHPFile):
 
     async def _render(self):
         r = J2.get_template(self.templatefile).render({
+            #'baseurl': settings.site.get('search'),
             'post': {},
             'site': settings.site,
+            'menu': settings.menu,
             'author': settings.author,
             'meta': settings.meta,
             'licence': settings.licence,
@@ -1307,6 +1330,7 @@ class IndexPHP(PHPFile):
         r = J2.get_template(self.templatefile).render({
             'post': {},
             'site': settings.site,
+            'menu': settings.menu,
             'gones': self.gone,
             'redirects': self.redirect
         })
@@ -1349,6 +1373,7 @@ class MicropubPHP(PHPFile):
     async def _render(self):
         r = J2.get_template(self.templatefile).render({
             'site': settings.site,
+            'menu': settings.menu,
             'paths': settings.paths
         })
         writepath(self.renderfile, r)
@@ -1490,7 +1515,9 @@ class Category(dict):
             c = post.published.format(self.trange)
 
         return {
+            #'baseurl': self.url,
             'site': settings.site,
+            'menu': settings.menu,
             'author': settings.author,
             'meta': settings.meta,
             'licence': settings.licence,
@@ -1506,7 +1533,7 @@ class Category(dict):
                 'next': n,
                 'currentyear': arrow.utcnow().format('YYYY')
             },
-            'posts': posts,
+            'posts': posts
         }
 
     def indexfpath(self, subpath=None):
@@ -1619,7 +1646,7 @@ class Category(dict):
         keys = list(by_time.keys())
         for p, c, n in zip([None] + keys[:-1], keys, keys[1:] + [None]):
             form = c.format(self.trange)
-            if arrow.utcnow().format(self.trange) == form:
+            if max(keys) == form:
                 fpath = self.indexfpath()
             else:
                 fpath = self.indexfpath(form)
diff --git a/settings.py b/settings.py
index 1642f59..e49244e 100644
--- a/settings.py
+++ b/settings.py
@@ -23,6 +23,35 @@ site = {
         'journal'
     ],
     'licence': 'CC-BY-NC-ND-4.0',
+    'search': 'https://petermolnar.net/search.php',
+    'favicon': 'https://petermolnar.net/favicon.ico'
+}
+
+menu = {
+    'home': {
+        'url': '%s/' % site['url'],
+        'text': 'home',
+    },
+    'photo': {
+        'url': '%s/category/photo/' % site['url'],
+        'text': 'photos',
+    },
+    'journal': {
+        'url': '%s/category/journal/' % site['url'],
+        'text': 'journal',
+    },
+    'article': {
+        'url': '%s/category/article/' % site['url'],
+        'text': 'IT',
+    },
+    'note': {
+        'url': '%s/category/note/' % site['url'],
+        'text': 'notes'
+    },
+    'follow': {
+        'url': '%s/follow/' % site['url'],
+        'text': 'follow'
+    }
 }
 
 categorydisplay = {
@@ -51,13 +80,19 @@ author = {
     'url': 'https://petermolnar.net/',
     'avatar': 'https://petermolnar.net/molnar_peter_avatar.jpg',
     'gpg': 'https://petermolnar.net/pgp.asc',
-    'cv': 'https://petermolnar.net/about.html',
-    'contact': {
-        'xmpp': 'xmpp:mail@petermolnar.net?message',
-        'flickr': 'https://flickr.com/people/petermolnareu',
-        'github': 'https://github.com/petermolnar',
-        'whatsapp': 'https://wa.me/447592011721',
-        'telegram': 'https://t.me/petermolnar',
+    'cv': 'https://petermolnar.net/cv.html',
+    'github': 'https://github.com/petermolnar',
+    'about': 'https://petermolnar.net/about/',
+    'following': 'https://petermolnar.net/following.opml',
+    'tips': {
+        'monzo': {
+            'text': 'Monzo (only in the UK or via Google Pay)',
+            'url': 'https://monzo.me/petermolnar/3'
+        },
+        'paypal': {
+            'text': 'Paypal',
+            'url': 'https://paypal.me/petermolnar/3GBP'
+        }
     }
 }
 
diff --git a/templates/Category.j2.html b/templates/Category.j2.html
index 0790a3c..24a7642 100644
--- a/templates/Category.j2.html
+++ b/templates/Category.j2.html
@@ -11,10 +11,53 @@
     
     
 {% endblock %}
+
+{% block pagination %}
+{% if category.display != 'flat' %}
+
+{% endif %}
+{% endblock %}
+
 {% block content %}
 
-

{{ category.name }}

+

+ +

@@ -22,6 +65,10 @@ {% for post in posts %} {% set _year = year.pop() %} {% if category.display == 'flat' and _year != post.year %} + {% if not loop.first %} + + {% endif %} +

{{ post.year }}

{% endif %} {% set _ = year.append(post.year)%} @@ -98,45 +145,9 @@

+ {% if loop.last %} +
+ {% endif %} {% endfor %}
{% endblock %} -{% block pagination %} -{% if category.display != 'flat' %} - -{% endif %} -{% endblock %} diff --git a/templates/Home.j2.html b/templates/Home.j2.html index 77579a9..d5d3ecc 100644 --- a/templates/Home.j2.html +++ b/templates/Home.j2.html @@ -1,4 +1,5 @@ {% extends "base.j2.html" %} + {% block meta %} @@ -9,6 +10,7 @@ {% endfor %} {% endblock %} + {% block licence %} {% endblock %} @@ -23,14 +25,15 @@ {% for category, latest in elements %}
+

Latest in + + + {{ category.name }} + +

-

- Latest in - - - {{ category.name }} -
+

{% if latest.is_reply %} @@ -46,7 +49,7 @@ {{ latest.title }} {% endif %} -

+
{% if latest.summary %} diff --git a/templates/Singular.j2.html b/templates/Singular.j2.html index 0c50ab7..6d53eee 100644 --- a/templates/Singular.j2.html +++ b/templates/Singular.j2.html @@ -1,4 +1,5 @@ {% extends "base.j2.html" %} + {% block meta %} @@ -9,6 +10,7 @@ {% endif %} {% endblock %} + {% block prism %} {% if post.has_code %} {% endif %} {% endblock %} + {% block licence %} {% endblock %} + +{% block content %} +{% if post.event %} + {% set mftype = 'h-entry h-event' %} +{% else %} + {% set mftype = 'h-entry' %} +{% endif %} +
+
+
+

+ {% if post.is_reply %} + + + + + + RE: + + + {{ post.is_reply }} + + + {% else %} + + {{ post.title }} + + {% endif %} +

+
+ + {% if post.review %} +
+ Review summary of: {{ post.review.title }} +

+ By + at +

+

+ + + {{ post.review.rated }} + out of + {{ post.review.outof }} + +

+

{{ post.review.summary }}

+
+ {% endif %} + + {% if post.summary %} +
+ {{ post.html_summary }} +
+ {% endif %} + +
+ {{ post.html_content }} +
+ +
+
+ {% if post.event %} +
Trip details
+
+ From + + to + , in + + {{ post.event.location }} + +
+ {% endif %} + +
Author
+ + +
Published
+
+ +
+ + +
License
+
+ {% if post.licence == 'CC-BY-4.0' %} + {{ post.licence }} +
    +
  • you can share it
  • +
  • you can republish it
  • +
  • you can modify it, but you need to indicate the modifications
  • +
  • you can use it for commercial purposes
  • +
  • you always need to make a link back here
  • +
+ {% elif post.licence == 'CC-BY-NC-4.0' %} + {{ post.licence }} +
    +
  • you can share it
  • +
  • you can republish it
  • +
  • you can modify it, but you need to indicate the modifications
  • +
  • you can't use it for commercial purposes
  • +
  • you always need to make a link back here
  • +
+ For commercial use, please contact me. + {% elif post.licence == 'CC-BY-NC-ND-4.0' %} + {{ post.licence }} +
    +
  • you can share it
  • +
  • you can't modify it
  • +
  • you can't republish it
  • +
  • you can't use it for commercial purposes
  • +
  • you always need to make a link back here
  • +
+ For commercial use, please contact me. + {% endif %} +
+ +
Entry URL
+
+ {% if not post.has_mainimg %} + + {% endif %} + + {{ post.url }} + +
+ +
+
+ + {% if not post.is_page %} + {% if post.syndicate|length %} + + {% endif %} + +
+

Encourage creation!

+

+ If this entry helped you, or you simply liked it, leave a tip via
+ {% for provider, info in author.tips.items() %} + {% if loop.last and not loop.first %} or {% endif %} + + + + {{ info.text }} + {% if not loop.last and not loop.first %}, {% endif %} + {% endfor %} +

+
+ + {% if post.replies|length %} +
+

Replies

+
    + {% for mtime, comment in post.replies.items() %} +
  1. + from + + {% if comment.author.url %} + + + {{ comment.author.name }} + + + {% else %} + + {{ comment.author.name }} + + {% endif %} +
    + + + + + + {{ comment.source }} + + +
  2. + {% endfor %} +
+
+ {% endif %} + + {% if post.reactions|length %} +
+

Reactions

+
+ {% for character, comments in post.reactions.items() %} +
{{ character }}
+
+ +
+ {% endfor %} +
+
+ {% endif %} + + {% endif %} +
+
+{% endblock %} diff --git a/templates/base.j2.html b/templates/base.j2.html index a79f1d9..77195f8 100644 --- a/templates/base.j2.html +++ b/templates/base.j2.html @@ -5,14 +5,14 @@ - + {% block licence %}{% endblock %} {% for key, value in meta.items() %} {% endfor %} {% block meta %}{% endblock %} + {% macro activemenu(name) %}{% if (post is defined and post.slug == name ) or (post is defined and post.category == name ) or ( category is defined and category.name == name ) %}active{% endif %}{% endmacro %} @@ -29,42 +30,16 @@
@@ -82,7 +57,7 @@ -
+
- - {% endblock %} {% block pagination %} {% endblock %} -