diff --git a/nasg.py b/nasg.py index 9577baf..c0f3df2 100644 --- a/nasg.py +++ b/nasg.py @@ -250,10 +250,10 @@ class Gone(object): # rmtree(self.renderdir) return # logger.info( - # "rendering %s to %s", self.__class__, self.renderfile + # "rendering %s to %s", self.__class__, self.renderfile # ) # writepath( - # self.renderfile, J2.get_template(self.template).render() + # self.renderfile, J2.get_template(self.template).render() # ) @@ -298,18 +298,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, @@ -1006,8 +1000,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 +1072,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 +1299,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 +1310,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 +1326,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 +1346,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 +1707,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 +2095,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): @@ -2758,7 +2762,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: diff --git a/pandoc.py b/pandoc.py index 0ad20bc..9a1c2ed 100644 --- a/pandoc.py +++ b/pandoc.py @@ -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" diff --git a/requirements.txt b/requirements.txt index a1ebfa1..4cc63cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/settings.py b/settings.py index e49439e..83adbc1 100644 --- a/settings.py +++ b/settings.py @@ -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"], diff --git a/templates/Singular.j2.html b/templates/Singular.j2.html index 87f9036..287b39b 100644 --- a/templates/Singular.j2.html +++ b/templates/Singular.j2.html @@ -63,24 +63,6 @@ {% block content %}
- -

{% if post.mentions %} @@ -220,6 +202,22 @@ {% endif %} {% endif %} + . + {% if post.sameAs|length %} + + This post also appears on other sites: + {% for url in post.sameAs %} + + {% endfor %}. + + {% endif %} + {% if 'WebPage' != post['@type'] %} + {% for action in post.potentialAction %} + {% if 'InteractAction' == action['@type'] %} + + {% endif %} + {% endfor %} + {% endif %}

{% if post.subjectOf %} diff --git a/templates/style.css b/templates/style.css index 3b3ff4d..3b4672f 100644 --- a/templates/style.css +++ b/templates/style.css @@ -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; } -} \ No newline at end of file +} diff --git a/wayback.py b/wayback.py index df3c88f..b4d70f6 100644 --- a/wayback.py +++ b/wayback.py @@ -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)