Compare commits

...

4 commits

Author SHA1 Message Date
Peter Molnar
4199eb4fd6 This might be the final commit to NASG the way it is.
I wrote about it in details under
<https://petermolnar.net/article/less-features-cleaner-site/index.html>; in essence, it doesn't make sense for a personal static generator to try to be a fully open sourced one-size-fits-all, that only ends with my frustration and no joy.

If you want the stuff that builds my site:
<https://petermolnar.net/fetch.py>
<https://petermolnar.net/build.py>

And for now, that's all.

I'll keep the repo up for historical purposes.
2020-06-06 20:47:28 +01:00
Peter Molnar
67f2978aeb Reverting layout back to divs, because the "semantic" structuring of HTML5 is a mess and only complicates my life.
It's also for more backwards compatibility, though <figure> and <figcaption> is going to stay, because those make a lot of sense.

Coming up next: out with JSON-LD. It was an interesting experiment which didn't bring any good at all, even in the long run.
2020-05-17 18:14:43 +01:00
Peter Molnar
71bf7f7266 before json-ld cleanup 2020-03-09 11:09:46 +00:00
Peter Molnar
02c131b200 mostly cleanups plus gopher shows markdown not plain text; still with 70em cutoff 2020-02-21 12:02:26 +00:00
15 changed files with 139 additions and 156 deletions

73
nasg.py
View file

