Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Menu
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kaushal Modi
hugo-theme-refined
Commits
f2ed84a1
Commit
f2ed84a1
authored
Mar 26, 2018
by
Kaushal Modi
Browse files
Parse comments from Disqus JSON (converted from xml)
parent
4af1ce7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
layouts/partials/disqus-json.html
0 → 100644
View file @
f2ed84a1
<!-- 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 }}
layouts/partials/webmention_rcv.html
View file @
f2ed84a1
<!-- 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
<a
class=
"headline-hash"
href=
"#comments"
>
#
</a>
</h2>
<!-- Show comments from Disqus-exported archive. -->
{{ partial "disqus-json.html" $page }}
{{ end }}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment