Compare commits

..

1 commit

Author SHA1 Message Date
dependabot[bot]
b16a21e07e
Bump feedgen from 0.8.0 to 0.9.0
Bumps [feedgen](https://github.com/lkiesow/python-feedgen) from 0.8.0 to 0.9.0.
- [Release notes](https://github.com/lkiesow/python-feedgen/releases)
- [Commits](https://github.com/lkiesow/python-feedgen/compare/v0.8.0...v0.9.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-01-28 22:44:15 +00:00
15 changed files with 157 additions and 140 deletions

73
nasg.py
View file

@ -244,7 +244,18 @@ class Gone(object):
return {"source": self.source}
async def render(self):
return
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()
# )
class FediverseStats(object):
def __init__(self, postcount=0, commentcount=0):
@ -287,12 +298,18 @@ 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,
@ -750,6 +767,15 @@ 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, "")
@ -980,10 +1006,8 @@ class Singular(MarkdownDoc):
@property
def is_front(self):
if self.is_reply:
if self.category in settings.notinfeed:
return False
# if self.category in settings.notinfeed:
# return False
return True
@property
@ -1052,7 +1076,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
@ -1279,7 +1303,9 @@ class Singular(MarkdownDoc):
".copy",
".cache",
]
include = ["map.png"]
include = [
"map.png"
]
files = glob.glob(
os.path.join(os.path.dirname(self.fpath), "*.*")
)
@ -1290,7 +1316,9 @@ 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
@ -1306,18 +1334,8 @@ 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):
@ -1326,7 +1344,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
@ -1687,12 +1705,11 @@ 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 = {}
@ -2075,8 +2092,7 @@ class Category(dict):
fe.content(post.html_content, type="CDATA")
fg.add_entry(fe)
output = fg.rss_str(pretty=True)
writepath(self.renderfile, output)
writepath(self.renderfile, fg.rss_str(pretty=True))
class Year(object):
def __init__(self, parent, year):
@ -2692,6 +2708,7 @@ 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)
@ -2741,7 +2758,7 @@ def make():
try:
logger.info("starting syncing")
os.system(
f"rsync -avuhH --exclude='.git' --delete-after {settings.paths.build}/ {settings.syncserver}:{settings.paths.remotewww}"
f"rsync -avuhH --delete-after {settings.paths.build}/ {settings.syncserver}:{settings.paths.remotewww}"
)
logger.info("syncing finished")
except Exception as e:

View file

@ -141,20 +141,8 @@ class PandocMD2TXT(Pandoc):
"+autolink_bare_uris",
"-smart",
]
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",
]
out_format = "plain"
out_options = []
columns = "--columns=80"

View file

@ -1,13 +1,14 @@
arrow==0.15.4
certifi==2019.11.28
chardet==3.0.4
feedgen==0.8.0
feedgen==0.9.0
filetype==1.0.5
idna==2.8
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,7 +55,9 @@ 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",
@ -71,7 +73,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",
},
@ -108,7 +110,7 @@ site = nameddict(
"recipient": author,
"target": "https://monzo.me/petermolnar/",
"price": "3",
"priceCurrency": "GBP",
"priceCurrency": "GBP"
},
{
"@context": "http://schema.org",
@ -118,7 +120,7 @@ site = nameddict(
"recipient": author,
"target": "https://paypal.me/petermolnar/",
"price": "3",
"priceCurrency": "GBP",
"priceCurrency": "GBP"
},
],
}
@ -155,7 +157,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"
}
)
@ -167,7 +169,8 @@ paths = nameddict(
base, "nasg", "templates", "watermark.png"
),
"build": os.path.join(base, "www"),
"remotewww": "/usr/local/www/petermolnar.net",
"remotewww": "/web/petermolnar.net/web",
"remotequeue": "/web/petermolnar.net/queue",
"micropub": os.path.join(base, "content", "note"),
"home": os.path.join(base, "content", "home", "index.md"),
"category": "category",
@ -181,11 +184,11 @@ filenames = nameddict(
"atom": "atom.xml",
"json": "index.json",
"md": "index.md",
"txt": "index.md",
"txt": "index.txt",
"html": "index.html",
"gopher": "gophermap",
"sitemap": "sitemap.txt",
"worldmap": "map.html",
"worldmap": "map.html"
}
)
@ -199,7 +202,7 @@ photo = nameddict(
"default": 720,
"sizes": {
# 90 = s
# 240: "_m",
#240: "_m",
720: "",
1280: "_b",
},
@ -207,7 +210,10 @@ 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/",
@ -236,12 +242,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 %}
<div id="main" class="h-feed hatom {{ category.name }}">
<main 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 %}
</div>
</section>
{% endif %}
<div class="year">
<section class="year">
<h2>{{ post.copyrightYear }}</h2>
{% endif %}
{% set _ = year.append(post.copyrightYear)%}
{% include 'meta-article.j2.html' %}
{% if loop.last %}
</div>
</section>
{% endif %}
{% endfor %}
</div>
</main>
{% endblock %}

