Browse Source

Complete migration to Jinja2 by porting the home page template

tags/v1.9.10
Danielle McLean 1 year ago
parent
commit
77816b6c5d
Signed by: Danielle McLean <dani@00dani.me> GPG Key ID: 8EB789DDF3ABD240

+ 0
- 17
entries/templates/entries/entry.html View File

@@ -1,17 +0,0 @@
1
-{% extends 'lemoncurry/layout.html' %}
2
-{% load absolute_url static %}
3
-
4
-{% block head %}
5
-<link rel="shortlink" href="{{ entry.short_url }}" />
6
-<link rel="alternate" type="application/json+oembed" href="https://wirres.net/oembed/oembed.php?url={{ uri | absolute_url | urlencode }}" />
7
-{% endblock %}
8
-
9
-{% block styles %}
10
-<link rel="stylesheet" type="text/stylus" href="{% static 'entries/css/h-entry.styl' %}" />
11
-{% endblock %}
12
-
13
-{% block main %}
14
-<div class="entry">
15
-{% include 'entries/h-entry.html' %}
16
-</div>
17
-{% endblock %}

+ 0
- 67
entries/templates/entries/h-entry.html View File

@@ -1,67 +0,0 @@
1
-{% load bleach friendly_url humanize jsonify markdown %}<article class="card h-entry">
2
-	{% if entry.photo %}<img class="card-img-top u-photo" src="{{ entry.photo.url }}" />{% endif %}
3
-
4
-	{% if entry.in_reply_to %}{% with reply=entry.reply_context %}
5
-	<article class="card-header media u-in-reply-to h-cite">
6
-		<a class="align-self-center p-author h-card" href="{{ reply.author.url }}">
7
-			<img class="mr-3 rounded" width="100" src="{{ reply.author.photo }}"
8
-					 alt="{{ reply.author.name }}" title="{{ reply.author.name }}" />
9
-		</a>
10
-		<div class="media-body">
11
-			{% if reply.name %}<h4 class="p-name">{{ reply.name }}</h4>{% endif %}
12
-			<div class="e-content{% if not reply.name %} p-name{% endif %}">{{ reply.content | bleach }}</div>
13
-		</div>
14
-	</article>{% endwith %}{% endif %}
15
-
16
-	<div class="card-body">
17
-		{% if entry.name %}<h4 class="card-title p-name">{{ entry.name }}</h4>{% endif %}
18
-		<div class="e-content{% if not entry.name %} p-name{% endif %}">{{ entry.content | markdown }}</div>
19
-	</div>
20
-
21
-	<div class="card-footer">
22
-		<a class="p-author h-card" href="{{ entry.author.url }}">
23
-			<img class="u-photo" src="{{ entry.author.avatar.url }}" />
24
-			{{ entry.author.first_name }} {{ entry.author.last_name }}
25
-		</a>
26
-		<a class="u-uid u-url" href="{{ entry.url }}">
27
-			<time class="dt-published" datetime="{{ entry.published.isoformat }}">
28
-				<i class="fas fa-calendar"></i>
29
-				{{ entry.published | naturaltime }}
30
-			</time>
31
-		</a>
32
-		{% if entry.updated != entry.published %}
33
-		<time class="dt-updated" datetime="{{ entry.updated.isoformat }}">
34
-			<i class="fas fa-pencil-alt"></i>
35
-			{{ entry.updated | naturaltime }}
36
-		</time>
37
-		{% endif %}
38
-		<a class="u-url" href="{{ entry.short_url }}">
39
-			<i class="fas fa-link"></i>
40
-			{{ entry.short_url | friendly_url }}
41
-		</a>
42
-	</div>
43
-
44
-	{% if entry.cats.exists %}
45
-	<div class="card-footer">
46
-		{% for c in entry.cats.all %}
47
-		<a class="p-category" href="{{ c.url }}">
48
-			<i class="fas fa-paw"></i>
49
-			{{ c.name }}
50
-		</a>
51
-		{% endfor %}
52
-	</div>
53
-	{% endif %}
54
-
55
-	{% if entry.syndications.exists %}
56
-	<div class="card-footer">
57
-		{% for s in entry.syndications.all %}
58
-		<a class="u-syndication" href="{{ s.url }}">
59
-			<i class="{{ s.profile.site.icon }}" aria-hidden="true"></i>
60
-			{{ s.profile }}
61
-		</a>
62
-		{% endfor %}
63
-	</div>
64
-	{% endif %}
65
-
66
-	<script class="p-json-ld" type="application/ld+json">{{ entry.json_ld | jsonify }}</script>
67
-</article>

