-
-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2521 from luisramos0/cookies_in_engine
[OFN Domains] Breaking OFN into domains - POC cookies inside an engine
- Loading branch information
Showing
41 changed files
with
253 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
@import 'base/*'; | ||
@import '*'; | ||
@import 'pages/*'; | ||
@import '../web/all'; | ||
|
||
ofn-modal { | ||
display: block; | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'web/cookies_consent' | ||
|
||
module FooterLinksHelper | ||
def cookies_policy_link | ||
link_to( t( '.footer_data_cookies_policy' ), '', 'cookies-policy-modal' => true, 'cookies-banner' => !Web::CookiesConsent.new(cookies, request.host).exists? && Spree::Config.cookies_consent_banner_toggle) | ||
end | ||
|
||
def privacy_policy_link | ||
link_to( t( '.footer_data_privacy_policy' ), Spree::Config.privacy_policy_url, target: '_blank' ) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Web | ||
|
||
This is the rails engine for the Web domain. | ||
|
||
See our wiki for [more info about domains and engines in OFN](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Tech-Doc:-How-OFN-is-organized-in-Domains-using-Rails-Engines). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This is a manifest file that'll be compiled into application.js, which will include all the files | ||
// listed below. | ||
// | ||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | ||
// | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// the compiled file. | ||
// | ||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD | ||
// GO AFTER THE REQUIRES BELOW. | ||
// | ||
//= require_tree . |
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...banner/cookies_banner_directive.js.coffee → ...banner/cookies_banner_directive.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
Darkswarm.directive 'cookiesBanner', (CookiesBannerService) -> | ||
Darkswarm.directive 'cookiesBanner', (CookiesBannerService, CookiesPolicyModalService) -> | ||
restrict: 'A' | ||
link: (scope, elm, attr)-> | ||
return if not attr.cookiesBanner? || attr.cookiesBanner == 'false' | ||
CookiesBannerService.enable() | ||
return if CookiesPolicyModalService.isEnabled() | ||
CookiesBannerService.open() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import 'web/pages/cookies_banner'; | ||
@import 'web/pages/cookies_policy_modal'; |
2 changes: 1 addition & 1 deletion
2
...s/darkswarm/pages/cookies_banner.css.scss → ...esheets/web/pages/cookies_banner.css.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@import '../branding'; | ||
@import 'darkswarm/branding'; | ||
|
||
.cookies-banner { | ||
background: $dark-grey; | ||
|
2 changes: 1 addition & 1 deletion
2
...swarm/pages/cookies_policy_modal.css.scss → ...s/web/pages/cookies_policy_modal.css.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@import '../branding'; | ||
@import 'darkswarm/branding'; | ||
|
||
.cookies-policy-modal { | ||
background: $disabled-light; | ||
|
9 changes: 9 additions & 0 deletions
9
engines/web/app/controllers/web/angular_templates_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Web | ||
class AngularTemplatesController < ApplicationController | ||
helper Web::Engine.helpers | ||
|
||
def show | ||
render params[:id].to_s, layout: nil | ||
end | ||
end | ||
end |
30 changes: 30 additions & 0 deletions
30
engines/web/app/controllers/web/api/cookies_consent_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require_dependency 'web/cookies_consent' | ||
|
||
module Web | ||
module Api | ||
class CookiesConsentController < BaseController | ||
include ActionController::Cookies | ||
respond_to :json | ||
|
||
def show | ||
render json: { cookies_consent: cookies_consent.exists? } | ||
end | ||
|
||
def create | ||
cookies_consent.set | ||
show | ||
end | ||
|
||
def destroy | ||
cookies_consent.destroy | ||
show | ||
end | ||
|
||
private | ||
|
||
def cookies_consent | ||
@cookies_consent ||= Web::CookiesConsent.new(cookies, request.host) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Web | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery with: :exception | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Web | ||
module CookiesPolicyHelper | ||
def render_cookie_entry(cookie_name, cookie_desc, cookie_domain = nil) | ||
render partial: 'cookies_policy_entry', | ||
locals: { cookie_name: cookie_name, | ||
cookie_desc: cookie_desc, | ||
cookie_domain: cookie_domain } | ||
end | ||
|
||
def matomo_iframe_src | ||
"#{Spree::Config.matomo_url}"\ | ||
"/index.php?module=CoreAdminHome&action=optOut"\ | ||
"&language=#{locale_language}"\ | ||
"&backgroundColor=&fontColor=222222&fontSize=16px&fontFamily=%22Roboto%22%2C%20Arial%2C%20sans-serif" | ||
end | ||
|
||
# removes country from locale if needed | ||
# for example, both locales en and en_GB return language en | ||
def locale_language | ||
I18n.locale[0..1] | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Web::Engine.routes.draw do | ||
namespace :api do | ||
scope '/cookies' do | ||
resource :consent, only: [:show, :create, :destroy], controller: "cookies_consent" | ||
end | ||
end | ||
|
||
get "/angular-templates/:id", to: "angular_templates#show", constraints: { name: %r{[\/\w\.]+} } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require "web/engine" | ||
|
||
module Web | ||
end |
Oops, something went wrong.