jekyll_jam_comments 0.0.1 → 0.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cab1988147e713f97a3a754b85c2be3b10356c84165966bbe0b4c13401899801
|
4
|
+
data.tar.gz: 316bce7d76454cbebcd0310fe4be6dfa00b502c10ba714406a8a0484af298096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c793a13bb427f570db98204d3f067cbf80f606a792719f37c5c9e1e91d803ccf724c07891dcd2a84872c8d5f021fa2fc5c8adc474ad706b3fd69fae4f7919b6c
|
7
|
+
data.tar.gz: 1c2ae50320c3a60affec563ce048d6168320a74f891c7ff668e67f8bc6343a5705d9b2552ba3b0d7db60efcaf2ddef069106f5d6d9021f16bab9ca68e3ea338b
|
@@ -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,6 +2,7 @@
|
|
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
|
@@ -14,10 +15,12 @@ module Jekyll
|
|
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>
|
@@ -30,10 +33,10 @@ module Jekyll
|
|
30
33
|
|
31
34
|
def service
|
32
35
|
@service ||= Service.new(
|
33
|
-
:domain =>
|
34
|
-
:api_key =>
|
35
|
-
:base_url =>
|
36
|
-
:environment =>
|
36
|
+
:domain => Jekyll::JamComments::Configuration.domain,
|
37
|
+
:api_key => Jekyll::JamComments::Configuration.api_key,
|
38
|
+
:base_url => Jekyll::JamComments::Configuration.base_url,
|
39
|
+
:environment => Jekyll::JamComments::Configuration.environment
|
37
40
|
)
|
38
41
|
end
|
39
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex MacArthur
|
@@ -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
|