diff options
-rw-r--r-- | app/assets/stylesheets/components/cookies_banner.css | 16 | ||||
-rw-r--r-- | app/controllers/sessions_controller.rb | 7 | ||||
-rw-r--r-- | app/views/layouts/_cookies.html.erb | 8 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 1 | ||||
-rw-r--r-- | config/routes.rb | 4 |
5 files changed, 35 insertions, 1 deletions
diff --git a/app/assets/stylesheets/components/cookies_banner.css b/app/assets/stylesheets/components/cookies_banner.css new file mode 100644 index 0000000..b675e82 --- /dev/null +++ b/app/assets/stylesheets/components/cookies_banner.css @@ -0,0 +1,16 @@ +#cookies-banner { + position: fixed; + bottom: 0; + height: 30%; + width: 100%; + background-color: darkred; + color: white; + text-align: center; + padding: 1em; + font-family: 'Arial', sans-serif; +} + +#cookies-banner p { + /* margin: 0; */ + font-weight: bold; +} diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 9785c92..fad2c4b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,5 @@ class SessionsController < ApplicationController - allow_unauthenticated_access only: %i[ new create ] + allow_unauthenticated_access only: %i[ new create dismiss_banner ] rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." } def new @@ -18,4 +18,9 @@ class SessionsController < ApplicationController terminate_session redirect_to new_session_path end + + def dismiss_banner + session[:dismissed_banner] = true + redirect_to root_path + end end diff --git a/app/views/layouts/_cookies.html.erb b/app/views/layouts/_cookies.html.erb new file mode 100644 index 0000000..0e6949a --- /dev/null +++ b/app/views/layouts/_cookies.html.erb @@ -0,0 +1,8 @@ +<div id="cookies-banner"> + <p> + Acceptez les cookies ou contribuer 2 € à la tartiflette de + Nicolas 💸 + </p> + <%= button_to "Accepter les cookies", dismiss_banner_path %> + <%= button_to "Faire un don", dismiss_banner_path %> +</div> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 680dec1..c9ca629 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -29,5 +29,6 @@ <%= yield %> </main> <%= render "layouts/footer" %> + <%= render "layouts/cookies" unless session[:dismissed_banner] %> </body> </html> diff --git a/config/routes.rb b/config/routes.rb index efa9589..2f18da0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,10 @@ Rails.application.routes.draw do to: "code_of_honor#toggle", as: :toggle_code_of_honor + post '/dismiss_banner', + to: 'sessions#dismiss_banner', + as: :dismiss_banner + resources :tartiflettes do get "scores/edit", to: "scores#edit_all", |