mostly cleanups plus gopher shows markdown not plain text; still with 70em cutoff
This commit is contained in:
parent
c55a4e756d
commit
02c131b200
7 changed files with 77 additions and 75 deletions
54
nasg.py
54
nasg.py
|
@ -250,10 +250,10 @@ class Gone(object):
|
||||||
# rmtree(self.renderdir)
|
# rmtree(self.renderdir)
|
||||||
return
|
return
|
||||||
# logger.info(
|
# logger.info(
|
||||||
# "rendering %s to %s", self.__class__, self.renderfile
|
# "rendering %s to %s", self.__class__, self.renderfile
|
||||||
# )
|
# )
|
||||||
# writepath(
|
# 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",
|
"github": "https://github.com/petermolnar/nasg",
|
||||||
"follow": f"{settings.site.url}",
|
"follow": f"{settings.site.url}",
|
||||||
},
|
},
|
||||||
"email": "webmaster@petermolnar.net"
|
"email": "webmaster@petermolnar.net",
|
||||||
},
|
},
|
||||||
"openRegistrations": False,
|
"openRegistrations": False,
|
||||||
"protocols": ["activitypub"],
|
"protocols": ["activitypub"],
|
||||||
"services": {
|
"services": {"inbound": [], "outbound": []},
|
||||||
"inbound": [],
|
"software": {"name": "nasg", "version": "6.6"},
|
||||||
"outbound": [],
|
|
||||||
},
|
|
||||||
"software": {
|
|
||||||
"name": "nasg",
|
|
||||||
"version": "6.6"
|
|
||||||
},
|
|
||||||
"usage": {
|
"usage": {
|
||||||
"localPosts": self.postcount,
|
"localPosts": self.postcount,
|
||||||
"localComments": self.commentcount,
|
"localComments": self.commentcount,
|
||||||
|
@ -1006,8 +1000,10 @@ class Singular(MarkdownDoc):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_front(self):
|
def is_front(self):
|
||||||
if self.category in settings.notinfeed:
|
if self.is_reply:
|
||||||
return False
|
return False
|
||||||
|
# if self.category in settings.notinfeed:
|
||||||
|
# return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1076,7 +1072,7 @@ class Singular(MarkdownDoc):
|
||||||
urls = self.meta.get("syndicate", [])
|
urls = self.meta.get("syndicate", [])
|
||||||
if not self.is_page:
|
if not self.is_page:
|
||||||
urls.append("https://fed.brid.gy/")
|
urls.append("https://fed.brid.gy/")
|
||||||
#urls.append("https://brid.gy/publish/mastodon")
|
# urls.append("https://brid.gy/publish/mastodon")
|
||||||
if self.is_photo:
|
if self.is_photo:
|
||||||
urls.append("https://brid.gy/publish/flickr")
|
urls.append("https://brid.gy/publish/flickr")
|
||||||
return urls
|
return urls
|
||||||
|
@ -1303,9 +1299,7 @@ class Singular(MarkdownDoc):
|
||||||
".copy",
|
".copy",
|
||||||
".cache",
|
".cache",
|
||||||
]
|
]
|
||||||
include = [
|
include = ["map.png"]
|
||||||
"map.png"
|
|
||||||
]
|
|
||||||
files = glob.glob(
|
files = glob.glob(
|
||||||
os.path.join(os.path.dirname(self.fpath), "*.*")
|
os.path.join(os.path.dirname(self.fpath), "*.*")
|
||||||
)
|
)
|
||||||
|
@ -1316,9 +1310,7 @@ class Singular(MarkdownDoc):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
t = os.path.join(
|
t = os.path.join(
|
||||||
settings.paths.get("build"),
|
settings.paths.get("build"), self.name, fname
|
||||||
self.name,
|
|
||||||
fname
|
|
||||||
)
|
)
|
||||||
if os.path.exists(t) and mtime(f) <= mtime(t):
|
if os.path.exists(t) and mtime(f) <= mtime(t):
|
||||||
continue
|
continue
|
||||||
|
@ -1334,8 +1326,18 @@ class Singular(MarkdownDoc):
|
||||||
|
|
||||||
style = settings.mapbox.style
|
style = settings.mapbox.style
|
||||||
size = settings.mapbox.size
|
size = settings.mapbox.size
|
||||||
lat = round(float(self.photo.jsonld["locationCreated"]["geo"]["latitude"]), 3)
|
lat = round(
|
||||||
lon = round(float(self.photo.jsonld["locationCreated"]["geo"]["longitude"]), 3)
|
float(
|
||||||
|
self.photo.jsonld["locationCreated"]["geo"]["latitude"]
|
||||||
|
),
|
||||||
|
3,
|
||||||
|
)
|
||||||
|
lon = round(
|
||||||
|
float(
|
||||||
|
self.photo.jsonld["locationCreated"]["geo"]["longitude"]
|
||||||
|
),
|
||||||
|
3,
|
||||||
|
)
|
||||||
token = keys.mapbox.get("private")
|
token = keys.mapbox.get("private")
|
||||||
mapfpath = os.path.join(self.dirpath, "map.png")
|
mapfpath = os.path.join(self.dirpath, "map.png")
|
||||||
if os.path.exists(mapfpath):
|
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}"
|
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)
|
logger.info("requesting map for %s with URL %s", self.name, url)
|
||||||
with requests.get(url, stream=True) as r:
|
with requests.get(url, stream=True) as r:
|
||||||
with open(mapfpath, 'wb') as f:
|
with open(mapfpath, "wb") as f:
|
||||||
copyfileobj(r.raw, f)
|
copyfileobj(r.raw, f)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1705,11 +1707,12 @@ class Micropub(PHPFile):
|
||||||
"wallabag": keys.wallabag,
|
"wallabag": keys.wallabag,
|
||||||
"site": settings.site,
|
"site": settings.site,
|
||||||
"paths": settings.paths,
|
"paths": settings.paths,
|
||||||
"tags": { "tags": self.tags }
|
"tags": {"tags": self.tags},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
writepath(self.renderfile, r)
|
writepath(self.renderfile, r)
|
||||||
|
|
||||||
|
|
||||||
class WorldMap(object):
|
class WorldMap(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
@ -2092,7 +2095,8 @@ class Category(dict):
|
||||||
fe.content(post.html_content, type="CDATA")
|
fe.content(post.html_content, type="CDATA")
|
||||||
fg.add_entry(fe)
|
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):
|
class Year(object):
|
||||||
def __init__(self, parent, year):
|
def __init__(self, parent, year):
|
||||||
|
@ -2758,7 +2762,7 @@ def make():
|
||||||
try:
|
try:
|
||||||
logger.info("starting syncing")
|
logger.info("starting syncing")
|
||||||
os.system(
|
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")
|
logger.info("syncing finished")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
16
pandoc.py
16
pandoc.py
|
@ -141,8 +141,20 @@ class PandocMD2TXT(Pandoc):
|
||||||
"+autolink_bare_uris",
|
"+autolink_bare_uris",
|
||||||
"-smart",
|
"-smart",
|
||||||
]
|
]
|
||||||
out_format = "plain"
|
out_format = "markdown"
|
||||||
out_options = []
|
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"
|
columns = "--columns=80"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ Jinja2==2.10.3
|
||||||
langdetect==1.0.7
|
langdetect==1.0.7
|
||||||
lxml==4.4.2
|
lxml==4.4.2
|
||||||
MarkupSafe==1.1.1
|
MarkupSafe==1.1.1
|
||||||
pkg-resources==0.0.0
|
|
||||||
python-dateutil==2.8.1
|
python-dateutil==2.8.1
|
||||||
python-frontmatter==0.5.0
|
python-frontmatter==0.5.0
|
||||||
PyYAML==5.2
|
PyYAML==5.2
|
||||||
|
|
38
settings.py
38
settings.py
|
@ -55,9 +55,7 @@ site = nameddict(
|
||||||
"image": "https://petermolnar.net/favicon.ico",
|
"image": "https://petermolnar.net/favicon.ico",
|
||||||
"license": "https://spdx.org/licenses/%s.html"
|
"license": "https://spdx.org/licenses/%s.html"
|
||||||
% (licence["_default"]),
|
% (licence["_default"]),
|
||||||
"sameAs": [
|
"sameAs": ["https://t.me/petermolnarnet"],
|
||||||
"https://t.me/petermolnarnet"
|
|
||||||
],
|
|
||||||
"author": {
|
"author": {
|
||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
|
@ -73,7 +71,7 @@ site = nameddict(
|
||||||
"https://t.me/petermolnar",
|
"https://t.me/petermolnar",
|
||||||
"https://twitter.com/petermolnar",
|
"https://twitter.com/petermolnar",
|
||||||
"https://mastodon.social/@petermolnar"
|
"https://mastodon.social/@petermolnar"
|
||||||
"https://www.flickr.com/people/petermolnareu/"
|
"https://www.flickr.com/people/petermolnareu/",
|
||||||
],
|
],
|
||||||
"follows": "https://petermolnar.net/following.opml",
|
"follows": "https://petermolnar.net/following.opml",
|
||||||
},
|
},
|
||||||
|
@ -110,7 +108,7 @@ site = nameddict(
|
||||||
"recipient": author,
|
"recipient": author,
|
||||||
"target": "https://monzo.me/petermolnar/",
|
"target": "https://monzo.me/petermolnar/",
|
||||||
"price": "3",
|
"price": "3",
|
||||||
"priceCurrency": "GBP"
|
"priceCurrency": "GBP",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
|
@ -120,7 +118,7 @@ site = nameddict(
|
||||||
"recipient": author,
|
"recipient": author,
|
||||||
"target": "https://paypal.me/petermolnar/",
|
"target": "https://paypal.me/petermolnar/",
|
||||||
"price": "3",
|
"price": "3",
|
||||||
"priceCurrency": "GBP"
|
"priceCurrency": "GBP",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -157,7 +155,7 @@ meta = nameddict(
|
||||||
"authorization_endpoint": "https://indieauth.com/auth",
|
"authorization_endpoint": "https://indieauth.com/auth",
|
||||||
"token_endpoint": "https://tokens.indieauth.com/token",
|
"token_endpoint": "https://tokens.indieauth.com/token",
|
||||||
"micropub": "https://petermolnar.net/micropub.php",
|
"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"
|
base, "nasg", "templates", "watermark.png"
|
||||||
),
|
),
|
||||||
"build": os.path.join(base, "www"),
|
"build": os.path.join(base, "www"),
|
||||||
"remotewww": "/web/petermolnar.net/web",
|
"remotewww": "/usr/local/www/petermolnar.net",
|
||||||
"remotequeue": "/web/petermolnar.net/queue",
|
|
||||||
"micropub": os.path.join(base, "content", "note"),
|
"micropub": os.path.join(base, "content", "note"),
|
||||||
"home": os.path.join(base, "content", "home", "index.md"),
|
"home": os.path.join(base, "content", "home", "index.md"),
|
||||||
"category": "category",
|
"category": "category",
|
||||||
|
@ -184,11 +181,11 @@ filenames = nameddict(
|
||||||
"atom": "atom.xml",
|
"atom": "atom.xml",
|
||||||
"json": "index.json",
|
"json": "index.json",
|
||||||
"md": "index.md",
|
"md": "index.md",
|
||||||
"txt": "index.txt",
|
"txt": "index.md",
|
||||||
"html": "index.html",
|
"html": "index.html",
|
||||||
"gopher": "gophermap",
|
"gopher": "gophermap",
|
||||||
"sitemap": "sitemap.txt",
|
"sitemap": "sitemap.txt",
|
||||||
"worldmap": "map.html"
|
"worldmap": "map.html",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -202,7 +199,7 @@ photo = nameddict(
|
||||||
"default": 720,
|
"default": 720,
|
||||||
"sizes": {
|
"sizes": {
|
||||||
# 90 = s
|
# 90 = s
|
||||||
#240: "_m",
|
# 240: "_m",
|
||||||
720: "",
|
720: "",
|
||||||
1280: "_b",
|
1280: "_b",
|
||||||
},
|
},
|
||||||
|
@ -210,10 +207,7 @@ photo = nameddict(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
mapbox = nameddict({
|
mapbox = nameddict({"style": "outdoors-v11", "size": "720x480"})
|
||||||
"style": "outdoors-v11",
|
|
||||||
"size": "720x480"
|
|
||||||
})
|
|
||||||
|
|
||||||
rewrites = {
|
rewrites = {
|
||||||
"^/(?:sysadmin|it|linux-tech-coding|sysadmin-blog)/?(page.*)?$": "category/article/",
|
"^/(?:sysadmin|it|linux-tech-coding|sysadmin-blog)/?(page.*)?$": "category/article/",
|
||||||
|
@ -242,12 +236,12 @@ formerdomains = [
|
||||||
|
|
||||||
formercategories = {
|
formercategories = {
|
||||||
# "article": [
|
# "article": [
|
||||||
# "linux-tech-coding",
|
# "linux-tech-coding",
|
||||||
# "diy-do-it-yourself",
|
# "diy-do-it-yourself",
|
||||||
# "sysadmin-blog",
|
# "sysadmin-blog",
|
||||||
# "sysadmin",
|
# "sysadmin",
|
||||||
# "szubjektiv-technika",
|
# "szubjektiv-technika",
|
||||||
# "wordpress",
|
# "wordpress",
|
||||||
# ],
|
# ],
|
||||||
# "note": ["blips", "blog", "r"],
|
# "note": ["blips", "blog", "r"],
|
||||||
# "journal": ["blog"],
|
# "journal": ["blog"],
|
||||||
|
|
|
@ -63,24 +63,6 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<main id="main">
|
<main id="main">
|
||||||
<article class="h-entry hentry" lang="{{ post.inLanguage }}" id="article">
|
<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">
|
<h1 class="p-name entry-title">
|
||||||
{% if post.mentions %}
|
{% if post.mentions %}
|
||||||
<span>
|
<span>
|
||||||
|
@ -220,6 +202,22 @@
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% 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>
|
</p>
|
||||||
|
|
||||||
{% if post.subjectOf %}
|
{% if post.subjectOf %}
|
||||||
|
|
|
@ -376,11 +376,6 @@ li p {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#syndication {
|
|
||||||
display: block;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#fediversefollow label {
|
#fediversefollow label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ import json
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import settings
|
|
||||||
import arrow
|
import arrow
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
import settings
|
||||||
|
|
||||||
logger = logging.getLogger("wayback")
|
logger = logging.getLogger("wayback")
|
||||||
logger.setLevel(10)
|
logger.setLevel(10)
|
||||||
|
|
Loading…
Reference in a new issue