View file

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

View file

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

View file

@ -32,6 +32,9 @@
<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') %}
@ -58,8 +61,26 @@
{% endblock %}
{% block content %}
<div id="main">
<div class="h-entry hentry" lang="{{ post.inLanguage }}" id="article">
<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>
@ -81,7 +102,7 @@
</h1>
{% if post.review %}
<div class="h-review hreview">
<section 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
@ -98,16 +119,16 @@
</span>
</p>
<p class="p-summary summary">{{ post.review.text }}</p>
</div>
</section>
{% endif %}
{% if post.description|length %}
<div class="e-summary entry-summary">
<section class="e-summary entry-summary">
{{ post.description|relurl(baseurl) }}
</div>
</section>
{% endif %}
<div class="section">
<section>
{% if post.image|length %}
{% for image in post.image %}
{% if image.representativeOfPage %}
@ -118,12 +139,12 @@
<div class="e-content entry-content">
{{ post.text|relurl(baseurl) }}
</div>
</div>
</section>
{% if 'WebPage' != post['@type'] %}
{% if post.comment|length %}
<div class="comments" id="comments">
<h2>Responses</h2>
<section class="comments">
<h2><a id="comments"></a>Responses</h2>
<ol>
{% for comment in post.comment %}
<li class="h-entry p-comment hentry">
@ -165,12 +186,12 @@
</li>
{% endfor %}
</ol>
</div>
</section>
{% endif %}
{% endif %}
<div class="entry-footer">
<footer class="entry-footer">
<p>Licenced under
<a rel="license" href="{{ post.license }}" class="u-license">{{ post.license | extractlicense }}</a>,
created by
@ -199,22 +220,6 @@
</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 %}
@ -235,8 +240,8 @@
<a class="u-url url" href="{{ post.url }}"></a>
</p>
{% endif %}
</div>
</footer>
</div>
</div>
</article>
</main>
{% endblock %}

View file

@ -12,7 +12,7 @@
{% block pagination %}
{% if category.paginated %}
<div id="pagination">
<section 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>
</div>
</section>
{% endif %}
{% endblock %}
{% block content %}
<div id="main" class="h-feed hatom {{ category.name }}">
<main 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 %}
</div>
</section>
{% endif %}
<div class="year">
<h2>{{ post.copyrightYear }}</h2>
<section class="year">
<h2>{{ post.copyrightYear }}</h2>
{% endif %}
{% set _ = year.append(post.copyrightYear)%}
{% include 'meta-article.j2.html' %}
{% if not category.paginated and loop.last %}
</div>
</section class="year">
{% endif %}
{% endfor %}
</div>
</main>
{% endblock %}

View file

@ -13,6 +13,9 @@
{% 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>
@ -36,9 +39,9 @@
or ( category is defined and category.name == name )%}class="active"{% endif %}
{% endmacro %}
<div id="header">
<header id="header">
<div>
<div class="nav">
<nav>
<ul>
{% for key, data in menu.items() %}
<li>
@ -51,7 +54,7 @@
</li>
{% endfor %}
</ul>
</div>
</nav>
<div id="header-forms">
{% for action in site.potentialAction %}
@ -69,7 +72,7 @@
{% endfor %}
</div>
</div>
</div>
</header>
{% block content %}
{% endblock %}
@ -77,7 +80,7 @@
{% block pagination %}
{% endblock %}
<div id="footer" class="p-author h-card vcard">
<footer id="footer" class="p-author h-card vcard">
<div>
<p>
<a href="https://creativecommons.org/">CC</a>,
@ -138,13 +141,6 @@
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>
@ -170,7 +166,7 @@
</ul>
</div>
</div>
</div>
</footer>
<script>
{% include 'themeswitcher.js' %}

View file

@ -1,5 +1,5 @@
<div class="h-entry hentry" lang="{{ post.inLanguage }}">
<div class="entry-header">
<article class="h-entry hentry" lang="{{ post.inLanguage }}">
<header 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>
</div>
</header>
{% if post.description|length %}
{% set summary = post.description %}
@ -47,7 +47,7 @@
</span>
</div>
<div class="entry-footer" aria-hidden="true" hidden="hidden">
<footer 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>
</div>
</div>
</footer>
</article>

View file

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

View file

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

View file

@ -91,7 +91,4 @@
<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: 16 KiB

After

Width:  |  Height:  |  Size: 15 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)