- re-added oembed

- symbol cleanup
- re-added tip list
- minibanners are hidden at the bottom for now
This commit is contained in:
Peter Molnar 2019-05-28 14:27:34 +02:00
parent bda93b05ef
commit 634d852dd5
6 changed files with 148 additions and 30 deletions

79
nasg.py
View file

@ -32,6 +32,7 @@ import frontmatter
from feedgen.feed import FeedGenerator
from slugify import slugify
import requests
import lxml.etree as etree
from pandoc import PandocMD2HTML, PandocMD2TXT, PandocHTML2TXT
from meta import Exif
@ -907,6 +908,53 @@ class Singular(MarkdownDoc):
self.content,
])
@cached_property
def oembed_xml(self):
oembed = etree.Element("oembed", version="1.0")
xmldoc = etree.ElementTree(oembed)
for k, v in self.oembed_json.items():
x = etree.SubElement(oembed, k)
t = "%s" % (v)
if "html" == k:
x.text = etree.CDATA(t)
else:
x.text = t
s = etree.tostring(
xmldoc,
encoding='utf-8',
xml_declaration=True,
pretty_print=True
)
return s
@cached_property
def oembed_json(self):
r = {
"version": "1.0",
"url": self.url,
"provider_name": settings.site.name,
"provider_url": settings.site.url,
"author_name": settings.author.name,
"author_url": settings.author.url,
"title": self.title,
"type": "link",
"html": self.html_content,
}
img = None
if self.is_photo:
img = self.photo
elif not self.is_photo and len(self.images):
img = list(self.images.values())[0]
if img:
r.update({
"type": "rich",
"thumbnail_url": img.jsonld.thumbnail.url,
"thumbnail_width": img.jsonld.thumbnail.width,
"thumbnail_height": img.jsonld.thumbnail.height
})
return r
async def copyfiles(self):
exclude = [
'.md',
@ -916,7 +964,8 @@ class Singular(MarkdownDoc):
'.ping',
'.url',
'.del',
'.copy']
'.copy'
]
files = glob.glob(
os.path.join(
os.path.dirname(self.fpath),
@ -974,6 +1023,16 @@ class Singular(MarkdownDoc):
json.dumps(j, indent=4, ensure_ascii=False)
)
del(j)
# oembed
writepath(
os.path.join(self.renderdir, 'oembed.json'),
json.dumps(self.oembed_json, indent=4, ensure_ascii=False)
)
writepath(
os.path.join(self.renderdir, 'oembed.xml'),
self.oembed_xml
)
class Home(Singular):
def __init__(self, fpath):
@ -2196,6 +2255,16 @@ class WebmentionIO(object):
# logger.error('failed to query granary.io: %s', e)
# pass
def dat():
for url in settings.site.sameAs:
if "dat://" in url:
p = os.path.join(settings.paths.build, '.well-known')
if not os.path.isdir(p):
os.makedirs(p)
p = os.path.join(settings.paths.build, '.well-known', 'dat')
if not os.path.exists(p):
writepath(p, "%s\nTTL=3600" % (url))
def make():
start = int(round(time.time() * 1000))
@ -2301,12 +2370,8 @@ def make():
continue
cp(e, t)
# ...
#for url in settings.site.sameAs:
#if "dat://" in url:
#p = os.path.join(settings.paths.build, '.well-known', 'dat')
#if not os.path.exists(p):
#writepath(p, "%s\nTTL=3600" % (url))
# dat data
dat()
end = int(round(time.time() * 1000))
logger.info('process took %d ms' % (end - start))

View file

@ -48,9 +48,9 @@ site = struct({
"name": "petermolnar.net",
"image": "https://petermolnar.net/favicon.ico",
"license": "https://spdx.org/licenses/%s.html" % (licence['_default']),
#"sameAs": [
#"dat://8d03735af11d82fff82028e0f830f9ac470f5e9fbe10ab5eb6feb877232714a2"
#],
"sameAs": [
"dat://7efecc3c33baf69d6fecf801e15ede92b369f4944f766489b156263119220939"
],
"author": {
"@context": "http://schema.org",
"@type": "Person",
@ -64,6 +64,7 @@ site = struct({
"xmpp:mail@petermolnar.net",
"https://wa.me/447592011721",
"https://t.me/petermolnar",
"https://twitter.com/petermolnar"
],
"follows": "https://petermolnar.net/following.opml"
},
@ -93,24 +94,30 @@ site = struct({
"url": "https://petermolnar.net/follow/",
"name": "follow"
},
#{
#"@context": "http://schema.org",
#"@type": "DonateAction",
#"description": "Monzo (only in the UK or via Google Pay)",
#"name": "monzo",
#"price": "3GBP",
#"url": "https://monzo.me/petermolnar/3",
#"recipient": author
#},
#{
#"@context": "http://schema.org",
#"@type": "DonateAction",
#"description": "Paypal",
#"name": "paypal",
#"price": "3GBP",
#"url": "https://paypal.me/petermolnar/3GBP",
#"recipient": author
#}
{
"@context": "http://schema.org",
"@type": "DonateAction",
"description": "Monzo",
"name": "monzo",
"url": "https://monzo.me/petermolnar/",
"recipient": author
},
{
"@context": "http://schema.org",
"@type": "DonateAction",
"description": "Paypal",
"name": "paypal",
"url": "https://paypal.me/petermolnar/",
"recipient": author
},
{
"@context": "http://schema.org",
"@type": "DonateAction",
"description": "Cash App",
"name": "cash",
"url": "https://cash.app/%C2%A3pmlnr",
"recipient": author
}
]
})
@ -184,6 +191,16 @@ photo = struct({
'earlyyears': 2014
})
#symlinks = {
#'files/a-view-from-barbican-1280x720.jpg': 'a-view-from-barbican/a-view-from-barbican_b.jpg',
#'files/hills_from_beachy_head-540x226.jpg': 'hills-from-beachy-head/hills-from-beachy-head.jpg',
#'files/seven_sisters_from_beachy_head-540x304.jpg': 'seven-sisters-from-beachy-head/seven-sisters-from-beachy-head.jpg',
#'files/the_countryside-540x304.jpg': 'the-countryside/the-countryside.jpg',
#'files/MGP0538-540x358.jpg': '',
#'files/IMGP0539-540x358.jpg': '',
#'files/IMGP0538-540x358.jpg': '',
#}
tmpdir = os.path.join(gettempdir(),'nasg')
if not os.path.isdir(tmpdir):
os.makedirs(tmpdir)

View file

@ -10,6 +10,8 @@
<link rel="alternate" type="application/json" href="{{ post.url }}index.json" />
<link rel="alternate" type="application/ld+json" href="{{ post.url }}index.json" />
<link rel="alternate" type="text/plain" href="{{ post.url }}index.txt" />
<link rel="alternate" type="application/json+oembed" href="{{ post.url }}oembed.json">
<link rel="alternate" type="text/xml+oembed" href="{{ post.url }}oembed.xml">
<meta property="og:title" content="{{ post.headline }}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ post.url }}" />

View file

@ -133,6 +133,24 @@
<a href="https://xn--sr8hvo.ws/%F0%9F%87%BB%F0%9F%87%AE%F0%9F%93%A2/next"></a>
</nav>
</section>
<section class="tip">
<span>Leave me a tip! </span>
<nav>
<ul>
{% for action in site.potentialAction %}
{% if 'DonateAction' == action['@type'] %}
<li>
<a href="{{ action.url }}">
<svg width="16" height="16"><use xlink:href="#icon-{{ action['name'] }}" /></svg>
{{ action.description }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</nav>
</section>
<!--
<section>
<nav>
<ul>
@ -174,6 +192,7 @@
</ul>
</nav>
</section>
-->
</footer>
<script>

View file

@ -178,6 +178,14 @@ body > footer .email span {
display: none;
}
body > footer > section.tip > * {
display: inline-block;
}
body > footer > section.tip a {
color: #090;
}
video,
figure img {
display: block;
@ -285,6 +293,10 @@ article > header {
margin: 0;
}
.h-feed article .photo .exif {
display: none;
}
main ul {
margin-left: 2em;
}
@ -368,4 +380,4 @@ body > img {
right: 0;
width: 10em;
height: auto;
}
}

View file

@ -2,11 +2,14 @@
<symbol id="icon-github" viewBox="0 0 16 16">
<path d="M8 0.198c-4.42 0-8 3.582-8 8 0 3.535 2.292 6.533 5.47 7.59 0.4 0.075 0.547-0.172 0.547-0.385 0-0.19-0.007-0.693-0.010-1.36-2.225 0.483-2.695-1.073-2.695-1.073-0.364-0.923-0.89-1.17-0.89-1.17-0.725-0.496 0.056-0.486 0.056-0.486 0.803 0.056 1.225 0.824 1.225 0.824 0.713 1.223 1.873 0.87 2.33 0.665 0.072-0.517 0.278-0.87 0.507-1.070-1.777-0.2-3.644-0.888-3.644-3.953 0-0.873 0.31-1.587 0.823-2.147-0.090-0.202-0.36-1.015 0.070-2.117 0 0 0.67-0.215 2.2 0.82 0.64-0.178 1.32-0.266 2-0.27 0.68 0.004 1.36 0.092 2 0.27 1.52-1.035 2.19-0.82 2.19-0.82 0.43 1.102 0.16 1.915 0.080 2.117 0.51 0.56 0.82 1.273 0.82 2.147 0 3.073-1.87 3.75-3.65 3.947 0.28 0.24 0.54 0.731 0.54 1.48 0 1.071-0.010 1.931-0.010 2.191 0 0.21 0.14 0.46 0.55 0.38 3.201-1.049 5.491-4.049 5.491-7.579 0-4.418-3.582-8-8-8z"></path>
</symbol>
<symbol id="icon-cash" viewBox="0 0 16 16">
<path d="M15.727 2.313c-0.351-0.948-1.086-1.682-2.010-2.026l-0.024-0.008c-0.873-0.28-1.667-0.28-3.28-0.28h-4.84c-1.6 0-2.407 0-3.267 0.267-0.949 0.353-1.683 1.090-2.026 2.016l-0.008 0.024c-0.273 0.867-0.273 1.667-0.273 3.267v4.847c0 1.607 0 2.4 0.267 3.267 0.351 0.948 1.086 1.682 2.010 2.026l0.023 0.008c0.867 0.273 1.667 0.273 3.267 0.273h4.853c1.607 0 2.407 0 3.267-0.267 0.952-0.351 1.689-1.088 2.032-2.016l0.008-0.024c0.273-0.867 0.273-1.667 0.273-3.267v-4.833c0-1.607 0-2.407-0.273-3.273zM11.613 5.4l-0.62 0.62c-0.059 0.055-0.139 0.089-0.227 0.089-0.084 0-0.161-0.031-0.22-0.083l0 0c-0.575-0.488-1.326-0.786-2.146-0.787h-0c-0.647 0-1.293 0.213-1.293 0.807 0 0.6 0.693 0.8 1.493 1.1 1.4 0.467 2.56 1.053 2.56 2.427 0 1.493-1.16 2.52-3.053 2.633l-0.173 0.8c-0.032 0.15-0.163 0.26-0.32 0.26-0 0-0 0-0 0h-1.193l-0.060-0.007c-0.15-0.035-0.26-0.167-0.26-0.325 0-0.024 0.003-0.048 0.007-0.070l-0 0.002 0.187-0.847c-0.75-0.192-1.397-0.556-1.922-1.049l0.002 0.002v-0.007c-0.058-0.058-0.094-0.138-0.094-0.227s0.036-0.169 0.094-0.227l0-0 0.667-0.647c0.058-0.055 0.137-0.088 0.223-0.088s0.165 0.034 0.224 0.088l-0-0c0.607 0.573 1.42 0.893 2.26 0.88 0.867 0 1.447-0.367 1.447-0.947s-0.587-0.733-1.693-1.147c-1.173-0.42-2.287-1.013-2.287-2.4 0-1.613 1.34-2.4 2.927-2.473l0.167-0.82c0.032-0.146 0.16-0.253 0.313-0.253 0.002 0 0.005 0 0.007 0h1.186l0.067 0.007c0.173 0.040 0.287 0.207 0.247 0.38l-0.18 0.913c0.6 0.2 1.167 0.513 1.653 0.927l0.013 0.013c0.127 0.133 0.127 0.333 0 0.453z"></path>
</symbol>
<symbol id="icon-paypal" viewBox="0 0 16 16">
<path d="M4.605 16h-2.069c-0.443 0-0.724-0.353-0.624-0.787l0.099-0.449h1.381c0.444 0 0.891-0.355 0.988-0.788l0.709-3.061c0.1-0.432 0.544-0.787 0.987-0.787h0.589c2.526 0 4.489-0.519 5.893-1.56s2.107-2.4 2.107-4.090c0-0.75-0.13-1.37-0.392-1.859 0-0.011-0.011-0.021-0.011-0.031l0.090 0.050c0.5 0.31 0.88 0.709 1.141 1.209 0.269 0.5 0.399 1.12 0.399 1.861 0 1.69-0.699 3.049-2.109 4.090-1.4 1.030-3.37 1.549-5.889 1.549h-0.6c-0.44 0-0.889 0.35-0.989 0.791l-0.71 3.070c-0.099 0.43-0.54 0.78-0.98 0.78l-0.008 0.012zM2.821 14.203h-2.070c-0.442 0-0.723-0.353-0.624-0.787l2.915-12.629c0.101-0.435 0.543-0.788 0.987-0.788h4.31c0.93 0 1.739 0.065 2.432 0.193 0.69 0.126 1.28 0.346 1.789 0.66 0.491 0.31 0.881 0.715 1.131 1.212 0.259 0.499 0.389 1.12 0.389 1.865 0 1.69-0.701 3.049-2.109 4.079-1.4 1.041-3.371 1.551-5.891 1.551h-0.589c-0.44 0-0.885 0.349-0.985 0.779l-0.707 3.059c-0.099 0.431-0.545 0.781-0.99 0.781l0.011 0.024zM7.785 2.624h-0.676c-0.444 0-0.888 0.353-0.987 0.785l-0.62 2.68c-0.1 0.432 0.18 0.786 0.62 0.786h0.511c1.109 0 1.98-0.229 2.6-0.681 0.619-0.457 0.93-1.103 0.93-1.941 0-0.553-0.201-0.963-0.6-1.227-0.4-0.269-1-0.403-1.791-0.403l0.013 0.001z"></path>
</symbol>
<symbol id="icon-monzo" viewBox="0 0 16 16">
<path d="M14.5 2h-13c-0.825 0-1.5 0.675-1.5 1.5v9c0 0.825 0.675 1.5 1.5 1.5h13c0.825 0 1.5-0.675 1.5-1.5v-9c0-0.825-0.675-1.5-1.5-1.5zM1.5 3h13c0.271 0 0.5 0.229 0.5 0.5v1.5h-14v-1.5c0-0.271 0.229-0.5 0.5-0.5zM14.5 13h-13c-0.271 0-0.5-0.229-0.5-0.5v-4.5h14v4.5c0 0.271-0.229 0.5-0.5 0.5zM2 10h1v2h-1zM4 10h1v2h-1zM6 10h1v2h-1z"></path>
<path d="M7.993 11.507h0.007l3.953-3.947v7.36c0.006 0.161 0.138 0.289 0.3 0.289 0.080 0 0.153-0.032 0.207-0.083l-0 0 3.32-3.313c0.132-0.134 0.213-0.317 0.213-0.52 0-0.005-0-0.009-0-0.014l0 0.001v-7.753l0.007-0.007-2.653-2.647c-0.053-0.055-0.128-0.089-0.21-0.089s-0.157 0.034-0.21 0.088l-0 0-4.927 4.92-4.94-4.933c-0.053-0.055-0.128-0.089-0.21-0.089s-0.157 0.034-0.21 0.088l-0 0-2.64 2.66v7.773c-0 0.002-0 0.004-0 0.007 0 0.203 0.081 0.386 0.213 0.52l-0-0 3.313 3.32c0.054 0.051 0.127 0.083 0.207 0.083 0.164 0 0.298-0.132 0.3-0.296v-0l0.007-7.373 3.953 3.96z"></path>
</symbol>
<symbol id="icon-lens" viewBox="0 0 16 16">
<path d="M8 4c-2.209 0-4 1.791-4 4s1.791 4 4 4 4-1.791 4-4-1.791-4-4-4zM8 11c-1.657 0-3-1.344-3-3s1.343-3 3-3 3 1.343 3 3-1.344 3-3 3zM8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zM8 14c-3.313 0-6-2.687-6-6s2.687-6 6-6 6 2.687 6 6-2.687 6-6 6zM8 6.5c-0.829 0-1.5 0.671-1.5 1.5s0.671 1.5 1.5 1.5 1.5-0.671 1.5-1.5-0.671-1.5-1.5-1.5z"></path>

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 23 KiB