all repos — nasg @ 02c131b200a87d762e657851f05b205c0d44d581

mostly cleanups plus gopher shows markdown not plain text; still with 70em cutoff
Peter Molnar hello@petermolnar.eu
Fri, 21 Feb 2020 12:02:26 +0000
commit

02c131b200a87d762e657851f05b205c0d44d581

parent

c55a4e756d92ac370585609be5b44bcb26705808

7 files changed, 77 insertions(+), 75 deletions(-)

jump to
M nasg.pynasg.py

@@ -250,10 +250,10 @@ os.rmdir(self.renderdir)

# 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 @@ "homepage": "https://github.com/petermolnar/nasg",

"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 @@ return False

@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 @@ def to_syndicate(self):

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 @@ ".del",

".copy", ".cache", ] - include = [ - "map.png" - ] + include = ["map.png"] files = glob.glob( os.path.join(os.path.dirname(self.fpath), "*.*") )

@@ -1316,9 +1310,7 @@ if fext.lower() in exclude and fname.lower() not in include:

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 @@ return

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 @@

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 @@ {

"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 @@ fe.link(href=post.url)

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 @@ # upload site

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:
M pandoc.pypandoc.py

@@ -141,8 +141,20 @@ "+lists_without_preceding_blankline",

"+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"
M requirements.txtrequirements.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
M settings.pysettings.py

@@ -55,9 +55,7 @@ "name": "petermolnar.net",

"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 @@ "https://wa.me/447592011721",

"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 @@ "name": "monzo",

"recipient": author, "target": "https://monzo.me/petermolnar/", "price": "3", - "priceCurrency": "GBP" + "priceCurrency": "GBP", }, { "@context": "http://schema.org",

@@ -120,7 +118,7 @@ "name": "paypal",

"recipient": author, "target": "https://paypal.me/petermolnar/", "price": "3", - "priceCurrency": "GBP" + "priceCurrency": "GBP", }, ], }

@@ -157,7 +155,7 @@ "hub": "https://petermolnar.superfeedr.com/",

"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 @@ "watermark": os.path.join(

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 @@ "rss": "index.xml",

"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 @@ ),

"default": 720, "sizes": { # 90 = s - #240: "_m", + # 240: "_m", 720: "", 1280: "_b", },

@@ -210,10 +207,7 @@ "earlyyears": 2014,

} ) -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 @@ ]

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"],
M templates/Singular.j2.htmltemplates/Singular.j2.html

@@ -63,24 +63,6 @@

{% 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> - <h1 class="p-name entry-title"> {% if post.mentions %} <span>

@@ -219,6 +201,22 @@ <span class="p-latitude">{{ post.image[0].locationCreated.geo.latitude }}</span>,

<span class="p-longitude">{{ post.image[0].locationCreated.geo.longitude }}</span> </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>
M templates/style.csstemplates/style.css

@@ -376,11 +376,6 @@ padding: 0 1em 1em 1em;

} */ -#syndication { - display: block; - text-align: right; -} - #fediversefollow label { font-weight: bold; }

@@ -426,4 +421,4 @@ #header a svg {

display: block; margin: 0 auto; } -} +}
M wayback.pywayback.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)