jekyll_jam_comments 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d5d448f4cd6edf18704e6380893b7a0da258e55816af17df9a778768fee0deeb
4
+ data.tar.gz: 4af7c2326c1c6124cc51d04aa90347cce7297b492b4abdc8ca1e4b405f83a974
5
+ SHA512:
6
+ metadata.gz: a9d23672db0a49e40665d9ff80dfb9548524324dde9ad0d889217110b2f7c0e1243aa9d4f35c15e894da6b18cab83d2c89c8659b427af42ee1547dc6f510f25a
7
+ data.tar.gz: a015ef0acf8d94c76234f8caf095b5e3d3d60ce199eada41c977757f611a7c26ec91656ba5b257d84c8ac2f5d1fc7f60c7cf035f5423a16c15d22a916d0052bc
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # jekyll-jam-comments
2
+
3
+ A Ruby gem for setting up your Jekyll blog with [JamComments](https://jamcomments.com), a guilt-free commment service for Jamstack blogs.
4
+
5
+ ## This Package's Documentation
6
+
7
+ [Read it here!](https://jamcomments.com/docs/integrations/jekyll)
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+
5
+ module Jekyll
6
+ module JamComments
7
+ class Service
8
+ attr_reader :base_url, :environment, :domain, :api_key, :client
9
+
10
+ def initialize(
11
+ domain:,
12
+ api_key:,
13
+ base_url: nil,
14
+ environment: nil,
15
+ client: HTTParty
16
+ )
17
+ @client = client
18
+ @domain = domain
19
+ @api_key = api_key
20
+ @base_url = base_url || "https://go.jamcomments.com"
21
+ @environment = environment || "production"
22
+ end
23
+
24
+ def fetch(path:)
25
+ options = {
26
+ :query => {
27
+ :path => formatted_path(path),
28
+ :domain => domain,
29
+ :stub => stub_value,
30
+ },
31
+ :headers => {
32
+ :Authorization => "Bearer #{api_key}",
33
+ :Accept => "application/json",
34
+ :'X-Platform' => "jekyll",
35
+ },
36
+ }
37
+
38
+ client.get(endpoint, options)
39
+ end
40
+
41
+ private
42
+
43
+ def stub_value
44
+ return "true" if environment != "production"
45
+
46
+ nil
47
+ end
48
+
49
+ def endpoint
50
+ "#{base_url}/api/markup"
51
+ end
52
+
53
+ def formatted_path(path)
54
+ path.empty? ? "/" : path
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module JamComments
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll"
4
+ require_relative "./jekyll_jam_comments/service"
5
+
6
+ module Jekyll
7
+ module JamComments
8
+ class Tag < Liquid::Tag
9
+ attr_reader :path, :markup
10
+
11
+ CLIENT_SCRIPT_URL = "https://unpkg.com/@jam-comments/client@1.0.4/dist/index.umd.js"
12
+
13
+ def initialize(tag_name, path, tokens)
14
+ super
15
+
16
+ @path = path
17
+ @markup = service.fetch(:path => path)
18
+ end
19
+
20
+ def render(_context)
21
+ "
22
+ #{markup}
23
+ <script src=\"#{CLIENT_SCRIPT_URL}\"></script>
24
+ <script>
25
+ const root = document.querySelector('[data-jam-comments-component=\"shell\"]');
26
+ JamComments.initialize(root);
27
+ </script>
28
+ "
29
+ end
30
+
31
+ def service
32
+ @service ||= Service.new(
33
+ :domain => configuration["domain"],
34
+ :api_key => configuration["api_key"],
35
+ :base_url => configuration["base_url"],
36
+ :environment => configuration["environment"]
37
+ )
38
+ end
39
+
40
+ def configuration
41
+ Jekyll.configuration({})["jam_comments"]
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ Liquid::Template.register_tag("jam_comments", Jekyll::JamComments::Tag)
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_jam_comments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex MacArthur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.7'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '3.7'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-jekyll
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ description:
118
+ email:
119
+ - alex@macarthur.me
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files:
123
+ - README.md
124
+ files:
125
+ - README.md
126
+ - lib/jekyll_jam_comments.rb
127
+ - lib/jekyll_jam_comments/service.rb
128
+ - lib/jekyll_jam_comments/version.rb
129
+ homepage: https://github.com/alexmacarthur/jekyll-jam-comments
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: 2.5.0
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubygems_version: 3.1.4
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: A Jekyll plugin for setting up JamComments in a Jekyll site.
152
+ test_files: []