Skip to content

Commit

Permalink
Improve metadata handling
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Oct 13, 2018
1 parent 924289b commit 712e922
Show file tree
Hide file tree
Showing 28 changed files with 233 additions and 49 deletions.
5 changes: 5 additions & 0 deletions data/identity.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
---
tagline: Open, customizable and skinnable platform dedicated to open data

social:
github: https://github.com/opendatateam
twitter: https://twitter.com/udata_project
gitter: https://gitter.im/opendatateam/udata
15 changes: 1 addition & 14 deletions pelicanconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import os

AUTHOR = 'Open Data Team'
SITENAME = 'udata'

SITEDESCRIPTION = 'Bla bla bla'
SITENAME = 'getudata.org'

TAGS = ('opendata', 'data')

Expand Down Expand Up @@ -36,11 +34,6 @@
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

# Blogroll
LINKS = (('Pelican', 'http://getpelican.com/'),
('Python.org', 'http://python.org/'),
('Jinja2', 'http://jinja.pocoo.org/'),
('You can modify those links in your config file', '#'),)

DEFAULT_PAGINATION = 10

Expand Down Expand Up @@ -111,12 +104,6 @@

RELATED_POSTS_MAX = 3

SOCIAL = (
('github', 'https://github.com/opendatateam'),
('twitter', 'https://twitter.com/udata_project'),
('gitter', 'https://gitter.im/opendatateam/udata'),
)

MENUITEMS = (
('Documentation', 'https://udata.readthedocs.io'),
)
2 changes: 0 additions & 2 deletions publishconf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

import os
import sys
sys.path.append(os.curdir)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/apple-touch-icon-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/apple-touch-icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/favicon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/favicon-196x196.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/favicon.ico
Binary file not shown.
Binary file added theme/static/favicons/mstile-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/mstile-310x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/mstile-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/static/favicons/mstile-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions theme/static/favicons/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions theme/templates/article.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{% extends 'base.html' %}

{% set meta = {
'title': article.title,
'lang': article.lang,
'description': article.summary|default('')|striptags,
'image': article.image,
'tags': article.tags|default([]),
} %}

{% block hero %}
<section class="hero article__hero">
<div class="article__container">
Expand Down
31 changes: 5 additions & 26 deletions theme/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
<!DOCTYPE html>
<html lang="{% block html_lang %}{{ DEFAULT_LANG }}{% endblock html_lang %}">
{% set meta = meta or {} %}
<html lang="{{ meta.lang or DEFAULT_LANG }}">
<head>
{% block head %}
<title>{% block title %}{{ SITENAME }}{% endblock title %}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">

{% from 'macros/metadata.html' import metadata with context %}
{{ metadata(meta) }}

