Commit 1f2f99ef authored by Kaushal Modi's avatar Kaushal Modi

Support link-only mentions where the author_obj is nil

parent 863536c9
......@@ -35,69 +35,82 @@
{{ $activity_type := (index $activity "type") }}
{{ $data := (index $wm "data") }}
{{/* partial "debugprint.html" $data */}}
{{ $author_obj := (index $data "author") }}
{{ $author_name := (index $author_obj "name") }}
{{ $author_photo := (index $author_obj "photo") }}
{{ $author_url := (index $author_obj "url") }}
{{ $mention_content := (index $data "content") }}
{{ $mention_url := (index $data "url") }}
{{ $mention_content := (index $data "content") }}
{{ with (index $data "published") }}
{{ $.Scratch.Set "__published_date" ((time .).Local | dateFormat "Mon Jan 2, 2006") }}
{{ end }}
{{ with (index $wm "verified_date") }} <!-- Webmention received date -->
{{ $.Scratch.Set "__verified_date" ((time .).Local | dateFormat "Mon Jan 2, 2006 15:04 MST") }}
{{ end }}
{{ if (eq $activity_type "reply") }}
{{/* partial "debugprint.html" $data */}}
<dl class="webmention comment">
<dt>
Comment by <a href="{{ $author_url }}" class="no-text-decoration">{{ $author_name }}</a>
{{ printf `<a href="%s" class="no-text-decoration">` $mention_url | safeHTML }}
{{ with $.Scratch.Get "__verified_date" }}on {{ . }}{{ end }}
{{ printf "</a>" | safeHTML }}
</dt>
<dd>
{{ if (findRE "^https://commentpara\\.de" $mention_url) }} <!-- Webmentions originated from commentpara.de -->
<!--
- Remove the HTML line-breaks, else the markdown code blocks won't work.
- commentpara.de transmits the data encoded in HTML. So the markdown blockquote
markers ">" would get converted to "&gt;", so convert them back to ">".
-->
{{ $mention_content | replaceRE "<br />" "" | replaceRE "(^|\\n)&gt; " "\n> " | replaceRE " -&gt; " " -> " | replaceRE " &lt;- " " <- " | markdownify | safeHTML }}
{{ else }} <!-- Webmentions originated from elsewhere like someone's site. -->
{{ $mention_content | safeHTML }}
{{ end }}
</dd>
</dl>
{{ else if (eq $activity_type "link") }}
{{/* partial "debugprint.html" $wm */}}
<dl class="webmention mention">
<dt>
Mentioned by <a href="{{ $author_url }}" class="no-text-decoration">{{ $author_name }}</a>
{{ printf `<a href="%s" class="no-text-decoration">` $mention_url | safeHTML }}
{{ with $.Scratch.Get "__verified_date" }}on {{ . }}{{ end }}
{{ printf "</a>" | safeHTML }}
</dt>
<dd>
{{ $mention_title := (index $data "name") }}
{{ with $mention_title }}
{{ printf `<strong><a href="%s">%s</a></strong>` $mention_url . | safeHTML }}<br />
{{ with $.Scratch.Get "__published_date" }}—Published on {{ . }}{{ end }}
<hr />
{{ end }}
<!-- Limit the mention content to 250 characters. -->
{{ $mention_content | safeHTML | truncate 250 }}
</dd>
</dl>
{{ else if (eq $activity_type "like") }}
{{ $.Scratch.Add "__like_cnt" 1 }}
{{ else if (eq $activity_type "repost") }}
{{ $.Scratch.Add "__repost_cnt" 1 }}
{{ $author_obj := (index $data "author") }}
{{ with $author_obj }}
{{ $author_name := (index . "name") }}
{{ $author_photo := (index . "photo") }}
{{ $author_url := (index . "url") }}
{{ if (eq $activity_type "reply") }}
{{/* partial "debugprint.html" $data */}}
<dl class="webmention comment">
<dt>
Comment by <a href="{{ $author_url }}" class="no-text-decoration">{{ $author_name }}</a>
{{ printf `<a href="%s" class="no-text-decoration">` $mention_url | safeHTML }}
{{ with $.Scratch.Get "__verified_date" }}on {{ . }}{{ end }}
{{ printf "</a>" | safeHTML }}
</dt>
<dd>
{{ if (findRE "^https://commentpara\\.de" $mention_url) }} <!-- Webmentions originated from commentpara.de -->
<!--
- Remove the HTML line-breaks, else the markdown code blocks won't work.
- commentpara.de transmits the data encoded in HTML. So the markdown blockquote
markers ">" would get converted to "&gt;", so convert them back to ">".
-->
{{ $mention_content | replaceRE "<br />" "" | replaceRE "(^|\\n)&gt; " "\n> " | replaceRE " -&gt; " " -> " | replaceRE " &lt;- " " <- " | markdownify | safeHTML }}
{{ else }} <!-- Webmentions originated from elsewhere like someone's site. -->
{{ $mention_content | safeHTML }}
{{ end }}
</dd>
</dl>
{{ else if (eq $activity_type "link") }}
{{/* partial "debugprint.html" $wm */}}
<dl class="webmention mention">
<dt>
Mentioned by <a href="{{ $author_url }}" class="no-text-decoration">{{ $author_name }}</a>
{{ printf `<a href="%s" class="no-text-decoration">` $mention_url | safeHTML }}
{{ with $.Scratch.Get "__verified_date" }}on {{ . }}{{ end }}
{{ printf "</a>" | safeHTML }}
</dt>
<dd>
{{ $mention_title := (index $data "name") }}
{{ with $mention_title }}
{{ printf `<strong><a href="%s">%s</a></strong>` $mention_url . | safeHTML }}<br />
{{ with $.Scratch.Get "__published_date" }}—Published on {{ . }}{{ end }}
<hr />
{{ end }}
<!-- Limit the mention content to 250 characters. -->
{{ $mention_content | safeHTML | truncate 250 }}
</dd>
</dl>
{{ else if (eq $activity_type "like") }}
{{ $.Scratch.Add "__like_cnt" 1 }}
{{ else if (eq $activity_type "repost") }}
{{ $.Scratch.Add "__repost_cnt" 1 }}
{{ else }}
{{ $activity }}
{{ end }}
{{ else }}
{{ $activity }}
{{ end }}
{{ end }} <!-- ends the range within "with $webmentions_rcv.links" -->
{{ end }} <!-- ends "with $webmentions_rcv.links" -->
{{ with $mention_url }}
<dl class="webmention mention">
<dt>
Mentioned at
</dt>
<dd>
{{ printf `<a href="%s" class="no-text-decoration">%s</a>` . . | safeHTML }}
</dd>
</dl>
{{ end }}
{{ end }} <!-- ends "with $author_obj"-->
{{ end }} <!-- ends the range within "with $webmentions_rcv.links" -->
{{ end }} <!-- ends "with $webmentions_rcv.links" -->
<!-- Show comments from Disqus-exported archive. -->
{{ partial "disqus-json.html" $page }}
......
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