Skip to content

Commit

Permalink
Merge pull request #346 from a-thousand-channels/ut/345-fuzzydate-to-api
Browse files Browse the repository at this point in the history
Adding fuzzy date to internal and public API, show on map's poup (ref…
  • Loading branch information
ut authored Oct 21, 2024
2 parents 928bf52 + 55672b9 commit 465ccfa
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Style/AsciiComments:
Layout/LineLength:
Enabled: false

Lint/SafeNavigationConsistency:
Enabled: false

Lint/UnusedBlockArgument:
Enabled: false

Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ gem 'cancancan'
gem 'devise'
gem 'exception_notification'
gem 'foundation-icons-sass-rails'
gem 'foundation-rails', '~> 6'
gem 'foundation-rails', '6.6.2.0'
gem 'geocoder'
gem 'haml-rails'
gem 'i18n-js', '~> 3' # breaking changes with v4
Expand All @@ -44,7 +44,7 @@ gem 'simple_form'
gem 'sprockets', '~> 4'
gem 'sprockets-es6'

gem 'image_processing'
gem 'image_processing', '~> 1.2'
gem 'mini_racer', platforms: :ruby
gem 'nokogiri'

Expand Down
49 changes: 27 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ GEM
bcrypt (3.1.20)
bigdecimal (3.1.8)
bindex (0.8.1)
brakeman (6.2.1)
brakeman (6.2.2)
racc
builder (3.3.0)
bundler-audit (0.9.2)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
byebug (11.1.3)
cancancan (3.5.0)
cancancan (3.6.1)
capistrano (3.19.1)
airbrussh (>= 1.0.0)
i18n
Expand Down Expand Up @@ -201,7 +201,7 @@ GEM
image_processing (1.13.0)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jbuilder (2.11.5)
jbuilder (2.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jquery-rails (4.6.0)
Expand All @@ -212,7 +212,7 @@ GEM
railties (>= 3.1.0)
turbolinks
json (2.7.2)
json-schema (5.0.0)
json-schema (5.0.1)
addressable (~> 2.8)
kaminari (1.2.2)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -248,7 +248,7 @@ GEM
marcel (1.0.4)
matrix (0.4.2)
method_source (1.1.0)
mini_exiftool (2.10.4)
mini_exiftool (2.11.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_racer (0.16.0)
Expand All @@ -272,7 +272,7 @@ GEM
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.5.0)
net-protocol
net-ssh (7.2.3)
net-ssh (7.3.0)
nio4r (2.7.3)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
Expand All @@ -282,9 +282,10 @@ GEM
parser (3.3.5.0)
ast (~> 2.4.1)
racc
passenger (6.0.20)
rack
rake (>= 0.8.1)
passenger (6.0.23)
rack (>= 1.6.13)
rackup
rake (>= 12.3.3)
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
Expand All @@ -298,6 +299,9 @@ GEM
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (1.0.0)
rack (< 3)
webrick
rails (6.1.7.9)
actioncable (= 6.1.7.9)
actionmailbox (= 6.1.7.9)
Expand Down Expand Up @@ -339,22 +343,22 @@ GEM
regexp_parser (2.9.2)
repo-small-badge (0.2.10)
victor (~> 0.3.0)
request_store (1.6.0)
request_store (1.7.0)
rack (>= 1.4)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.7)
rexml (3.3.8)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.1)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.5)
Expand All @@ -368,7 +372,7 @@ GEM
rspec-support (3.13.1)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.66.1)
rubocop (1.67.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -380,7 +384,7 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-rspec (3.0.5)
rubocop-rspec (3.1.0)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
Expand Down Expand Up @@ -436,20 +440,20 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sshkit (1.23.1)
sshkit (1.23.2)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
ostruct
sync (0.5.0)
temple (0.10.3)
term-ansicolor (1.7.2)
term-ansicolor (1.11.2)
tins (~> 1.0)
thor (1.3.2)
tilt (2.4.0)
timeout (0.4.1)
tins (1.33.0)
tins (1.37.0)
bigdecimal
sync
tinymce-rails (5.10.9)
Expand Down Expand Up @@ -479,17 +483,18 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0, < 4.11)
webmock (3.23.1)
webmock (3.24.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.2)
websocket (1.2.11)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.7.0)
zeitwerk (2.7.1)