@ -244,18 +244,7 @@ class Gone(object):
return {"source": self.source}
async def render(self):
if self.exists:
os.remove(self.renderfile)
os.rmdir(self.renderdir)
# rmtree(self.renderdir)
return
# logger.info(
# "rendering %s to %s", self.__class__, self.renderfile
# )
# writepath(
# self.renderfile, J2.get_template(self.template).render()
# )
return
class FediverseStats(object):
def __init__(self, postcount=0, commentcount=0):
@ -298,18 +287,12 @@ class FediverseStats(object):
"github": "https://github.com/petermolnar/nasg",
"follow": f"{settings.site.url}",
},
"email": "webmaster@petermolnar.net"
"email": "webmaster@petermolnar.net",
},
"openRegistrations": False,
"protocols": ["activitypub"],
"services": {
"inbound": [],
"outbound": [],
},
"software": {
"name": "nasg",
"version": "6.6"
},
"services": {"inbound": [], "outbound": []},
"software": {"name": "nasg", "version": "6.6"},
"usage": {
"localPosts": self.postcount,
"localComments": self.commentcount,
@ -767,15 +750,6 @@ class WebImage(object):
self.size = size
self.crop = crop
# @property
# def data(self):
# with open(self.fpath, "rb") as f:
# encoded = base64.b64encode(f.read())
# return "data:%s;base64,%s" % (
# self.parent.mime_type,
# encoded.decode("utf-8"),
# )
@property
def suffix(self):
return settings.photo.get("sizes").get(self.size, "")
@ -1006,8 +980,10 @@ class Singular(MarkdownDoc):
@property
def is_front(self):
if self.category in settings.notinfeed:
if self.is_reply:
return False
# if self.category in settings.notinfeed:
# return False
return True
@property
@ -1076,7 +1052,7 @@ class Singular(MarkdownDoc):
urls = self.meta.get("syndicate", [])
if not self.is_page:
urls.append("https://fed.brid.gy/")
#urls.append("https://brid.gy/publish/mastodon")
# urls.append("https://brid.gy/publish/mastodon")
if self.is_photo:
urls.append("https://brid.gy/publish/flickr")
return urls
@ -1303,9 +1279,7 @@ class Singular(MarkdownDoc):
".copy",
".cache",
]
include = [
"map.png"
]
include = ["map.png"]
files = glob.glob(
os.path.join(os.path.dirname(self.fpath), "*.*")
)
@ -1316,9 +1290,7 @@ class Singular(MarkdownDoc):
continue
t = os.path.join(
settings.paths.get("build"),
self.name,
fname
settings.paths.get("build"), self.name, fname
)
if os.path.exists(t) and mtime(f) <= mtime(t):
continue
@ -1334,8 +1306,18 @@ class Singular(MarkdownDoc):
style = settings.mapbox.style
size = settings.mapbox.size
lat = round(float(self.photo.jsonld["locationCreated"]["geo"]["latitude"]), 3)
lon = round(float(self.photo.jsonld["locationCreated"]["geo"]["longitude"]), 3)
lat = round(
float(
self.photo.jsonld["locationCreated"]["geo"]["latitude"]
),
3,
)
lon = round(
float(
self.photo.jsonld["locationCreated"]["geo"]["longitude"]
),
3,
)
token = keys.mapbox.get("private")
mapfpath = os.path.join(self.dirpath, "map.png")
if os.path.exists(mapfpath):
@ -1344,7 +1326,7 @@ class Singular(MarkdownDoc):
url = f"https://api.mapbox.com/styles/v1/mapbox/{style}/static/pin-s({lon},{lat})/{lon},{lat},11,20/{size}?access_token={token}"
logger.info("requesting map for %s with URL %s", self.name, url)
with requests.get(url, stream=True) as r:
with open(mapfpath, 'wb') as f:
with open(mapfpath, "wb") as f:
copyfileobj(r.raw, f)
@property
@ -1705,11 +1687,12 @@ class Micropub(PHPFile):
"wallabag": keys.wallabag,
"site": settings.site,
"paths": settings.paths,
"tags": { "tags": self.tags }
"tags": {"tags": self.tags},
}
)
writepath(self.renderfile, r)
class WorldMap(object):
def __init__(self):
self.data = {}
@ -2092,7 +2075,8 @@ class Category(dict):
fe.content(post.html_content, type="CDATA")
fg.add_entry(fe)
writepath(self.renderfile, fg.rss_str(pretty=True))
output = fg.rss_str(pretty=True)
writepath(self.renderfile, output)
class Year(object):
def __init__(self, parent, year):
@ -2708,7 +2692,6 @@ def make():
# make gone and redirect arrays for PHP
for e in glob.glob(os.path.join(content, "*", "*.del")):
post = Gone(e)
queue.put(post.render())
rules.add_gone(post.source)
for e in glob.glob(os.path.join(content, "*", "*.url")):
post = Redirect(e)
@ -2758,7 +2741,7 @@ def make():
try:
logger.info("starting syncing")
os.system(
f"rsync -avuhH --delete-after {settings.paths.build}/ {settings.syncserver}:{settings.paths.remotewww}"
f"rsync -avuhH --exclude='.git' --delete-after {settings.paths.build}/ {settings.syncserver}:{settings.paths.remotewww}"
)
logger.info("syncing finished")
except Exception as e:

View file

@ -141,8 +141,20 @@ class PandocMD2TXT(Pandoc):
"+autolink_bare_uris",
"-smart",
]
out_format = "plain"
out_options = []
out_format = "markdown"
out_options = [
"+footnotes",
"+pipe_tables",
"+strikeout",
"+raw_html",
"+definition_lists",
"+backtick_code_blocks",
"+fenced_code_attributes",
"+shortcut_reference_links",
"+lists_without_preceding_blankline",
"+autolink_bare_uris",
"-smart",
]
columns = "--columns=80"

View file

@ -8,7 +8,6 @@ Jinja2==2.10.3
langdetect==1.0.7
lxml==4.4.2
MarkupSafe==1.1.1
pkg-resources==0.0.0
python-dateutil==2.8.1
python-frontmatter==0.5.0
PyYAML==5.2

View file

