Skip to content
Snippets Groups Projects
Commit 25d10934 authored by Nikos Roussos's avatar Nikos Roussos
Browse files

Add opengraph support

parent 0379b612
No related branches found
No related tags found
No related merge requests found
sitename: blog title here
author: your name here
rooturl: https://example.com/
logo: avatar.png
license: Creative Commons Attribution-ShareAlike
Loading
Loading
@@ -42,7 +42,10 @@ def generate_pages():
html = template.render({'page': page,
'author': cfg['author'],
'sitename': cfg['sitename'],
'license': cfg['license']})
'license': cfg['license'],
'logo': cfg['logo'],
'rooturl': cfg['rooturl'],
'link': page})
with open(page, 'w') as file:
file.write(html)
 
Loading
Loading
@@ -85,9 +88,12 @@ def generate_posts():
except OSError:
pass
 
images = []
if 'files' in headers:
files = headers['files'].split(', ')
for file in files:
if (file.find('.png') != -1) or (file.find('.jpg') != -1):
images.append(file)
copy2(path.join('posts/files/', file), postpath)
 
link = '{0}/'.format(postpath)
Loading
Loading
@@ -104,7 +110,9 @@ def generate_posts():
author=cfg['author'],
sitename=cfg['sitename'],
license=cfg['license'],
logo=cfg['logo'],
content=content,
images=images,
link=link
)
 
Loading
Loading
@@ -133,6 +141,7 @@ def generate_archive(posts, tag_set):
html = tpl.render(dict(
sitename=cfg['sitename'],
license=cfg['license'],
logo=cfg['logo'],
title='blog',
posts=posts
))
Loading
Loading
@@ -173,7 +182,8 @@ def generate_feeds(posts, tag_set):
author=cfg['author'],
rooturl=cfg['rooturl'],
license=cfg['license'],
updated=updated
logo=cfg['logo'],
updated=updated
)
with open('feed.xml', 'w') as file:
file.write(xml)
Loading
Loading
Loading
Loading
@@ -4,10 +4,17 @@
<meta charset="utf-8">
<title>{{ sitename }}{% block title %}{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/feed.xml" rel="alternate" type="application/rss+xml" title="{{ sitename }}">
<meta property="og:site_name" content="{{ sitename }}">
{% block meta %}
<meta property="og:title" content="{{ sitename }}">
<meta property="og:type" content="website">
<meta property="og:url" content="{{ rooturl }}{{ link }}">
{% endblock %}
<meta property="og:image" content="{{ rooturl }}static/img/{{ logo }}">
<link rel="stylesheet" href="/static/css/lib/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/lib/bootstrap-theme.min.css">
<link rel="stylesheet" href="/static/css/app.css">
<link href="/feed.xml" rel="alternate" type="application/rss+xml" title="{{ sitename }}">
{% block css %}{% endblock %}
<link rel="shortcut icon" href="/favicon.ico">
</head>
Loading
Loading
@@ -20,7 +27,7 @@
<div class="col-md-12 text-center">
<p class="avatar">
<a href="/">
<img src="/static/img/avatar.png" alt="{{ author }}" class="avatar img-circle" />
<img src="/static/img/{{ logo }}" alt="{{ author }}" class="avatar img-circle" />
</a>
</p>
<h3>
Loading
Loading
Loading
Loading
@@ -2,6 +2,10 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<author>{{ author }}</author>
<title>{{ sitename }}{{ tagtitle }}</title>
<link href="{{ rooturl }}feed.xml" rel="self" />
<link href="{{ rooturl }}" />
<icon>{{ rooturl }}favicon.ico</icon>
<logo>{{ rooturl }}static/img/{{ logo }}</logo>
<updated>{{ updated }}</updated>
{% for item in items %}
<entry>
Loading
Loading
Loading
Loading
@@ -2,6 +2,18 @@
 
{% block title %} &bull; {{ title }}{% endblock title %}
 
{% block meta %}
<meta property="og:title" content="{{ title}}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ rooturl }}{{ link }}">
{% if images %}
{% for image in images %}
<meta property="og:image" content="{{ rooturl }}{{ link }}{{ image }}">
{% endfor %}
{% endif %}
<meta property="og:description" content="{{ content|striptags|truncate(300, True)|e }}">
{% endblock %}
{% block content %}
<div class="container">
<div class="row">
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment