pagiii 0.0.10 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pagiii +67 -37
- data/lib/pagiii/site_info.rb +31 -0
- data/lib/pagiii/theme_sync.rb +65 -51
- data/lib/pagiii.rb +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfaa4ea7a12fa55eb6c25f09edd7d7af72cb0cb941ca6484d01771a15f6585b9
|
4
|
+
data.tar.gz: 39ef43287e308e86601181ef3ed9cac9626344fe974ae63eda91c28d46c24635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e04eb945f09eb79f4e11b0de238cc0c84a0c140aa2644e9e140018d297624bb907cb3abb3577064e0223708ad20f5d566e02c47bee9b099191b254b16cf5c5
|
7
|
+
data.tar.gz: f0cc199c4f1905f7bc0ba84f68d202a64ea36e2e26c14a4d4497db909b6599a97bbd5717645bc18edd43ab5934f2e7fba3f105c36e275caf04f1301172bb3100
|
data/bin/pagiii
CHANGED
@@ -19,7 +19,7 @@ secret_id = 'WlENailhg7KEbZqXXwX4Y470HYGL8-U2af_bOZGVWeQ'
|
|
19
19
|
redirect_uri = 'http://localhost:7654'
|
20
20
|
scope = 'read_theme write_theme delete_theme'
|
21
21
|
|
22
|
-
program :version, '0.
|
22
|
+
program :version, '0.1.2'
|
23
23
|
program :description, 'Pagiii CLI'
|
24
24
|
|
25
25
|
|
@@ -49,7 +49,7 @@ def check_authorized(response)
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def update_config(
|
52
|
+
def update_config(email, password)
|
53
53
|
dir = "#{Dir.home}/.pagiii"
|
54
54
|
FileUtils.mkdir_p(dir) unless Dir.exists?(dir)
|
55
55
|
file = File.join(dir, 'config.json')
|
@@ -57,19 +57,21 @@ def update_config(site_name, token)
|
|
57
57
|
if File.exists?(file)
|
58
58
|
hash = JSON.parse(IO.read(file))
|
59
59
|
end
|
60
|
-
hash[
|
60
|
+
hash[:email] = email
|
61
|
+
hash[:password] = password
|
62
|
+
|
61
63
|
File.open(file, 'w+') do |f|
|
62
64
|
f.write(hash.to_json)
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
|
-
def read_config
|
68
|
+
def read_config
|
67
69
|
dir = "#{Dir.home}/.pagiii"
|
68
70
|
return nil unless Dir.exists?(dir)
|
69
71
|
file = File.join(dir, 'config.json')
|
70
72
|
return nil unless File.exists?(file)
|
71
73
|
hash = JSON.parse(IO.read(file))
|
72
|
-
hash
|
74
|
+
hash
|
73
75
|
end
|
74
76
|
|
75
77
|
command :help do |c|
|
@@ -78,39 +80,66 @@ command :help do |c|
|
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
83
|
+
command 'login' do |c|
|
84
|
+
c.action do
|
85
|
+
email = ask("Email: ")
|
86
|
+
password = ask("Password: "){|q| q.echo = '*'}
|
87
|
+
url = "#{root_api}/api/v1/admin/auth"
|
88
|
+
conn = Faraday.new(
|
89
|
+
url: url,
|
90
|
+
params: {},
|
91
|
+
headers: {
|
92
|
+
'Content-Type' => 'application/json'
|
93
|
+
}
|
94
|
+
)
|
95
|
+
response = conn.post do |req|
|
96
|
+
req.body = {email: email, password: password}.to_json
|
97
|
+
end
|
98
|
+
if response.status == 200
|
99
|
+
api_token = JSON.parse(response.body)['api_token']
|
100
|
+
update_config(email, api_token)
|
101
|
+
puts "logged as #{email}"
|
102
|
+
else
|
103
|
+
message = JSON.parse(response.body)['message']
|
104
|
+
say "login failed http [#{message}]"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
command 'site:list' do |c|
|
110
|
+
c.action do
|
111
|
+
user = read_config
|
112
|
+
site_info = Pagiii::SiteInfo.new(token: user['password'], root_api: root_api)
|
113
|
+
site_info.list
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
81
117
|
|
82
118
|
# bundle exec ruby pagiii.rb theme:sync --site=dokumentasi --theme=doc
|
83
119
|
command 'theme:sync' do |c|
|
84
120
|
c.option '--theme STRING', String, 'Theme name'
|
85
121
|
c.option '--site STRING', String, 'Site name'
|
86
122
|
c.action do |args, options|
|
87
|
-
if options.
|
88
|
-
say "please specify theme name using --theme option"
|
89
|
-
exit(false)
|
90
|
-
elsif options.site.nil?
|
123
|
+
if options.site.nil?
|
91
124
|
say "please specify site name using --site option"
|
92
125
|
exit(false)
|
93
126
|
end
|
94
|
-
|
95
|
-
theme = Pagiii::ThemeSync.new(token:
|
96
|
-
theme.sync_all(options.
|
127
|
+
user = read_config
|
128
|
+
theme = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
129
|
+
theme.sync_all(options.site)
|
97
130
|
end
|
98
131
|
end
|
99
132
|
|
100
133
|
command 'theme:watch' do |c|
|
101
|
-
c.option '--site STRING', String, 'Site name'
|
102
|
-
c.
|
103
|
-
|
104
|
-
if options.theme.nil?
|
105
|
-
say "please specify theme name using --theme option"
|
106
|
-
exit(false)
|
107
|
-
elsif options.site.nil?
|
134
|
+
c.option '--site STRING', String, 'Site name'
|
135
|
+
c.action do |args, options|
|
136
|
+
if options.site.nil?
|
108
137
|
say "please specify site name using --site option"
|
109
138
|
exit(false)
|
110
139
|
end
|
111
|
-
|
112
|
-
theme_sync = Pagiii::ThemeSync.new(token:
|
113
|
-
theme_sync.watch(options.
|
140
|
+
user = read_config
|
141
|
+
theme_sync = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
142
|
+
theme_sync.watch(options.site)
|
114
143
|
end
|
115
144
|
end
|
116
145
|
|
@@ -121,13 +150,13 @@ command 'theme:create' do |c|
|
|
121
150
|
c.option '--theme STRING', String, 'Theme name'
|
122
151
|
|
123
152
|
c.action do |args, options|
|
124
|
-
|
153
|
+
user = read_config
|
125
154
|
if options.theme.nil?
|
126
155
|
say "please specify theme name using --theme option"
|
127
156
|
else
|
128
157
|
say "Create theme #{options.theme}"
|
129
|
-
theme_sync = Pagiii::ThemeSync.new(token:
|
130
|
-
response = theme_sync.create_theme(options.theme)
|
158
|
+
theme_sync = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
159
|
+
response = theme_sync.create_theme(options.site, options.theme)
|
131
160
|
|
132
161
|
if response.status == 200
|
133
162
|
say "theme created"
|
@@ -149,10 +178,10 @@ command 'theme:pull' do |c|
|
|
149
178
|
elsif options.site.nil?
|
150
179
|
say "please provide site name"
|
151
180
|
else
|
152
|
-
|
181
|
+
user = read_config
|
153
182
|
say "Pull theme #{options.theme}"
|
154
|
-
theme_sync = Pagiii::ThemeSync.new(token:
|
155
|
-
theme_sync.pull_theme(options.theme)
|
183
|
+
theme_sync = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
184
|
+
theme_sync.pull_theme(options.site, options.theme)
|
156
185
|
end
|
157
186
|
end
|
158
187
|
end
|
@@ -165,9 +194,10 @@ command 'theme:list' do |c|
|
|
165
194
|
if options.site.nil?
|
166
195
|
say "please provide name using --site"
|
167
196
|
else
|
168
|
-
|
169
|
-
|
170
|
-
theme_sync.
|
197
|
+
user = read_config
|
198
|
+
|
199
|
+
theme_sync = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
200
|
+
theme_sync.list_themes(options.site)
|
171
201
|
end
|
172
202
|
end
|
173
203
|
end
|
@@ -184,10 +214,10 @@ command 'theme:delete' do |c|
|
|
184
214
|
say "please provide site name using --site"
|
185
215
|
else
|
186
216
|
say "Delete theme #{options.theme}"
|
187
|
-
|
217
|
+
user = read_config
|
188
218
|
|
189
|
-
theme_sync = Pagiii::ThemeSync.new(token:
|
190
|
-
theme_sync.delete_theme(options.theme)
|
219
|
+
theme_sync = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
220
|
+
theme_sync.delete_theme(options.site, options.theme)
|
191
221
|
end
|
192
222
|
end
|
193
223
|
end
|
@@ -205,9 +235,9 @@ command 'theme:set_current' do |c|
|
|
205
235
|
say "please provide name using --site"
|
206
236
|
else
|
207
237
|
say "Set current theme of #{options.site} to #{options.theme}"
|
208
|
-
|
209
|
-
theme_sync = Pagiii::ThemeSync.new(token:
|
210
|
-
theme_sync.set_current_theme(options.theme)
|
238
|
+
user = read_config
|
239
|
+
theme_sync = Pagiii::ThemeSync.new(token: user['password'], root_api: root_api)
|
240
|
+
theme_sync.set_current_theme(options.site, options.theme)
|
211
241
|
end
|
212
242
|
end
|
213
243
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Pagiii
|
2
|
+
class SiteInfo
|
3
|
+
def initialize(token:, root_api:)
|
4
|
+
@token = token
|
5
|
+
@root_api = root_api
|
6
|
+
end
|
7
|
+
|
8
|
+
def list
|
9
|
+
conn = Faraday.new(
|
10
|
+
url: "#{@root_api}/api/v1/admin/sites",
|
11
|
+
headers: {
|
12
|
+
'Content-Type' => 'application/json',
|
13
|
+
'api-token' => @token
|
14
|
+
}
|
15
|
+
)
|
16
|
+
response = conn.get
|
17
|
+
# check_authorized(response)
|
18
|
+
if response.status == 200
|
19
|
+
organizations = JSON.parse(response.body)
|
20
|
+
organizations.each do |o|
|
21
|
+
puts "Organization: #{o['name']}"
|
22
|
+
o['sites'].each do |site|
|
23
|
+
puts " #{site['name']}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
say "unknown error"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/pagiii/theme_sync.rb
CHANGED
@@ -10,12 +10,12 @@ class Pagiii::ThemeSync
|
|
10
10
|
@root_api = root_api
|
11
11
|
end
|
12
12
|
|
13
|
-
def list_themes
|
13
|
+
def list_themes(site_name)
|
14
14
|
conn = Faraday.new(
|
15
|
-
url: "#{root_api}/api/v1/admin/themes",
|
15
|
+
url: "#{root_api}/api/v1/admin/themes?site_name=#{site_name}",
|
16
16
|
headers: {
|
17
17
|
'Content-Type' => 'application/json',
|
18
|
-
'
|
18
|
+
'api-token' => @token
|
19
19
|
}
|
20
20
|
)
|
21
21
|
response = conn.get
|
@@ -23,9 +23,9 @@ class Pagiii::ThemeSync
|
|
23
23
|
if response.status == 200
|
24
24
|
hash = JSON.parse(response.body)
|
25
25
|
say "List themes at #{hash['site']['name']}"
|
26
|
-
say "--------------------------------------"
|
26
|
+
say "--------------------------------------"
|
27
27
|
hash['themes'].each do |theme|
|
28
|
-
say " - #{theme['name']}"
|
28
|
+
say " - #{theme['name']} #{(theme['id'] == hash['current']['id'])? "(active)" : '' }"
|
29
29
|
end
|
30
30
|
else
|
31
31
|
say "error"
|
@@ -33,14 +33,14 @@ class Pagiii::ThemeSync
|
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
-
def sync_file(theme_name, file)
|
36
|
+
def sync_file(site, theme_name, file)
|
37
37
|
#puts "sync #{file}"
|
38
38
|
conn = Faraday.new(
|
39
39
|
url: @root_api,
|
40
40
|
params: {param: '1'},
|
41
41
|
headers: {
|
42
42
|
'Content-Type' => 'application/json',
|
43
|
-
'
|
43
|
+
'api-token' => @token
|
44
44
|
}
|
45
45
|
)
|
46
46
|
|
@@ -52,12 +52,12 @@ class Pagiii::ThemeSync
|
|
52
52
|
else
|
53
53
|
data = IO.read(file)
|
54
54
|
end
|
55
|
-
response = get_theme_by_name(name: theme_name)
|
55
|
+
response = get_theme_by_name(site: site, name: theme_name)
|
56
56
|
|
57
57
|
check_authorized(response)
|
58
58
|
theme_id = JSON.parse(response.body)['theme']['id']
|
59
59
|
|
60
|
-
response = conn.post("/api/v1/admin/themes/#{theme_id}/assets") do |req|
|
60
|
+
response = conn.post("/api/v1/admin/themes/#{theme_id}/assets?site_name=#{site}") do |req|
|
61
61
|
req.params['limit'] = 100
|
62
62
|
req.body = {
|
63
63
|
key: get_asset_key(file),
|
@@ -68,9 +68,9 @@ class Pagiii::ThemeSync
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
def sync_delete(theme_name, file)
|
71
|
+
def sync_delete(site, theme_name, file)
|
72
72
|
puts "deleteing #{file}"
|
73
|
-
response = get_theme_by_name(name: theme_name)
|
73
|
+
response = get_theme_by_name(site: site, name: theme_name)
|
74
74
|
check_authorized(response)
|
75
75
|
theme_id = JSON.parse(response.body)['theme']['id']
|
76
76
|
|
@@ -79,15 +79,15 @@ class Pagiii::ThemeSync
|
|
79
79
|
params: {param: '1'},
|
80
80
|
headers: {
|
81
81
|
'Content-Type' => 'application/json',
|
82
|
-
'
|
82
|
+
'api-token' => @token
|
83
83
|
}
|
84
84
|
)
|
85
|
-
response = conn.delete("/api/v1/admin/themes/#{theme_id}/assets?key=#{get_asset_key(file)}")
|
85
|
+
response = conn.delete("/api/v1/admin/themes/#{theme_id}/assets?key=#{get_asset_key(file)}&site_name=#{site}")
|
86
86
|
end
|
87
87
|
|
88
|
-
def delete_remote(theme, asset_key)
|
88
|
+
def delete_remote(site, theme, asset_key)
|
89
89
|
puts "deleting #{asset_key}"
|
90
|
-
response = get_theme_by_name(name: theme)
|
90
|
+
response = get_theme_by_name(site: site, name: theme)
|
91
91
|
check_authorized(response)
|
92
92
|
theme_id = JSON.parse(response.body)['theme']['id']
|
93
93
|
|
@@ -96,25 +96,25 @@ class Pagiii::ThemeSync
|
|
96
96
|
params: {param: '1'},
|
97
97
|
headers: {
|
98
98
|
'Content-Type' => 'application/json',
|
99
|
-
'
|
99
|
+
'api-token' => @token
|
100
100
|
}
|
101
101
|
)
|
102
|
-
response = conn.delete("/api/v1/admin/themes/#{theme_id}/assets?key=#{asset_key}")
|
102
|
+
response = conn.delete("/api/v1/admin/themes/#{theme_id}/assets?key=#{asset_key}&site_name=#{site}")
|
103
103
|
end
|
104
104
|
|
105
|
-
def compare_and_delete(theme)
|
105
|
+
def compare_and_delete(site, theme)
|
106
106
|
conn = Faraday.new(
|
107
107
|
url: @root_api,
|
108
108
|
params: {param: '1'},
|
109
109
|
headers: {
|
110
110
|
'Content-Type' => 'application/json',
|
111
|
-
'
|
111
|
+
'api-token' => @token
|
112
112
|
}
|
113
113
|
)
|
114
|
-
response = get_theme_by_name(name: theme)
|
114
|
+
response = get_theme_by_name(site: site, name: theme)
|
115
115
|
check_authorized(response)
|
116
116
|
theme_id = JSON.parse(response.body)['theme']['id']
|
117
|
-
response = conn.get("/api/v1/admin/themes/#{theme_id}/assets")
|
117
|
+
response = conn.get("/api/v1/admin/themes/#{theme_id}/assets?site_name=#{site}")
|
118
118
|
remote_assets = JSON.parse(response.body)['assets'].map{|x| x['asset_key']}
|
119
119
|
|
120
120
|
local_assets = []
|
@@ -130,7 +130,7 @@ class Pagiii::ThemeSync
|
|
130
130
|
|
131
131
|
assets_to_be_deleted = remote_assets - local_assets
|
132
132
|
assets_to_be_deleted.each do |asset_key|
|
133
|
-
delete_remote(theme, asset_key)
|
133
|
+
delete_remote(site, theme, asset_key)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -142,15 +142,17 @@ class Pagiii::ThemeSync
|
|
142
142
|
"#{dir}/#{file}"
|
143
143
|
end
|
144
144
|
|
145
|
-
def sync_all(
|
146
|
-
|
145
|
+
def sync_all(site)
|
146
|
+
response = current_theme(site: site)
|
147
|
+
theme = JSON.parse(response.body)['theme']['name']
|
148
|
+
compare_and_delete(site, theme)
|
147
149
|
Dir.entries('.').each do |dir|
|
148
150
|
if ALLOWED_DIRS.include?(dir) && File.directory?(dir)
|
149
151
|
puts "--#{dir}"
|
150
152
|
Dir.entries(dir).reject{|x| [".", ".."].include?(x)}.each do |file|
|
151
153
|
print "----#{file}"
|
152
154
|
file_path = "./#{dir}/#{file}"
|
153
|
-
resp = sync_file(theme, file_path)
|
155
|
+
resp = sync_file(site, theme, file_path)
|
154
156
|
if resp.status == 200
|
155
157
|
puts " [OK]"
|
156
158
|
else
|
@@ -162,44 +164,56 @@ class Pagiii::ThemeSync
|
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
165
|
-
def watch(
|
167
|
+
def watch(site)
|
168
|
+
response = current_theme(site: site)
|
169
|
+
theme_name = JSON.parse(response.body)['theme']['name']
|
166
170
|
Filewatcher.new(ALLOWED_DIRS).watch do |changes|
|
167
171
|
changes.each do |filename, event|
|
168
172
|
puts "#{filename} #{event}"
|
169
173
|
if event == :updated || event == :created
|
170
|
-
sync_file(theme_name, filename)
|
174
|
+
sync_file(site, theme_name, filename)
|
171
175
|
elsif event == :deleted
|
172
|
-
sync_delete(theme_name, filename)
|
176
|
+
sync_delete(site, theme_name, filename)
|
173
177
|
end
|
174
178
|
end
|
175
179
|
end
|
176
180
|
end
|
177
181
|
|
178
|
-
def get_theme_by_name(name:)
|
182
|
+
def get_theme_by_name(site:, name:)
|
179
183
|
conn = Faraday.new(
|
180
|
-
url: "#{@root_api}/api/v1/admin/themes/by_name?name=#{name}",
|
184
|
+
url: "#{@root_api}/api/v1/admin/themes/by_name?name=#{name}&site_name=#{site}",
|
181
185
|
headers: {
|
182
186
|
'Content-Type' => 'application/json',
|
183
|
-
'
|
187
|
+
'api-token' => @token
|
188
|
+
}
|
189
|
+
)
|
190
|
+
response = conn.get
|
191
|
+
end
|
192
|
+
|
193
|
+
def current_theme(site:)
|
194
|
+
conn = Faraday.new(
|
195
|
+
url: "#{@root_api}/api/v1/admin/themes/current?site_name=#{site}",
|
196
|
+
headers: {
|
197
|
+
'Content-Type' => 'application/json',
|
198
|
+
'api-token' => @token
|
184
199
|
}
|
185
200
|
)
|
186
|
-
|
187
201
|
response = conn.get
|
188
202
|
end
|
189
203
|
|
190
204
|
|
191
205
|
|
192
|
-
def pull_theme(name)
|
193
|
-
response = get_theme_by_name(name: name)
|
206
|
+
def pull_theme(site, name)
|
207
|
+
response = get_theme_by_name(site: site, name: name)
|
194
208
|
check_authorized(response)
|
195
209
|
parsed_response = JSON.parse(response.body)
|
196
210
|
|
197
211
|
conn = Faraday.new(
|
198
|
-
url: "#{root_api}/api/v1/admin/themes/#{parsed_response['theme']['id']}/pull",
|
212
|
+
url: "#{root_api}/api/v1/admin/themes/#{parsed_response['theme']['id']}/pull?site_name=#{site}",
|
199
213
|
params: {param: '1'},
|
200
214
|
headers: {
|
201
215
|
'Content-Type' => 'application/json',
|
202
|
-
'
|
216
|
+
'api-token' => @token
|
203
217
|
}
|
204
218
|
)
|
205
219
|
response = conn.get
|
@@ -208,7 +222,7 @@ class Pagiii::ThemeSync
|
|
208
222
|
|
209
223
|
assets.each do |asset|
|
210
224
|
say "downloading #{asset['asset_key']}"
|
211
|
-
response = download_asset(theme_id: parsed_response['theme']['id'], key: asset['asset_key'])
|
225
|
+
response = download_asset(site: site, theme_id: parsed_response['theme']['id'], key: asset['asset_key'])
|
212
226
|
path = File.split(asset['asset_key'])
|
213
227
|
FileUtils.mkdir(path.first) unless Dir.exists?(path.first)
|
214
228
|
File.open(asset['asset_key'], 'wb') do |f|
|
@@ -223,28 +237,28 @@ class Pagiii::ThemeSync
|
|
223
237
|
end
|
224
238
|
end
|
225
239
|
|
226
|
-
def delete_theme(name)
|
227
|
-
response = get_theme_by_name(name: name)
|
240
|
+
def delete_theme(site, name)
|
241
|
+
response = get_theme_by_name(site: site, name: name)
|
228
242
|
check_authorized(response)
|
229
243
|
parsed_response = JSON.parse(response.body)
|
230
244
|
conn = Faraday.new(
|
231
|
-
url: "#{root_api}/api/v1/admin/themes/#{parsed_response['theme']['id']}",
|
245
|
+
url: "#{root_api}/api/v1/admin/themes/#{parsed_response['theme']['id']}?site_name=#{site}",
|
232
246
|
params: {param: '1'},
|
233
247
|
headers: {
|
234
248
|
'Content-Type' => 'application/json',
|
235
|
-
'
|
249
|
+
'api-token' => @token
|
236
250
|
}
|
237
251
|
)
|
238
252
|
response = conn.delete
|
239
253
|
end
|
240
254
|
|
241
|
-
def create_theme(name)
|
255
|
+
def create_theme(site, name)
|
242
256
|
conn = Faraday.new(
|
243
|
-
url: "#{root_api}/api/v1/admin/themes",
|
257
|
+
url: "#{@root_api}/api/v1/admin/themes?site_name=#{site}",
|
244
258
|
params: {param: '1'},
|
245
259
|
headers: {
|
246
260
|
'Content-Type' => 'application/json',
|
247
|
-
'
|
261
|
+
'api-token' => @token
|
248
262
|
}
|
249
263
|
)
|
250
264
|
response = conn.post do |req|
|
@@ -256,16 +270,16 @@ class Pagiii::ThemeSync
|
|
256
270
|
end
|
257
271
|
end
|
258
272
|
|
259
|
-
def set_current_theme(name)
|
260
|
-
response = get_theme_by_name(name: name)
|
273
|
+
def set_current_theme(site, name)
|
274
|
+
response = get_theme_by_name(site: site, name: name)
|
261
275
|
check_authorized(response)
|
262
276
|
parsed_response = JSON.parse(response.body)
|
263
277
|
conn = Faraday.new(
|
264
|
-
url: "#{root_api}/api/v1/admin/themes/#{parsed_response['theme']['id']}/set_current",
|
278
|
+
url: "#{root_api}/api/v1/admin/themes/#{parsed_response['theme']['id']}/set_current?site_name=#{site}",
|
265
279
|
params: {param: '1'},
|
266
280
|
headers: {
|
267
281
|
'Content-Type' => 'application/json',
|
268
|
-
'
|
282
|
+
'api-token' => @token
|
269
283
|
}
|
270
284
|
)
|
271
285
|
response = conn.patch do |req|
|
@@ -275,13 +289,13 @@ class Pagiii::ThemeSync
|
|
275
289
|
|
276
290
|
private
|
277
291
|
|
278
|
-
def download_asset(theme_id:, key:)
|
292
|
+
def download_asset(site:,theme_id:, key:)
|
279
293
|
conn = Faraday.new(
|
280
|
-
url: "#{root_api}/api/v1/admin/themes/#{theme_id}/assets/download?key=#{key}",
|
294
|
+
url: "#{root_api}/api/v1/admin/themes/#{theme_id}/assets/download?key=#{key}&site_name=#{site}",
|
281
295
|
params: {param: '1'},
|
282
296
|
headers: {
|
283
297
|
'Content-Type' => 'application/json',
|
284
|
-
'
|
298
|
+
'api-token' => @token
|
285
299
|
}
|
286
300
|
)
|
287
301
|
response = conn.get
|
data/lib/pagiii.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagiii
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sugiarto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
12
|
-
dependencies:
|
11
|
+
date: 2023-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
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'
|
13
27
|
description: CLI to support themes on pagiii CMS
|
14
28
|
email:
|
15
29
|
- ugidmtest@gmail.com
|
@@ -21,6 +35,7 @@ files:
|
|
21
35
|
- bin/pagiii
|
22
36
|
- lib/pagiii.rb
|
23
37
|
- lib/pagiii/info.rb
|
38
|
+
- lib/pagiii/site_info.rb
|
24
39
|
- lib/pagiii/theme_sync.rb
|
25
40
|
homepage: http://rubygems.org/gems/pagiii
|
26
41
|
licenses:
|