jekyll-action-network 0.4.0 → 0.4.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2947b846e07427841ccd8923055f0bcda8f01f80fc38291fd0b9bf077af007c6
|
4
|
+
data.tar.gz: 9ff2f727a3da1e2c31015b3d9fc90f4c94ab1666db54a939473c02f2a1a81aa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 685c03c3b844d8fdd9cbfe373db626a492175958e3624f2dd1ec685057f05bceb652ec6179d7d6f348f934eb1a88b963601a08a5c0097167635f0bf5bfaca914
|
7
|
+
data.tar.gz: d6cc9aaa7040eb21d42458b4f09c2fa27f3668aa959f0196be2eed55ae69d455c510722601df65a3fc0126886e93171f376706e3091eb79090edcf0b9661c126
|
@@ -8,8 +8,9 @@ module Jekyll
|
|
8
8
|
class Collection
|
9
9
|
UTILS = Jekyll::ActionNetwork::Utils.new
|
10
10
|
|
11
|
-
def initialize(site, client, config_init, settings)
|
11
|
+
def initialize(site, generator, client, config_init, settings)
|
12
12
|
@site = site
|
13
|
+
@generator = generator
|
13
14
|
@settings = settings
|
14
15
|
@client = client
|
15
16
|
@config_init = config_init
|
@@ -44,7 +45,7 @@ module Jekyll
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def actions
|
47
|
-
@actions ||=
|
48
|
+
@actions ||= @generator.get_full_list(@name)
|
48
49
|
end
|
49
50
|
|
50
51
|
def filters
|
@@ -29,19 +29,26 @@ module Jekyll
|
|
29
29
|
|
30
30
|
def make_collections
|
31
31
|
@config["import"].each do |config|
|
32
|
-
|
33
|
-
name
|
34
|
-
next unless name
|
32
|
+
col_config = make_collection_config(config)
|
33
|
+
name = col_config["name"]
|
34
|
+
next unless col_config["name"]
|
35
35
|
|
36
|
-
make_collection(name,
|
36
|
+
make_collection(name, col_config)
|
37
37
|
end
|
38
38
|
@site.collections["actions"] = actions if @config["actions"]
|
39
39
|
end
|
40
40
|
|
41
|
+
def make_collection_config(col_config_init)
|
42
|
+
return col_config_init if col_config_init.is_a? Hash
|
43
|
+
return { "name" => col_config_init } if col_config_init.is_a? String
|
44
|
+
|
45
|
+
Jekyll.logger.warn LOG_NAME, "Config format #{col_config_init} not recognised"
|
46
|
+
end
|
47
|
+
|
41
48
|
def make_collection(name, config)
|
42
49
|
return unless defaults[name]
|
43
50
|
|
44
|
-
collection = Jekyll::ActionNetwork::Collection.new(@site, @client, config, settings)
|
51
|
+
collection = Jekyll::ActionNetwork::Collection.new(@site, self, @client, config, settings)
|
45
52
|
@site.collections[collection.config["collection"]] = collection.populate
|
46
53
|
actions.docs.concat(collection.collection.docs)
|
47
54
|
end
|
@@ -50,7 +57,7 @@ module Jekyll
|
|
50
57
|
return @actions if @actions
|
51
58
|
|
52
59
|
actions_config = @config["actions"] if @config["actions"].is_a? Hash
|
53
|
-
actions_settings =
|
60
|
+
actions_settings = settings["actions"].merge(actions_config || {})
|
54
61
|
@actions ||= Jekyll::Collection.new(@site, actions_settings["collection"])
|
55
62
|
end
|
56
63
|
|
@@ -67,10 +74,8 @@ module Jekyll
|
|
67
74
|
@defaults ||= settings["defaults"]
|
68
75
|
end
|
69
76
|
|
70
|
-
private
|
71
|
-
|
72
77
|
def api_key
|
73
|
-
key = @config["key"] ||
|
78
|
+
key = @config["key"] || settings["key"]
|
74
79
|
return ENV.fetch(key[4..key.length - 1], nil) if key[0..3] == "ENV_"
|
75
80
|
|
76
81
|
key
|
@@ -82,13 +87,37 @@ module Jekyll
|
|
82
87
|
return
|
83
88
|
end
|
84
89
|
|
85
|
-
|
86
|
-
unless @client.entry_point.authenticated_successfully?
|
90
|
+
unless entry_point.dig("_links", "osdi:tags").present?
|
87
91
|
Jekyll.logger.warn "Action Network Authentication Unsucessful"
|
88
92
|
return
|
89
93
|
end
|
90
94
|
true
|
91
95
|
end
|
96
|
+
|
97
|
+
def client
|
98
|
+
@client ||= ActionNetworkRest.new(api_key: api_key)
|
99
|
+
end
|
100
|
+
|
101
|
+
def entry_point
|
102
|
+
@entry_point ||= client.entry_point.get
|
103
|
+
end
|
104
|
+
|
105
|
+
def page_size
|
106
|
+
@page_size ||= @entry_point["max_page_size"]
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_full_list(name)
|
110
|
+
page = 1
|
111
|
+
actions = []
|
112
|
+
loop do
|
113
|
+
action_page = @client.send(name).list(page: page)
|
114
|
+
actions.concat(action_page)
|
115
|
+
break if action_page.size < page_size
|
116
|
+
|
117
|
+
page += 1
|
118
|
+
end
|
119
|
+
actions
|
120
|
+
end
|
92
121
|
end
|
93
122
|
end
|
94
123
|
end
|
@@ -26,19 +26,6 @@ module Jekyll
|
|
26
26
|
"#{css}<script src='https://actionnetwork.org/widgets/v5/#{resource}/#{slug}?format=js&source=widget'></script>
|
27
27
|
<div id='can-#{resource}-area-#{slug}' style='width: 100%'></div>"
|
28
28
|
end
|
29
|
-
|
30
|
-
def get_full_list(client, name)
|
31
|
-
page = 1
|
32
|
-
actions = []
|
33
|
-
loop do
|
34
|
-
action_page = client.send(name).list(page: page)
|
35
|
-
break if action_page.empty?
|
36
|
-
|
37
|
-
actions.concat(action_page)
|
38
|
-
page += 1
|
39
|
-
end
|
40
|
-
actions
|
41
|
-
end
|
42
29
|
end
|
43
30
|
end
|
44
31
|
end
|