+ 0
- 17
entries/templates/entries/index.html View File

@@ -1,17 +0,0 @@
1
-{% extends 'lemoncurry/layout.html' %}
2
-{% load static %}
3
-{% block html_class %}h-feed{% endblock %}
4
-
5
-{% block styles %}
6
-<link rel="stylesheet" type="text/stylus" href="{% static 'entries/css/h-entry.styl' %}" />
7
-{% endblock %}
8
-
9
-{% block main %}
10
-<ol class="list-unstyled entries">
11
-	{% for entry in entries %}
12
-	<li>
13
-		{% include 'entries/h-entry.html' %}
14
-	</li>
15
-	{% endfor %}
16
-</ol>
17
-{% endblock %}

+ 102
- 0
home/jinja2/home/index.html View File

@@ -0,0 +1,102 @@
1
+{% extends 'lemoncurry/layout.html' %}
2
+
3
+{% block html_attr %}
4
+ class="h-feed"{{ super() }}
5
+{%- endblock %}
6
+
7
+{% block styles %}
8
+    <link rel="stylesheet" type="text/stylus" href="{{ static('home/css/index.styl') }}" />
9
+    <link rel="stylesheet" type="text/stylus" href="{{ static('entries/css/h-entry.styl') }}" />
10
+{% endblock %}
11
+
12
+{% block head %}
13
+  {% for key in user.keys.all() %}
14
+    <link rel="pgpkey" href="{{ key.file.url }}" />
15
+  {% endfor %}
16
+{% endblock %}
17
+
18
+{% block main %}
19
+      <aside class="author">
20
+        <article class="h-card p-author card">
21
+          <a class="u-uid u-url" href="{{ user.full_url }}">
22
+          {% if user.avatar %}
23
+            <img class="u-photo card-img-top" src="{{ user.avatar.url }}" alt="{{ user.name }}" />
24
+          {% endif %}
25
+          </a>
26
+
27
+          <div class="card-body">
28
+            <h4 class="p-name card-title">
29
+              <span class="p-given-name">{{ user.first_name }}</span> <span class="p-family-name">{{ user.last_name }}</span>
30
+            </h4>
31
+            {% if user.note %}
32
+            <div class="p-note">
33
+              {{ user.note | markdown }}
34
+            </div>
35
+            {% endif %}
36
+          </div>
37
+
38
+          <div class="card-footer">
39
+            <ul class="profiles">
40
+              <li>
41
+                <a class="u-email" rel="me" href="mailto:{{ user.email }}">
42
+                  <i class="fas fa-envelope" aria-hidden="true"></i>
43
+                  {{ user.email }}
44
+                </a>
45
+              </li>
46
+              {% if user.xmpp %}
47
+
48
+              <li>
49
+                <a class="u-impp" rel="me" href="xmpp:{{ user.xmpp }}">
50
+                  <i class="openwebicons-xmpp" aria-hidden="true"></i>
51
+                  {{ user.xmpp }}
52
+                </a>
53
+              </li>
54
+              {% endif %}
55
+            </ul>
56
+          </div>
57
+          {% if user.keys.exists() %}
58
+
59
+          <div class="card-footer">
60
+            <ul class="profiles">
61
+              {% for key in user.keys.all() %}
62
+              <a class="u-key" href="{{ key.file.url }}">
63
+                <i class="fas fa-key" aria-hidden="true"></i>
64
+                {{ key.pretty_print() }}
65
+              </a>
66
+              {% endfor %}
67
+            </ul>
68
+          </div>
69
+          {% endif %}
70
+          {% if user.profiles.exists() %}
71
+
72
+          <div class="card-footer">
73
+            <ul class="profiles">
74
+              {% for profile in user.profiles.all() %}
75
+              <a class="u-url" rel="me" href="{{ profile.url }}" title="{{ profile }}">
76
+                <i class="{{ profile.site.icon }}" aria-hidden="true"></i>
77
+                <span class="sr-only">{{ profile }}</span>
78
+              </a>
79
+              {% endfor %}
80
+            </ul>
81
+          </div>
82
+          {% endif %}
83
+
84
+          <script class="p-json-ld" type="application/ld+json">{{ user.json_ld | tojson }}</script>
85
+        </article>
86
+      </aside>
87
+
88
+      {% import 'entries/h-entry.html' as h %}
89
+      <ol class="list-unstyled entries">
90
+        {% for entry in entries %}
91
+        <li>
92
+          {{ h.hEntry(entry, indent_width=10) }}
93
+        </li>
94
+        {% endfor %}
95
+      </ol>
96
+{% endblock %}
97
+
98
+{% block foot %}
99
+    <script type="text/javascript">
100
+      tippy('.profiles [title]', {arrow: true});
101
+    </script>
102
+{% endblock %}

