glib-web 3.22.0 → 3.22.2

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: 61bf1dd4994bb6105fb043e7b7b0943cb44e4e418baf246556855816442d6293
4
- data.tar.gz: 88902efc0cc5e18d925a1261106df0dca345f5880959dc2cbaca1a91938f83d4
3
+ metadata.gz: 806df354ed58edcee98f342d40209e0f42b16343f79427941accd17b796d6c33
4
+ data.tar.gz: 8b0de205b315c74ad1a773cf6963f461e2952cf1fbf5f36e63aea66c648c4640
5
5
  SHA512:
6
- metadata.gz: 8b86a31567e3e1eeb2252d5e3fa72796e563873ee7ff72f394e322227a876c31267bc4462383c323ebba40f302fa5fc16be86703569b86ebec3607cbc8caa967
7
- data.tar.gz: ebdd87d23e46513bfce6804d6d1ed3fd6004cd00fa9c57b706aace77350d0c13b8603a8344b5e285535286b8fbb8e0b3bbdd23aeb227597ea289709736822e7f
6
+ metadata.gz: 5e9062feefed9651443c3a128de05df41e63a755cafdc10b66167f60643b9bf847a1dc4c68af9f95e8b9eff4f7a0f3b52d31fa61907575a6f09de7903dffb684
7
+ data.tar.gz: 651ae04bd671192239d8bc08e144733a011f6777e6b33347739579ec7511c7ff9bd9d0f23ff36ff110076242424606ac0500cb80ba0212b4487f788b177b7f55
@@ -62,14 +62,27 @@ module Glib::Json::Libs
62
62
  JSON.parse(render_to_string(template, locals: args))
63
63
  end
64
64
 
65
- def glib_redirect_to(url)
65
+ def glib_html_url(url)
66
+ url = url.include?('?') ? url.sub(/.json\?/, '?') : url.sub(/.json$/, '')
67
+
68
+ # As much as possible, try retaining the front fragment by matching the back, because
69
+ # the front could be either a `?` or `&`
70
+ url = url.sub(/format=json\&/, '');
71
+
72
+ # If no match, then we replace the front fragment
73
+ url.sub(/[\&\?]format=json/, '');
74
+ end
75
+
76
+ def glib_redirect_to(url, return_to_previous: false)
77
+ url = __delete_redirect_back_url(url) if return_to_previous
78
+
66
79
  respond_to do |format|
67
80
  format.html do
68
81
  redirect_to url
69
82
  end
70
83
  format.json do
71
84
  if __json_ui_rendering?
72
- redirect_to url
85
+ redirect_to glib_html_url(url)
73
86
  return
74
87
  end
75
88
 
@@ -147,10 +160,10 @@ module Glib::Json::Libs
147
160
  session.delete(REDIRECT_BACK_KEY) || url
148
161
  end
149
162
 
150
- def html_ui_redirect_back_or_to(default_url)
151
- redirect_url = __delete_redirect_back_url(default_url)
152
- redirect_to redirect_url
153
- end
163
+ # def html_ui_redirect_back_or_to(default_url)
164
+ # redirect_url = __delete_redirect_back_url(default_url)
165
+ # redirect_to redirect_url
166
+ # end
154
167
 
155
168
  def json_ui_redirect_back_or_to(default_url, json_action)
156
169
  redirect_url = __delete_redirect_back_url(default_url)
@@ -210,9 +223,15 @@ module Glib::Json::Libs
210
223
  end
211
224
 
212
225
  def json_ui_redirect_to(url)
213
- render json: {
214
- onResponse: { action: 'dialogs/close', onClose: { action: 'windows/open', url: url } }
215
- }
226
+ # `onLoad` also executes in `onResponse` situation, e.g. form submit.
227
+ on_load = { action: 'windows/open', url: url }
228
+
229
+ if glib_json_dialog_mode?
230
+ # Only do this in dialog mode because this seems to add to the rendering time
231
+ # (i.e. longer flicker time), presumably due to the use of things like `nextTick()`.
232
+ on_load = { action: 'dialogs/close', onClose: on_load }
233
+ end
234
+ render json: { onLoad: on_load }
216
235
  end
217
236
 
218
237
  module ClassMethods
@@ -1,7 +1,7 @@
1
1
  module Glib
2
2
  module UrlsHelper
3
- def glib_url_current(new_params = {})
4
- url_for(params.to_unsafe_h.merge(new_params.merge(only_path: false)))
3
+ def glib_url_current(override_params: params.to_unsafe_h, extra_params: {})
4
+ url_for(override_params.merge(extra_params.merge(only_path: false)))
5
5
  end
6
6
 
7
7
  def glib_url_equals_current?(url)
@@ -1,5 +1,6 @@
1
+ # Deprecated. Use Glib::Crypt instead.
1
2
  module Glib
2
- module Crypt
3
+ class Crypt
3
4
  class Utils
4
5
  def self.encrypt(original_message, encryption_secret, encryption_salt)
5
6
  encryptor = message_encryptor(encryption_secret, encryption_salt)
data/lib/glib/crypt.rb CHANGED
@@ -1 +1,28 @@
1
1
  require_relative './crypt/utils'
2
+
3
+ # A replacement of Glib::Crypt::Utils
4
+ module Glib
5
+ class Crypt
6
+ # Recommended digest: 'SHA256'
7
+ def self.encrypt(original_message, encryption_secret, encryption_salt, digest)
8
+ encryptor = message_encryptor(encryption_secret, encryption_salt, digest)
9
+ CGI.escape(encryptor.encrypt_and_sign(original_message))
10
+ end
11
+
12
+ def self.decrypt(encrypted_message, encryption_secret, encryption_salt, digest)
13
+ encryptor = message_encryptor(encryption_secret, encryption_salt, digest)
14
+ begin
15
+ encryptor.decrypt_and_verify(CGI.unescape(encrypted_message))
16
+ rescue ActiveSupport::MessageEncryptor::InvalidMessage
17
+ nil
18
+ end
19
+ end
20
+
21
+ private
22
+ def self.message_encryptor(encryption_secret, encryption_salt, digest)
23
+ key_generator = ActiveSupport::KeyGenerator.new(encryption_secret, iterations: 1000)
24
+ key_secret = key_generator.generate_key(encryption_salt, 32)
25
+ ActiveSupport::MessageEncryptor.new(key_secret, digest: digest, serializer: JSON)
26
+ end
27
+ end
28
+ end
@@ -24,7 +24,7 @@ module Glib
24
24
  # See TimeFreezableMailer
25
25
  preview.try(:return_time_if_frozen)
26
26
 
27
- _assert_last_mail_body_unchanged("#{preview_class.name.underscore}##{mailer_method}")
27
+ _assert_mail_body_unchanged("#{preview_class.name.underscore}##{mailer_method}", last_mail)
28
28
 
29
29
  # logfile = File.join(log_dir, "#{preview_class.name.underscore}##{mailer_method}.txt")
30
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.22.0
4
+ version: 3.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''