icfs 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/icfs.css +7 -1
- data/data/icfs.js +17 -19
- data/devel/run/base.rb +2 -1
- data/devel/run/case-backup.rb +24 -0
- data/devel/run/case-restore.rb +24 -0
- data/devel/run/copy-s3.rb +2 -0
- data/devel/run/init-icfs.rb +7 -37
- data/devel/run/init-template.rb +33 -0
- data/lib/icfs/api.rb +92 -48
- data/lib/icfs/cache_elastic.rb +10 -2
- data/lib/icfs/config.rb +4 -3
- data/lib/icfs/items.rb +21 -5
- data/lib/icfs/utils/backup.rb +22 -18
- data/lib/icfs/utils/check.rb +24 -22
- data/lib/icfs/web/client.rb +302 -160
- data/lib/icfs.rb +70 -1
- metadata +5 -3
- data/bin/icfs_demo_fcgi.rb +0 -53
data/lib/icfs.rb
CHANGED
@@ -22,7 +22,7 @@ require_relative 'icfs/validate'
|
|
22
22
|
module ICFS
|
23
23
|
|
24
24
|
# version: major, minor, patch
|
25
|
-
Version = [0,
|
25
|
+
Version = [0, 3, 0].freeze
|
26
26
|
|
27
27
|
# version pre-release
|
28
28
|
VersionPre = nil
|
@@ -233,6 +233,75 @@ module ICFS
|
|
233
233
|
end # def self.time_parse()
|
234
234
|
|
235
235
|
|
236
|
+
###############################################
|
237
|
+
# Get epoch time as local
|
238
|
+
#
|
239
|
+
# @param tme [Integer] the epoch time
|
240
|
+
# @param cfg [Config] the config
|
241
|
+
#
|
242
|
+
def self.time_local(tme, cfg)
|
243
|
+
Time.at(tme).getlocal(cfg.get('tz')).strftime('%F %T')
|
244
|
+
end # def self.time_local()
|
245
|
+
|
246
|
+
|
247
|
+
###############################################
|
248
|
+
# Get epoch time as local with weekday
|
249
|
+
#
|
250
|
+
# @param tme [Integer] the epoch time
|
251
|
+
# @param cfg [Config] the config
|
252
|
+
#
|
253
|
+
def self.time_weekday(tme, cfg)
|
254
|
+
Time.at(tme).getlocal(cfg.get('tz')).strftime('%F %T (%a)')
|
255
|
+
end # def self.time_weekday()
|
256
|
+
|
257
|
+
|
258
|
+
###############################################
|
259
|
+
# Get relative display time from epoch
|
260
|
+
#
|
261
|
+
# @param tme [Integer] the epoch time
|
262
|
+
# @return [String] Relative time string
|
263
|
+
#
|
264
|
+
def self.time_relative(tme)
|
265
|
+
rel = Time.now.to_i - tme
|
266
|
+
abs = rel.abs
|
267
|
+
|
268
|
+
# time periods
|
269
|
+
if abs >= (2*365*24*60*60)
|
270
|
+
num = abs / (365*24*60*60)
|
271
|
+
txt = 'years'
|
272
|
+
elsif abs >= (3*7*24*60*60)
|
273
|
+
num = abs / (7*24*60*60)
|
274
|
+
txt = 'weeks'
|
275
|
+
elsif abs >= (3*24*60*60)
|
276
|
+
num = abs / (24*60*60)
|
277
|
+
txt = 'days'
|
278
|
+
elsif abs >= (3*60*60)
|
279
|
+
num = abs / (60*60)
|
280
|
+
txt = 'hours'
|
281
|
+
elsif abs >= 2*60
|
282
|
+
num = abs / 60
|
283
|
+
txt = 'minutes'
|
284
|
+
else
|
285
|
+
num = 0
|
286
|
+
txt = 'just now'
|
287
|
+
end
|
288
|
+
|
289
|
+
# description
|
290
|
+
desc = '%d %s' % [num, txt]
|
291
|
+
|
292
|
+
# before/after
|
293
|
+
if num == 0
|
294
|
+
final = 'just now'
|
295
|
+
elsif rel < 0
|
296
|
+
final = 'in ' + desc
|
297
|
+
else
|
298
|
+
final = desc + ' ago'
|
299
|
+
end
|
300
|
+
|
301
|
+
return final
|
302
|
+
end # def self.time_relative()
|
303
|
+
|
304
|
+
|
236
305
|
##########################################################################
|
237
306
|
# Error
|
238
307
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Graham A. Field
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2-
|
14
14
|
|
@@ -24,7 +24,6 @@ extensions: []
|
|
24
24
|
extra_rdoc_files: []
|
25
25
|
files:
|
26
26
|
- LICENSE.txt
|
27
|
-
- bin/icfs_demo_fcgi.rb
|
28
27
|
- data/icfs.css
|
29
28
|
- data/icfs.js
|
30
29
|
- devel/demo/ssl_gen.rb
|
@@ -33,11 +32,14 @@ files:
|
|
33
32
|
- devel/icfs
|
34
33
|
- devel/icfs-wrk/Dockerfile
|
35
34
|
- devel/run/base.rb
|
35
|
+
- devel/run/case-backup.rb
|
36
|
+
- devel/run/case-restore.rb
|
36
37
|
- devel/run/copy-s3.rb
|
37
38
|
- devel/run/email.rb
|
38
39
|
- devel/run/email_imap.rb
|
39
40
|
- devel/run/email_smime.rb
|
40
41
|
- devel/run/init-icfs.rb
|
42
|
+
- devel/run/init-template.rb
|
41
43
|
- devel/run/webrick.rb
|
42
44
|
- lib/icfs.rb
|
43
45
|
- lib/icfs/api.rb
|
data/bin/icfs_demo_fcgi.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Investigative Case File System
|
4
|
-
#
|
5
|
-
# Copyright 2019 by Graham A. Field
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License version 3.
|
9
|
-
#
|
10
|
-
# This program is distributed WITHOUT ANY WARRANTY; without even the
|
11
|
-
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
12
|
-
|
13
|
-
# frozen_string_literal: true
|
14
|
-
|
15
|
-
require 'yaml'
|
16
|
-
require 'faraday'
|
17
|
-
|
18
|
-
require_relative '../lib/icfs'
|
19
|
-
require_relative '../lib/icfs/cache_elastic'
|
20
|
-
require_relative '../lib/icfs/store_fs'
|
21
|
-
require_relative '../lib/icfs/users_fs'
|
22
|
-
require_relative '../lib/icfs/web/client'
|
23
|
-
require_relative '../lib/icfs/web/auth_ssl'
|
24
|
-
require_relative '../lib/icfs/demo/timezone'
|
25
|
-
|
26
|
-
# load the config file
|
27
|
-
cfg = YAML.load_file(ARGV[0])
|
28
|
-
map = {}
|
29
|
-
cfg['cache']['map'].each do |key, val|
|
30
|
-
map[key.to_sym] = val
|
31
|
-
end
|
32
|
-
|
33
|
-
es = Faraday.new(cfg['elastic']['base'])
|
34
|
-
cache = ICFS::CacheElastic.new(map, es)
|
35
|
-
store = ICFS::StoreFs.new(cfg['store']['dir'])
|
36
|
-
users = ICFS::UsersFs.new(cfg['users']['dir'])
|
37
|
-
api = ICFS::Api.new([], users, cache, store)
|
38
|
-
web = ICFS::Web::Client.new(cfg['web']['css'], cfg['web']['script'])
|
39
|
-
|
40
|
-
user_map = {
|
41
|
-
'CN=client 1,OU=Test Client,OU=example,OU=org' => 'user1',
|
42
|
-
'CN=client 2,OU=Test Client,OU=example,OU=org' => 'user2',
|
43
|
-
'CN=client 3,OU=Test Client,OU=example,OU=org' => 'user3'
|
44
|
-
}
|
45
|
-
|
46
|
-
app = Rack::Builder.new do
|
47
|
-
use(ICFS::Web::AuthSsl, user_map, api)
|
48
|
-
use(ICFS::Demo::Timezone, cfg['web']['tz'])
|
49
|
-
run web
|
50
|
-
end
|
51
|
-
|
52
|
-
puts 'try to run'
|
53
|
-
Rack::Handler::FastCGI.run(app, {Host: '127.0.0.1', Port: 9000} )
|