moved hardcoded rss, atom, json, etc. filenames into settings and template variables

This commit is contained in:
Peter Molnar 2019-05-29 21:34:47 +02:00
parent 634d852dd5
commit f07e5bf522
6 changed files with 38 additions and 25 deletions

24
nasg.py
View file

@ -998,11 +998,13 @@ class Singular(MarkdownDoc):
'site': settings.site,
'menu': settings.menu,
'meta': settings.meta,
'fnames': settings.filenames
}
writepath(
self.renderfile,
J2.get_template(self.template).render(v)
)
del(v)
g = {
'post': self.jsonld,
@ -1013,27 +1015,27 @@ class Singular(MarkdownDoc):
self.gopherfile,
J2.get_template(self.gophertemplate).render(g)
)
del(g)
j = settings.site.copy()
j.update({
"mainEntity": self.jsonld
})
writepath(
os.path.join(self.renderdir, 'index.json'),
os.path.join(self.renderdir, settings.filenames.json),
json.dumps(j, indent=4, ensure_ascii=False)
)
del(j)
# oembed
writepath(
os.path.join(self.renderdir, 'oembed.json'),
os.path.join(self.renderdir, settings.filenames.oembed_json),
json.dumps(self.oembed_json, indent=4, ensure_ascii=False)
)
writepath(
os.path.join(self.renderdir, 'oembed.xml'),
os.path.join(self.renderdir, settings.filenames.oembed_xml),
self.oembed_xml
)
class Home(Singular):
def __init__(self, fpath):
super().__init__(fpath)
@ -1078,9 +1080,6 @@ class Home(Singular):
)
lines.append(line)
lines.append('')
#lines.append('')
#lines = lines + list(settings.bye.split('\n'))
#lines.append('')
writepath(
self.renderfile.replace(
settings.filenames.html,
@ -1099,7 +1098,8 @@ class Home(Singular):
'site': settings.site,
'menu': settings.menu,
'meta': settings.meta,
'posts': self.posts
'posts': self.posts,
'fnames': settings.filenames
})
writepath(self.renderfile, r)
await self.render_gopher()
@ -1864,6 +1864,7 @@ class Category(dict):
'years': self.years,
},
'posts': posts,
'fnames': settings.filenames
}
def indexfpath(self, subpath=None, fname=settings.filenames.html):
@ -1880,14 +1881,15 @@ class Category(dict):
)
async def render_feed(self, xmlformat):
if 'json' == xmlformat:
await self.render_json()
return
logger.info(
'rendering category "%s" %s feed',
self.name,
xmlformat
)
if 'json' == xmlformat:
await self.render_json()
return
start = 0
end = int(settings.pagination)

View file

@ -176,7 +176,9 @@ filenames = struct({
'md': 'index.md',
'txt': 'index.txt',
'html': 'index.html',
'gopher': 'gophermap'
'gopher': 'gophermap',
'oembed_xml': 'oembed.xml',
'oembed_json': 'oembed.json'
})
photo = struct({

View file

@ -3,9 +3,10 @@
{% block title %}{{ category.title }}{% endblock %}
{% block meta %}
<link rel="alternate" type="application/rss+xml" title="{{ category.title }} RSS feed" href="{{ category.feed }}" />
<link rel="alternate" type="application/atom+xml" title="{{ category.title }} ATOM feed" href="{{ category.feed }}atom.xml" />
<link rel="alternate" type="application/json" title="{{ category.title }} JSON feed" href="{{ category.feed }}index.json" />
<link rel="canonical" href="{{ category.url }}" />
<link rel="alternate" type="application/rss+xml" title="{{ category.title }} RSS feed" href="{{ category.feed }}{{ fnames.rss }}" />
<link rel="alternate" type="application/atom+xml" title="{{ category.title }} ATOM feed" href="{{ category.feed }}{{ fnames.atom }}" />
<link rel="alternate" type="application/json" title="{{ category.title }} JSON feed" href="{{ category.feed }}{{ fnames.json }}" />
<link rel="feed" title="{{ category.title}} feed" href="http://www.unmung.com/feed?feed={{ category.feed|urlencode }}" />
{% endblock %}

View file

@ -7,10 +7,10 @@
<meta name="author" content="{{ site.author.name }} <{{ site.author.email }}>" />
<meta name="description" content="{{ post.description|e }}" />
<link rel="canonical" href="{{ site.url }}" />
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} RSS feed" href="{{ feed }}" />
<link rel="alternate" type="application/atom+xml" title="{{ site.title }} ATOM feed" href="{{ feed }}atom.xml" />
<link rel="alternate" type="application/json" title="{{ site.title }} JSON feed" href="{{ feed }}index.json" />
<link rel="feed" title="{{ site.title}} feed" href="http://www.unmung.com/feed?feed={{ feed|urlencode }}" />
<link rel="alternate" type="application/rss+xml" title="{{ site.name }} RSS feed" href="{{ feed }}{{ fnames.rss }}" />
<link rel="alternate" type="application/atom+xml" title="{{ site.name }} ATOM feed" href="{{ feed }}{{ fnames.atom }}" />
<link rel="alternate" type="application/json" title="{{ site.name }} JSON feed" href="{{ feed }}{{ fnames.json }}" />
<link rel="feed" title="{{ site.name }} feed" href="http://www.unmung.com/feed?feed={{ feed|urlencode }}" />
{% endblock %}
{% block content %}

View file

@ -7,11 +7,10 @@
{% block meta %}
<meta name="description" content="{{ post.description|striptags|e }}" />
<link rel="canonical" href="{{ post.url }}" />
<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">
<link rel="alternate" type="application/ld+json" href="{{ post.url }}{{ fnames.json }}" />
<link rel="alternate" type="text/plain" href="{{ post.url }}{{ fnames.txt }}" />
<link rel="alternate" type="application/oembed+json" href="{{ post.url }}{{ fnames.oembed_json }}">
<link rel="alternate" type="text/oembed+xml" href="{{ post.url }}{{ fnames.oembed_xml }}">
<meta property="og:title" content="{{ post.headline }}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ post.url }}" />
@ -19,6 +18,13 @@
<meta property="article:published_time" content="{{ post.datePublished }}" />
<meta property="article:modified_time" content="{{ post.dateModified }}" />
<meta property="article:author" content="{{ post.author.name }} ({{ post.author.email}})" />
<!--
<meta name="DC.Format" content="text/html" />
<meta name="DC.Language" content="{{ post.inLanguage }}" />
<meta name="DC.Publisher" content="{{ post.Publisher.name }}" />
<meta name="DC.Title" content="{{ post.headline }}" />
<meta name="DC.Rights" content="{{ post.headline }}" />
-->
{% if post.image is iterable %}
<meta property="og:image" content="{{ post.image[0].url }}" />
<meta property="og:image:type" content="{{ post.image[0].encodingFormat }}" />

View file

@ -8,12 +8,14 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1" />
<meta name="author" content="{{ site.author.name }} ({{ site.author.email }})" />
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="{{ site.name }}">
<link rel="icon" href="{{ site.image }}" />
<!-- <base href="{{ baseurl }}" /> -->
{% for key, value in meta.items() %}
<link rel="{{ key }}" href="{{ value }}" />
{% endfor %}
{% block meta %}{% endblock %}
<style media="all">
{% include('style.css') %}
</style>
@ -26,7 +28,7 @@
<style media="print">
{% include('style-print.css') %}
</style>
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="{{ site.name }}">
</head>
<body>