sinatra-hexacta 1.3.0 → 1.4.4
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/sinatra/extensions/mailsender.rb +35 -11
- data/lib/sinatra/handlers/cross_origin.rb +22 -0
- data/lib/sinatra/handlers/init.rb +1 -0
- data/lib/sinatra/helpers/user_configurations.rb +0 -1
- data/lib/sinatra/hexacta.rb +1 -0
- data/lib/sinatra/public/js/app.js +4 -0
- data/lib/sinatra/views/inputs/select.slim +18 -2
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 309f78d43f4e7447e920edaa8e90d36f4992e1cdc0fde8a40ee7ad8f0e17498a
|
4
|
+
data.tar.gz: 66e5d4cceb9b6bf3e1f83919bc2f0962827ef6fba83d459eec4aceea85ac6675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c0c94b820a01db53ae1450f5dd014ca2d1541b6c9f2bb1a0f216e6579b64352ef59bfb2940e405e69a8ae7f19eef4b0f3e434d178a51d75cf3bfe75751b019e
|
7
|
+
data.tar.gz: 3536f3971f4cb17aa0674a496b98d33d2794a0dfe84bf5418ce88b8b4b9e65354d7a7784226b2bf3378cf9de4a775d9f72ef740280b4afc6c0d134c8f5e55e74
|
@@ -20,16 +20,32 @@ class MailSender
|
|
20
20
|
http.start { |http| http.request(request) }
|
21
21
|
end
|
22
22
|
|
23
|
+
|
23
24
|
def _authorize_mail
|
24
25
|
params = [ [ "grant_type", "password" ], [ "client_id", "MailApp" ], [ "client_secret", "MailAppPRD2018!" ] ]
|
25
|
-
|
26
|
+
retry_times = 0
|
27
|
+
begin
|
28
|
+
response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
|
29
|
+
rescue StandardError => bang
|
30
|
+
response = nil
|
31
|
+
end
|
32
|
+
until response.is_a?( Net::HTTPSuccess ) || retry_times > 10 do
|
33
|
+
begin
|
34
|
+
retry_times = retry_times + 1
|
35
|
+
sleep(retry_times)
|
36
|
+
response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
|
37
|
+
rescue StandardError => bang
|
38
|
+
end
|
39
|
+
end
|
26
40
|
if( response.is_a?( Net::HTTPSuccess ) )
|
27
41
|
token = JSON.parse(response.body)
|
28
42
|
@access_token = token["access_token"]
|
29
43
|
@refresh_token = token["refresh_token"]
|
30
44
|
@expire = DateTime.parse(token[".expires"])
|
45
|
+
return true
|
31
46
|
else
|
32
47
|
NotificationSender.instance.send_error(nil,'Authorize mail failed',response.body)
|
48
|
+
return false
|
33
49
|
end
|
34
50
|
end
|
35
51
|
|
@@ -54,26 +70,34 @@ class MailSender
|
|
54
70
|
end
|
55
71
|
|
56
72
|
def _expired?
|
57
|
-
expire.nil? || DateTime.now < expire
|
73
|
+
@expire.nil? || DateTime.now < @expire
|
58
74
|
end
|
59
75
|
|
76
|
+
|
60
77
|
def do_send(mail)
|
61
|
-
|
62
|
-
if _expired?
|
63
|
-
_authorize_mail
|
64
|
-
end
|
78
|
+
authorized = _expired?? _authorize_mail : true
|
65
79
|
|
80
|
+
if authorized
|
66
81
|
params = [ [ "ApplicationCode", 2009 ], [ "Name", mail.template ], [ "Subject", mail.subject ], [ "EmailAddress", mail.from ] ]
|
67
82
|
params = params + _build_map_values(mail.values) + _build_to_map(mail.to)
|
68
83
|
|
69
|
-
|
70
|
-
|
84
|
+
retry_times = 0
|
85
|
+
begin
|
86
|
+
response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
|
87
|
+
rescue StandardError => bang
|
88
|
+
response = nil
|
89
|
+
end
|
90
|
+
until response.is_a?( Net::HTTPSuccess ) || retry_times > 10 do
|
91
|
+
begin
|
92
|
+
retry_times = retry_times + 1
|
93
|
+
sleep(retry_times)
|
94
|
+
response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
|
95
|
+
rescue StandardError => bang
|
96
|
+
end
|
97
|
+
end
|
71
98
|
if( !response.is_a?( Net::HTTPSuccess ) )
|
72
99
|
NotificationSender.instance.send_error(nil,'Send mail failed',response.body)
|
73
100
|
end
|
74
|
-
rescue StandardError => error
|
75
|
-
message = error.backtrace.join(',');
|
76
|
-
NotificationSender.instance.send_error(nil,"Mail send error",message)
|
77
101
|
end
|
78
102
|
end
|
79
103
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Sinatra
|
3
|
+
module CrossOriginHandler
|
4
|
+
extend Hexacta
|
5
|
+
|
6
|
+
def enable_cross_origin
|
7
|
+
p "Enabling cross origin..."
|
8
|
+
|
9
|
+
configure do
|
10
|
+
enable :cross_origin
|
11
|
+
end
|
12
|
+
|
13
|
+
before do
|
14
|
+
response.headers['Access-Control-Allow-Origin'] = '*'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
register CrossOriginHandler
|
21
|
+
end
|
22
|
+
|
@@ -14,7 +14,6 @@ module Sinatra
|
|
14
14
|
p "Setting up user configurations directory..."
|
15
15
|
setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/user_configurations")
|
16
16
|
copy_all_files("/lib/sinatra/views/user_configurations","/app/views/#{Hexacta::GEM_FILE_DIR}/user_configurations")
|
17
|
-
|
18
17
|
end
|
19
18
|
|
20
19
|
helpers UserConfigurationHelper
|
data/lib/sinatra/hexacta.rb
CHANGED
@@ -11,7 +11,16 @@
|
|
11
11
|
-unless defined? readonly
|
12
12
|
-readonly = false
|
13
13
|
|
14
|
-
-if
|
14
|
+
-if readonly
|
15
|
+
.form-group
|
16
|
+
label #{placeholder}
|
17
|
+
select.chosen id="#{id}" class="#{clazz}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;") disabled=""
|
18
|
+
-for element in elements
|
19
|
+
-if chosen == element[:value]
|
20
|
+
option value="#{element[:value]}" selected="" #{element[:text]}
|
21
|
+
-else
|
22
|
+
option value="#{element[:value]}" #{element[:text]}
|
23
|
+
-elsif required
|
15
24
|
.form-group.has-success
|
16
25
|
label #{placeholder}
|
17
26
|
select.chosen.form-control id="#{id}" class="#{clazz}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;") required=""
|
@@ -29,4 +38,11 @@
|
|
29
38
|
-if chosen == element[:value]
|
30
39
|
option value="#{element[:value]}" selected="" #{element[:text]}
|
31
40
|
-else
|
32
|
-
option value="#{element[:value]}" #{element[:text]}
|
41
|
+
option value="#{element[:value]}" #{element[:text]}
|
42
|
+
|
43
|
+
|
44
|
+
/ For enabling
|
45
|
+
/ var myselect=$('select');
|
46
|
+
/ myselect.chosen();
|
47
|
+
/ myselect.prop('disabled', true);
|
48
|
+
/ myselect.trigger("chosen:updated");
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-hexacta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Zanger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sucker_punch
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.0.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra-cross_origin
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.3.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.3.1
|
69
83
|
description: A gem to support general functionality accross all apps
|
70
84
|
email: mzanger@hexacta.com
|
71
85
|
executables: []
|
@@ -84,6 +98,7 @@ files:
|
|
84
98
|
- lib/sinatra/extensions/notification.rb
|
85
99
|
- lib/sinatra/extensions/processmanager.rb
|
86
100
|
- lib/sinatra/handlers/constants.rb
|
101
|
+
- lib/sinatra/handlers/cross_origin.rb
|
87
102
|
- lib/sinatra/handlers/errors.rb
|
88
103
|
- lib/sinatra/handlers/init.rb
|
89
104
|
- lib/sinatra/handlers/notifications.rb
|