@ -55,9 +55,7 @@ site = nameddict(
"image": "https://petermolnar.net/favicon.ico",
"license": "https://spdx.org/licenses/%s.html"
% (licence["_default"]),
"sameAs": [
"https://t.me/petermolnarnet"
],
"sameAs": ["https://t.me/petermolnarnet"],
"author": {
"@context": "http://schema.org",
"@type": "Person",
@ -73,7 +71,7 @@ site = nameddict(
"https://t.me/petermolnar",
"https://twitter.com/petermolnar",
"https://mastodon.social/@petermolnar"
"https://www.flickr.com/people/petermolnareu/"
"https://www.flickr.com/people/petermolnareu/",
],
"follows": "https://petermolnar.net/following.opml",
},
@ -110,7 +108,7 @@ site = nameddict(
"recipient": author,
"target": "https://monzo.me/petermolnar/",
"price": "3",
"priceCurrency": "GBP"
"priceCurrency": "GBP",
},
{
"@context": "http://schema.org",
@ -120,7 +118,7 @@ site = nameddict(
"recipient": author,
"target": "https://paypal.me/petermolnar/",
"price": "3",
"priceCurrency": "GBP"
"priceCurrency": "GBP",
},
],
}
@ -157,7 +155,7 @@ meta = nameddict(
"authorization_endpoint": "https://indieauth.com/auth",
"token_endpoint": "https://tokens.indieauth.com/token",
"micropub": "https://petermolnar.net/micropub.php",
"microsub": "https://aperture.p3k.io/microsub/83"
"microsub": "https://aperture.p3k.io/microsub/83",
}
)
@ -169,8 +167,7 @@ paths = nameddict(
base, "nasg", "templates", "watermark.png"
),
"build": os.path.join(base, "www"),
"remotewww": "/web/petermolnar.net/web",
"remotequeue": "/web/petermolnar.net/queue",
"remotewww": "/usr/local/www/petermolnar.net",
"micropub": os.path.join(base, "content", "note"),
"home": os.path.join(base, "content", "home", "index.md"),
"category": "category",
@ -184,11 +181,11 @@ filenames = nameddict(
"atom": "atom.xml",
"json": "index.json",
"md": "index.md",
"txt": "index.txt",
"txt": "index.md",
"html": "index.html",
"gopher": "gophermap",
"sitemap": "sitemap.txt",
"worldmap": "map.html"
"worldmap": "map.html",
}
)
@ -202,7 +199,7 @@ photo = nameddict(
"default": 720,
"sizes": {
# 90 = s
#240: "_m",
# 240: "_m",
720: "",
1280: "_b",
},
@ -210,10 +207,7 @@ photo = nameddict(
}
)
mapbox = nameddict({
"style": "outdoors-v11",
"size": "720x480"
})
mapbox = nameddict({"style": "outdoors-v11", "size": "720x480"})
rewrites = {
"^/(?:sysadmin|it|linux-tech-coding|sysadmin-blog)/?(page.*)?$": "category/article/",
@ -242,12 +236,12 @@ formerdomains = [
formercategories = {
# "article": [
# "linux-tech-coding",
# "diy-do-it-yourself",
# "sysadmin-blog",
# "sysadmin",
# "szubjektiv-technika",
# "wordpress",
# "linux-tech-coding",
# "diy-do-it-yourself",
# "sysadmin-blog",
# "sysadmin",
# "szubjektiv-technika",
# "wordpress",
# ],
# "note": ["blips", "blog", "r"],
# "journal": ["blog"],

View file

@ -11,23 +11,23 @@
{% endblock %}
{% block content %}
<main id="main" class="h-feed hatom {{ category.name }}">
<div id="main" class="h-feed hatom {{ category.name }}">
{% set year = [0] %}
{% for post in posts %}
{% set _year = year.pop() %}
{% if _year != post.copyrightYear %}
{% if not loop.first %}
</section>
</div>
{% endif %}
<section class="year">
<div class="year">
<h2>{{ post.copyrightYear }}</h2>
{% endif %}
{% set _ = year.append(post.copyrightYear)%}
{% include 'meta-article.j2.html' %}
{% if loop.last %}
</section>
</div>
{% endif %}
{% endfor %}
</main>
</div>
{% endblock %}

View file

@ -14,15 +14,15 @@
{% endblock %}
{% block content %}
<main id="main" class="h-feed hatom">
<section id="intro">
<div id="main" class="h-feed hatom">
<div class="section" id="intro">
<div>
{{ post.text }}
</div>
</section>
</div>
{% set isFrontPage = 1 %}
<section id="latest">
<div id="latest">
<h1>Latest entries</h1>
{% for category, post in posts %}
<h2>in:
@ -33,6 +33,6 @@
</h2>
{% include 'meta-article.j2.html' %}
{% endfor %}
</section>
</main>
</div>
</div>
{% endblock %}

View file

@ -120,7 +120,7 @@ if (isset($_GET['json'])) {
{% block title %}Search results for: <?php echo($q); ?>{% endblock %}
{% block content %}
<main id="main" class="h-feed hatom">
<div id="main" class="h-feed hatom main">
<h1>Search results for: <?php echo($q); ?></h1>
<dl>
<?php
@ -129,5 +129,5 @@ if (isset($_GET['json'])) {
}
?>
</dl>
</main>
</div>
{% endblock %}

View file

@ -32,9 +32,6 @@
<meta NAME="DC.Creator" content="{{ post.author.name }}" />
<meta NAME="DC.Date" content="{{ post.datePublished }}" />
<meta NAME="DC.Description" content="{{ post.description|striptags|e }}" />
<script type="application/ld+json">
{{ post|tojson(indent=4) }}
</script>
{% if post['@type'] == 'TechArticle' %}
<style media="all">
{% include('prism.css') %}
@ -61,26 +58,8 @@
{% endblock %}
{% block content %}
<main id="main">
<article class="h-entry hentry" lang="{{ post.inLanguage }}" id="article">
<aside id="entry-meta">
{% if post.sameAs|length %}
<span id="syndication">
this post on other sites:
{% for url in post.sameAs %}
<a class="u-syndication" href="{{ url }}"><svg width="16" height="16" aria-label="{{ url|extractdomain }}"><use xlink:href="#icon-{{ url|extractdomain }}" /></svg></a>
{% endfor %}
</span>
{% endif %}
{% if 'WebPage' != post['@type'] %}
{% for action in post.potentialAction %}
{% if 'InteractAction' == action['@type'] %}
<a href="{{ action.target }}"></a>
{% endif %}
{% endfor %}
{% endif %}
</aside>
<div id="main">
<div class="h-entry hentry" lang="{{ post.inLanguage }}" id="article">
<h1 class="p-name entry-title">
{% if post.mentions %}
<span>
@ -102,7 +81,7 @@
</h1>
{% if post.review %}
<section class="h-review hreview">
<div class="h-review hreview">
<strong>Review summary of: <a href="{{ post.review.url }}" class="p-name u-url p-item h-product item fn url">{{ post.review.name }}</a></strong>
<p>
By
@ -119,16 +98,16 @@
</span>
</p>
<p class="p-summary summary">{{ post.review.text }}</p>
</section>
</div>
{% endif %}
{% if post.description|length %}
<section class="e-summary entry-summary">
<div class="e-summary entry-summary">
{{ post.description|relurl(baseurl) }}
</section>
</div>
{% endif %}
<section>
<div class="section">
{% if post.image|length %}
{% for image in post.image %}
{% if image.representativeOfPage %}
@ -139,12 +118,12 @@
<div class="e-content entry-content">
{{ post.text|relurl(baseurl) }}
</div>
</section>
</div>
{% if 'WebPage' != post['@type'] %}
{% if post.comment|length %}
<section class="comments">
<h2><a id="comments"></a>Responses</h2>
<div class="comments" id="comments">
<h2>Responses</h2>
<ol>
{% for comment in post.comment %}
<li class="h-entry p-comment hentry">
@ -186,12 +165,12 @@
</li>
{% endfor %}
</ol>
</section>
</div>
{% endif %}
{% endif %}
<footer class="entry-footer">
<div class="entry-footer">
<p>Licenced under
<a rel="license" href="{{ post.license }}" class="u-license">{{ post.license | extractlicense }}</a>,
created by
@ -220,6 +199,22 @@
</a>
{% endif %}
{% endif %}
.
{% if post.sameAs|length %}
<span id="syndication">
This post also appears on other sites:
{% for url in post.sameAs %}
<a class="u-syndication" href="{{ url }}"><svg width="16" height="16" aria-label="{{ url|extractdomain }}"><use xlink:href="#icon-{{ url|extractdomain }}" /></svg></a>
{% endfor %}.
</span>
{% endif %}
{% if 'WebPage' != post['@type'] %}
{% for action in post.potentialAction %}
{% if 'InteractAction' == action['@type'] %}
<a href="{{ action.target }}"></a>
{% endif %}
{% endfor %}
{% endif %}
</p>
{% if post.subjectOf %}
@ -240,8 +235,8 @@
<a class="u-url url" href="{{ post.url }}"></a>
</p>
{% endif %}
</footer>
</div>
</article>
</main>
</div>
</div>
{% endblock %}

View file

@ -12,7 +12,7 @@
{% block pagination %}
{% if category.paginated %}
<section id="pagination">
<div id="pagination">
<ol>
{% for y, url in category.years.items() %}
{% if (y == category.year) or (not category.year and loop.first) %}
@ -30,28 +30,28 @@
{% endif %}
{% endfor %}
</ol>
</section>
</div>
{% endif %}
{% endblock %}
{% block content %}
<main id="main" class="h-feed hatom {{ category.name }}">
<div id="main" class="h-feed hatom {{ category.name }}">
{% set year = [0] %}
{% for post in posts %}
{% set _year = year.pop() %}
{% if not category.paginated and _year != post.copyrightYear %}
{% if not loop.first %}
</section>
</div>
{% endif %}
<section class="year">
<h2>{{ post.copyrightYear }}</h2>
<div class="year">
<h2>{{ post.copyrightYear }}</h2>
{% endif %}
{% set _ = year.append(post.copyrightYear)%}
{% include 'meta-article.j2.html' %}
{% if not category.paginated and loop.last %}
</section class="year">
</div>
{% endif %}
{% endfor %}
</main>
</div>
{% endblock %}

View file

@ -13,9 +13,6 @@
{% for key, value in meta.items() %}
<link rel="{{ key }}" href="{{ value }}" />
{% endfor %}
<script type="application/ld+json">
{{ site|tojson(indent=4) }}
</script>
<style media="all">
{% include('style.css') %}
</style>
@ -39,9 +36,9 @@
or ( category is defined and category.name == name )%}class="active"{% endif %}
{% endmacro %}
<header id="header">
<div id="header">
<div>
<nav>
<div class="nav">
<ul>
{% for key, data in menu.items() %}
<li>
@ -54,7 +51,7 @@
</li>
{% endfor %}
</ul>
</nav>
</div>
<div id="header-forms">
{% for action in site.potentialAction %}
@ -72,7 +69,7 @@
{% endfor %}
</div>
</div>
</header>
</div>
{% block content %}
{% endblock %}
@ -80,7 +77,7 @@
{% block pagination %}
{% endblock %}
<footer id="footer" class="p-author h-card vcard">
<div id="footer" class="p-author h-card vcard">
<div>
<p>
<a href="https://creativecommons.org/">CC</a>,
@ -141,6 +138,13 @@
flickr
</a>
</li>
{% elif 'xmpp' in url %}
<li>
<a rel="me" href="{{ url }}">
<svg width="16" height="16"><use xlink:href="#icon-xmpp" /></svg>
XMPP
</a>
</li>
{% endif %}
{% endfor %}
</ul>
@ -166,7 +170,7 @@
</ul>
</div>
</div>
</footer>
</div>
<script>
{% include 'themeswitcher.js' %}

View file

@ -1,5 +1,5 @@
<article class="h-entry hentry" lang="{{ post.inLanguage }}">
<header class="entry-header">
<div class="h-entry hentry" lang="{{ post.inLanguage }}">
<div class="entry-header">
<h3 class="p-name entry-title">
{% if post.mentions %}
<span>
@ -21,7 +21,7 @@
</h3>
<a href="{{ post.url }}" class="u-url bookmark"></a>
</header>
</div>
{% if post.description|length %}
{% set summary = post.description %}
@ -47,7 +47,7 @@
</span>
</div>
<footer class="entry-footer" aria-hidden="true" hidden="hidden">
<div class="entry-footer" aria-hidden="true" hidden="hidden">
Published at
<time datetime="{{ post.datePublished }}" class="dt-published published">{{ post.datePublished|printdate }}</time>
<time datetime="{{ post.dateModified }}" class="dt-updated updated"></time>
@ -57,5 +57,5 @@
<a class="p-name u-url fn url org" href="{{ post.author.url }}">{{ post.author.name }}</a>
<a class="u-email email" href="mailto:{{ post.author.email }}">{{ post.author.email }}</a>
</span>
</footer>
</article>
</div>
</div>

View file

@ -51,20 +51,18 @@ td, th {
text-overflow:initial !important;
}
.footnote-back {
display: none;
}
body > header,
body > footer,
#header,
#footer,
video,
audio,
.syndication,
#syndication,
.footnote-back,
.footnote-backref,
.footnote-back,
.encourage,
.noprint {
display:none !important;
}
code, pre {

View file

@ -376,11 +376,6 @@ li p {
}
*/
#syndication {
display: block;
text-align: right;
}
#fediversefollow label {
font-weight: bold;
}
@ -426,4 +421,4 @@ li p {
display: block;
margin: 0 auto;
}
}
}

