Skip to content

Commit

Permalink
Merge branch 'main' into spike_5000_queries_round_deux
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Dec 11, 2024
2 parents 1c544aa + 4b2f0e1 commit c4fcac0
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 23 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', require: false
gem 'cal-heatmap-rails', '~> 3.6' # provides assets for cal heatmap, that requires old d3
gem 'colorize', require: false
gem 'cookies_eu'
gem 'd3-rails', '~> 3.5.5' # For cal heatmap
gem 'devise', '>= 4.6.2'
gem 'devise_invitable', '~> 2.0'
Expand Down
5 changes: 0 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ GEM
colorize (1.1.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cookies_eu (1.7.8)
js_cookie_rails (~> 2.2.0)
crack (1.0.0)
bigdecimal
rexml
Expand Down Expand Up @@ -225,8 +223,6 @@ GEM
thor (>= 0.14, < 2.0)
jquery-ui-rails (7.0.0)
railties (>= 3.2.16)
js_cookie_rails (2.2.0)
railties (>= 3.1)
json (2.9.0)
json-jwt (1.16.7)
activesupport (>= 4.2)
Expand Down Expand Up @@ -547,7 +543,6 @@ DEPENDENCIES
cal-heatmap-rails (~> 3.6)
capybara
colorize
cookies_eu
d3-rails (~> 3.5.5)
debug
derailed_benchmarks
Expand Down
Binary file added app/assets/images/algolia-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions app/assets/javascripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
//= require d3
//= require d3-tip

// Cookie prompt only renders properly in the core app
//= require cookies_eu

//= require angular/angular
//= require ace-builds/src-min-noconflict/ace
//= require ace-builds/src-min-noconflict/ext-language_tools
Expand Down
2 changes: 0 additions & 2 deletions app/assets/stylesheets/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* We use Bootstrap Icons to have icons that work between core and the rest of the app
*= require bootstrap-icons/font/bootstrap-icons
*
*= require cookies_eu
*
*= require fonts
*= require bootstrap3-add
*
Expand Down
4 changes: 2 additions & 2 deletions app/assets/templates/views/searchResults.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ <h2 class="results-title">

<span ng-show="query.isNotAllRated()" class="pull-right" style="margin-right: 20px;" title="Hop to it! There are unrated results!">
<div class="icon-container">
<i class="bi bi-balloon" style="font-size: 2rem;"></i>
<div class="notification-bubble">3</div>
🐸
<div class="notification-bubble">3</div>
</div>
</span>

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
class PagesController < ApplicationController
skip_before_action :require_login
skip_before_action :check_for_announcement
# before_action :check_page, only: [:show]
before_action :check_page, only: [ :show ]

# def show
# render template: "pages/#{params[:page]}"
# end
def show
render template: "pages/#{params[:page]}"
end

private

Expand Down
27 changes: 26 additions & 1 deletion app/javascript/application2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

// Note: the file in vendor/javascript/vendored-local-time.js is the one that was downloaded via
// importmap pin. See https://github.com/basecamp/local_time/issues/113 for others who suggested
// remaining it
// vendoring it
import "@hotwired/turbo-rails"
import LocalTime from "local-time"
import Cookies from 'js-cookie'
LocalTime.start()

Turbo.config.drive.progressBarDelay = 1
Expand All @@ -17,3 +18,27 @@ import "vega-lite"
import "vega-embed"

window.dispatchEvent(new Event("vega:load"))

// cookies consent toast handling begin
// Only rendered on the home page.
document.addEventListener("turbo:load", function() {
// Show the toast when the page loads if it's been rendered.
// The logic for deciding if we need to show the banner is in the server side partial _consent_toast.html.erb.
const toastEl = document.getElementById('consent_banner');
if (toastEl){
const toast = new bootstrap.Toast(toastEl);
toast.show();
}

const cookiesEuOKButton = document.querySelector('.js-cookies-eu-ok');
if (cookiesEuOKButton) {
cookiesEuOKButton.addEventListener('click', setCookie, false);
}

});

function setCookie() {
const isSecure = location.protocol === 'https:';
Cookies.set('cookie_eu_consented', true, { path: '/', expires: 365, secure: isSecure });
}
// cookies consent toast handling end
20 changes: 20 additions & 0 deletions app/views/home/_consent_toast.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<% unless Rails.application.config.cookies_url.blank? %>
<% if cookies.kind_of? ActionDispatch::Cookies::CookieJar %>
<% if cookies && cookies['cookie_eu_consented'] != 'true' %>
<div class="toast" id="consent_banner" role="alert" data-bs-autohide="true" data-bs-delay="15000">
<div class="toast-header">
<strong class="me-auto">Cookies</strong>
<!--small class="text-muted">11 mins ago</small-->
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Cookies help us deliver our services. By using our services, you agree to our use of cookies.
<div class="mt-2 pt-2 border-top">
<%= link_to 'Learn more', Rails.application.config.cookies_url, class: "btn btn-sm btn-secondary", target: "_blank" %>
<button type="button" class="js-cookies-eu-ok btn btn-primary btn-sm" data-bs-dismiss="toast">Accept</button>
</div>
</div>
</div>
<% end %>
<% end %>
<% end %>
5 changes: 5 additions & 0 deletions app/views/home/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Inspired by https://dev.to/themesberg/tutorial-how-to-build-a-simple-admin-dashb
-->
<%= turbo_stream_from(:notifications) %>

<div class="toast-container top-0 end-0 p-3">
<%= render partial: "consent_toast" %>

</div>

<div class="text-center">
<p/>
<h5 class="card-title"><%= Time.now.strftime("%A, %B %d") %></h5>
Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@

<%= javascript_include_tag 'application', 'data-turbo-track': 'reload' %>
<%= javascript_importmap_tags 'application2' %>


</head>

Expand Down
2 changes: 0 additions & 2 deletions app/views/layouts/core.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
<base href="<%= ENV['RAILS_RELATIVE_URL_ROOT'] %>/">
</head>
<body ng-app="QuepidApp">
<%= render 'cookies_eu/consent_banner', link: '/cookies', target: '_blank' unless Rails.application.config.cookies_url.blank? %>

<%= render 'layouts/header_core_app' %>

<div id="main-content">
Expand Down
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
pin 'vega', to: 'vega.js'
pin 'vega-lite', to: 'vega-lite.js'
pin 'vega-embed', to: 'vega-embed.js'
pin 'js-cookie' # @3.0.5
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@
get '/scorers' => 'core#index'

# Static pages
# get '*page' => 'pages#show'
#
get '*page' => 'pages#show'
end
# rubocop:enable Metrics/BlockLength
2 changes: 2 additions & 0 deletions docs/operating_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ PRIVACY_URL # privacy policy
COOKIES_URL # cookies policy
```

Quepid ships with a default cookie policy page available via `COOKIES_URL=/cookies`.

To comply with GDPR, and be a good citizen, the hosted version of Quepid asks if they are willing to receive Quepid related updates via email. This feature isn't useful to private installs, so this controls the display.

```
Expand Down
4 changes: 4 additions & 0 deletions vendor/javascript/js-cookie.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4fcac0

Please sign in to comment.