From c0a3378d2587c9fda27e97645799dd7a008819a1 Mon Sep 17 00:00:00 2001 From: hellekin Date: Thu, 8 Oct 2020 17:38:04 +0200 Subject: Make map more beautiful This commit introduces a few things: 1. New `content_for` hooks for :debug, :head, and :body_end so that views code remains consistent and clean 2. Fullscreen map! 3. Welcome#index view, the Rails way It also moves controller-related code to the controller, Enjoy! --- app/assets/images/incommon-map-icon.svg | 116 +++++++++++++++++++++++++ app/assets/stylesheets/application/_body.scss | 4 + app/assets/stylesheets/application/_debug.scss | 12 +++ app/assets/stylesheets/application/_map.scss | 14 +++ app/controllers/welcome_controller.rb | 2 + app/views/application/_debug.html.erb | 5 ++ app/views/layouts/application.html.erb | 3 + app/views/welcome/index.html.erb | 53 +++++------ 8 files changed, 177 insertions(+), 32 deletions(-) create mode 100644 app/assets/images/incommon-map-icon.svg create mode 100644 app/assets/stylesheets/application/_debug.scss create mode 100644 app/assets/stylesheets/application/_map.scss create mode 100644 app/views/application/_debug.html.erb (limited to 'app') diff --git a/app/assets/images/incommon-map-icon.svg b/app/assets/images/incommon-map-icon.svg new file mode 100644 index 0000000..558325a --- /dev/null +++ b/app/assets/images/incommon-map-icon.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/app/assets/stylesheets/application/_body.scss b/app/assets/stylesheets/application/_body.scss index cadac51..f151b47 100644 --- a/app/assets/stylesheets/application/_body.scss +++ b/app/assets/stylesheets/application/_body.scss @@ -38,6 +38,10 @@ body { } } +main > article { + background-color: rgba(255, 255, 255, 0.8); +} + img { max-width: 100%; } diff --git a/app/assets/stylesheets/application/_debug.scss b/app/assets/stylesheets/application/_debug.scss new file mode 100644 index 0000000..75b1988 --- /dev/null +++ b/app/assets/stylesheets/application/_debug.scss @@ -0,0 +1,12 @@ +/* + DEBUG +*/ + +#debug { + position: fixed; + bottom: 0; + left: 0; + padding: 0.5rem; + background-color: rgba(255,0,0,0.5); + color: white; +} diff --git a/app/assets/stylesheets/application/_map.scss b/app/assets/stylesheets/application/_map.scss new file mode 100644 index 0000000..d2330e1 --- /dev/null +++ b/app/assets/stylesheets/application/_map.scss @@ -0,0 +1,14 @@ +/* + MAP +*/ + +#map { + position: fixed; + height: 100%; + width: 100%; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: -1; +} diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 5e80d26..48167b2 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,6 +1,8 @@ class WelcomeController < ApplicationController # GET / def index + @resources = Resource.order(:uuid).page params[:page] + Rails.logger.info "WECLOME ///// #{@resources&.count || 0}" end # GET /authenticate(/:token) diff --git a/app/views/application/_debug.html.erb b/app/views/application/_debug.html.erb new file mode 100644 index 0000000..fce114d --- /dev/null +++ b/app/views/application/_debug.html.erb @@ -0,0 +1,5 @@ +<% if Rails.env.development? %> +
+ <%= yield :debug %> +
+<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 38dcf46..02c8553 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,6 +7,7 @@ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= yield :head %> @@ -26,6 +27,8 @@ + <%= render partial: 'debug' %> <%= render partial: 'flash' %> + <%= yield :body_end %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 9873194..1977962 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -1,23 +1,26 @@ - - - - - - +<% content_for :head do %> + <%= stylesheet_link_tag("https://unpkg.com/leaflet@1.7.1/dist/leaflet.css", + integrity: "sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==", + crossorigin: '') %> + <%= javascript_include_tag("https://unpkg.com/leaflet@1.7.1/dist/leaflet.js", + integrity: "sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==", + crossorigin: '') %> +<% end %>

Bienvenue à l'atelier carto d'IN COMMON

-
-
+<%= tag.div(id: 'map') %> + +<% content_for :debug do %> +

Premier élément de la liste:

+ <% res = @resources.first %> +

<%= res.feature["properties"]["name"] %>

+

<%= res.feature["geometry"]["coordinates"] %>

+<% end %> + +<% content_for :body_end do %> -

Premier élément de la liste:

-

<%= res.feature["properties"]["name"] %>

-

<%= res.feature["geometry"]["coordinates"] %>

+<% end %> -- cgit v1.2.3