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 +4 -4
- data/app/assets/stylesheets/beyond_canvas/components/_layouts.sass +5 -0
- data/app/assets/stylesheets/beyond_canvas.sass +1 -0
- data/app/controllers/beyond_canvas/application_controller.rb +16 -0
- data/app/controllers/concerns/beyond_canvas/locale_management.rb +12 -17
- data/lib/beyond_canvas/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a704eb8fc8c4b55d55948f72b6f694d67bac4c4fd668a3542f1c2e0a3826bfdb
         | 
| 4 | 
            +
              data.tar.gz: 9521ae434f1eeee686b9f3421a79057cf807ad854f881be29e2d8ccffceab5e1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bd1726b41d4a3e55a4704660b2056dad15a4ec191b35377bb4275b2396885fa1591dd4402f2ff21b29035ae61a4719d54d137ab509efcd04287a400674616f3a
         | 
| 7 | 
            +
              data.tar.gz: fa0bec465852750728d95e985a61797fde9625d38c771fe2a97f367475f8ffbfbeaff17bba23e12c30869b0c3583b6b7fb6f6eba57fe82a47eedf9a9f3aadc90
         | 
| @@ -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 + | 
| 24 | 
            -
                # compatible locale (if + | 
| 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 | 
            -
                   | 
| 28 | 
            -
             | 
| 29 | 
            -
                   | 
| 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 | 
            -
                #  | 
| 45 | 
            +
                # Checks if the given locale parameter is included on +I18n.available_locales+
         | 
| 51 46 | 
             
                #
         | 
| 52 | 
            -
                def  | 
| 53 | 
            -
                   | 
| 47 | 
            +
                def valid_locale?(locale)
         | 
| 48 | 
            +
                  I18n.available_locales.map(&:to_s).include? locale
         | 
| 54 49 | 
             
                end
         | 
| 55 50 | 
             
              end
         | 
| 56 51 | 
             
            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. | 
| 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- | 
| 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
         |