gloo 4.0.0 → 4.1.0
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 +4 -4
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +6 -0
- data/lib/gloo/objs/system/file_handle.rb +9 -1
- data/lib/gloo/objs/web_svr/page.rb +75 -0
- data/lib/gloo/web_svr/asset_info.rb +5 -1
- data/lib/gloo/web_svr/request_params.rb +58 -4
- data/lib/gloo/web_svr/response.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56c4555331bec60162670855f1719a51f45a7e071894e593cc3c03978fc99af
|
4
|
+
data.tar.gz: 4728ef424397e70d8d0cd61ff1aec8bbf89a6eb18474e0a9cb1e283f7fb627a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d08f2ccb6e471d19bc34897a5cce4f906d5b3345e3937b7d291853a9e122783ae797afe56b1e76268dad9f0b6b4eb99a49d577a56cf5261f7d0442b7caf9ff52
|
7
|
+
data.tar.gz: 987e9c14f85397171f44a853fa7db9e7455d1b2afc5a5e515d79cc47b5a8b57629e4e58d2ad28b7c3d7d0d13008634fbd7dd9766580f3d875b20ca795bcfcb86
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.1.0
|
data/lib/VERSION_NOTES
CHANGED
@@ -37,7 +37,7 @@ module Gloo
|
|
37
37
|
# Get a list of message names that this object receives.
|
38
38
|
#
|
39
39
|
def self.messages
|
40
|
-
basic = %w[read write get_name get_ext get_parent get_sha256]
|
40
|
+
basic = %w[read write delete get_name get_ext get_parent get_sha256]
|
41
41
|
checks = %w[exists? is_file? is_dir?]
|
42
42
|
search = %w[find_match]
|
43
43
|
show = %w[show page open]
|
@@ -103,6 +103,14 @@ module Gloo
|
|
103
103
|
File.write( value, data )
|
104
104
|
end
|
105
105
|
|
106
|
+
#
|
107
|
+
# Delete the file.
|
108
|
+
#
|
109
|
+
def msg_delete
|
110
|
+
return unless value
|
111
|
+
File.delete( value )
|
112
|
+
end
|
113
|
+
|
106
114
|
#
|
107
115
|
# Check to see if the file exists.
|
108
116
|
#
|
@@ -35,8 +35,15 @@ module Gloo
|
|
35
35
|
HTML_CONTENT = 'html'.freeze
|
36
36
|
TEXT_CONTENT = 'text'.freeze
|
37
37
|
JSON_CONTENT = 'json'.freeze
|
38
|
+
FILE_CONTENT = 'file'.freeze
|
38
39
|
RETURN_CODE = 'return_code'.freeze
|
39
40
|
|
41
|
+
# Children for FILE pages.
|
42
|
+
FILE_TYPE = 'file_type'.freeze
|
43
|
+
FILE_PATH = 'file_path'.freeze
|
44
|
+
FILE_NAME = 'file_name'.freeze
|
45
|
+
DOWNLOAD_FILE = 'download_file'.freeze
|
46
|
+
|
40
47
|
#
|
41
48
|
# The name of the object type.
|
42
49
|
#
|
@@ -203,6 +210,10 @@ module Gloo
|
|
203
210
|
return content_type == JSON_CONTENT
|
204
211
|
end
|
205
212
|
|
213
|
+
def is_file?
|
214
|
+
return content_type == FILE_CONTENT
|
215
|
+
end
|
216
|
+
|
206
217
|
|
207
218
|
# ---------------------------------------------------------------------
|
208
219
|
# Events
|
@@ -311,6 +322,7 @@ module Gloo
|
|
311
322
|
return content
|
312
323
|
end
|
313
324
|
|
325
|
+
|
314
326
|
# ---------------------------------------------------------------------
|
315
327
|
# Render
|
316
328
|
# ---------------------------------------------------------------------
|
@@ -376,6 +388,8 @@ module Gloo
|
|
376
388
|
contents = render_json
|
377
389
|
elsif is_text?
|
378
390
|
contents = render_text params
|
391
|
+
elsif is_file?
|
392
|
+
contents = render_file params
|
379
393
|
else
|
380
394
|
@engine.err "Unknown content type: #{content_type}"
|
381
395
|
return nil
|
@@ -465,6 +479,67 @@ module Gloo
|
|
465
479
|
return content
|
466
480
|
end
|
467
481
|
|
482
|
+
|
483
|
+
# ---------------------------------------------------------------------
|
484
|
+
# File Renderer
|
485
|
+
# ---------------------------------------------------------------------
|
486
|
+
|
487
|
+
#
|
488
|
+
# Get the type of the file.
|
489
|
+
#
|
490
|
+
def file_type
|
491
|
+
o = find_child FILE_TYPE
|
492
|
+
return nil unless o
|
493
|
+
|
494
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
495
|
+
return o&.value
|
496
|
+
end
|
497
|
+
|
498
|
+
#
|
499
|
+
# Get the path to the file.
|
500
|
+
#
|
501
|
+
def file_path
|
502
|
+
o = find_child FILE_PATH
|
503
|
+
return nil unless o
|
504
|
+
|
505
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
506
|
+
return o&.value
|
507
|
+
end
|
508
|
+
|
509
|
+
#
|
510
|
+
# Get the name of the file.
|
511
|
+
#
|
512
|
+
def file_name
|
513
|
+
o = find_child FILE_NAME
|
514
|
+
return nil unless o
|
515
|
+
|
516
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
517
|
+
return o&.value
|
518
|
+
end
|
519
|
+
|
520
|
+
def download_file
|
521
|
+
o = find_child DOWNLOAD_FILE
|
522
|
+
return false unless o
|
523
|
+
|
524
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
525
|
+
return o&.value
|
526
|
+
end
|
527
|
+
|
528
|
+
#
|
529
|
+
# Render a file.
|
530
|
+
#
|
531
|
+
def render_file params
|
532
|
+
type = file_type
|
533
|
+
data = File.binread file_path
|
534
|
+
code = Gloo::WebSvr::ResponseCode::SUCCESS
|
535
|
+
fname = file_name
|
536
|
+
download = download_file
|
537
|
+
|
538
|
+
return Gloo::WebSvr::Response.new(
|
539
|
+
@engine, code, type, data, true, fname, download )
|
540
|
+
end
|
541
|
+
|
542
|
+
|
468
543
|
end
|
469
544
|
end
|
470
545
|
end
|
@@ -73,6 +73,8 @@ module Gloo
|
|
73
73
|
# Index the the given asset info record.
|
74
74
|
#
|
75
75
|
def self.index info
|
76
|
+
return unless info
|
77
|
+
|
76
78
|
@@index_by_pn[ info.pn ] = info
|
77
79
|
@@index_by_published[ info.published_pn ] = info
|
78
80
|
end
|
@@ -81,7 +83,9 @@ module Gloo
|
|
81
83
|
# Find the asset info for the given published name.
|
82
84
|
#
|
83
85
|
def self.find_published_name_for pn
|
84
|
-
return
|
86
|
+
return nil unless pn
|
87
|
+
|
88
|
+
return @@index_by_pn[ pn ]&.published_pn
|
85
89
|
end
|
86
90
|
|
87
91
|
#
|
@@ -15,7 +15,7 @@ module Gloo
|
|
15
15
|
class RequestParams
|
16
16
|
|
17
17
|
attr_accessor :id, :route_params
|
18
|
-
attr_reader :query_params, :body_params
|
18
|
+
attr_reader :query_params, :body_params, :body_binary
|
19
19
|
|
20
20
|
# ---------------------------------------------------------------------
|
21
21
|
# Initialization
|
@@ -48,13 +48,59 @@ module Gloo
|
|
48
48
|
# Detect the parameters from the body of the request.
|
49
49
|
#
|
50
50
|
def init_body_params body
|
51
|
-
if body
|
52
|
-
|
51
|
+
if body && body.length > 0
|
52
|
+
# if body is binary, then it is not a query string
|
53
|
+
begin
|
54
|
+
@body_params = Rack::Utils.parse_query body
|
55
|
+
rescue => exception
|
56
|
+
init_multipart body
|
57
|
+
end
|
53
58
|
else
|
54
59
|
@body_params = {}
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
63
|
+
#
|
64
|
+
# Set the body to a binary file.
|
65
|
+
#
|
66
|
+
# TODO: find a lib or method to handle this.
|
67
|
+
# This is very rough and will need to be fixed.
|
68
|
+
#
|
69
|
+
def init_multipart body
|
70
|
+
# puts "*********** first lines: *********** "
|
71
|
+
# body.lines[0..3].each { |line| puts line }
|
72
|
+
# puts "*********** last lines: *********** "
|
73
|
+
# body.lines.last(5).each { |line| puts line }
|
74
|
+
# puts "************************************"
|
75
|
+
|
76
|
+
# boundary = body.lines.first
|
77
|
+
# puts "boundary: #{boundary}"
|
78
|
+
|
79
|
+
header = body.lines[1..3].join
|
80
|
+
# puts "header: #{header}"
|
81
|
+
|
82
|
+
footer = body.lines.last(5).join
|
83
|
+
# puts "footer: #{footer}"
|
84
|
+
|
85
|
+
binary_data = body.lines[4..-6].join
|
86
|
+
# puts "binary_data length: #{binary_data.length}"
|
87
|
+
# puts "binary first line: #{binary_data.lines.first}"
|
88
|
+
# puts "binary last line: #{binary_data.lines.last}"
|
89
|
+
|
90
|
+
i = header.lines.first.index( 'filename=' )
|
91
|
+
filename = header.lines.first[ i+10..-4 ]
|
92
|
+
content_type = header.lines.second[14..-3]
|
93
|
+
# puts "filename: #{filename}"
|
94
|
+
# puts "content_type: #{content_type}"
|
95
|
+
|
96
|
+
@body_binary = body
|
97
|
+
@body_params = {}
|
98
|
+
@body_params[ 'content_type' ] = content_type
|
99
|
+
@body_params[ 'file_name' ] = filename
|
100
|
+
@body_params[ 'file_size' ] = binary_data.length
|
101
|
+
@body_params[ 'file_data' ] = binary_data
|
102
|
+
end
|
103
|
+
|
58
104
|
|
59
105
|
# ---------------------------------------------------------------------
|
60
106
|
# Authenticity Token checking
|
@@ -105,7 +151,15 @@ module Gloo
|
|
105
151
|
end
|
106
152
|
|
107
153
|
if @body_params && ! @body_params.empty?
|
108
|
-
@
|
154
|
+
if @body_params[ 'file_data' ]
|
155
|
+
# exclude the file data from the params shown
|
156
|
+
params = @body_params.dup
|
157
|
+
params.delete( 'file_data' )
|
158
|
+
params[ 'file_data' ] = '...'
|
159
|
+
@log.info "--- Body Parameters: #{params}"
|
160
|
+
else
|
161
|
+
@log.info "--- Body Parameters: #{@body_params}"
|
162
|
+
end
|
109
163
|
end
|
110
164
|
end
|
111
165
|
|
@@ -19,6 +19,7 @@ module Gloo
|
|
19
19
|
|
20
20
|
attr_reader :code, :type, :data
|
21
21
|
attr_accessor :location
|
22
|
+
attr_accessor :file_name
|
22
23
|
|
23
24
|
|
24
25
|
# ---------------------------------------------------------------------
|
@@ -32,7 +33,9 @@ module Gloo
|
|
32
33
|
code = Gloo::WebSvr::ResponseCode::SUCCESS,
|
33
34
|
type = HTML_TYPE,
|
34
35
|
data = nil,
|
35
|
-
assetCache = false
|
36
|
+
assetCache = false,
|
37
|
+
file_name = nil,
|
38
|
+
download = false )
|
36
39
|
|
37
40
|
@engine = engine
|
38
41
|
@log = @engine.log if @engine
|
@@ -42,6 +45,8 @@ module Gloo
|
|
42
45
|
@data = data
|
43
46
|
@assetCache = assetCache
|
44
47
|
@location = nil
|
48
|
+
@file_name = file_name
|
49
|
+
@download = download
|
45
50
|
end
|
46
51
|
|
47
52
|
|
@@ -125,8 +130,15 @@ module Gloo
|
|
125
130
|
headers[ 'Location' ] = @location
|
126
131
|
end
|
127
132
|
|
128
|
-
if @assetCache
|
133
|
+
if @assetCache || @file_name
|
129
134
|
headers[ 'Cache-Control' ] = 'public, max-age=604800'
|
135
|
+
headers[ 'Expires' ] = (Time.now.utc + 604800).to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
if @file_name
|
139
|
+
disp = @download ? 'attachment' : 'inline'
|
140
|
+
headers[ 'Content-Disposition' ] = "#{disp}; filename=#{@file_name}"
|
141
|
+
headers[ 'Content-Length' ] = @data.length.to_s
|
130
142
|
end
|
131
143
|
|
132
144
|
session = @engine&.running_app&.obj&.session
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Crane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|