Skip to content

Commit

Permalink
feature: Add cookie banner
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jul 3, 2024
1 parent e0d8338 commit 6d8740a
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 9 deletions.
40 changes: 40 additions & 0 deletions app/assets/stylesheets/bioportal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1254,4 +1254,44 @@ turbo-frame[busy] ~ .show-if-loading {

.hide{
display:none;
}

.cookies-modal {
position: fixed;
height: auto;
top: initial;
left: initial;
right: 10px;
bottom: 10px;
transform: initial;
grid-template-rows: minmax(0, 1fr);
z-index: 99999;
background: white;
border-style: solid;
border-color: #f2f2f2;
border-radius: 0;
border-width: 0;
padding: 15px 20px;
display: grid;
grid-gap: 10px;
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
width: 526px;
grid-row-gap: 10px;

h4{
justify-self: center;
font-size: 16px;
color: var(--primary-color);
font-weight: 500;
}
p {
word-wrap: break-word;
font-size: 12px;
margin-bottom: 5px;
}
.cookie-privacy-link {
font-size: 12px;
text-align: center;
text-decoration: underline;
}
}
5 changes: 5 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def index

end

def set_cookies
session[:cookies_accepted] = params[:cookies] if params[:cookies]
render 'cookies', layout: nil
end

def tools
@tools = {
search: {
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ def ontologies_selector(id:, label: nil, name: nil, selected: nil, placeholder:
end
end

def link_button_component(href: , value: , id:, size: nil)
render Buttons::RegularButtonComponent.new(id:id, value: value, variant: "primary", type: 'link', href: href, size: size)
end

def save_button_component(class_name: nil, id: , value:, data: nil, size: nil, type: nil)
content_tag(:div, data: data, class: class_name) do
render Buttons::RegularButtonComponent.new(id:id, value: value, variant: "primary", state: 'regular', size: size, type: type) do |btn|
Expand Down
18 changes: 18 additions & 0 deletions app/views/home/cookies.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
= turbo_frame_tag :cookies_modal do
- if session[:cookies_accepted].nil? # don't re-render if a true/false selected
%section.cookies-modal
%h4
= t('cookies_modal.title')
%p
= t('cookies_modal.paragraph1')
%p
= t('cookies_modal.paragraph2')
%p
= t('cookies_modal.paragraph3')
%div.d-flex
%div.w-50
= link_button_component(id:'accept-cookie-selector', value: t('cookies_modal.accept_button'), href: cookies_path(cookies: true), size: "slim")
%div.w-50.ml-1
= link_button_component(id:'deny-cookie-selector', value: t('cookies_modal.deny_button'), href: cookies_path(cookies: false), size: "slim")
%div.cookie-privacy-link
= link_to t('cookies_modal.privacy_link'), $FOOTER_LINKS.dig(:sections, :agreements, :privacy_policy)
5 changes: 3 additions & 2 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</head>
<body class="<%= controller_name %> <%= action_name %>">
<%=render partial: 'layouts/topnav'%>

<div class="flex-grow-1">
<%= turbo_frame_tag :cookies_modal, src: cookies_path if session[:cookies_accepted].nil? %>

<div class="flex-grow-1">
<%=render partial: 'layouts/notices'%>
3 changes: 2 additions & 1 deletion app/views/layouts/appliance.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

%body{:class => "#{controller_name} #{action_name}"}
= render partial: "layouts/topnav"

= turbo_frame_tag :cookies_modal, src: cookies_path if session[:cookies_accepted].nil?

%div.flex-grow-1
= render partial: "layouts/notices"
= modal_frame_container
Expand Down
14 changes: 11 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ en:
export_metadata: Export all metadata
abstract: Abstract
description: Description

htaccess_modal_title: "Rewrite rules for %{acronym} semantic resource"
instructions_servers: Instructions for %{server} servers
htaccess_redirection_description: "We offer a seamless solution to make your semantic resource URIs resolvable and content negotiable by allowing URL redirection for your semantic resource URIs to our EcoPortal URIs. To facilitate this process, we've provided you with a set of .htaccess rewrite rules. By following the simple instructions below, you'll be able to implement these rules swiftly and efficiently, ensuring smooth redirection"
Expand Down Expand Up @@ -1374,7 +1374,7 @@ en:
instruction_4_content: "Run the following command to test the redirection configuration `sudo nginx -t`"
instruction_5: "Reload Nginx to apply the changes:"
instruction_5_content: "Restart the nginx server to apply the redirection using this command `sudo systemctl reload nginx`"

components:
check_resolvability: checking resolvability...
error_block: child_data_generator block did not provide all the child arguements
Expand Down Expand Up @@ -1462,4 +1462,12 @@ en:
description: >
This tool/service verifies the resolvability of Uniform Resource Identifiers (URIs) and their content negotiability.
It checks whether a given URI is accessible and whether the content associated with it can be negotiated based on the client's preferences.
This functionality ensures the reliability and accessibility of linked resources within the RDF ecosystem, aiding in maintaining data integrity and facilitating seamless integration with external resources.
This functionality ensures the reliability and accessibility of linked resources within the RDF ecosystem, aiding in maintaining data integrity and facilitating seamless integration with external resources.
cookies_modal:
title: "Manage Cookie Consent"
paragraph1: "We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies in the \"Privacy Statement\" link."
paragraph2: "We also use third-party cookies that help us analyse how you use this website, store your preferences, and provide the content that is relevant to you. These cookies will only be stored in your browser with your prior consent."
paragraph3: "Please note that disabling such cookies may affect your browsing experience."
accept_button: "Accept"
deny_button: "Deny"
privacy_link: "Privacy Statement"
14 changes: 11 additions & 3 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ fr:
total_results: Résultats totaux
insert_sample_text: Insérer un texte d'exemple
sample_text: Il y a eu de nombreuses études récentes sur l'utilisation d'antagonistes microbiens pour contrôler les maladies causées par des bactéries phytopathogènes telluriques
et aériennes, dans le but de remplacer les méthodes actuelles de contrôle chimique et d'éviter l'utilisation extensive de fongicides, qui conduisent souvent à une résistance chez les pathogènes des plantes.
En agriculture, les microorganismes promoteurs de croissance des plantes et de biocontrôle ont émergé comme des alternatives sûres aux pesticides chimiques. Les espèces de Streptomyces et leurs
métabolites peuvent avoir un grand potentiel en tant qu'agents excellents pour contrôler divers phytopathogènes fongiques et bactériens.
et aériennes, dans le but de remplacer les méthodes actuelles de contrôle chimique et d'éviter l'utilisation extensive de fongicides, qui conduisent souvent à une résistance chez les pathogènes des plantes.
En agriculture, les microorganismes promoteurs de croissance des plantes et de biocontrôle ont émergé comme des alternatives sûres aux pesticides chimiques. Les espèces de Streptomyces et leurs
métabolites peuvent avoir un grand potentiel en tant qu'agents excellents pour contrôler divers phytopathogènes fongiques et bactériens.

concepts:
error_valid_concept: "Erreur : Vous devez fournir un identifiant de concept valide"
Expand Down Expand Up @@ -1505,3 +1505,11 @@ fr:
Cette fonctionnalité garantit la fiabilité et l'accessibilité des ressources liées dans l'écosystème RDF, aidant ainsi à maintenir l'intégrité des données et facilitant l'intégration transparente avec des ressources externes.
cookies_modal:
title: "Gérer le consentement des cookies"
paragraph1: "Nous utilisons des cookies pour vous aider à naviguer efficacement et à effectuer certaines fonctions. Vous trouverez des informations détaillées sur tous les cookies dans le lien \"Déclaration de confidentialité\"."
paragraph2: "Nous utilisons également des cookies tiers qui nous aident à analyser comment vous utilisez ce site Web, à stocker vos préférences et à fournir le contenu qui vous est pertinent. Ces cookies ne seront stockés dans votre navigateur qu'avec votre consentement préalable."
paragraph3: "Veuillez noter que la désactivation de ces cookies peut affecter votre expérience de navigation."
accept_button: "Accepter"
deny_button: "Refuser"
privacy_link: "Déclaration de confidentialité"
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
match 'cookies', to: 'home#set_cookies', via: [:post, :get]

root to: 'home#index'
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
Expand Down

0 comments on commit 6d8740a

Please sign in to comment.