+ 0
- 70
home/templates/home/index.html View File

@@ -1,70 +0,0 @@
1
-{% extends 'lemoncurry/layout.html' %}
2
-{% load jsonify markdown static %}
3
-{% block html_class %}h-feed{% endblock %}
4
-{% block styles %}
5
-<link rel="stylesheet" type="text/stylus" href="{% static 'home/css/index.styl' %}" />
6
-<link rel="stylesheet" type="text/stylus" href="{% static 'entries/css/h-entry.styl' %}" />
7
-{% endblock %}
8
-
9
-{% block head %}{% for key in user.keys.all %}<link rel="pgpkey" href="{{ key.file.url }}" />{% endfor %}{% endblock %}
10
-
11
-{% block main %}
12
-<aside class="author">
13
-	<article class="h-card card p-author">
14
-		<a class="u-uid u-url" href="{{ uri }}">
15
-		{% if user.avatar %}<img class="card-img-top u-photo" src="{{ user.avatar.url }}" alt="{{ user.first_name }} {{ user.last_name }}" />{% endif %}
16
-		</a>
17
-
18
-		<div class="card-body">
19
-			<h4 class="card-title p-name">
20
-				<span class="p-given-name">{{ user.first_name }}</span> <span class="p-family-name">{{ user.last_name }}</span>
21
-			</h4>
22
-			{% if user.note %}<div class="p-note">{{ user.note | markdown }}</div>{% endif %}
23
-		</div>
24
-
25
-		<div class="card-footer">
26
-			<ul class="profiles">
27
-				<li><a class="u-email" rel="me" href="mailto:{{ user.email }}">
28
-						<i class="fas fa-envelope"></i> {{ user.email }}
29
-				</a></li>
30
-				{% if user.xmpp %}<li><a class="u-impp" rel="me" href="xmpp:{{ user.xmpp }}">
31
-						<i class="openwebicons-xmpp" aria-hidden="true"></i> {{ user.xmpp }}
32
-				</a></li>{% endif %}
33
-			</ul>
34
-		</div>
35
-
36
-		{% if user.keys.exists %}<div class="card-footer">
37
-			<ul class="profiles">
38
-				{% for key in user.keys.all %}<li>
39
-					<a class="u-key" href="{{ key.file.url }}">
40
-						<i class="fas fa-key"></i> {{ key.pretty_print }}
41
-					</a>
42
-				</li>
43
-				{% endfor %}
44
-			</ul>
45
-		</div>{% endif %}
46
-
47
-		{% if user.profiles.exists %}<div class="card-footer">
48
-			<ul class="profiles">
49
-				{% for profile in user.profiles.all %}<li>
50
-					<a class="u-url" rel="me" href="{{ profile.url }}" title="{{ profile }}"><i class="{{ profile.site.icon }}" aria-hidden="true"></i><span class="sr-only">{{ profile }}</span></a>
51
-				</li>{% endfor %}
52
-			</ul>
53
-		</div>{% endif %}
54
-
55
-		<script class="p-json-ld" type="application/ld+json">{{ user.json_ld | jsonify }}</script>
56
-	</article>
57
-</aside>
58
-<ol class="list-unstyled entries">
59
-	{% for entry in entries %}
60
-	<li>
61
-		{% include 'entries/h-entry.html' %}
62
-	</li>
63
-	{% endfor %}
64
-</ol>
65
-{% endblock %}
66
-{% block foot %}
67
-<script type="text/javascript">
68
-	tippy('.profiles [title]', {arrow: true});
69
-</script>
70
-{% endblock %}

+ 35
- 0
lemoncurry/jinja2/lemoncurry/layout.html View File

@@ -81,6 +81,41 @@
81 81
 
82 82
     <footer>
83 83
       <p>all content licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">cc by-sa 4.0</a></p>
84
+      {% if entries is defined and entries.has_other_pages() %}
85
+
86
+      <nav>
87
+        <ul class="pagination">
88
+          {% if entries.prev %}
89
+          <li class="page-item">
90
+            <a class="page-link" rel="prev" href="{{ entries.prev.url }}">
91
+              <i class="fas fa-step-backward" aria-hidden="true"></i> <span class="sr-only">previous page</span>
92
+            </a>
93
+          </li>
94
+
95
+          {% endif %}
96
+          {% for page in entries.pages %}
97
+          {% if page.current %}
98
+          <li class="page-item active">
99
+            <span class="page-link">{{ page.i }} <span class="sr-only">(current page)</span></span>
100
+          </li>
101
+          {% else %}
102
+          <li class="page-item">
103
+            <a class="page-link" href="{{ page.url }}">{{ page.i }}</a>
104
+          </li>
105
+          {% endif %}
106
+          {% endfor %}
107
+          {% if entries.next %}
108
+
109
+          <li class="page-item">
110
+            <a class="page-link" rel="next" href="{{ entries.next.url }}">
111
+              <i class="fas fa-step-forward" aria-hidden="true"></i> <span class="sr-only">next page</span>
112
+            </a>
113
+          </li>
114
+          {% endif %}
115
+        </ul>
116
+      </nav>
117
+
118
+      {% endif %}
84 119
       <p>powered by <a rel="code-repository" href="{{ package.repository }}/src/tag/v{{ package.version }}">{{ package.name }} {{ package.version }}</a></p>
85 120
     </footer>
86 121
 

+ 0
- 134
lemoncurry/templates/lemoncurry/layout.html View File

@@ -1,134 +0,0 @@
1
-{% load analytical compress favicon lemoncurry_tags meta static theme_colour %}<!doctype html>
2
-<html dir="ltr" lang="en" class="{% block html_class %}{% endblock %}">
3
-	<head{% meta_namespaces %}>{% site_name as site_name %}{% request_uri request as uri %}{% request_origin request as origin %}
4
-		<meta charset="utf-8" />
5
-		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6
-
7
-		<base href="{{ origin }}" />
8
-		<link rel="canonical" href="{{ uri }}" />
9
-		<title class="p-name">{% if title %}{{ title }} ~ {% endif %}{{ site_name }}</title>
10
-
11
-		{% analytical_head_top %}
12
-		{% if atom %}<link rel="alternate" type="application/atom+xml" href="{{ atom }}" />{% endif %}
13
-		{% if rss %}<link rel="alternate" type="application/rss+xml" href="{{ rss }}" /> {% endif %}
14
-		{% block head %}{% endblock %}
15
-
16
-		<link rel="authorization_endpoint" href="{{ origin }}{% url 'lemonauth:indie' %}" />
17
-		<link rel="token_endpoint" href="{{ origin }}{% url 'lemonauth:token' %}" />
18
-		<link rel="micropub" href="{{ origin }}{% url 'micropub:micropub' %}" />
19
-		<link rel="openid.delegate" href="{{ uri }}" />
20
-		<link rel="openid.server" href="https://openid.indieauth.com/openid" />
21
-
22
-		<link rel="hub" href="{% get_push_hub %}" />
23
-		<link rel="self" href="{{ uri }}" />
24
-
25
-		<link rel="manifest" href="{% url 'wellknowns:manifest' %}" />
26
-		<meta name="theme-color" content="{% theme_colour 2 %}" />
27
-		{% get_package_json as package %}
28
-		<meta name="generator" content="{{ package.name }} {{ package.version }}" />
29
-
30
-		<meta property="og:url" content="{{ uri }}" />
31
-		<meta property="og:title" content="{% firstof title site_name %}" />
32
-		{% include 'meta/meta.html' %}
33
-		{% get_favicons 'favicon/' %}
34
-
35
-		<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
36
-					integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous" />
37
-		<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai.min.css"
38
-					integrity="sha384-bHqbpRh/XW+phptvH9nQvMKHwPH1ZbOxpIeAB2D2OIEL4Ni7aZzZgMFpsRra+v1g" crossorigin="anonymous" />
39
-		<link rel="stylesheet" type="text/css" href="https://unpkg.com/openwebicons@1.4.3/css/openwebicons.min.css"
40
-					integrity="sha384-Ljk0G9f8GyEhAzrdHNkQc89A/Kpq+sy09gejdAPyMyTDnPe4aDfS/ppZ/rDGM0Y9" crossorigin="anonymous" />
41
-		<link rel="stylesheet" type="text/css" href="https://unpkg.com/tippy.js@2.5.2/dist/tippy.css"
42
-					integrity="sha384-JsezPuW/bNd38848K5/8rIEbB+23QGQ8faCF8xEmjFT3i1qujgGiewfYevzMO3J1" crossorigin="anonymous" />
43
-		{% compress css %}
44
-		<link rel="stylesheet" type="text/stylus" href="{% static 'lemoncurry/css/layout.styl' %}" />
45
-		{% block styles %}{% endblock %}
46
-		{% endcompress %}
47
-		<script type="text/javascript" defer src="https://use.fontawesome.com/releases/v5.0.13/js/all.js"
48
-						integrity="sha384-xymdQtn1n3lH2wcu0qhcdaOpQwyoarkgLVxC/wZ5q7h9gHtxICrpcaSUfygqZGOe" crossorigin="anonymous"></script>
49
-		{% analytical_head_bottom %}
50
-	</head>
51
-	<body{% block body_attr %}{% endblock %}>
52
-		{% analytical_body_top %}
53
-		<header>
54
-			<nav class="navbar navbar-expand-md navbar-dark">
55
-				<a class="navbar-brand" rel="home" href="{% url 'home:index' %}">{% site_name %}</a>
56
-				<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"
57
-								aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
58
-					<span class="navbar-toggler-icon"></span>
59
-				</button>
60
-
61
-				<div class="collapse navbar-collapse" id="navbar">
62
-					{% block nav_left %}{% nav_left request %}{% endblock %}
63
-					{% block nav_right %}{% nav_right request %}{% endblock %}
64
-				</div>
65
-			</nav>
66
-			{% if request.resolver_match.view_name %}
67
-			{% nav_crumbs request.resolver_match %}
68
-			{% endif %}
69
-		</header>
70
-
71
-		<main>
72
-			{% block main %}{% endblock %}
73
-		</main>
74
-
75
-		<footer>
76
-			<p>all content licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">cc by-sa 4.0</a></p>
77
-
78
-			{% if entries.has_other_pages %}
79
-			<nav>
80
-				<ul class="pagination">
81
-					{% if entries.prev %}
82
-					<li class="page-item">
83
-						<a class="page-link" rel="prev" href="{{ entries.prev.url }}">
84
-							<i class="fas fa-step-backward"></i><span class="sr-only">previous page</span>
85
-						</a>
86
-					</li>
87
-					{% endif %}
88
-
89
-					{% for page in entries.pages %}
90
-					{% if page.current %}
91
-					<li class="page-item active">
92
-						<span class="page-link">{{ page.i }} <span class="sr-only">(current page)</span></span>
93
-					</li>
94
-					{% else %}
95
-					<li class="page-item">
96
-						<a class="page-link" href="{{ page.url }}">{{ page.i }}</a>
97
-					</li>
98
-					{% endif %}
99
-					{% endfor %}
100
-
101
-					{% if entries.next %}
102
-					<li class="page-item">
103
-						<a class="page-link" rel="next" href="{{ entries.next.url }}">
104
-							<i class="fas fa-step-forward"></i><span class="sr-only">next page</span>
105
-						</a>
106
-					</li>
107
-					{% endif %}
108
-				</ul>
109
-			</nav>
110
-			{% endif %}
111
-
112
-			<p>powered by <a rel="code-repository" href="{{ package.repository }}/src/tag/v{{ package.version }}">{{ package.name }} {{ package.version }}</a></p>
113
-		</footer>
114
-
115
-		<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" crossorigin="anonymous"
116
-						integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"></script>
117
-		<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" crossorigin="anonymous"
118
-						integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"></script>
119
-		<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" crossorigin="anonymous"
120
-						integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"></script>
121
-		<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" crossorigin="anonymous"
122
-						integrity="sha384-ZeLYJ2PNSQjvogWP559CDAf02Qb8FE5OyQicqtz/+UhZutbrwyr87Be7NPH/RgyC"></script>
123
-		<script src="https://unpkg.com/tippy.js@2.5.2/dist/tippy.standalone.min.js" crossorigin="anonymous"
124
-						integrity="sha384-VEMCz3fC5atUNN+ezSHq2AZIBciT3aWGEZsStnW58gtO9PYb3wenWsYNoxLTbi/M"></script>
125
-
126
-		{% compress js %}
127
-		<script type="text/javascript">
128
-			hljs.initHighlightingOnLoad();
129
-		</script>
130
-		{% block foot %}{% endblock %}
131
-		{% endcompress %}
132
-		{% analytical_body_bottom %}
133
-	</body>
134
-</html>

