phoseum-cli 0.0.24 → 0.0.30

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: 0b2515ecd25464bc144a69a49c3886cfb026c0d8f0ddf472027164b93e6919c5
4
- data.tar.gz: 5f6264f4f0d50d4d154f7a4741cc846b52d778f7729f416cbf603f3523afda54
3
+ metadata.gz: f53423a1821a507dc1d206fb7c6353a0de579a4f18c301504b0d48f8bda44215
4
+ data.tar.gz: d66ca654de0d5b95c58744f3647aab47ec5a598b1b30f5ee61b907a0d0342767
5
5
  SHA512:
6
- metadata.gz: be476a9a88cc455cf16ba96ecc8716b162c7031fa75e1613d171b5247529b2484167733aba93f068d84348baf0403ad57db8395aa28bfc485b029c92a86cde15
7
- data.tar.gz: 0ee2429307623d92a6791681f0ba8bcb036057d95776ca2db4cd7639a40a4f83053cba655fc27694da20d007b4515305593a41b40761de65e24d28650bbbc1ed
6
+ metadata.gz: 3da519912424da022ff5ba68455a3759be3445d7e0a184e04b5d0a1b00dce296c82f36edff730ed01f95be186ec59d39985c0deff7431e94bb002c6f8cd2b0d6
7
+ data.tar.gz: 7a42a48b927f9d2a220618b38acdbc67e19621f6807a4cbc0b899238357e84f6ce21f586e372a72954c215f82b2561ae0d9567ea58dd25ee396ee14d78c255a7
data/bin/phoseum-cli CHANGED
@@ -205,14 +205,13 @@ def health(what='',name='')
205
205
 
206
206
  if list['success']
207
207
  data=list['success']
208
-
209
208
  if data['Albums']
210
209
  puts " >> Albums Available at this level (#{data['Albums'].count})".green if !$QUIET
211
210
  data['Albums'].each do |album|
212
211
  if $DEBUG
213
212
  puts JSON.pretty_generate(album)
214
213
  else
215
- created = DateTime.strptime(album['created'],'%s')
214
+ created = DateTime.strptime(album['created'].to_s,'%s')
216
215
  puts "Name: #{album['name']} | Web Path: #{album['web_path']} | description: #{album['description']} | created: #{created} "
217
216
  end
218
217
  end
@@ -224,8 +223,9 @@ def health(what='',name='')
224
223
  if $DEBUG
225
224
  puts JSON.pretty_generate(photo)
226
225
  else
227
- added = DateTime.strptime(photo['added'],'%s')
228
- puts "Name: #{photo['name']} | Filename: #{photo['image']} | Format: #{photo['full_info']['format']} | Dim.(WxH): #{photo['full_info']['geometry']['width']} x #{photo['full_info']['geometry']['height']} | Size: #{photo['size']} | Included: #{added}"
226
+ added = DateTime.strptime(photo['added'].to_s,'%s')
227
+ photo['exif']=JSON.parse(photo['exif'])
228
+ puts "Name: #{photo['name']} | Filename: #{photo['image']} | Format: #{photo['exif']['format']} | Dim.(WxH): #{photo['exif']['geometry']['width']} x #{photo['exif']['geometry']['height']} | Size: #{photo['size']} | Included: #{added}"
229
229
  end
230
230
  end
231
231
  end
@@ -287,10 +287,11 @@ def user_login(puser='',ppass='')
287
287
  data=list['success']
288
288
  puts data if !$QUIET
289
289
  $config['TOKEN']=list['token']
290
- home_cfg=File.expand_path('~/.phoseum/cli-config.yml')
291
- file_to_write = home_cfg
292
- File.open(file_to_write, 'w') do |f|
293
- f.write(Psych.dump($config))
290
+ begin
291
+ save_config('cli',$config)
292
+ puts "New configuration saved" if $DEBUG
293
+ rescue StandardError => e
294
+ puts "ERROR: Failed to save configuration :: #{e}"
294
295
  end
295
296
  puts "Newly received token is: #{list['token']}" if $DEBUG
296
297
  return list['token']
@@ -370,4 +370,4 @@ def local_version
370
370
  return
371
371
  end
372
372
 
373
- VERSION_SIGN="0.0.24"
373
+ VERSION_SIGN="0.0.30"
@@ -124,6 +124,17 @@ def load_config(who)
124
124
  puts "CLI CFG Not found: #{file_to_load} "
125
125
  exit 1
126
126
  end
127
+ elsif who == "fe"
128
+ local_dir=Dir.pwd
129
+ home_cfg=File.expand_path("#{local_dir}/cfg")
130
+ file_to_load = [home_cfg,"phoseum-fe-config.yml"].join('/')
131
+ if !Dir.exist?(home_cfg)
132
+ gen_config(who)
133
+ puts "New configuration was generated for #{file_to_load} FrontEnd."
134
+ end
135
+ if !File.file?(file_to_load)
136
+ puts "FE CFG Not found: #{file_to_load} "
137
+ end
127
138
  else
128
139
  puts "Not sure which configuration to load. Abort."
129
140
  exit 1
