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