Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
I
ikiwiki-bootstrap-anarcat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Beaupré
ikiwiki-bootstrap-anarcat
Commits
491dd6bf
Verified
Commit
491dd6bf
authored
2 years ago
by
Antoine Beaupré
Browse files
Options
Downloads
Patches
Plain Diff
import mastodon comment templates from Carl Schwan
Source:
https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/
CC-BY-SA
parent
b9ce78bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
LICENSE
+4
-0
4 additions, 0 deletions
LICENSE
templates/page.tmpl
+64
-7
64 additions, 7 deletions
templates/page.tmpl
with
68 additions
and
7 deletions
LICENSE
+
4
−
0
View file @
491dd6bf
The Mastodon comments mechanism is by Carl Schwan CC-BY-SA:
https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/
The file in templates/, bootstrap.min.css, bootstrap.min.js, and local.css
are derived from bootstrap. They and all remaining files are licensed under
the MIT license:
...
...
This diff is collapsed.
Click to expand it.
templates/page.tmpl
+
64
−
7
View file @
491dd6bf
...
...
@@ -123,19 +123,76 @@
</TMPL_IF>
<TMPL_UNLESS
DYNAMIC
>
<!-- legacy Ikiwiki comments.pm section -->
<TMPL_IF
COMMENTS
>
<TMPL_IF
HTML5
><section
id=
"comments"
><TMPL_ELSE><div
id=
"comments"
></TMPL_IF>
<TMPL_VAR
COMMENTS
>
<TMPL_IF
ADDCOMMENTURL
>
<div
class=
"addcomment"
>
<a
href=
"<TMPL_VAR ADDCOMMENTURL>"
>
Add a comment
</a>
</div>
<TMPL_ELSE>
<div
class=
"addcomment"
>
Comments on this page are closed.
</div>
</TMPL_IF>
<TMPL_IF
HTML5
></section><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
<!-- Mastodon comments -->
<div
class=
"article-content"
>
<h2>
Comments
</h2>
<p>
You can use your Mastodon account to reply to this
<a
class=
"link"
href=
"https://{{ .host }}/@{{ .username }}/{{ .id }}"
>
post
</a>
.
</p>
<p><a
class=
"button"
href=
"https://{{ .host }}/interact/{{ .id }}?type=reply"
>
Reply
</a></p>
<p
id=
"mastodon-comments-list"
><button
id=
"load-comment"
>
Load comments
</button></p>
<noscript><p>
You need JavaScript to view the comments.
</p></noscript>
<script
src=
"/assets/js/purify.min.js"
></script>
<script
type=
"text/javascript"
>
function
escapeHtml
(
unsafe
)
{
return
unsafe
.
replace
(
/&/g
,
"
&
"
)
.
replace
(
/</g
,
"
<
"
)
.
replace
(
/>/g
,
"
>
"
)
.
replace
(
/"/g
,
"
"
"
)
.
replace
(
/'/g
,
"
'
"
);
}
document
.
getElementById
(
"
load-comment
"
).
addEventListener
(
"
click
"
,
function
()
{
document
.
getElementById
(
"
load-comment
"
).
innerHTML
=
"
Loading
"
;
fetch
(
'
https://{{ .host }}/api/v1/statuses/{{ .id }}/context
'
)
.
then
(
function
(
response
)
{
return
response
.
json
();
})
.
then
(
function
(
data
)
{
if
(
data
[
'
descendants
'
]
&&
Array
.
isArray
(
data
[
'
descendants
'
])
&&
data
[
'
descendants
'
].
length
>
0
)
{
document
.
getElementById
(
'
mastodon-comments-list
'
).
innerHTML
=
""
;
data
[
'
descendants
'
].
forEach
(
function
(
reply
)
{
reply
.
account
.
display_name
=
escapeHtml
(
reply
.
account
.
display_name
);
reply
.
account
.
emojis
.
forEach
(
emoji
=>
{
reply
.
account
.
display_name
=
reply
.
account
.
display_name
.
replace
(
`:
${
emoji
.
shortcode
}
:`
,
`<img src="
${
escapeHtml
(
emoji
.
static_url
)}
" alt="Emoji
${
emoji
.
shortcode
}
" height="20" width="20" />`
);
});
mastodonComment
=
`<div class="mastodon-comment">
<div class="avatar">
<img src="
${
escapeHtml
(
reply
.
account
.
avatar_static
)}
" height=60 width=60 alt="">
</div>
<div class="content">
<div class="author">
<a href="
${
reply
.
account
.
url
}
" rel="nofollow">
<span>
${
reply
.
account
.
display_name
}
</span>
<span class="disabled">
${
escapeHtml
(
reply
.
account
.
acct
)}
</span>
</a>
<a class="date" href="
${
reply
.
uri
}
" rel="nofollow">
${
reply
.
created_at
.
substr
(
0
,
10
)}
</a>
</div>
<div class="mastodon-comment-content">
${
reply
.
content
}
</div>
</div>
</div>`
;
document
.
getElementById
(
'
mastodon-comments-list
'
).
appendChild
(
DOMPurify
.
sanitize
(
mastodonComment
,
{
'
RETURN_DOM_FRAGMENT
'
:
true
}));
});
}
else
{
document
.
getElementById
(
'
mastodon-comments-list
'
).
innerHTML
=
"
<p>Not comments found</p>
"
;
}
});
});
</script>
</div>
<div
class=
"pagedate"
>
<span
class=
"created"
>
Created
<TMPL_VAR
CTIME
>
.
</span>
<span
class=
"edited"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment