Commit 398ea39e authored by Jamie Tanna's avatar Jamie Tanna

Render sent webmentions

Now I've connected Brid.gy and am starting to get more interactions with
Webmentions, I need to start displaying these Webmentions for site
viewers to see.

For likes, we should render a facepile[0] because it doesn't matter as
much how they've liked, just that they have.

However for other webmentions, we do want to have a list of the author
and a link to the webmention.

For each of the webmentions, we want a separate partial that can be
composed easily.

Additionally, we can the partial's context to render a slice of
webmentions.

Part of jvt.me#352.

[0]: https://indieweb.org/facepile
parent 4b1408f7
......@@ -11,3 +11,4 @@
@import 'tale/talk';
@import 'tale/divider';
@import 'tale/microformats';
@import 'tale/webmentions';
.webmentions {
.facepile {
img {
display: inline-block;
height: 32px;
margin: 0;
width: 32px;
}
}
.likes {
ul li {
display: inline-block;
list-style: none;
}
}
}
......@@ -56,6 +56,7 @@
{{ end }}
{{- end -}}
{{ partial "webmention.html" . }}
</div>
<div class="pagination">
......
{{ $url := printf "%s%s" .Site.Params.LiveSiteUrl .URL }}
{{ $webmentions := getJSON (printf .Site.Params.WebMentionFormatUrl $url) }}
{{ if gt (len $webmentions.children) 0 }}
{{ $likes := slice }}
{{ $reposts := slice }}
{{ $replies := slice }}
{{ $mentions := slice }}
{{ $bookmarks := slice }}
{{ $rsvps := slice }}
{{ range $webmentions.children }}
{{ if eq "like-of" (index . "wm-property") }}
{{ $likes = $likes | append . }}
{{ end }}
{{ if eq "repost-of" (index . "wm-property") }}
{{ $reposts = $reposts | append . }}
{{ end }}
{{ if eq "in-reply-to" (index . "wm-property") }}
{{ $replies = $replies | append . }}
{{ end }}
{{ if eq "mention-of" (index . "wm-property") }}
{{ $mentions = $mentions | append . }}
{{ end }}
{{ if eq "bookmark-of" (index . "wm-property") }}
{{ $bookmarks = $bookmarks | append . }}
{{ end }}
{{ if eq "rsvp" (index . "wm-property") }}
{{ $rsvps = $rsvps | append . }}
{{ end }}
{{ end }}
<div class="webmentions">
<h2>Interactions with this post</h2>
<p>This post has had {{ len $webmentions.children }} <a href="http://indieweb.org/webmention">WebMention</a> interactions, as of {{ now.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}.</p>
{{ partial "webmention/likes.html" $likes }}
{{ partial "webmention/mentions.html" $mentions }}
{{ partial "webmention/reposts.html" $reposts }}
{{ partial "webmention/replies.html" $replies }}
{{ partial "webmention/bookmarks.html" $bookmarks }}
{{ partial "webmention/rsvps.html" $rsvps }}
</div>
{{ end }}
{{ if gt (len .) 0 }}
<div class="bookmarks">
<h3>Bookmarks</h3>
<ul>
{{ range . }}
<li>
<a href="{{ .author.url }}">{{ .author.name }}</a> bookmarked this post in <a href="{{ .url }}">{{ .url }}</a> on {{ dateFormat "02 January 2006" .published }}.
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ if gt (len .) 0 }}
<div class="likes">
<h3>Likes</h3>
<ul class="facepile">
{{ range . }}
<li>
<a href="{{ .url }}">
<img src=" {{ .author.photo }}" alt="{{ .author.name }}'s photo" />
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ if gt (len .) 0 }}
<div class="mentions">
<h3>Mentions</h3>
<ul>
{{ range . }}
<li>
<a href="{{ .author.url }}">{{ .author.name }}</a> mentioned this post at <a href="{{ .url }}">{{ .url }}</a> on {{ dateFormat "02 January 2006" .published }}.
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ if gt (len .) 0 }}
<div class="replies">
<h3>Replies</h3>
<ul>
{{ range . }}
<li>
<a href="{{ .author.url }}">{{ .author.name }}</a> wrote a reply to this post at <a href="{{ .url }}">{{ .url }}</a> on {{ dateFormat "02 January 2006" .published }}.
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ if gt (len .) 0 }}
<div class="reposts">
<h3>Reposts</h3>
<ul>
{{ range . }}
<li>
<a href="{{ .author.url }}">{{ .author.name }}</a> reposted this at <a href="{{ .url }}">{{ .url }}</a> on {{ dateFormat "02 January 2006" .published }}.
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ if gt (len .) 0 }}
<div class="rsvps">
<h3>RSVPs</h3>
<ul>
{{ range . }}
<li>
<a href="{{ .author.url }}">{{ .author.name }}</a> RSVP'd <code>{{ .rsvp }}</code> to this event <a href="{{ .url }}">{{ .url }}</a> on {{ dateFormat "02 January 2006" .published }}.
</li>
{{ end }}
</ul>
</div>
{{ end }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment