Commit f2ed84a1 authored by Kaushal Modi's avatar Kaushal Modi
Browse files

Parse comments from Disqus JSON (converted from xml)

parent 4af1ce7a
<!-- Reads Old Disqus comments saved as JSON file.-->
<!-- The Disqus comments were first exported from disqus.com, which you receive in email as an xml file.
This JSON file was converted from xml using http://www.utilities-online.info/xmltojson/.
-->
{{ $page := . }}
{{ with .Site.Data.disqus_comments.disqus }}
{{ $threads := (index . "thread") }}
{{ $comments := (index . "post") }}
{{ range $threads }}
{{ $thread := . }}
{{ $thread_link := (index $thread "link") | replaceRE "^https?://scripter.co" "" }}
{{ if (eq $thread_link $page.RelPermalink) }}
{{/* partial "debugprint.html" $thread */}}
{{ $thread_id := (index $thread "-dsq:id") }}
{{ range $comments }}
{{ $comment := . }}
{{ $comment_thread_id := (index (index $comment "thread") "-dsq:id") }}
{{ if (eq $comment_thread_id $thread_id) }}
{{/* partial "debugprint.html" $comment */}}
{{ $comment_author_obj := (index . "author") }}
{{ $comment_author_name := (index $comment_author_obj "name") }}
{{ $comment_string := (index $comment "message") }}
{{ $comment_parent := (index $comment "parent") }}
{{ $comment_date := (index $comment "createdAt") | replaceRE "T.*" "" | dateFormat "Mon Jan 2, 2006" }}
<dl class="disqus comment">
<dt>
Comment by {{ $comment_author_name }} on {{ $comment_date }}
</dt>
<dd>
{{ if $comment_parent }}
{{ $parent_comment_id := (index $comment_parent "-dsq:id") }}
{{ range $comments }}
{{ $comment_id := (index . "-dsq:id") }}
{{ if (eq $comment_id $parent_comment_id) }}
{{ $parent_comment_author := (index (index . "author") "name") }}
{{ $parent_comment_snippet := (index . "message") | plainify | truncate 35 }}
<em>Replying to comment by {{ $parent_comment_author }}: "{{- $parent_comment_snippet | safeHTML }}"</em>
{{ end }}
{{ end }}
{{ end }}
{{ $comment_string | safeHTML }}
</dd>
</dl>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
<!-- https://github.com/aaronpk/webmention.io#api -->
<!-- https://github.com/aaronpk/webmention.io#find-links-of-a-specific-type-to-a-specific-page -->
{{ $page := . }}
{{ $domain := "https://scripter.co" }} <!-- Hard-code the domain during testing on localhost, branches -->
{{ $num_mentions_max := 200 }}
{{ $webmentions_rcv := getJSON (printf "https://webmention.io/api/mentions?target=%s%s&per-page=%d&page=0" $domain .RelPermalink $num_mentions_max) }}
......@@ -59,6 +60,11 @@
{{ $activity }}
{{ end }}
{{ end }}
<!-- Show comments from Disqus-exported archive. -->
{{ partial "disqus-json.html" $page }}
<!-- Likes count -->
{{ if (ge ($.Scratch.Get "__like_cnt") 1) }}
<span class="like">
<span class="icon">
......@@ -69,6 +75,8 @@
</span>
</span>
{{ end }}
<!-- Retweets/reposts count -->
{{ if (ge ($.Scratch.Get "__repost_cnt") 1) }}
<span class="retweet">
<span class="icon">
......@@ -79,4 +87,8 @@
</span>
</span>
{{ end }}
{{ else }}
<h2 id="comments">Comments&nbsp;<a class="headline-hash" href="#comments">#</a> </h2>
<!-- Show comments from Disqus-exported archive. -->
{{ partial "disqus-json.html" $page }}
{{ end }}
Supports Markdown
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