jekyll-theme-ascii 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/_includes/mastodon_comments.html +10 -0
- data/_layouts/post.html +1 -1
- data/assets/js/mastodon_comments.js +73 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec677fbdfae2e8d8bd566c7fc4acb5a9df07368efe1da0a6be4853c83741282b
|
4
|
+
data.tar.gz: f75072c1f6925413b879a7a390679de6725eb8c7c86d17e39b6d96265b7ea327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 851d4e8e684a43324d0257beb645190a1edd7b93b92219336f551709bd7915020e70a9b601c057c67b648a67fa87760283bd64b20b39433fcd1787a067fa2a0f
|
7
|
+
data.tar.gz: 27728c86a76274b08e624cc7d5c7cd9d8c76a75d148981e93340e9b6cacf5e295eb841cc452b769cee4ddb053d4c00273c9e170b19529010903b192b95c283be
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{%- assign mastodon_host = page.mastodon_comments.host | default: site.mastodon_comments.host -%}
|
2
|
+
<div style="border-top: dashed 1px rgba(219, 219, 219, 0.9)">
|
3
|
+
<h2>Comments in Mastodon</h2>
|
4
|
+
<div id="mastodon_comments_list" style="margin-top: 22px;">
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
<script src="/assets/js/mastodon_comments.js"></script>
|
8
|
+
<script>
|
9
|
+
window.onload = mastodon_comments_load('{{ mastodon_host }}', '{{ page.mastodon_comments.toot_id }}', 'mastodon_comments_list')
|
10
|
+
</script>
|
data/_layouts/post.html
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
function mastodon_comments_load(host, toot_id, element) {
|
2
|
+
fetch(`https://${host}/api/v1/statuses/${toot_id}`)
|
3
|
+
.then(function (response) {
|
4
|
+
return response.json()
|
5
|
+
})
|
6
|
+
.then(function (data) {
|
7
|
+
mastodon_comment_render(data, element)
|
8
|
+
fetch(`https://${host}/api/v1/statuses/${toot_id}/context`)
|
9
|
+
.then(function (response) {
|
10
|
+
return response.json()
|
11
|
+
})
|
12
|
+
.then(function (data) {
|
13
|
+
if (data['descendants'] && Array.isArray(data['descendants']) && data['descendants'].length > 0) {
|
14
|
+
data['descendants'].forEach(function (reply) {
|
15
|
+
mastodon_comment_render(reply, element)
|
16
|
+
})
|
17
|
+
}
|
18
|
+
})
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
function mastodon_comment_render(toot, element) {
|
23
|
+
console.log('Comment:')
|
24
|
+
console.log(toot)
|
25
|
+
container = document.createElement('a')
|
26
|
+
container.href = toot.url
|
27
|
+
container.style.textDecoration = 'none'
|
28
|
+
comment = document.createElement('div')
|
29
|
+
comment.style.lineHeight = 'normal'
|
30
|
+
comment.style.background = '#111111'
|
31
|
+
comment.style.borderRadius = '10px'
|
32
|
+
comment.style.padding = '10px'
|
33
|
+
comment.style.marginBottom = '10px'
|
34
|
+
comment.style.paddingBottom = '1px'
|
35
|
+
comment.append(mastodon_comment_create_author(toot.account))
|
36
|
+
comment_content = document.createElement('div')
|
37
|
+
comment_content.innerHTML = toot.content
|
38
|
+
comment.append(comment_content)
|
39
|
+
container.append(comment)
|
40
|
+
document.getElementById(element).append(container)
|
41
|
+
}
|
42
|
+
|
43
|
+
function mastodon_comment_create_author(account) {
|
44
|
+
author = document.createElement('a')
|
45
|
+
author.style.display = 'flex'
|
46
|
+
author.style.gap = '10px'
|
47
|
+
author.href = account.url
|
48
|
+
author_avatar = document.createElement('img')
|
49
|
+
author_avatar.src = account.avatar
|
50
|
+
author_avatar.width = 46
|
51
|
+
author_avatar.height = 46
|
52
|
+
author_avatar.style.borderRadius = '5px'
|
53
|
+
author.append(author_avatar)
|
54
|
+
author_info = document.createElement('span')
|
55
|
+
author_display_name = document.createElement('strong')
|
56
|
+
author_display_name.style.display = 'block'
|
57
|
+
author_display_name.append(document.createTextNode(account.display_name))
|
58
|
+
author_info.append(author_display_name)
|
59
|
+
author_account = document.createElement('span')
|
60
|
+
author_account.append(document.createTextNode(mastodon_acct_full(account)))
|
61
|
+
author_info.append(author_account)
|
62
|
+
author.append(author_info)
|
63
|
+
return author
|
64
|
+
}
|
65
|
+
|
66
|
+
function mastodon_acct_full(account) {
|
67
|
+
acct = account.acct
|
68
|
+
if (acct.indexOf('@') == -1) {
|
69
|
+
account_url = new URL(account.url)
|
70
|
+
acct += '@' + account_url.hostname
|
71
|
+
}
|
72
|
+
return '@' + acct
|
73
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-theme-ascii
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonio Vázquez Blanco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- _includes/google-analytics.html
|
97
97
|
- _includes/head.html
|
98
98
|
- _includes/header.html
|
99
|
+
- _includes/mastodon_comments.html
|
99
100
|
- _layouts/default.html
|
100
101
|
- _layouts/home.html
|
101
102
|
- _layouts/page.html
|
@@ -104,6 +105,7 @@ files:
|
|
104
105
|
- _sass/jekyll-theme-ascii/skins/classic-highlighting.scss
|
105
106
|
- _sass/jekyll-theme-ascii/skins/classic.scss
|
106
107
|
- assets/css/style.scss
|
108
|
+
- assets/js/mastodon_comments.js
|
107
109
|
homepage: https://github.com/antoniovazquezblanco/jekyll-theme-ascii
|
108
110
|
licenses:
|
109
111
|
- MIT
|