Skip to content

Commit 103c9de

Browse files
committed
Added author full name, bio, gravatar to blog authors.
1 parent 600611c commit 103c9de

File tree

57 files changed

+135
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+135
-60
lines changed

.lektorproject

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ lektor-google-analytics = 0.1.3
1212
lektor-webpack-support = 0.5
1313
lektor-atom = 0.3
1414
lektor-disqus-comments = 0.4.1
15+
lektor-gravatar = 0.1.2

content/archives/old-tech-blog/entries/contents.lr

+2
+3-1
+3-1
+3-1
+3-1
+3-1
+3-1
+8-1
+3-1
+3-1

content/blog/entries/Pipfile

Whitespace-only changes.

content/blog/entries/meet-gsoc-2019-students/contents.lr

+1-1

models/author.ini

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
[model]
22
name = Author
3-
label = {{ this.name }}
3+
label = {{ this.username }}
44
hidden = yes
55

66
[children]
77
replaced_with = site.query(this.parent.parent.path + '/entries').filter(F.author.contains(this))
88

9+
[fields.username]
10+
label = Username
11+
type = string
12+
913
[fields.name]
1014
label = Name
1115
type = string
16+
17+
[fields.email]
18+
label = Email
19+
type = string
20+
21+
[fields.about]
22+
label = About
23+
type = markdown

models/authors.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ protected = yes
66

77
[children]
88
model = author
9-
order_by = name
9+
order_by = name,username

models/blog-post.ini

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ width = 1/2
1919

2020
[fields.author]
2121
label = Author
22-
type = string
22+
type = select
23+
// TODO: this is far too opaque, fix this. basically it's finding authors by
24+
// going up to entries.blog, then getting everything in
25+
// the blog.authors.<author name> files
26+
source = record.parent.parent.children.get('authors').children.all()
2327
2428
[fields.body]
2529
label = Body

templates/author.html

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
{% extends "layout.html" %}
2+
23
{% from "macros/posts.html" import render_posts %}
3-
{% block title %}{{ this.name + ' - ' + this.parent.parent.children.get('entries').title }}{% endblock %}
4+
{% from "macros/author_name.html" import render_author_name %}
5+
6+
{% block title %}{{ render_author_name(this) + ' - ' + this.parent.parent.children.get('entries').title }}{% endblock %}
47
{% block header %}{{ this.parent.parent.children.get('entries').title }}{% endblock %}
58
{% block body %}
6-
<h2>Posts by {{ this.name }}</h2>
9+
<h2>{{ render_author_name(this) }}</h2>
10+
{% if this.about %}
11+
{% if this.email %}
12+
<img src="{{ this.email|gravatar }}size=120" alt="gravatar" style="float:right;" class="p-2" />
13+
{% endif %}
14+
{{ this.about }}
15+
{% endif %}
16+
<h3>Posts</h3>
717
{{ render_posts(this.children) }}
8-
<hr>
9-
<strong><a href="{{ this.parent.path }}">All Authors</a></strong>
18+
<hr/>
19+
<p class="text-muted"><strong><a href="{{ this.parent|url }}">All Authors</a></strong></p>
1020
{% endblock %}

templates/blog-post.html

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{% extends "layout.html" %}
2+
3+
{% from "macros/author_name.html" import render_author_name %}
4+
5+
{% set author = this.parent.parent.children.get('authors').children.get(this.author) %}
6+
27
{% block title %}{{ this.title }}{% endblock %}
38
{% block header %}{{ this.parent.title }}{% endblock %}
49
{% block body %}
510
<h2 class="mb-0">{{ this.title }}</h2>
611
{{ check_file('content' + this.parent.parent.path + '/authors/' + this.author + '/contents.lr') }}
7-
<p class="meta text-muted mt-0">by <a href="{{ this.parent.parent.children.get('authors').path + '/' + this.author }}">{{ this.author }}</a>
8-
on {{ this.pub_date|dateformat('EEEE, yyyy ''MMMM d') }}</p>
12+
<p class="meta text-muted mt-0">by <a href="{{ author|url }}">{{ render_author_name(author) }}</a>
13+
on {{ this.pub_date|dateformat('EEEE, yyyy-''MM-d') }}</p>
914
<div class="body">{{ this.body }}</div>
1015
<div class="card bg-light">
1116
<div class="card-body p-2">

templates/blog.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{% extends "layout.html" %}
2+
23
{% from "macros/pagination.html" import render_pagination %}
34
{% from "macros/posts.html" import render_posts %}
5+
46
{% block title %}{{ this.title }}{% endblock %}
57
{% block body %}
68
{{ this.description }}

templates/macros/author_name.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% macro render_author_name(author) %}
2+
{% if author.name %}{{ author.name }}{% else %}{{ author.username }}{% endif %}
3+
{% endmacro %}

templates/macros/authors.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
{% from "macros/author_name.html" import render_author_name %}
2+
13
{% macro render_authors(authors) %}
24
<ul class="list-inline">
35
{% for author in site.query(authors.path) %}
4-
<li class="list-inline-item"><a href="{{ author|url }}">{{ author.name }}</a></li>
6+
<li class="list-inline-item"><a href="{{ author|url }}">{{ render_author_name(author) }}</a></li>
57
{% endfor %}
68
</ul>
79
{% endmacro %}

templates/macros/posts.html

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
{% from "macros/author_name.html" import render_author_name %}
2+
13
{% macro render_posts(posts) %}
24
<ul class="blog-index list-unstyled">
35
{% for post in posts %}
4-
<li>
5-
<a href="{{ post|url }}">{{ post.title }}</a>
6-
<p class="text-muted small">by <a href="{{ post.parent.parent.children.get('authors').path + '/' + post.author }}">{{ post.author }}</a>
7-
on {{ post.pub_date|dateformat("YYYY-MM-dd") }}</p>
8-
</li>
6+
{% set author = post.parent.parent.children.get('authors').children.get(post.author) %}
7+
<li>
8+
<a href="{{ post|url }}">{{ post.title }}</a>
9+
<p class="text-muted small">by <a href="{{ author|url }}">{{ render_author_name(author) }}</a>
10+
on {{ post.pub_date|dateformat("YYYY-MM-dd") }}</p>
11+
</li>
912
{% endfor %}
1013
</ul>
1114
{% endmacro %}

0 commit comments

Comments
 (0)