View file

@ -91,4 +91,7 @@
<symbol id="icon-twitter" viewBox="0 0 16 16">
<path d="M15.969 3.046c-0.59 0.259-1.22 0.436-1.883 0.517 0.676-0.407 1.196-1.049 1.442-1.815-0.634 0.37-1.337 0.639-2.085 0.789-0.597-0.639-1.449-1.039-2.394-1.039-1.811 0-3.28 1.469-3.28 3.278 0 0.26 0.030 0.51 0.085 0.749-2.727-0.129-5.143-1.438-6.761-3.417-0.285 0.481-0.444 1.041-0.444 1.65 0 1.14 0.58 2.142 1.459 2.731-0.538-0.017-1.044-0.165-1.485-0.411v0.041c0 1.59 1.129 2.916 2.631 3.218-0.275 0.074-0.566 0.114-0.864 0.114-0.209 0-0.41-0.020-0.611-0.057 0.421 1.302 1.63 2.251 3.069 2.278-1.12 0.879-2.539 1.403-4.068 1.403-0.26 0-0.519-0.015-0.78-0.045 1.459 0.929 3.179 1.473 5.038 1.473 6.036 0 9.333-4.997 9.333-9.324 0-0.139 0-0.28-0.010-0.42 0.641-0.459 1.2-1.040 1.64-1.699l-0.031-0.013z"></path>
</symbol>
<symbol id="icon-xmpp" width="16" height="16" viewBox="0 0 16 16">
<path d="M0 2.13c0.1 3.83 3.24 7.8 7.020 10-0.87 0.68-1.84 1.2-2.9 1.46v0.18c1.3-0.12 2.6-0.5 3.87-1.1 0.42 0.2 0.85 0.38 1.28 0.54 0.43 0.17 0.88 0.3 1.33 0.4 0.5 0.13 0.97 0.2 1.44 0.25v-0.050h0.030v-0.14c-1.12-0.3-2.14-0.84-3.040-1.56 3.77-2.17 6.87-6.11 6.97-9.99l-2.4 0.94-2.47 0.73v0.36c0 2.28-1.15 5.060-3.080 7.050-1.87-1.97-3-4.7-3-6.95 0-0.12 0-0.24 0.020-0.37l-2.3-0.68-2.77-1.070z"></path>
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -9,9 +9,9 @@ import json
import os
import logging
import requests
import settings
import arrow
from time import sleep
import settings
logger = logging.getLogger("wayback")
logger.setLevel(10)