<link rel="stylesheet" href="{{SITEURL}}/theme/css/fonts.css">
<link rel="stylesheet" href="{{SITEURL}}/theme/css/template.css">
<link rel="stylesheet" href="{{SITEURL}}/theme/css/typography.css">
<link rel="stylesheet" href="{{SITEURL}}/theme/css/main.css">
{% if FEED_ALL_ATOM %}
<link href="{{ FEED_DOMAIN }}/{% if FEED_ALL_ATOM_URL %}{{ FEED_ALL_ATOM_URL }}{% else %}{{ FEED_ALL_ATOM }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Full Atom Feed" />
{% endif %}
{% if FEED_ALL_RSS %}
<link href="{{ FEED_DOMAIN }}/{% if FEED_ALL_RSS_URL %}{{ FEED_ALL_RSS_URL }}{% else %}{{ FEED_ALL_RSS }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Full RSS Feed" />
{% endif %}
{% if FEED_ATOM %}
<link href="{{ FEED_DOMAIN }}/{%if FEED_ATOM_URL %}{{ FEED_ATOM_URL }}{% else %}{{ FEED_ATOM }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom Feed" />
{% endif %}
{% if FEED_RSS %}
<link href="{{ FEED_DOMAIN }}/{% if FEED_RSS_URL %}{{ FEED_RSS_URL }}{% else %}{{ FEED_RSS }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS Feed" />
{% endif %}
{% if CATEGORY_FEED_ATOM and category %}
<link href="{{ FEED_DOMAIN }}/{% if CATEGORY_FEED_ATOM_URL %}{{ CATEGORY_FEED_ATOM_URL|format(category.slug) }}{% else %}{{ CATEGORY_FEED_ATOM|format(category.slug) }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Categories Atom Feed" />
{% endif %}
{% if CATEGORY_FEED_RSS and category %}
<link href="{{ FEED_DOMAIN }}/{% if CATEGORY_FEED_RSS_URL %}{{ CATEGORY_FEED_RSS_URL|format(category.slug) }}{% else %}{{ CATEGORY_FEED_RSS|format(category.slug) }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Categories RSS Feed" />
{% endif %}
{% if TAG_FEED_ATOM and tag %}
<link href="{{ FEED_DOMAIN }}/{% if TAG_FEED_ATOM_URL %}{{ TAG_FEED_ATOM_URL|format(tag.slug) }}{% else %}{{ TAG_FEED_ATOM|format(tag.slug) }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Tags Atom Feed" />
{% endif %}
{% if TAG_FEED_RSS and tag %}
<link href="{{ FEED_DOMAIN }}/{% if TAG_FEED_RSS_URL %}{{ TAG_FEED_RSS_URL|format(tag.slug) }}{% else %}{{ TAG_FEED_RSS|format(tag.slug) }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Tags RSS Feed" />
{% endif %}
{% endblock head %}
</head>

Expand Down
6 changes: 3 additions & 3 deletions theme/templates/includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<div class="container">
<div class="footer__logo">
<h2>opendatateam</h2>
{% if SOCIAL %}
{% if data.identity.social %}
<ul class="footer__social">
{% for name, link in SOCIAL %}
{% for name, link in data.identity.social.items() %}
<li><a href="{{link}}" title="{{name}}"><svg class="icon icon-{{name}}"><use xlink:href="#{{name}}"></use></svg></a></li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
</footer>
</footer>
91 changes: 91 additions & 0 deletions theme/templates/macros/metadata.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{% macro metadata(meta) %}
{% set title = meta.title|default(SITENAME) %}
{% set full_title = ' - '.join((SITENAME, title)) if meta.title else SITENAME %}
{% set description = meta.description|default(data.identity.tagline) %}
{% set tags = TAGS|list + meta.tags|default([])|list %}

<title>{{ full_title }}</title>

<!-- Standard HTML metadata -->
<meta name="keywords" content="{{ tags|join(',') }}">
<meta name="description" content="{{ description }}">
<meta name="author" content="{{ AUTHOR }}">
<meta name="generator" content="Pelican" />

<!-- Standard favicons and colors -->
<meta name="theme-color" content="#ffffff" />
<link rel="icon" type="image/png" href="{{ SITEURL }}/theme/favicons/favicon-196x196.png" sizes="196x196" />
<link rel="icon" type="image/png" href="{{ SITEURL }}/theme/favicons/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/png" href="{{ SITEURL }}/theme/favicons/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="{{ SITEURL }}/theme/favicons/favicon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/png" href="{{ SITEURL }}/theme/favicons/favicon-128.png" sizes="128x128" />
<link rel="icon" type="image/x-icon" href="{{ SITEURL }}/theme/favicons/favicon.ico" />
<link rel="shortcut icon" type="image/x-icon" href="{{ SITEURL }}/theme/favicons/favicon.ico" />
<!-- Apple and Safari favicons -->
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-60x60.png" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="{{ SITEURL }}/theme/favicons/apple-touch-icon-152x152.png" />
<link rel="mask-icon" href="{{ SITEURL }}/theme/favicons/safari-pinned-tab.svg" color="#5bbad5">

