jekyll-theme-ascii 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1f17a0869e02037b27d7eaf386318be1aac55e7e2516b52296846f0f462a46b
4
- data.tar.gz: dcb5ef2abb390080f3efc5e07c03b64512cdbc33766c424f35dd1409aac8a854
3
+ metadata.gz: ec677fbdfae2e8d8bd566c7fc4acb5a9df07368efe1da0a6be4853c83741282b
4
+ data.tar.gz: f75072c1f6925413b879a7a390679de6725eb8c7c86d17e39b6d96265b7ea327
5
5
  SHA512:
6
- metadata.gz: 49b11c453d56b28389a5f24e5f659c23934b1240d95afd9312ffb03d8f652f4af64431ddd8c86ac2b136053db6c578bdb1df62b91684caedc94e0a35f5b3258b
7
- data.tar.gz: ba594eeddf43a487178593d885e500de27df06e7b6e553ce40f1e29e941f27a5b8206882970df4823272c3dfd643e86d2446cea3fd46da2330a6f6d52a6e17f4
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
@@ -8,7 +8,7 @@ layout: default
8
8
 
9
9
  {{ content }}
10
10
 
11
- {%- if page.mastodon_comments.toot_id -%}
11
+ {%- if page.mastodon_comments.toot_id and (page.mastodon_comments.host or site.mastodon_comments.host) -%}
12
12
  {%- include mastodon_comments.html -%}
13
13
  {%- endif -%}
14
14
 
@@ -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.1.4
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-24 00:00:00.000000000 Z
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