beyond_canvas 0.11.2.pre → 0.12.0.pre

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e3fb33f8c3a76af104b94c6bb5291c6c6b4a4a0ff9e62f5388c282289f0dec9
4
- data.tar.gz: 41a5f4403e38347a5050e8a0390ecf636617d60813f0e76d709003e7b32d9261
3
+ metadata.gz: a704eb8fc8c4b55d55948f72b6f694d67bac4c4fd668a3542f1c2e0a3826bfdb
4
+ data.tar.gz: 9521ae434f1eeee686b9f3421a79057cf807ad854f881be29e2d8ccffceab5e1
5
5
  SHA512:
6
- metadata.gz: 49992be8568fb4962642c4e400753d1ceec3daa8b7802d2065864a2ae6ba7b6e678217342a74baa3dfa75938fc0159dc893fcd40a8c2dcc1f7e555149ae25031
7
- data.tar.gz: 35a6b36b8832265a71a4e40bb7ff3eca879cca0dae6cc72d980d86dfc972c9f7b509720d414dfac527e242d0fe6ed78660b97eb98085b129ad7b55817c4415ca
6
+ metadata.gz: bd1726b41d4a3e55a4704660b2056dad15a4ec191b35377bb4275b2396885fa1591dd4402f2ff21b29035ae61a4719d54d137ab509efcd04287a400674616f3a
7
+ data.tar.gz: fa0bec465852750728d95e985a61797fde9625d38c771fe2a97f367475f8ffbfbeaff17bba23e12c30869b0c3583b6b7fb6f6eba57fe82a47eedf9a9f3aadc90
@@ -0,0 +1,5 @@
1
+ .body--public
2
+
3
+ .select--locale
4
+ +position(absolute, 40px 40px null null)
5
+ width: 200px
@@ -13,6 +13,7 @@
13
13
  @import 'beyond_canvas/components/flash'
14
14
  @import 'beyond_canvas/components/forms'
15
15
  @import 'beyond_canvas/components/inputs'
16
+ @import 'beyond_canvas/components/layouts'
16
17
  @import 'beyond_canvas/components/links'
17
18
  @import 'beyond_canvas/components/main'
18
19
  @import 'beyond_canvas/components/margins'
@@ -5,5 +5,21 @@ module BeyondCanvas
5
5
  protect_from_forgery with: :exception
6
6
 
7
7
  include ::BeyondCanvas::LocaleManagement
8
+
9
+ def update_locale
10
+ cookies[:locale] = { value: app_locale_params[:locale], expires: 1.day.from_now }
11
+ set_locale
12
+
13
+ redirect_back(fallback_location: main_app.root_path)
14
+ end
15
+
16
+ private
17
+
18
+ #
19
+ # Strong parameters for locale switch
20
+ #
21
+ def app_locale_params
22
+ params.require(:app).permit(:locale)
23
+ end
8
24
  end
9
25
  end
@@ -6,27 +6,22 @@ module BeyondCanvas
6
6
 
7
7
  included do
8
8
  before_action :set_locale, except: :update_locale
9
-
10
- def update_locale
11
- if I18n.available_locales.map(&:to_s).include? app_locale_params[:locale]
12
- session[:locale] = app_locale_params[:locale]
13
- set_locale
14
- end
15
-
16
- redirect_back(fallback_location: main_app.root_path)
17
- end
18
9
  end
19
10
 
20
11
  private
21
12
 
22
13
  #
23
- # Sets the I18n.locale to either +session[ :locale ]+ or the browser
24
- # compatible locale (if +session[ :locale ]+ is not set)
14
+ # Sets the I18n.locale to either +cookies[ :locale ]+ or the browser
15
+ # compatible locale (if +cookies[ :locale ]+ is not set)
25
16
  #
26
17
  def set_locale
27
- puts '*' * 100
28
- puts '*' * 100
29
- I18n.locale = session[:locale] || session[:locale] = browser_compatible_locale
18
+ unless valid_locale?(cookies[:locale])
19
+ cookies[:locale] = { value: browser_compatible_locale, expires: 1.day.from_now }
20
+ end
21
+
22
+ I18n.locale = cookies[:locale]
23
+
24
+ logger.debug "[BeyondCanvas] Locale set to: #{I18n.locale}".yellow
30
25
  end
31
26
 
32
27
  #
@@ -47,10 +42,10 @@ module BeyondCanvas
47
42
  end
48
43
 
49
44
  #
50
- # Strong parameters for locale switch
45
+ # Checks if the given locale parameter is included on +I18n.available_locales+
51
46
  #
52
- def app_locale_params
53
- params.require(:app).permit(:locale)
47
+ def valid_locale?(locale)
48
+ I18n.available_locales.map(&:to_s).include? locale
54
49
  end
55
50
  end
56
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeyondCanvas
4
- VERSION = '0.11.2.pre'
4
+ VERSION = '0.12.0.pre'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2.pre
4
+ version: 0.12.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-30 00:00:00.000000000 Z
11
+ date: 2020-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bourbon
@@ -167,6 +167,7 @@ files:
167
167
  - app/assets/stylesheets/beyond_canvas/components/_flash.sass
168
168
  - app/assets/stylesheets/beyond_canvas/components/_forms.sass
169
169
  - app/assets/stylesheets/beyond_canvas/components/_inputs.sass
170
+ - app/assets/stylesheets/beyond_canvas/components/_layouts.sass
170
171
  - app/assets/stylesheets/beyond_canvas/components/_links.sass
171
172
  - app/assets/stylesheets/beyond_canvas/components/_main.sass
172
173
  - app/assets/stylesheets/beyond_canvas/components/_margins.sass