PLATFORMS
x86_64-linux
Expand Down Expand Up @@ -517,12 +522,12 @@ DEPENDENCIES
exception_notification
factory_bot_rails
foundation-icons-sass-rails
foundation-rails (~> 6)
foundation-rails (= 6.6.2.0)
friendly_id
geocoder
haml-rails
i18n-js (~> 3)
image_processing
image_processing (~> 1.2)
jbuilder
jquery-rails
jquery-turbolinks
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/helpers/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function PopupFullContent(place) {
content += "<img src='" + place.imagelink + "' />";
}
content += '<div class="leaflet-popup-content-text">';
if (place.date) {
content += "<p>" + place.date;
if (place.date_with_qualifier) {
content += "<p>" + place.date_with_qualifier;
if (place.address) {
content += " // " + place.address;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/layers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def layer_params
end

def validate_images_format
return unless layer_params && layer_params[:images_files] && layer_params[:images_files].any?
return unless layer_params && layer_params[:images_files]&.any?

layer_params[:images_files].each do |file|
unless ['image/jpeg', 'image/png', 'image/gif'].include?(file.content_type)
Expand Down
8 changes: 8 additions & 0 deletions app/models/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ def date
ApplicationController.helpers.smart_date_display(startdate, enddate)
end

def date_with_qualifier
if (startdate_qualifier && enddate_qualifier) && (startdate_qualifier != '' || enddate_qualifier != '')
ApplicationController.helpers.smart_date_display_with_qualifier(startdate, enddate, startdate_qualifier, enddate_qualifier)
else
date
end
end

def show_link
ApplicationController.helpers.show_link(title, layer.map.id, layer.id, id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/layers/_layer.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ json.extract! layer, :id, :title, :subtitle, :text, :credits, :image_link, :publ
json.url map_layer_url(layer, format: :json)
json.iconset layer.map.iconset, :title, :icon_anchor, :icon_size, :popup_anchor, :class_name if layer.map.iconset
json.places layer.places do |place|
json.extract! place, :id, :title, :subtitle, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :layer_id, :layer_type, :created_at, :updated_at, :date, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.extract! place, :id, :title, :subtitle, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :layer_id, :layer_type, :created_at, :updated_at, :date, :date_with_qualifier, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.lat place.public_lat
json.lon place.public_lon
json.annotations place.annotations do |annotation|
Expand Down
2 changes: 1 addition & 1 deletion app/views/places/_place.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ json.iconset place.layer.map.iconset, :title, :icon_anchor, :icon_size, :popup_a

json.places do
json[] do
json.extract! place, :id, :title, :teaser, :text, :sources, :link, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :layer_id, :created_at, :updated_at, :date, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.extract! place, :id, :title, :teaser, :text, :sources, :link, :date, :date_with_qualifier, :startdate, :enddate, :full_address, :location, :address, :zip, :city, :country, :published, :featured, :layer_id, :created_at, :updated_at, :date, :edit_link, :show_link, :imagelink2, :imagelink, :icon_link, :icon_class, :icon_name
json.lat place.public_lat
json.lon place.public_lon
json.images(place.images).order('sorting ASC') do |image|
Expand Down
2 changes: 1 addition & 1 deletion app/views/public/places/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
json.place do
next unless @place.published

json.call(@place, :id, :uid, :title, :subtitle, :teaser, :text, :sources, :link, :imagelink, :imagelink2, :audiolink, :published, :startdate, :enddate, :startdate_qualifier, :enddate_qualifier, :location, :address, :zip, :city, :text, :country, :featured, :layer_id, :icon_link, :icon_class, :icon_name)
json.call(@place, :id, :uid, :title, :subtitle, :teaser, :text, :sources, :link, :imagelink, :imagelink2, :audiolink, :published, :date, :date_with_qualifier, :startdate, :enddate, :startdate_qualifier, :enddate_qualifier, :location, :address, :zip, :city, :text, :country, :featured, :layer_id, :icon_link, :icon_class, :icon_name)
end

0 comments on commit 465ccfa

Please sign in to comment.