diff --git a/Gemfile b/Gemfile index 612a5bc28ebb7f29a3513dd5722e0d3d73a96c4a..63370895bb064f8f55e6fd88362e1ac62b1d9d79 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ gem "font-awesome-sass" gem "front_matter_parser" gem "gdpr" gem "geocoder", "~> 1.8" +gem "geo_point" gem "gitlab" gem "hal_openscience", "~> 0.1" # gem "hal_openscience", path: "../hal_openscience" @@ -38,6 +39,7 @@ gem "jquery-rails" gem "jquery-ui-rails", "~> 6.0.1" gem "kamifusen"#, path: "../kamifusen" gem "kaminari" +gem "leaflet-rails" gem "mini_magick" gem "octokit" gem "omniauth-rails_csrf_protection", "~> 1.0" diff --git a/Gemfile.lock b/Gemfile.lock index c6747c13781548393616547c5d55a2288f0e2c64..b067b14958b12f266689deb332dfa6dddaa31a27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,6 +221,20 @@ GEM js_cookie_rails rails sassc-rails + geo_calc (0.7.8) + activesupport (>= 3.0.1) + geo_units (~> 0.3.2) + i18n (>= 0.5) + require_all (>= 1.2.0) + sugar-high (~> 0.7.2) + sweetloader + geo_point (0.2.6) + geo_calc (>= 0.7.7.1) + geo_units (0.3.4) + activesupport (>= 4) + i18n (>= 0.8) + sugar-high (~> 0.7.2) + sweetloader (~> 0.1.6) geocoder (1.8.1) gitlab (4.19.0) httparty (~> 0.20) @@ -277,6 +291,8 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + leaflet-rails (1.9.3) + rails (>= 4.2.0) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -408,6 +424,7 @@ GEM ffi (~> 1.0) regexp_parser (2.7.0) requests (1.0.2) + require_all (3.0.0) responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) @@ -479,6 +496,10 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) stringio (3.0.5) + sugar-high (0.7.3) + sweetloader (0.1.6) + activesupport (>= 3.0.1) + i18n terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) thor (1.2.1) @@ -560,6 +581,7 @@ DEPENDENCIES font-awesome-sass front_matter_parser gdpr + geo_point geocoder (~> 1.8) gitlab hal_openscience (~> 0.1) @@ -571,6 +593,7 @@ DEPENDENCIES jquery-ui-rails (~> 6.0.1) kamifusen kaminari + leaflet-rails listen (~> 3.3) mini_magick octokit diff --git a/app/assets/javascripts/extranet.js b/app/assets/javascripts/extranet.js index ca7451c7833082a0749e90a3db42f26611bb8c36..1bb3ee541721c56a5c7d12ec8380345569d8f078 100644 --- a/app/assets/javascripts/extranet.js +++ b/app/assets/javascripts/extranet.js @@ -10,6 +10,7 @@ //= require simple_form_bs5_file_input //= require summernote/summernote-bs5 //= require gdpr/cookie_consent +//= require leaflet //= require autocomplete-rails //= require_tree ./application/plugins //= require_tree ./extranet diff --git a/app/assets/stylesheets/extranet.sass b/app/assets/stylesheets/extranet.sass index b0734c2c9ff3388d1896cc41a01490858f54abba..f502e046a4e4422e45379503f399721372a9a218 100644 --- a/app/assets/stylesheets/extranet.sass +++ b/app/assets/stylesheets/extranet.sass @@ -10,6 +10,7 @@ @import 'cropperjs/dist/cropper' @import 'commons/summernote' @import 'commons/bootstrap-icons' +@import 'leaflet' // Default @import 'extranet/layout/*' diff --git a/app/assets/stylesheets/extranet/layout/_leaflet.sass b/app/assets/stylesheets/extranet/layout/_leaflet.sass new file mode 100644 index 0000000000000000000000000000000000000000..715e7ceffaa7ffaa10e3359181947391be033139 --- /dev/null +++ b/app/assets/stylesheets/extranet/layout/_leaflet.sass @@ -0,0 +1,2 @@ +#map + height: 300px \ No newline at end of file diff --git a/app/assets/stylesheets/extranet/layout/_typography.sass b/app/assets/stylesheets/extranet/layout/_typography.sass index 1da69d9fe841a674a87875baa8f1340de88e9194..023898c348f5b397a4cda95a052d0560bfaa2b5d 100644 --- a/app/assets/stylesheets/extranet/layout/_typography.sass +++ b/app/assets/stylesheets/extranet/layout/_typography.sass @@ -5,13 +5,6 @@ font-weight: 400 src: asset-url("Basier-Square/basiersquare-regular-webfont.woff2") format("woff2"), url("Basier-Square/basiersquare-regular-webfont.woff") format("woff") -@font-face - font-display: swap - font-family: 'Basier Square' - font-style: normal - font-weight: 500 - src: asset-url("Basier-Square/basiersquare-medium-webfont.woff2") format("woff2"), url("Basier-Square/basiersquare-medium-webfont.woff") format("woff") - @font-face font-display: swap font-family: 'Basier Square' @@ -21,7 +14,7 @@ h1 margin-top: 20px - font-weight: 500 + font-weight: 700 line-height: 125% @include media-breakpoint-up(md) max-width: 70vw diff --git a/app/models/concerns/with_geolocation.rb b/app/models/concerns/with_geolocation.rb index d233db29ec68b0e415874f6a697f2f012e08dd59..df92252bd5228b5eefd05626eeca2dc4a85820d6 100644 --- a/app/models/concerns/with_geolocation.rb +++ b/app/models/concerns/with_geolocation.rb @@ -11,6 +11,28 @@ module WithGeolocation "#{address}, #{zipcode} #{city} #{country}" end + def full_address + string = "" + string += "#{address_name}<br>" if address_name.present? + string += "#{address}<br>" if address.present? + string += "#{address_additional}<br>" if address_additional.present? + string += "#{zipcode} #{city}" + string += "<br>#{ISO3166::Country[country]}" if country + string + end + + def geolocated? + latitude.present? && longitude.present? + end + + def latlong + @latlong ||= [latitude, longitude] + end + + def geo_point + @geo_point ||= GeoPoint.new latitude, longitude + end + protected def full_street_address_present? diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb index 5454b724f81da5f38f0b7b4dcc97649f68077917..760bf3e64e1e0b7f07030a315876c3f4ae82a179 100644 --- a/app/views/admin/university/organizations/show.html.erb +++ b/app/views/admin/university/organizations/show.html.erb @@ -34,6 +34,10 @@ <% end %> </div> </div> + <% if @organization.geolocated? %> + <%= osuny_label University::Organization.human_attribute_name('geolocation') %> + <p><%= @organization.geo_point.to_s %></p> + <% end %> <% end %> <%= osuny_panel University::Organization.human_attribute_name('digital') do %> <div class="row pure__row--small"> diff --git a/app/views/extranet/contacts/organizations/show.html.erb b/app/views/extranet/contacts/organizations/show.html.erb index 0a7a6118ac8d40bc55b83df475bfe731aa392d36..7e294913f1fba849ab800f8e7e133a04d0cd0924 100644 --- a/app/views/extranet/contacts/organizations/show.html.erb +++ b/app/views/extranet/contacts/organizations/show.html.erb @@ -13,6 +13,8 @@ <div class="offset-md-1 col-md-3 order-1 order-md-2"> <%= kamifusen_tag @organization.logo, width: 400, class: 'img-fluid organization__logo' if @organization.logo.attached? %> <dl> + <dt><%= University::Organization.human_attribute_name(:address) %></dt> + <dd><%= sanitize @organization.full_address %></dd> <% if @organization.phone.present? %> <dt><%= University::Organization.human_attribute_name(:phone) %></dt> <dd><a href="tel:<%= @organization.phone %>" target="_blank" rel="noreferrer"><%= @organization.phone %></a></dd> @@ -29,6 +31,20 @@ </a> </dd> <% end %> + <% if @organization.geolocated? %> + <dt><%= University::Organization.human_attribute_name(:map) %></dt> + <dl><%= map( + center: { + latlng: @organization.latlong, + zoom: 15 + }, + markers: [ + { + latlng: @organization.latlong + } + ] + ) %></dl> + <% end %> </dl> </div> </div> diff --git a/config/initializers/leaflet.rb b/config/initializers/leaflet.rb new file mode 100644 index 0000000000000000000000000000000000000000..d0bf69b811405d9748d79c4e78e5224f525210ea --- /dev/null +++ b/config/initializers/leaflet.rb @@ -0,0 +1,3 @@ +Leaflet.tile_layer = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" +Leaflet.attribution = "Osuny" +Leaflet.max_zoom = 18 diff --git a/config/locales/university/en.yml b/config/locales/university/en.yml index fe0f1837a2e62dab6835db1f1cfd4a7ec72e502b..b71021709b80578c36b747a0c278993028422419 100644 --- a/config/locales/university/en.yml +++ b/config/locales/university/en.yml @@ -92,12 +92,14 @@ en: description: Personne morale liée à une université, une composante, un laboratoire, etc. digital: Digital contact email: Email + geolocation: Geographical coordinates kind: Kind legal: Legal information linkedin: LinkedIn logo: Logo for light backgrounds (default) logo_on_dark_background: Logo for dark backgrounds (optional) long_name: Long name + map: Map name: Name phone: Telephone physical: Contact information diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index 00e6aa77c29a083deb905d3114caa9949e73379c..8214f25cd9d402d78a1fbc9b3e43e5651ab27f36 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -93,11 +93,13 @@ fr: digital: Coordonnées numériques email: Email kind: Type + geolocation: Coordonnées géographiques legal: Informations légales linkedin: LinkedIn logo: Logo sur fond clair (par défaut) logo_on_dark_background: Logo sur fond sombre (optionnel) long_name: Nom complet + map: Carte name: Nom phone: Téléphone physical: Coordonnées physiques