moved hardcoded rss, atom, json, etc. filenames into settings and template variables
This commit is contained in:
parent
634d852dd5
commit
f07e5bf522
6 changed files with 38 additions and 25 deletions
24
nasg.py
24
nasg.py
|
@ -998,11 +998,13 @@ class Singular(MarkdownDoc):
|
||||||
'site': settings.site,
|
'site': settings.site,
|
||||||
'menu': settings.menu,
|
'menu': settings.menu,
|
||||||
'meta': settings.meta,
|
'meta': settings.meta,
|
||||||
|
'fnames': settings.filenames
|
||||||
}
|
}
|
||||||
writepath(
|
writepath(
|
||||||
self.renderfile,
|
self.renderfile,
|
||||||
J2.get_template(self.template).render(v)
|
J2.get_template(self.template).render(v)
|
||||||
)
|
)
|
||||||
|
del(v)
|
||||||
|
|
||||||
g = {
|
g = {
|
||||||
'post': self.jsonld,
|
'post': self.jsonld,
|
||||||
|
@ -1013,27 +1015,27 @@ class Singular(MarkdownDoc):
|
||||||
self.gopherfile,
|
self.gopherfile,
|
||||||
J2.get_template(self.gophertemplate).render(g)
|
J2.get_template(self.gophertemplate).render(g)
|
||||||
)
|
)
|
||||||
|
del(g)
|
||||||
|
|
||||||
j = settings.site.copy()
|
j = settings.site.copy()
|
||||||
j.update({
|
j.update({
|
||||||
"mainEntity": self.jsonld
|
"mainEntity": self.jsonld
|
||||||
})
|
})
|
||||||
writepath(
|
writepath(
|
||||||
os.path.join(self.renderdir, 'index.json'),
|
os.path.join(self.renderdir, settings.filenames.json),
|
||||||
json.dumps(j, indent=4, ensure_ascii=False)
|
json.dumps(j, indent=4, ensure_ascii=False)
|
||||||
)
|
)
|
||||||
del(j)
|
del(j)
|
||||||
# oembed
|
# oembed
|
||||||
writepath(
|
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)
|
json.dumps(self.oembed_json, indent=4, ensure_ascii=False)
|
||||||
)
|
)
|
||||||
writepath(
|
writepath(
|
||||||
os.path.join(self.renderdir, 'oembed.xml'),
|
os.path.join(self.renderdir, settings.filenames.oembed_xml),
|
||||||
self.oembed_xml
|
self.oembed_xml
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Home(Singular):
|
class Home(Singular):
|
||||||
def __init__(self, fpath):
|
def __init__(self, fpath):
|
||||||
super().__init__(fpath)
|
super().__init__(fpath)
|
||||||
|
@ -1078,9 +1080,6 @@ class Home(Singular):
|
||||||
)
|
)
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
lines.append('')
|
lines.append('')
|
||||||
#lines.append('')
|
|
||||||
#lines = lines + list(settings.bye.split('\n'))
|
|
||||||
#lines.append('')
|
|
||||||
writepath(
|
writepath(
|
||||||
self.renderfile.replace(
|
self.renderfile.replace(
|
||||||
settings.filenames.html,
|
settings.filenames.html,
|
||||||
|
@ -1099,7 +1098,8 @@ class Home(Singular):
|
||||||
'site': settings.site,
|
'site': settings.site,
|
||||||
'menu': settings.menu,
|
'menu': settings.menu,
|
||||||
'meta': settings.meta,
|
'meta': settings.meta,
|
||||||
'posts': self.posts
|
'posts': self.posts,
|
||||||
|
'fnames': settings.filenames
|
||||||
})
|
})
|
||||||
writepath(self.renderfile, r)
|
writepath(self.renderfile, r)
|
||||||
await self.render_gopher()
|
await self.render_gopher()
|
||||||
|
@ -1864,6 +1864,7 @@ class Category(dict):
|
||||||
'years': self.years,
|
'years': self.years,
|
||||||
},
|
},
|
||||||
'posts': posts,
|
'posts': posts,
|
||||||
|
'fnames': settings.filenames
|
||||||
}
|
}
|
||||||
|
|
||||||
def indexfpath(self, subpath=None, fname=settings.filenames.html):
|
def indexfpath(self, subpath=None, fname=settings.filenames.html):
|
||||||
|
@ -1880,14 +1881,15 @@ class Category(dict):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def render_feed(self, xmlformat):
|
async def render_feed(self, xmlformat):
|
||||||
|
if 'json' == xmlformat:
|
||||||
|
await self.render_json()
|
||||||
|
return
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
'rendering category "%s" %s feed',
|
'rendering category "%s" %s feed',
|
||||||
self.name,
|
self.name,
|
||||||
xmlformat
|
xmlformat
|
||||||
)
|
)
|
||||||
if 'json' == xmlformat:
|
|
||||||
await self.render_json()
|
|
||||||
return
|
|
||||||
|
|
||||||
start = 0
|
start = 0
|
||||||
end = int(settings.pagination)
|
end = int(settings.pagination)
|
||||||
|
|
|
@ -176,7 +176,9 @@ filenames = struct({
|
||||||
'md': 'index.md',
|
'md': 'index.md',
|
||||||
'txt': 'index.txt',
|
'txt': 'index.txt',
|
||||||
'html': 'index.html',
|
'html': 'index.html',
|
||||||
'gopher': 'gophermap'
|
'gopher': 'gophermap',
|
||||||
|
'oembed_xml': 'oembed.xml',
|
||||||
|
'oembed_json': 'oembed.json'
|
||||||
})
|
})
|
||||||
|
|
||||||
photo = struct({
|
photo = struct({
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
{% block title %}{{ category.title }}{% endblock %}
|
{% block title %}{{ category.title }}{% endblock %}
|
||||||
{% block meta %}
|
{% block meta %}
|
||||||
<link rel="alternate" type="application/rss+xml" title="{{ category.title }} RSS feed" href="{{ category.feed }}" />
|
<link rel="canonical" href="{{ category.url }}" />
|
||||||
<link rel="alternate" type="application/atom+xml" title="{{ category.title }} ATOM feed" href="{{ category.feed }}atom.xml" />
|
<link rel="alternate" type="application/rss+xml" title="{{ category.title }} RSS feed" href="{{ category.feed }}{{ fnames.rss }}" />
|
||||||
<link rel="alternate" type="application/json" title="{{ category.title }} JSON feed" href="{{ category.feed }}index.json" />
|
<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 }}" />
|
<link rel="feed" title="{{ category.title}} feed" href="http://www.unmung.com/feed?feed={{ category.feed|urlencode }}" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
<meta name="author" content="{{ site.author.name }} <{{ site.author.email }}>" />
|
<meta name="author" content="{{ site.author.name }} <{{ site.author.email }}>" />
|
||||||
<meta name="description" content="{{ post.description|e }}" />
|
<meta name="description" content="{{ post.description|e }}" />
|
||||||
<link rel="canonical" href="{{ site.url }}" />
|
<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/rss+xml" title="{{ site.name }} RSS feed" href="{{ feed }}{{ fnames.rss }}" />
|
||||||
<link rel="alternate" type="application/atom+xml" title="{{ site.title }} ATOM feed" href="{{ feed }}atom.xml" />
|
<link rel="alternate" type="application/atom+xml" title="{{ site.name }} ATOM feed" href="{{ feed }}{{ fnames.atom }}" />
|
||||||
<link rel="alternate" type="application/json" title="{{ site.title }} JSON feed" href="{{ feed }}index.json" />
|
<link rel="alternate" type="application/json" title="{{ site.name }} JSON feed" href="{{ feed }}{{ fnames.json }}" />
|
||||||
<link rel="feed" title="{{ site.title}} feed" href="http://www.unmung.com/feed?feed={{ feed|urlencode }}" />
|
<link rel="feed" title="{{ site.name }} feed" href="http://www.unmung.com/feed?feed={{ feed|urlencode }}" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
{% block meta %}
|
{% block meta %}
|
||||||
<meta name="description" content="{{ post.description|striptags|e }}" />
|
<meta name="description" content="{{ post.description|striptags|e }}" />
|
||||||
<link rel="canonical" href="{{ post.url }}" />
|
<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 }}{{ fnames.json }}" />
|
||||||
<link rel="alternate" type="application/ld+json" href="{{ post.url }}index.json" />
|
<link rel="alternate" type="text/plain" href="{{ post.url }}{{ fnames.txt }}" />
|
||||||
<link rel="alternate" type="text/plain" href="{{ post.url }}index.txt" />
|
<link rel="alternate" type="application/oembed+json" href="{{ post.url }}{{ fnames.oembed_json }}">
|
||||||
<link rel="alternate" type="application/json+oembed" href="{{ post.url }}oembed.json">
|
<link rel="alternate" type="text/oembed+xml" href="{{ post.url }}{{ fnames.oembed_xml }}">
|
||||||
<link rel="alternate" type="text/xml+oembed" href="{{ post.url }}oembed.xml">
|
|
||||||
<meta property="og:title" content="{{ post.headline }}" />
|
<meta property="og:title" content="{{ post.headline }}" />
|
||||||
<meta property="og:type" content="article" />
|
<meta property="og:type" content="article" />
|
||||||
<meta property="og:url" content="{{ post.url }}" />
|
<meta property="og:url" content="{{ post.url }}" />
|
||||||
|
@ -19,6 +18,13 @@
|
||||||
<meta property="article:published_time" content="{{ post.datePublished }}" />
|
<meta property="article:published_time" content="{{ post.datePublished }}" />
|
||||||
<meta property="article:modified_time" content="{{ post.dateModified }}" />
|
<meta property="article:modified_time" content="{{ post.dateModified }}" />
|
||||||
<meta property="article:author" content="{{ post.author.name }} ({{ post.author.email}})" />
|
<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 %}
|
{% if post.image is iterable %}
|
||||||
<meta property="og:image" content="{{ post.image[0].url }}" />
|
<meta property="og:image" content="{{ post.image[0].url }}" />
|
||||||
<meta property="og:image:type" content="{{ post.image[0].encodingFormat }}" />
|
<meta property="og:image:type" content="{{ post.image[0].encodingFormat }}" />
|
||||||
|
|
|
@ -8,12 +8,14 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1" />
|
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1" />
|
||||||
<meta name="author" content="{{ site.author.name }} ({{ site.author.email }})" />
|
<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 }}" />
|
<link rel="icon" href="{{ site.image }}" />
|
||||||
<!-- <base href="{{ baseurl }}" /> -->
|
<!-- <base href="{{ baseurl }}" /> -->
|
||||||
{% for key, value in meta.items() %}
|
{% for key, value in meta.items() %}
|
||||||
<link rel="{{ key }}" href="{{ value }}" />
|
<link rel="{{ key }}" href="{{ value }}" />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% block meta %}{% endblock %}
|
{% block meta %}{% endblock %}
|
||||||
|
|
||||||
<style media="all">
|
<style media="all">
|
||||||
{% include('style.css') %}
|
{% include('style.css') %}
|
||||||
</style>
|
</style>
|
||||||
|
@ -26,7 +28,7 @@
|
||||||
<style media="print">
|
<style media="print">
|
||||||
{% include('style-print.css') %}
|
{% include('style-print.css') %}
|
||||||
</style>
|
</style>
|
||||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="{{ site.name }}">
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in a new issue