Experimental support for webmentions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Yarmo Mackenbach 2020-06-16 00:54:04 +02:00
parent 8640d5764c
commit dcdaa3fc25
5 changed files with 70 additions and 0 deletions

View File

@ -58,6 +58,11 @@ function getBlogPosts($params) {
continue;
}
if (isset($params['slug'])) {
$post["webmentions"] = getWebmentions($post["url"]);
$post["hasWebmentions"] = count($post["webmentions"]) > 0;
}
$posts[] = $post;
}
@ -104,6 +109,11 @@ function getNotes($params) {
continue;
}
if (isset($params['slug'])) {
$post["webmentions"] = getWebmentions($post["url"]);
$post["hasWebmentions"] = count($post["webmentions"]) > 0;
}
$posts[] = $post;
}
@ -150,12 +160,29 @@ function getProjects($params) {
continue;
}
if (isset($params['slug'])) {
$project["webmentions"] = getWebmentions($post["url"]);
$project["hasWebmentions"] = count($project["webmentions"]) > 0;
}
$projects[] = $project;
}
return $projects;
}
function getWebmentions($target) {
$data json_decode(file_get_contents("https://webm.yarmo.eu/get?target=$target"), true);
foreach ($data as $id => $entry) {
$time = strtotime($entry["created_at"]);
$data[$id]["date"] = date("Y-m-d",$time);
$data[$id]["time"] = date("H:i:s",$time);
}
return $data;
}
function getFOSS() {
return Yaml::parseFile('content/foss/foss.yaml');
}

View File

@ -307,6 +307,10 @@ table.music th:nth-child(3) {
font-style: normal;
font-size: 90%;
}
.webmentions {
margin: 64px 0 0;
border-top: 3px dashed rgba(0,0,0,0.5);
}
/* Lists */
.list {

View File

@ -1,5 +1,10 @@
extends layout
mixin webmention($item)
p
a(href="{$item['source']}") !{$item['title']}
| by !{$item['author_name']} on !{$item['date']} at !{$item['time']}
block content
header
nav
@ -19,3 +24,11 @@ block content
.longform__content.e-content
| !{$post['content']}
.webmentions
h2 Webmentions
if ($post['hasWebmentions'])
each $item in $post["webmentions"]
+webmention($item)
else
p This post has not been mentioned yet.

View File

@ -1,5 +1,10 @@
extends layout
mixin webmention($item)
p
a(href="{$item['source']}") !{$item['title']}
| by !{$item['author_name']} on !{$item['date']} at !{$item['time']}
block content
header
nav
@ -19,3 +24,11 @@ block content
.longform__content.e-content
| !{$post['content']}
.webmentions
h2 Webmentions
if ($post['hasWebmentions'])
each $item in $post["webmentions"]
+webmention($item)
else
p This post has not been mentioned yet.

View File

@ -1,5 +1,10 @@
extends layout
mixin webmention($item)
p
a(href="{$item['source']}") !{$item['title']}
| by !{$item['author_name']} on !{$item['date']} at !{$item['time']}
block content
header
nav
@ -17,3 +22,11 @@ block content
p.longform__header
.longform__content
| !{$project['content']}
.webmentions
h2 Webmentions
if ($project['hasWebmentions'])
each $item in $project["webmentions"]
+webmention($item)
else
p This project has not been mentioned yet.