Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.19.0 #621

Merged
merged 62 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b1cc32b
db/seeds.rb: Give restroom entries an edit_id (#567)
DeeDeeG Mar 31, 2019
7aaf380
Explain how to run individual tests and access psql (#570)
Apr 3, 2019
be1f773
Make filter with "focus" class more readable
Hkly Apr 25, 2019
207baa4
Remove unused li
Hkly Apr 25, 2019
8a46a26
Allow dropdown menu text to wrap and fit within the dropdown
Hkly Apr 25, 2019
3c406be
Merge pull request #583 from Hkly/filter-focus-color
mi-wood Apr 27, 2019
e1d35b9
Merge pull request #584 from Hkly/word-wrap-dropdown-menu
mi-wood Apr 27, 2019
9b2f321
yarn.lock: Update jquery (#587)
DeeDeeG May 13, 2019
16b9bde
Dockerfile: Update and streamline steps (#586)
DeeDeeG May 27, 2019
c02db62
Dockerfile: Get latest Node.js in a major version (#589)
DeeDeeG Aug 20, 2019
03d8933
Update Node.js and Ruby dependencies (#590)
DeeDeeG Aug 20, 2019
4d722df
Add Bugsnag to readme
tkwidmer Sep 3, 2019
ca942b3
.travis.yml: Use minimal base image for Travis CI
DeeDeeG Aug 20, 2019
4b86b63
docker-compose.yml: Use postgresql:alpine image
DeeDeeG Aug 20, 2019
c6cf8d9
Merge pull request #591 from DeeDeeG/faster-travis-ci
DeeDeeG Sep 22, 2019
9f3f942
layouts/_footer.html.haml: Remove tumblr link
DeeDeeG Aug 21, 2019
384740e
stylesheets/.../common: Remove tumblr icon stlye
DeeDeeG Aug 21, 2019
89f9162
en/footer.en.yml: Remove string for tumblr blog
DeeDeeG Sep 22, 2019
7074c49
Merge pull request #592 from DeeDeeG/remove-tumblr
DeeDeeG Sep 22, 2019
7fd61d3
removed tumblr from about page (#593)
Oct 1, 2019
b7359cc
Create about.fil.yml (#465)
vinzruzell Feb 19, 2018
b80146f
Filipino Translation devise.fil.yml (#454)
vinzruzell Feb 22, 2018
4fc16ae
100% completed for restroom.fil.yml file (#467)
vinzruzell Feb 25, 2018
d4957e1
Translations for EN to FIL Issue 451 (#556)
Dec 17, 2018
d8a4cfe
config/locales/fil/: Remove tumblr
DeeDeeG Oct 5, 2019
3e46d8d
Updated filipino translations
brynmrk Oct 7, 2019
db3e900
switched sass-rails gem (#595)
btyy77c Oct 8, 2019
b941f43
Changed the word `restroom` to `banyo` to be mroe understandable to m…
brynmrk Oct 9, 2019
ef24b4b
Fixed some unnoticed words that needed some changes in translation
brynmrk Oct 11, 2019
8f9e765
additional translation changes
brynmrk Oct 14, 2019
56e5cbc
Merge pull request #596 from brynmrk/updated_filipino_translations
DeeDeeG Oct 14, 2019
96d4dcc
config/application.rb: Add 'fil' locale (Filipino)
DeeDeeG Oct 14, 2019
ac8f6ab
.travis.yml: Set "dist" to "trusty" (#600)
DeeDeeG Oct 25, 2019
9b76d05
config/application.rb: Set default locale to "en"
DeeDeeG Oct 19, 2019
a71013b
production.rb: Fix i18n.fallbacks deprecation warn
DeeDeeG Oct 19, 2019
7378cda
production.rb: I18n fallbacks for :tl --> :fil
DeeDeeG Oct 19, 2019
c4e9d20
config/application.rb: Add Tagalog (:tl) locale
DeeDeeG Oct 19, 2019
15e2e42
Merge pull request #599 from DeeDeeG/i18n-fallbacks
DeeDeeG Oct 26, 2019
17f8762
package.json: Update swagger to master with patch
DeeDeeG Oct 15, 2019
2a56975
yarn.lock: Update all packages
DeeDeeG Oct 15, 2019
701d9df
Gemfile[.lock]: Update devise, simple_form
DeeDeeG Oct 15, 2019
1750825
Merge pull request #597 from DeeDeeG/update-dependencies
DeeDeeG Oct 26, 2019
c388c97
yarn.lock: Upgrade swagger-ui's dependencies
DeeDeeG Oct 26, 2019
792ed5b
Ruby: Upgrade from 2.5.3 to 2.5.7
DeeDeeG Oct 14, 2019
77715cb
Dockerfile: Work around an issue with phantomjs
DeeDeeG Oct 26, 2019
05c74cb
Merge pull request #598 from DeeDeeG/ruby-2.5.7
DeeDeeG Oct 26, 2019
7381796
Merge branch 'master' into develop
tkwidmer Oct 29, 2019
6c96368
Fix Travis tests failing on distributions other than trusty (#606)
stardust66 Nov 1, 2019
5154cd1
Dockerfile: Upgrade Node from v10.x to v12.x (#603)
DeeDeeG Nov 1, 2019
01c3c21
Webpack Upgrade (#607)
btyy77c Dec 21, 2019
c6dc441
PR #607: Minor tweaks/cleanup
DeeDeeG Dec 21, 2019
da6e0e2
CONTRIBUTING.md: Remove the reference to "Cmd + C"
DeeDeeG Dec 21, 2019
297980c
db/schema.rb: Commit with underscores in date
DeeDeeG Dec 24, 2019
3714303
restrooms_spec.rb: Fix a test (#608)
DeeDeeG Dec 24, 2019
89c8355
Update some dependencies, fix some deprecation warnings (#609)
DeeDeeG Jan 5, 2020
61e5df4
Tweak CSS a bit for narrow screens (e.g. mobile phones) (#610)
DeeDeeG Jan 5, 2020
dd5441e
CSS: Center logo and brand name on narrow screens (#611)
DeeDeeG Jan 28, 2020
cc9f2a7
Update docker config (#616)
DeeDeeG Mar 17, 2020
15fe9f7
Ruby: Update from 2.5.7 to 2.5.8 (#618)
DeeDeeG Apr 2, 2020
a3ba4b7
Update Node.JS and Ruby Dependencies (#617)
DeeDeeG Apr 4, 2020
73de17f
Implement Google's reCAPTCHA (#566)
stardust66 Apr 13, 2020
93d5733
Merge branch 'master' into develop
mi-wood Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export DEVISE_SECRET_KEY=3f4915489bd10fdbacb4f22dbf772a4be6e2d2d1616a1af7913f0f6645784ddffd6a71ab9f69a99ed7941f16d3092e1872bc4bc9add5a0615c630c90f94fc032
export RAILS_SECRET_KEY=4944cf251e3dbf309ed71ebcd8990a1479d793011cd4011761e3fbea9ecc59edefd0cb49a0ed9b5c0261ab0dda841962bb7dd28fd3f99579bfa2beec26329961
export RECAPTCHA_SITE_KEY=6Le_W5gUAAAAAJFOELNu2LkSR2E6sXYIVZrMe6V0
export RECAPTCHA_SECRET_KEY=6Le_W5gUAAAAABZpnGQtfVaQdfluuLrf8wihooeo
26 changes: 19 additions & 7 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
require_relative '../helpers/recaptcha_helper'

class ContactsController < ApplicationController
def new
@contact = Contact.new(restroom_id: params['restroom_id'], restroom_name: params['restroom_name'])
end

def create
@contact = Contact.new(params[:contact])
unless @contact.valid?
flash.now[:error] = I18n.t('contacts.submitted.cannot-send')
render :new
return
end

# Verify recaptcha code
recaptcha_response = params['g-recaptcha-response']
unless RecaptchaHelper.valid_token? recaptcha_response
flash.now[:error] = I18n.t('helpers.reCAPTCHA.failed')
render :new
return
end

@contact.request = request
if @contact.deliver
flash.now[:error] = nil
flash.now[:notice] = I18n.t('contacts.submitted.thank-you-exclamation')
else
flash.now[:error] = I18n.t('contacts.submitted.cannot-send')
render :new
end
@contact.deliver
flash.now[:error] = nil
flash.now[:notice] = I18n.t('contacts.submitted.thank-you-exclamation')
end
end
15 changes: 13 additions & 2 deletions app/controllers/restrooms_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../helpers/recaptcha_helper'

class RestroomsController < ApplicationController
respond_to :html, :json

Expand Down Expand Up @@ -27,8 +29,17 @@ def new
end

def create
restroom = Restroom.new(permitted_params)
@restroom = SaveRestroom.new(restroom).call
@restroom = Restroom.new(permitted_params)

# Verify recaptcha code
recaptcha_response = params['g-recaptcha-response']
unless RecaptchaHelper.valid_token? recaptcha_response
flash.now[:error] = I18n.t('helpers.reCAPTCHA.failed')
render 'new'
return
end

@restroom = SaveRestroom.new(@restroom).call

if @restroom.errors.empty?
if @restroom.approved?
Expand Down
25 changes: 25 additions & 0 deletions app/helpers/recaptcha_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'net/http'
require 'uri'
require 'json'

module RecaptchaHelper
def self.valid_token?(token)
# Get secret from env
secret = ENV['RECAPTCHA_SECRET_KEY']

uri = URI('https://www.google.com/recaptcha/api/siteverify')
request = Net::HTTP::Post.new(uri)
request.set_form_data('secret' => secret, 'response' => token)
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https|
https.request(request)
end

# Check response
json_body = JSON.parse(response.body)
if json_body['success']
true
else
false
end
end
end
2 changes: 2 additions & 0 deletions app/views/contacts/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
= f.hidden_field :restroom_id, :required => false
= f.hidden_field :restroom_name, :required => false
= f.hidden_field :nickname, :hint => t('.leave-this-field-blank')
.form-group
.g-recaptcha{'data-sitekey' => "#{ENV['RECAPTCHA_SITE_KEY']}"}
.form-actions
= f.button :submit, :class=> "linkbutton"
1 change: 1 addition & 0 deletions app/views/layouts/_head.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
%meta{:content => "initial-scale=1, maximum-scale=1", :name => "viewport"}/

%script{:src => "https://maps.googleapis.com/maps/api/js?v=quarterly&libraries=places&key=AIzaSyBXcCrqzMlm-ZmtNQve7AuipNdE4vySUF0"}
= javascript_include_tag "https://www.google.com/recaptcha/api.js", :async => true, :defer => true
= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
= javascript_pack_tag "application", "data-turbolinks-track": "reload"
= csrf_meta_tags
Expand Down
3 changes: 3 additions & 0 deletions app/views/restrooms/_formsubmit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
= f.input :directions, :placeholder => t('restroom.directions_hint'), :as => :text, :required => false, :input_html => { :class => "span6" }
= f.input :comment, :placeholder => t('restroom.comments_hint'), :as => :text, :required => false, :input_html => { :class => "span6" }

.form-group
.g-recaptcha{'data-sitekey' => "#{ENV['RECAPTCHA_SITE_KEY']}"}

/ Click to preview location
%button{type: 'button', class: 'preview-btn linkbutton'}
= t('restroom.preview')
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/simple_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
# in this configuration, which is recommended due to some quirks from different browsers.
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
# change this configuration to true.
config.browser_validations = false
config.browser_validations = true

# Collection of methods to detect if a file type was given.
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ en:
message: 'Message'

helpers:
reCAPTCHA:
failed: 'reCAPTCHA required.'
submit:
contact:
# This is the "Send message" button on the "Contact" page.
Expand Down
6 changes: 6 additions & 0 deletions spec/support/rspec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'capybara/poltergeist'
require 'capybara/rspec'
require 'rspec/rails'
require 'json'
# spec/spec_helper.rb
#

Expand All @@ -25,6 +26,11 @@
.with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'})
.to_return(:status => 200, :body => File.new("#{Rails.root}/spec/fixtures/guess_in_oakland.json"), :headers => {})

recaptcha_response = {'success' => true}
stub_request(:post, 'https://www.google.com/recaptcha/api/siteverify')
.to_return(status: 200, body: recaptcha_response.to_json,
headers: {'Content-Type' => 'application/json'})

# Akismet response for spam
stub_request(:post, /.*.rest.akismet.com\/1.1\/comment-check/).
with(body: /^.*Spam.*$/).
Expand Down