Provide simple support for fetching entries in AMP format - can't handle images yet and needs some other tweaks, but works nicely so far c:
This commit is contained in:
parent
3e4f55fa9c
commit
40ead1bbe1
9 changed files with 131 additions and 1 deletions
|
@ -1,7 +1,10 @@
|
|||
{% extends 'lemoncurry/layout.html' %}
|
||||
{% load shorturl static %}
|
||||
|
||||
{% block head %}<link rel="shortlink" href="{% shorturl entry %}" />{% endblock %}
|
||||
{% block head %}
|
||||
<link rel="amphtml" href="{{ entry.amp_url }}" />
|
||||
<link rel="shortlink" href="{% shorturl entry %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" type="text/stylus" href="{% static 'entries/css/h-entry.styl' %}" />
|
||||
|
|
89
entries/templates/entries/entry_amp.html
Normal file
89
entries/templates/entries/entry_amp.html
Normal file
|
@ -0,0 +1,89 @@
|
|||
{% load favtags jsonify lemoncurry_tags markdown theme_colour %}<!doctype html>
|
||||
<html ⚡ lang="en" class="h-entry">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{{ entry.title }} ~ {% site_name %}</title>
|
||||
<link rel="canonical" href="{{ entry.url }}">
|
||||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
||||
<script class="p-json-ld" type="application/ld+json">
|
||||
{{ entry.json_ld | jsonify }}
|
||||
</script>
|
||||
{% placeFavicon %}
|
||||
|
||||
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
||||
|
||||
<style amp-custom>
|
||||
*, ::after, ::before {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html {
|
||||
background-color: {% theme_colour 0 %};
|
||||
font-family: sans-serif;
|
||||
line-height: 1.15;
|
||||
}
|
||||
body {
|
||||
color: {% theme_colour 7 %};
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
}
|
||||
body > header {
|
||||
background-color: {% theme_colour 1 %};
|
||||
padding: .5rem 1rem;
|
||||
}
|
||||
body > header > a {
|
||||
color: inherit;
|
||||
display: inline-block;
|
||||
font-size: 1.25rem;
|
||||
font-weight: unset;
|
||||
margin-right: 1rem;
|
||||
margin: 0;
|
||||
padding-bottom: .3125rem;
|
||||
padding-top: .3125rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
body > main {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 2rem 1rem;
|
||||
}
|
||||
body > main > article {
|
||||
background-color: {% theme_colour 2 %};
|
||||
border: 1px solid rgba(0,0,0,.125);
|
||||
border-radius: .25rem;
|
||||
padding: 1.25rem;
|
||||
}
|
||||
body > main > article > h4 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
margin-bottom: .75rem;
|
||||
}
|
||||
</style>
|
||||
<script async src="https://cdn.ampproject.org/v0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<a rel="home" href="{% url 'home:index' %}">{% site_name %}</a>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<article>
|
||||
{% if entry.name %}
|
||||
<h4 class="p-name">{{ entry.name }}</h4>
|
||||
{% endif %}
|
||||
|
||||
<main class="e-content{% if not entry.name %} p-name{% endif %}">
|
||||
{{ entry.content | markdown }}
|
||||
</main>
|
||||
</article>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -35,6 +35,10 @@
|
|||
{{ entry.updated | naturaltime }}
|
||||
</time>
|
||||
{% endif %}
|
||||
<a class="u-url" href="{{ entry.amp_url }}">
|
||||
<i class="fas fa-bolt"></i>
|
||||
amp
|
||||
</a>
|
||||
{% shortlink entry as short %}<a class="u-url" href="{{ short }}">
|
||||
<i class="fas fa-link"></i>
|
||||
{{ short | friendly_url }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue