mostly cleanups plus gopher shows markdown not plain text; still with 70em cutoff

This commit is contained in:
Peter Molnar 2020-02-21 12:02:26 +00:00
parent c55a4e756d
commit 02c131b200
7 changed files with 77 additions and 75 deletions

54
nasg.py
View file

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

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

@ -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>
@ -220,6 +202,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 %}

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

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