<!-- Microsoft/Metro tiles -->
<meta name="application-name" content="{{ full_title }}"/>
<meta name="msapplication-TileColor" content="#2d89ef" />
<meta name="msapplication-TileImage" content="{{ SITEURL }}/theme/favicons/mstile-144x144" />
<meta name="msapplication-square70x70logo" content="{{ SITEURL }}/theme/favicons/mstile-70x70" />
<meta name="msapplication-square150x150logo" content="{{ SITEURL }}/theme/favicons/mstile-150x150" />
<meta name="msapplication-wide310x150logo" content="{{ SITEURL }}/theme/favicons/mstile-310x150" />
<meta name="msapplication-square310x310logo" content="{{ SITEURL }}/theme/favicons/mstile-310x310" />

<!-- OpenGraph -->
<meta property="og:title" content="{{ title }}" />
<meta property="og:site_name" content="{{ SITENAME }}" />
<meta property="og:description" content="{{ description }}" />
<meta property="og:locale" content="{{ meta.lang or DEFAULT_LANG }}" />
{% if meta.image %}
<meta property="og:image" content="{{ meta.image }}" />
{% endif %}

<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image" />
{% if data.identity.social.twitter %}<meta name="twitter:site" content="{{ data.identity.social.twitter }}" />{% endif %}
<meta name="twitter:title" content="{{ full_title }}" />
<meta name="twitter:description" content="{{ description }}" />
{% if meta.image %}
<meta name="twitter:image" content="{{ meta.image }}" />
{% endif %}

{% if JSON_LD %}
<!-- JSON-LD -->
<script type="application/ld+json">{{ JSON_LD | json }}</script>
{% endif %}

<!-- Feeds -->
{#
The `or` condition ensure that each feed is present once.
The `*_FEED_ALL_*` include the entire content in the feed
whereas the `*_FEED_*` only include the summary
#}
{% if FEED_ALL_ATOM or FEED_ATOM %}
<link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_ATOM or FEED_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }}" />
{% endif %}
{% if FEED_ALL_RSS or FEED_RSS %}
<link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_RSS or FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }}" />
{% endif %}
{% if category and (CATEGORY_FEED_ALL_ATOM or CATEGORY_FEED_ATOM) %}
<link href="{{ FEED_DOMAIN }}/{{ (CATEGORY_FEED_ATOM_URL or CATEGORY_FEED_ATOM) | format(category.slug) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} - {{ category }} category" />
{% endif %}
{% if category and (CATEGORY_FEED_ALL_RSS or CATEGORY_FEED_RSS) %}
<link href="{{ FEED_DOMAIN }}/{{ (CATEGORY_FEED_RSS_URL or CATEGORY_FEED_RSS) | format(category.slug) }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} - {{ category }} category" />
{% endif %}
{% if tag and (TAG_FEED_ALL_ATOM or TAG_FEED_ATOM) %}
<link href="{{ FEED_DOMAIN }}/{{ (TAG_FEED_ATOM_URL or TAG_FEED_ATOM)|format(tag.slug) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} - {{ tag }} tag" />
{% endif %}
{% if tag and (TAG_FEED_ALL_RSS or TAG_FEED_RSS) %}
<link href="{{ FEED_DOMAIN }}/{{ (TAG_FEED_RSS_URL or TAG_FEED_RSS)|format(tag.slug) }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} - {{ tag }} tag" />
{% endif %}
{% endmacro %}
12 changes: 8 additions & 4 deletions theme/templates/page.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{% extends "base.html" %}
{% block html_lang %}{{ page.lang }}{% endblock %}

{% block title %}{{ SITENAME }} - {{ page.title }}{%endblock%}
{% set meta = {
'title': page.title,
'lang': page.lang,
'description': page.summary|default('')|striptags,
'image': page.image,
'tags': page.tags|default([]),
} %}

{% block content %}
<section class="section-white">
Expand All @@ -18,4 +22,4 @@
{% endif %}
</div>
</section>
{% endblock %}
{% endblock %}

0 comments on commit 712e922

Please sign in to comment.