diff --git a/.rubocop.yml b/.rubocop.yml index 98524b1..dfa34bc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -64,7 +64,7 @@ AllCops: # If a value is specified for TargetRubyVersion then it is used. # Else if .ruby-version exists and it contains an MRI version it is used. # Otherwise we fallback to the oldest officially supported Ruby version (2.0). - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 RSpec: Patterns: diff --git a/Gemfile b/Gemfile index 13180e7..b461294 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" ruby RUBY_VERSION # DECIDIM_VERSION = { git: "https://github.com/decidim/decidim" } -DECIDIM_VERSION = "0.21" +DECIDIM_VERSION = "0.23.1" gem "decidim", DECIDIM_VERSION gem "decidim-navigation_maps", path: "." diff --git a/Gemfile.lock b/Gemfile.lock index 812411b..1c86cd0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ PATH remote: . specs: - decidim-navigation_maps (1.0.1) - decidim-admin (>= 0.18.0, < 0.22) - decidim-core (>= 0.18.0, < 0.22) + decidim-navigation_maps (1.1.0) + decidim-admin (>= 0.22, < 0.24) + decidim-core (>= 0.22, < 0.24) GEM remote: https://rubygems.org/ @@ -109,6 +109,7 @@ GEM actionpack (>= 3.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.7) + chef-utils (16.9.17) childprocess (3.0.0) codecov (0.2.15) simplecov (>= 0.15, < 0.21) @@ -133,65 +134,65 @@ GEM db-query-matchers (0.9.0) activesupport (>= 4.0, <= 6.0) rspec (~> 3.0) - decidim (0.21.0) - decidim-accountability (= 0.21.0) - decidim-admin (= 0.21.0) - decidim-api (= 0.21.0) - decidim-assemblies (= 0.21.0) - decidim-blogs (= 0.21.0) - decidim-budgets (= 0.21.0) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) - decidim-debates (= 0.21.0) - decidim-forms (= 0.21.0) - decidim-generators (= 0.21.0) - decidim-meetings (= 0.21.0) - decidim-pages (= 0.21.0) - decidim-participatory_processes (= 0.21.0) - decidim-proposals (= 0.21.0) - decidim-sortitions (= 0.21.0) - decidim-surveys (= 0.21.0) - decidim-system (= 0.21.0) - decidim-verifications (= 0.21.0) - decidim-accountability (0.21.0) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) - kaminari (~> 1.1) + decidim (0.23.1) + decidim-accountability (= 0.23.1) + decidim-admin (= 0.23.1) + decidim-api (= 0.23.1) + decidim-assemblies (= 0.23.1) + decidim-blogs (= 0.23.1) + decidim-budgets (= 0.23.1) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) + decidim-debates (= 0.23.1) + decidim-forms (= 0.23.1) + decidim-generators (= 0.23.1) + decidim-meetings (= 0.23.1) + decidim-pages (= 0.23.1) + decidim-participatory_processes (= 0.23.1) + decidim-proposals (= 0.23.1) + decidim-sortitions (= 0.23.1) + decidim-surveys (= 0.23.1) + decidim-system (= 0.23.1) + decidim-verifications (= 0.23.1) + decidim-accountability (0.23.1) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-admin (0.21.0) + decidim-admin (0.23.1) active_link_to (~> 1.0) - decidim-core (= 0.21.0) + decidim-core (= 0.23.1) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 1.7) jquery-rails (~> 4.3) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - decidim-api (0.21.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + decidim-api (0.23.1) graphiql-rails (~> 1.4, < 1.5) graphql (~> 1.9) rack-cors (~> 1.0) redcarpet (~> 3.4) sprockets-es6 (~> 0.9.2) - decidim-assemblies (0.21.0) - decidim-core (= 0.21.0) - decidim-blogs (0.21.0) - decidim-admin (= 0.21.0) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) + decidim-assemblies (0.23.1) + decidim-core (= 0.23.1) + decidim-blogs (0.23.1) + decidim-admin (= 0.23.1) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) httparty (~> 0.17) jquery-tmpl-rails (~> 1.1) - kaminari (~> 1.1) - decidim-budgets (0.21.0) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) + decidim-budgets (0.23.1) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-comments (0.21.0) - decidim-core (= 0.21.0) + decidim-comments (0.23.1) + decidim-core (= 0.23.1) jquery-rails (~> 4.3) redcarpet (~> 3.4) - decidim-core (0.21.0) + decidim-core (0.23.1) active_link_to (~> 1.0) anchored (>= 1.1.0) autoprefixer-rails (~> 8.0) @@ -202,7 +203,7 @@ GEM cells-rails (~> 0.0.9) charlock_holmes (~> 0.7) date_validator (~> 0.9.0) - decidim-api (= 0.21.0) + decidim-api (= 0.23.1) devise (~> 4.7) devise-i18n (~> 1.2) diffy (~> 3.3) @@ -210,18 +211,18 @@ GEM doorkeeper-i18n (~> 4.0) etherpad-lite (~> 0.3) file_validators (~> 2.1) - foundation-rails (~> 6.4, < 6.5) + foundation-rails (~> 6.6, < 6.7) foundation_rails_helper (~> 3.0) geocoder (>= 1.5) hashdiff (>= 0.4.0, < 2.0.0) invisible_captcha (~> 0.12) jquery-rails (~> 4.3) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) loofah (~> 2.3.1) mini_magick (~> 4.9) mustache (~> 1.1.0) nobspw (~> 0.6.0) - omniauth (= 1.9.0) + omniauth (~> 1.9) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 0.7) omniauth-rails_csrf_protection (~> 0.1) @@ -230,16 +231,17 @@ GEM pg (~> 1.1.4, < 2) pg_search (~> 2.2) premailer-rails (~> 1.10) - rack (>= 2.0.8) + rack (>= 2.2.3) rack-attack (~> 6.0) - rails (>= 5.2, < 6.0.x) + rails (>= 5.2.4.4, < 6.0.x) rails-i18n (~> 5.0) rectify (~> 0.13.0) redis (~> 4.1) + request_store (~> 1.5.0) rubyzip (~> 2.0) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - seven_zip_ruby (~> 1.2, >= 1.2.2) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + seven_zip_ruby (~> 1.3) social-share-button (~> 1.2, >= 1.2.1) spreadsheet (~> 1.2) sprockets (~> 3.7, < 4) @@ -248,20 +250,20 @@ GEM uglifier (~> 4.1) valid_email2 (~> 2.1) wisper (~> 2.0) - decidim-debates (0.21.0) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) - kaminari (~> 1.1) + decidim-debates (0.23.1) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-dev (0.21.0) + decidim-dev (0.23.1) byebug (~> 11.0) capybara (~> 3.24) db-query-matchers (~> 0.9.0) - decidim (= 0.21.0) + decidim (= 0.23.1) erb_lint (~> 0.0.28) factory_bot_rails (~> 4.8) i18n-tasks (~> 0.9.18) - mdl (~> 0.5.0) + mdl (~> 0.5) nokogiri (>= 1.10.8) puma (>= 4.3) rails-controller-testing (~> 1.0) @@ -274,58 +276,60 @@ GEM rubocop-rails (~> 2.0) rubocop-rspec (~> 1.21) selenium-webdriver (~> 3.142) - simplecov (~> 0.18.5) + simplecov (~> 0.19.0) simplecov-cobertura (~> 1.3.1) system_test_html_screenshots (~> 0.1.1) webmock (~> 3.6) wisper-rspec (~> 1.0) - decidim-forms (0.21.0) - decidim-core (= 0.21.0) - decidim-generators (0.21.0) - decidim-core (= 0.21.0) - decidim-meetings (0.21.0) + decidim-forms (0.23.1) + decidim-core (= 0.23.1) + wicked_pdf (~> 1.4) + wkhtmltopdf-binary (~> 0.12) + decidim-generators (0.23.1) + decidim-core (= 0.23.1) + decidim-meetings (0.23.1) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - decidim-core (= 0.21.0) - decidim-forms (= 0.21.0) + decidim-core (= 0.23.1) + decidim-forms (= 0.23.1) httparty (~> 0.17) icalendar (~> 2.5) jquery-tmpl-rails (~> 1.1) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-pages (0.21.0) - decidim-core (= 0.21.0) - decidim-participatory_processes (0.21.0) - decidim-core (= 0.21.0) - decidim-proposals (0.21.0) + decidim-pages (0.23.1) + decidim-core (= 0.23.1) + decidim-participatory_processes (0.23.1) + decidim-core (= 0.23.1) + decidim-proposals (0.23.1) acts_as_list (~> 0.9) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) doc2text (~> 0.4.2) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) ransack (~> 2.1.1) redcarpet (~> 3.4) - decidim-sortitions (0.21.0) - decidim-admin (= 0.21.0) - decidim-comments (= 0.21.0) - decidim-core (= 0.21.0) - decidim-proposals (= 0.21.0) - decidim-surveys (0.21.0) - decidim-core (= 0.21.0) - decidim-forms (= 0.21.0) - decidim-system (0.21.0) + decidim-sortitions (0.23.1) + decidim-admin (= 0.23.1) + decidim-comments (= 0.23.1) + decidim-core (= 0.23.1) + decidim-proposals (= 0.23.1) + decidim-surveys (0.23.1) + decidim-core (= 0.23.1) + decidim-forms (= 0.23.1) + decidim-system (0.23.1) active_link_to (~> 1.0) - decidim-core (= 0.21.0) + decidim-core (= 0.23.1) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 1.7) jquery-rails (~> 4.3) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - decidim-verifications (0.21.0) - decidim-core (= 0.21.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + decidim-verifications (0.23.1) + decidim-core (= 0.23.1) declarative-builder (0.1.0) declarative-option (< 0.2.0) declarative-option (0.1.0) @@ -354,7 +358,7 @@ GEM railties (>= 5) doorkeeper-i18n (4.0.1) equalizer (0.0.11) - erb_lint (0.0.36) + erb_lint (0.0.37) activesupport better_html (~> 1.0.7) html_tokenizer @@ -380,13 +384,13 @@ GEM multipart-post (>= 1.2, < 3) ruby2_keywords faraday-net_http (1.0.0) - ffi (1.9.25) + ffi (1.14.2) file_validators (2.3.0) activemodel (>= 3.2) mime-types (>= 1.0) - foundation-rails (6.4.3.0) + foundation-rails (6.6.2.0) railties (>= 3.1.0) - sass (>= 3.3.0, < 3.5) + sass (>= 3.3.0) sprockets-es6 (>= 0.9.0) foundation_rails_helper (3.0.0) actionpack (>= 4.1, < 6.0) @@ -402,7 +406,7 @@ GEM sprockets-rails graphql (1.11.6) hashdiff (1.0.1) - hashie (3.6.0) + hashie (4.1.0) highline (2.0.3) html_tokenizer (0.0.7) htmlentities (4.3.4) @@ -450,7 +454,10 @@ GEM activerecord kaminari-core (= 1.2.1) kaminari-core (1.2.1) - kramdown (1.17.0) + kramdown (2.3.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) launchy (2.5.0) addressable (~> 2.7) letter_opener (1.7.0) @@ -469,10 +476,12 @@ GEM mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - mdl (0.5.0) - kramdown (~> 1.12, >= 1.12.0) - mixlib-cli (~> 1.7, >= 1.7.0) - mixlib-config (~> 2.2, >= 2.2.1) + mdl (0.11.0) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + mixlib-cli (~> 2.1, >= 2.1.1) + mixlib-config (>= 2.2.1, < 4) + mixlib-shellout method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) @@ -482,9 +491,11 @@ GEM mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.14.3) - mixlib-cli (1.7.0) - mixlib-config (2.2.18) + mixlib-cli (2.1.8) + mixlib-config (3.0.9) tomlrb + mixlib-shellout (3.2.2) + chef-utils msgpack (1.3.3) multi_json (1.15.0) multi_xml (0.6.0) @@ -502,8 +513,8 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (1.9.0) - hashie (>= 3.4.6, < 3.7.0) + omniauth (1.9.1) + hashie (>= 3.4.6) rack (>= 1.6.2, < 3) omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) @@ -515,9 +526,9 @@ GEM omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) - omniauth-oauth2 (1.7.0) + omniauth-oauth2 (1.7.1) oauth2 (~> 1.4) - omniauth (~> 1.9) + omniauth (>= 1.9, < 3) omniauth-rails_csrf_protection (0.1.2) actionpack (>= 4.2) omniauth (>= 1.3.1) @@ -660,15 +671,17 @@ GEM ruby-progressbar (1.11.0) ruby2_keywords (0.0.2) rubyzip (2.0.0) - sass (3.4.25) - sassc (1.12.1) - ffi (~> 1.9.6) - sass (>= 3.3.0) - sassc-rails (1.3.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sassc (2.3.0) + ffi (~> 1.9) + sassc-rails (2.1.2) railties (>= 4.0.0) - sass - sassc (~> 1.9) - sprockets (> 2.11) + sassc (>= 2.0) + sprockets (> 3.0) sprockets-rails tilt searchlight (4.1.0) @@ -676,7 +689,7 @@ GEM childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) seven_zip_ruby (1.3.0) - simplecov (0.18.5) + simplecov (0.19.1) docile (~> 1.1) simplecov-html (~> 0.11) simplecov-cobertura (1.3.1) @@ -745,8 +758,11 @@ GEM websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + wicked_pdf (1.4.0) + activesupport wisper (2.0.1) wisper-rspec (1.1.0) + wkhtmltopdf-binary (0.12.6.5) xpath (3.2.0) nokogiri (~> 1.8) @@ -757,8 +773,8 @@ DEPENDENCIES bootsnap (~> 1.4) byebug (~> 11.0) codecov - decidim (= 0.21) - decidim-dev (= 0.21) + decidim (= 0.23.1) + decidim-dev (= 0.23.1) decidim-navigation_maps! faker (~> 1.9) letter_opener_web (~> 1.3) diff --git a/README.md b/README.md index bc48c04..32ef2fc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ homepage only). 👉 [Check the usage guide here!](USAGE.md) +![Homepage](examples/homepage.png) + ![Admin editor](examples/admin.gif) ## Installation @@ -22,7 +24,7 @@ homepage only). Add this line to your application's Gemfile: ```ruby -gem "decidim-navigation_maps", "~> 1.0.0" +gem "decidim-navigation_maps", "~> 1.1.0" ``` And then execute: @@ -37,7 +39,8 @@ Depending on your Decidim version, choose the corresponding Plugin version to en | Navigation Maps version | Compatible Decidim versions | |---|---| -| 1.0.x | 0.18.x, 0.21.x | +| 1.0.x | 0.18.x - 0.21.x | +| 1.1.x | 0.22.x, 0.23.x | ## Contributing diff --git a/app/assets/stylesheets/decidim/navigation_maps/admin/navigation_maps.scss b/app/assets/stylesheets/decidim/navigation_maps/admin/navigation_maps.scss index 75cfada..3dff7a9 100644 --- a/app/assets/stylesheets/decidim/navigation_maps/admin/navigation_maps.scss +++ b/app/assets/stylesheets/decidim/navigation_maps/admin/navigation_maps.scss @@ -63,7 +63,7 @@ .tabs-content { .map { - height: 475px; + height: 700px; } .thumbnail { img { diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_tabs_content.erb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_tabs_content.erb index 1b45c8d..b538bdc 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_tabs_content.erb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_tabs_content.erb @@ -2,7 +2,7 @@
<% tabs.each_with_index do |item, index| %>
" id="map<%= index %>"> - <%= content_tag(:div, "", id: "navigation_maps-map-#{item.id}", class: "map", data: { id: item.id, image: item.image.url, blueprint: item.blueprint }) %> + <%= content_tag(:div, "", id: "navigation_maps-map-#{item.id}", class: "map", style: "height: #{item.height}px", data: { id: item.id, image: item.image.url, blueprint: item.blueprint }) %>
<% end %>
diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_template.erb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_template.erb index 17d1ad2..91634bd 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_template.erb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_template.erb @@ -5,7 +5,7 @@