@@ -134,15 +145,36 @@ def load_config(who)
134
145
  puts "Opening configuration from #{file_to_load}" if config_data['DEBUG']
135
146
  rescue
136
147
  puts "Failed loading configuration from #{file_to_load}"
137
- exit 1
148
+ exit 1 if who != 'fe'
149
+ return false
138
150
  end
139
151
  return config_data
140
152
  end
141
153
 
142
- def gen_config(who)
154
+ def sane_config(type,key)
155
+ ct = {}
156
+ case type
157
+ when 'cli'
158
+ ct = { type => ['SERVER','DEBUG','PORT','CALL_TIMEOUT','DEFAULT_SECRET','TOKEN']}
159
+ when 'api'
160
+ ct = { type => ['THREADED','BASEALBUM','ALBUM_URL','STORE_DIR','DEBUG','PORT','EXT_URL','MAX_IMG_SIZE','RESIZE','RESAMPLE','CALL_TIMEOUT','DEFAULT_SECRET']}
161
+ when 'fe'
162
+ ct = { type => ['THEME','THEME_STYLE','LIMIT','NXT_LOAD','SCROLL_SPEED','ROTATE_TO','SCROLL_BACK','LOGO','TITLE_P','TITLE_B','IMG_LABEL','REFRESH_DELETE','IMG_COLUMNS','ALB_COLUMNS','DEF_VIEW','LOAD_METHOD']}
163
+ end
143
164
 
165
+ good_key=false
166
+ ct[type].each do |k|
167
+ if k == key
168
+ good_key=true
169
+ end
170
+ end
171
+ return good_key
172
+ end
173
+
174
+ def gen_config(who)
144
175
  local_config={}
145
176
  file_to_write=''
177
+ local_dir=Dir.pwd
146
178
 
147
179
  case who
148
180
  when "cli"
@@ -164,10 +196,9 @@ def gen_config(who)
164
196
  end
165
197
  file_to_write = [home_cfg,"cli-config.yml"].join('/')
166
198
  puts "Creating config at #{file_to_write}"
167
-
168
199
  when "api"
169
200
  local_config['THREADED']=false
170
- local_dir=Dir.pwd
201
+ local_config['SUBCHECK']=true
171
202
  local_config['BASEALBUM']="#{local_dir}/Albums"
172
203
  local_config['ALBUM_URL']="Albums"
173
204
  local_config['STORE_DIR']="#{local_dir}"
@@ -188,12 +219,57 @@ def gen_config(who)
188
219
  new_secret = SecureRandom.base64(32)
189
220
  local_config['DEFAULT_SECRET'] = new_secret
190
221
  puts "\nGenerating new secret: #{new_secret}"
222
+ when "fe"
223
+ local_config['THEME']="Default"
224
+ local_config['THEME_STYLE']="single"
225
+ local_config['LIMIT']=30
226
+ local_config['NXT_LOAD']=10
227
+ local_config['SCROLL_SPEED']=40
228
+ local_config['SCROLL_BACK']="smooth"
229
+ local_config['ROTATE_TO']="left"
230
+ local_config['DEF_VIEW']="basic"
231
+ local_config['LOGO']="logo-phoseum.png"
232
+ local_config['TITLE_P']="Your personal museum of photography"
233
+ local_config['TITLE_B']="Phoseum"
234
+ local_config['IMG_LABEL']=false
235
+ local_config['REFRESH_DELETE']=false
236
+ local_config['LOAD_METHOD']="auto"
237
+ local_config['IMG_COLUMNS']=4
238
+ local_config['ALB_COLUMNS']=4
191
239
 
240
+ home_cfg="#{local_dir}/cfg"
241
+ if !Dir.exist?(home_cfg)
242
+ Dir.mkdir(home_cfg)
243
+ end
244
+ file_to_write = [home_cfg,"phoseum-fe-config.yml"].join('/')
245
+ puts "Creating config at #{file_to_write}"
192
246
  end
193
-
194
247
  File.open(file_to_write, 'w') do |f|
195
248
  f.write(Psych.dump(local_config))
196
249
  end
197
250
  return true
251
+ end
252
+
253
+ def save_config(which,config_var)
254
+ file_to_write=''
255
+ local_dir=Dir.pwd
256
+
257
+ case which
258
+ when "cli"
259
+ home_cfg=File.expand_path('~/.phoseum/')
260
+ file_to_write = [home_cfg,"cli-config.yml"].join('/')
261
+ when "api"
262
+ home_cfg="#{local_dir}/cfg"
263
+ file_to_write = [home_cfg,"phoseum-api-config.yml"].join('/')
264
+ when "fe"
265
+ home_cfg="#{local_dir}/cfg"
266
+ file_to_write = [home_cfg,"phoseum-fe-config.yml"].join('/')
267
+ end
268
+ puts "Saving #{which} config at #{file_to_write}" if $config['DEBUG']
269
+
270
+ File.open(file_to_write, 'w') do |f|
271
+ f.write(Psych.dump(config_var))
272
+ end
273
+ return true
198
274
 
199
275
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoseum-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julio C Hegedus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-28 00:00:00.000000000 Z
11
+ date: 2022-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.1.4
148
+ rubygems_version: 3.3.8
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Client for Phoseum