jekyll_jam_comments 0.0.1 → 1.0.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/lib/jekyll_jam_comments/configuration.rb +29 -0
- data/lib/jekyll_jam_comments/service.rb +15 -1
- data/lib/jekyll_jam_comments/version.rb +1 -1
- data/lib/jekyll_jam_comments.rb +11 -9
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed96118f67d15dea5569a01659a53d43d8c549d3c5ddb0d219157eb6c46bd80f
|
4
|
+
data.tar.gz: 9e3c1df5e53a48ef7c3cc5179cc3bf085f099f1f531f558a93c0b773eb81cb48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff97b18a9e60e384d50a9cfc018863f41f2b3365da6ee1c903fbd66fffffe8d69e5ab55cc60ae609a967df63b8e03b4e32855f8eb6d8272099cb1019e1b854c3
|
7
|
+
data.tar.gz: 2a37f45c205bc5e51d7118fe5150480cf0f6254d02c50920d57c4436e4c0a5e5ce97c20fba6180f5219939a43dae3853f5e86c11fdf1be3d4ab414b847656a63
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module JamComments
|
5
|
+
class Configuration
|
6
|
+
class << self
|
7
|
+
def domain
|
8
|
+
configuration["domain"] || ENV["JAM_COMMENTS_DOMAIN"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def base_url
|
12
|
+
configuration["base_url"] || ENV["JAM_COMMENTS_BASE_URL"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def api_key
|
16
|
+
configuration["api_key"] || ENV["JAM_COMMENTS_API_KEY"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def environment
|
20
|
+
configuration["environment"] || ENV["JAM_COMMENTS_ENVIRONMENT"] || ENV["JEKYLL_ENV"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def configuration
|
24
|
+
Jekyll.configuration({})["jam_comments"] || {}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -35,11 +35,25 @@ module Jekyll
|
|
35
35
|
},
|
36
36
|
}
|
37
37
|
|
38
|
-
|
38
|
+
send_request(options)
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
+
def send_request(options)
|
44
|
+
response = client.get(endpoint, options)
|
45
|
+
|
46
|
+
if response.code == 401
|
47
|
+
raise "Oh no! It looks like your credentials for JamComments are incorrect."
|
48
|
+
end
|
49
|
+
|
50
|
+
if response.code != 200
|
51
|
+
raise "Oh no! JamComments request failed. Please try again. Status: #{response.code}"
|
52
|
+
end
|
53
|
+
|
54
|
+
response.body
|
55
|
+
end
|
56
|
+
|
43
57
|
def stub_value
|
44
58
|
return "true" if environment != "production"
|
45
59
|
|
data/lib/jekyll_jam_comments.rb
CHANGED
@@ -2,38 +2,40 @@
|
|
2
2
|
|
3
3
|
require "jekyll"
|
4
4
|
require_relative "./jekyll_jam_comments/service"
|
5
|
+
require_relative "./jekyll_jam_comments/configuration"
|
5
6
|
|
6
7
|
module Jekyll
|
7
8
|
module JamComments
|
8
9
|
class Tag < Liquid::Tag
|
9
10
|
attr_reader :path, :markup
|
10
11
|
|
11
|
-
CLIENT_SCRIPT_URL = "https://unpkg.com/@jam-comments/client@
|
12
|
+
CLIENT_SCRIPT_URL = "https://unpkg.com/@jam-comments/client@2.0.0-beta.2/dist/index.umd.js"
|
12
13
|
|
13
14
|
def initialize(tag_name, path, tokens)
|
14
15
|
super
|
15
16
|
|
16
17
|
@path = path
|
17
|
-
@markup = service.fetch(:path => path)
|
18
18
|
end
|
19
19
|
|
20
|
-
def render(
|
20
|
+
def render(context)
|
21
|
+
path = context["page"] && context["page"]["url"]
|
22
|
+
markup = service.fetch(:path => path)
|
23
|
+
|
21
24
|
"
|
22
25
|
#{markup}
|
23
26
|
<script src=\"#{CLIENT_SCRIPT_URL}\"></script>
|
24
27
|
<script>
|
25
|
-
|
26
|
-
JamComments.initialize(root);
|
28
|
+
window.JamComments.initialize(root);
|
27
29
|
</script>
|
28
30
|
"
|
29
31
|
end
|
30
32
|
|
31
33
|
def service
|
32
34
|
@service ||= Service.new(
|
33
|
-
:domain =>
|
34
|
-
:api_key =>
|
35
|
-
:base_url =>
|
36
|
-
:environment =>
|
35
|
+
:domain => Jekyll::JamComments::Configuration.domain,
|
36
|
+
:api_key => Jekyll::JamComments::Configuration.api_key,
|
37
|
+
:base_url => Jekyll::JamComments::Configuration.base_url,
|
38
|
+
:environment => Jekyll::JamComments::Configuration.environment
|
37
39
|
)
|
38
40
|
end
|
39
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_jam_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex MacArthur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '5.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: pry
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
@@ -124,6 +124,7 @@ extra_rdoc_files:
|
|
124
124
|
files:
|
125
125
|
- README.md
|
126
126
|
- lib/jekyll_jam_comments.rb
|
127
|
+
- lib/jekyll_jam_comments/configuration.rb
|
127
128
|
- lib/jekyll_jam_comments/service.rb
|
128
129
|
- lib/jekyll_jam_comments/version.rb
|
129
130
|
homepage: https://github.com/alexmacarthur/jekyll-jam-comments
|