{{:description}}

- <%= t(".view") %> + <%= t("navigation_map.view", scope: "decidim.navigation_maps.content_blocks") %>
diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_form.erb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_form.erb index 31cb201..2d7307f 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_form.erb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_form.erb @@ -1,15 +1,17 @@ diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb index f69d45f..f619fd8 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb @@ -33,3 +33,4 @@ <%= render partial: "modal" %> <%= javascript_include_tag "decidim/navigation_maps/admin/navigation_maps" %> <%= stylesheet_link_tag "decidim/navigation_maps/admin/navigation_maps" %> + <% console %> diff --git a/app/commands/decidim/navigation_maps/save_blueprints.rb b/app/commands/decidim/navigation_maps/save_blueprints.rb index 798440c..e64ffd5 100644 --- a/app/commands/decidim/navigation_maps/save_blueprints.rb +++ b/app/commands/decidim/navigation_maps/save_blueprints.rb @@ -48,6 +48,7 @@ def initialize_blueprint(form) def update_blueprint!(form) @blueprint.image = form.image if form.image.present? @blueprint.title = form.title + @blueprint.height = form.height @blueprint.description = form.description @blueprint.save! end diff --git a/app/forms/decidim/navigation_maps/blueprint_form.rb b/app/forms/decidim/navigation_maps/blueprint_form.rb index 02e50bf..f752e23 100644 --- a/app/forms/decidim/navigation_maps/blueprint_form.rb +++ b/app/forms/decidim/navigation_maps/blueprint_form.rb @@ -15,9 +15,11 @@ class BlueprintForm < Decidim::Form attribute :image translatable_attribute :title, String translatable_attribute :description, String + attribute :height, Integer # validate :check_image_or_blueprint validates :title, translatable_presence: true + validates :height, numericality: { greater_than: 0 } # def check_image_or_blueprint # return if image.present? || blueprint.present? diff --git a/app/models/decidim/navigation_maps/blueprint.rb b/app/models/decidim/navigation_maps/blueprint.rb index 721c036..518b0f1 100644 --- a/app/models/decidim/navigation_maps/blueprint.rb +++ b/app/models/decidim/navigation_maps/blueprint.rb @@ -6,6 +6,8 @@ module NavigationMaps class Blueprint < ApplicationRecord self.table_name = "decidim_navigation_maps_blueprints" + attribute :height, :integer, default: 475 + belongs_to :organization, foreign_key: :decidim_organization_id, class_name: "Decidim::Organization" has_many :areas, foreign_key: "decidim_navigation_maps_blueprint_id", @@ -14,8 +16,8 @@ class Blueprint < ApplicationRecord validates :organization, presence: true validates :image, - file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png", "image/svg+xml"] } + validates :height, numericality: { greater_than: 0 } mount_uploader :image, Decidim::NavigationMaps::BlueprintUploader diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 783b6b3..9382f4d 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -3,8 +3,19 @@ base_locale: en locales: [en] +# Read and write translations. +data: + yaml: + write: + # do not wrap lines at 80 characters + line_width: -1 + ignore_unused: - - "decidim.components.navigation_maps.name" + - decidim.components.navigation_maps.name + - decidim.navigation_maps.content_blocks.name + - decidim.navigation_maps.content_blocks.navigation_map_settings_form.* + # these keys are reused from decidim core ignore_missing: - decidim.participatory_processes.scopes.global + - decidim.content_blocks.html.html_content diff --git a/config/locales/en.yml b/config/locales/en.yml index 519f68c..3a26e6e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -33,6 +33,7 @@ en: blueprint_image: Blueprint image description: Description editor: Map Editor + height: Height (px) id: Id image_missing: Please add a blueprint image to start info: General info diff --git a/db/migrate/20210112135817_add_height_to_navigation_maps_blueprints.rb b/db/migrate/20210112135817_add_height_to_navigation_maps_blueprints.rb new file mode 100644 index 0000000..7ba1bf1 --- /dev/null +++ b/db/migrate/20210112135817_add_height_to_navigation_maps_blueprints.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddHeightToNavigationMapsBlueprints < ActiveRecord::Migration[5.2] + def change + add_column :decidim_navigation_maps_blueprints, :height, :integer, null: false, default: 475 + end +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..f112e75 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true + +if !Rails.env.production? || ENV["SEED"] + print "Creating seeds for decidim_navigation maps...\n" unless Rails.env.test? + + require "decidim/faker/localized" + seeds_root = File.join(__dir__, "seeds") + + organization = Decidim::Organization.first + + Decidim::ContentBlock.create( + decidim_organization_id: organization.id, + weight: 1, + scope_name: :homepage, + manifest_name: :navigation_map, + published_at: Time.current, + settings: { title: Decidim::Faker::Localized.sentence(5) } + ) + + blueprint1 = Decidim::NavigationMaps::Blueprint.create( + organization: organization, + image: File.new(File.join(seeds_root, "antarctica.png")), + title: Decidim::Faker::Localized.sentence(2), + description: Decidim::Faker::Localized.sentence(10) + ) + + Decidim::NavigationMaps::Blueprint.create( + organization: organization, + image: File.new(File.join(seeds_root, "penguins.jpg")), + title: Decidim::Faker::Localized.sentence(2), + description: Decidim::Faker::Localized.sentence(10) + ) + + Decidim::NavigationMaps::BlueprintArea.create( + blueprint: blueprint1, + area_id: "10", + area_type: "Feature", + area: { + type: "Polygon", + coordinates: [[ + [717.21875, 277.162511], + [717.21875, 317.104475], + [758.029018, 317.104475], + [758.029018, 277.162511], + [717.21875, 277.162511] + ]] + }, + link: "https://en.wikipedia.org/wiki/South_Pole", + link_type: "link", + color: "#ff2a00", + title: { en: "South Pole" }, + description: { en: "It's cold in here" } + ) + + Decidim::NavigationMaps::BlueprintArea.create( + blueprint: blueprint1, + area_id: "11", + area_type: "Feature", + area: { + type: "Polygon", + coordinates: [[ + [376.84375, 516.814296], + [384.658482, 464.716082], + [411.575893, 432.58885], + [438.493304, 416.091082], + [425.46875, 402.198225], + [436.756696, 383.095546], + [428.941964, 375.280814], + [448.912946, 358.783046], + [462.805804, 367.466082], + [486.25, 373.544207], + [526.191964, 416.091082], + [450.649554, 448.218314], + [401.15625, 484.687064], + [376.84375, 516.814296] + ]] + }, + link: "#map1", + link_type: "link", + color: "#ffbb00", + title: { en: "Penguins" }, + description: { en: "Penguins are beatiful animals" } + ) + + Decidim::NavigationMaps::BlueprintArea.create( + blueprint: blueprint1, + area_id: "12", + area_type: "Feature", + area: { + type: "Polygon", + coordinates: [[ + [1068.013393, 418.695993], + [1023.729911, 412.617868], + [1025.466518, 343.153582], + [1104.482143, 324.050903], + [1045.4375, 379.622332], + [1068.013393, 418.695993] + ]] + }, + link: "#map1", + link_type: "direct" + ) +end diff --git a/db/seeds/antarctica.png b/db/seeds/antarctica.png new file mode 100644 index 0000000..ef64217 Binary files /dev/null and b/db/seeds/antarctica.png differ diff --git a/db/seeds/penguins.jpg b/db/seeds/penguins.jpg new file mode 100644 index 0000000..12cf48d Binary files /dev/null and b/db/seeds/penguins.jpg differ diff --git a/decidim-navigation_maps.gemspec b/decidim-navigation_maps.gemspec index a6ebb2f..6f14107 100644 --- a/decidim-navigation_maps.gemspec +++ b/decidim-navigation_maps.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.email = ["ivan@platoniq.net"] s.license = "AGPL-3.0" s.homepage = "https://github.com/Platoniq/decidim-module-navigation_maps" - s.required_ruby_version = ">= 2.5" + s.required_ruby_version = ">= 2.6" s.name = "decidim-navigation_maps" s.summary = "A decidim navigation_maps module" diff --git a/examples/homepage.png b/examples/homepage.png new file mode 100644 index 0000000..56c1d11 Binary files /dev/null and b/examples/homepage.png differ diff --git a/lib/decidim/navigation_maps/version.rb b/lib/decidim/navigation_maps/version.rb index 66c6349..1bb2cc8 100644 --- a/lib/decidim/navigation_maps/version.rb +++ b/lib/decidim/navigation_maps/version.rb @@ -3,7 +3,7 @@ module Decidim # This holds the decidim-meetings version. module NavigationMaps - VERSION = "1.0.1" - DECIDIM_VERSION = [">= 0.18.0", "< 0.22"].freeze + VERSION = "1.1.0" + DECIDIM_VERSION = [">= 0.22", "< 0.24"].freeze end end diff --git a/spec/commands/save_blueprints_spec.rb b/spec/commands/save_blueprints_spec.rb index cf4661a..5b279f3 100644 --- a/spec/commands/save_blueprints_spec.rb +++ b/spec/commands/save_blueprints_spec.rb @@ -21,6 +21,7 @@ module Decidim::NavigationMaps blueprint: blueprint_object, id: id, title: title, + height: height, description: title, remove: remove, image: uploaded_image @@ -32,6 +33,7 @@ module Decidim::NavigationMaps blueprint: blueprint_object, id: 2, title: title, + height: height, description: nil, remove: false, image: nil @@ -49,6 +51,7 @@ module Decidim::NavigationMaps { x: 0.5, y: 0.6 } end let(:title) { Decidim::Faker::Localized.sentence(2) } + let(:height) { 500 } let(:id) { 1 } let(:remove) { false } let(:uploaded_image) do diff --git a/spec/content_blocks/navigation_map_cell_spec.rb b/spec/content_blocks/navigation_map_cell_spec.rb index 5b22d00..41cf25d 100644 --- a/spec/content_blocks/navigation_map_cell_spec.rb +++ b/spec/content_blocks/navigation_map_cell_spec.rb @@ -7,7 +7,7 @@ module Decidim::NavigationMaps::ContentBlocks subject { cell(content_block.cell, content_block).call } let(:organization) { create(:organization) } - let(:content_block) { create :content_block, organization: organization, manifest_name: :navigation_map, scope: :homepage } + let(:content_block) { create :content_block, organization: organization, manifest_name: :navigation_map, scope_name: :homepage } let!(:blueprint) { create(:blueprint, organization: organization) } controller Decidim::PagesController diff --git a/spec/content_blocks/navigation_map_settings_form_cell_spec.rb b/spec/content_blocks/navigation_map_settings_form_cell_spec.rb index 8a9e659..1a6401c 100644 --- a/spec/content_blocks/navigation_map_settings_form_cell_spec.rb +++ b/spec/content_blocks/navigation_map_settings_form_cell_spec.rb @@ -7,7 +7,7 @@ module Decidim::NavigationMaps::ContentBlocks subject { cell(content_block.cell, content_block).call } let(:organization) { create(:organization) } - let(:content_block) { create :content_block, organization: organization, manifest_name: :navigation_map, scope: :homepage } + let(:content_block) { create :content_block, organization: organization, manifest_name: :navigation_map, scope_name: :homepage } let!(:blueprint) { create(:blueprint, organization: organization) } let(:settings) { NavigationMapSettingsFormCell.new } diff --git a/spec/forms/blueprint_form_spec.rb b/spec/forms/blueprint_form_spec.rb index b17061d..2f09bea 100644 --- a/spec/forms/blueprint_form_spec.rb +++ b/spec/forms/blueprint_form_spec.rb @@ -10,6 +10,7 @@ module Decidim::NavigationMaps let(:attributes) do { title: title, + height: height, id: id, image: image, blueprint: { @@ -19,6 +20,7 @@ module Decidim::NavigationMaps } end let(:title) { Decidim::Faker::Localized.sentence(2) } + let(:height) { 500 } let(:id) { 101 } let(:image) { {} } let(:context) do @@ -27,34 +29,54 @@ module Decidim::NavigationMaps } end - before do - allow(subject.image).to receive(:url).and_return(true) - allow(subject.image).to receive(:content_type).and_return("image/jpeg") - end + context "when there is image" do + before do + allow(subject.image).to receive(:url).and_return(true) + allow(subject.image).to receive(:content_type).and_return("image/jpeg") + end - context "when everything is OK" do - it { is_expected.to be_valid } + context "when everything is OK" do + it { is_expected.to be_valid } - it "ident matches id" do - expect(subject.ident).to eq(id) + it "ident matches id" do + expect(subject.ident).to eq(id) + end + + it "image? responds true" do + expect(subject.image?).to eq(true) + end end - it "image? responds true" do - expect(subject.image?).to eq(true) + context "when there is no title" do + let(:title) { nil } + + it { is_expected.not_to be_valid } end - end - context "when there is no title" do - let(:title) { nil } + context "when there is no height" do + let(:height) { nil } - it { is_expected.not_to be_valid } - end + it { is_expected.not_to be_valid } + end + + context "when height is not a number" do + let(:height) { "abracadabra" } + + it { is_expected.not_to be_valid } + end + + context "when height is not positive" do + let(:height) { -100 } + + it { is_expected.not_to be_valid } + end - context "when there is no id" do - let(:id) { nil } + context "when there is no id" do + let(:id) { nil } - it "ident is an underscore" do - expect(subject.ident).to eq("_") + it "ident is an underscore" do + expect(subject.ident).to eq("_") + end end end diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb new file mode 100644 index 0000000..4a05e6d --- /dev/null +++ b/spec/i18n_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require "i18n/tasks" + +describe "I18n sanity" do + let(:locales) do + ENV["ENFORCED_LOCALES"].presence || "en" + end + + let(:i18n) { I18n::Tasks::BaseTask.new(locales: locales.split(",")) } + let(:missing_keys) { i18n.missing_keys } + let(:unused_keys) { i18n.unused_keys } + let(:non_normalized_paths) { i18n.non_normalized_paths } + + it "does not have missing keys" do + expect(missing_keys).to be_empty, "#{missing_keys.inspect} are missing" + end + + it "does not have unused keys" do + expect(unused_keys).to be_empty, "#{unused_keys.inspect} are unused" + end + + unless ENV["SKIP_NORMALIZATION"] + it "is normalized" do + error_message = "The following files need to be normalized:\n" \ + "#{non_normalized_paths.map { |path| " #{path}" }.join("\n")}\n" \ + "Please run `bundle exec i18n-tasks normalize --locales #{locales}` to fix them" + + expect(non_normalized_paths).to be_empty, error_message + end + end +end diff --git a/spec/model/blueprint_area_spec.rb b/spec/models/blueprint_area_spec.rb similarity index 100% rename from spec/model/blueprint_area_spec.rb rename to spec/models/blueprint_area_spec.rb diff --git a/spec/model/blueprint_spec.rb b/spec/models/blueprint_spec.rb similarity index 93% rename from spec/model/blueprint_spec.rb rename to spec/models/blueprint_spec.rb index b5f21e0..fee13a2 100644 --- a/spec/model/blueprint_spec.rb +++ b/spec/models/blueprint_spec.rb @@ -16,12 +16,8 @@ module NavigationMaps expect(subject.organization).to eq(organization) end - context "when the file is too big" do - before do - expect(subject.image).to receive(:size).and_return(11.megabytes) - end - - it { is_expected.not_to be_valid } + it "has a default height" do + expect(subject.height).to eq(475) end context "when the file is a malicious image" do