+ 0
- 11
lemoncurry/templates/lemoncurry/tags/breadcrumbs.html View File

@@ -1,11 +0,0 @@
1
-{% load jsonify %}{% if crumbs %}
2
-<nav class="breadcrumbs" aria-label="breadcrumb" role="navigation">
3
-	<ol class="breadcrumb">
4
-		{% for crumb in crumbs %}
5
-		<li class="breadcrumb-item"><a href="{{ crumb.url }}">{{ crumb.label }}</a></li>
6
-		{% endfor %}
7
-		<li class="breadcrumb-item active" aria-current="page">{% firstof current.label title %}</li>
8
-	</ol>
9
-	<script type="application/ld+json">{{ breadcrumb_list | jsonify }}</script>
10
-</nav>
11
-{% endif %}

+ 0
- 8
lemoncurry/templates/lemoncurry/tags/nav.html View File

@@ -1,8 +0,0 @@
1
-{% load activeurl %}{% activeurl %}<ul class="navbar-nav">
2
-	{% for item in items %}
3
-	<li class="nav-item"><a class="nav-link" href="{{ item.url }}">
4
-			<i class="{{ item.icon }} fa-fw"></i>
5
-			{{ item.label }}
6
-	</a></li>
7
-	{% endfor %}
8
-</ul>{% endactiveurl %}

Loading…
Cancel
Save