From 1ba35931e4d24dc3854fe663a19fcce61dd4009c Mon Sep 17 00:00:00 2001 From: Cess Date: Wed, 15 May 2019 16:44:27 +0300 Subject: [PATCH] Reorganize and consolidate templates (#558) * add map and images seeds * add faker for faking and pry for debuggging * Remove will-paginate-bootstrap It is no longer maintained Center pagination bar Add will-paginate-bootstrap4 * add hidden overflow --- Gemfile | 4 ++- Gemfile.lock | 17 +++++++++-- app/assets/stylesheets/maps.css.scss | 1 + app/views/map/_authors.html.erb | 2 +- app/views/maps/_list.html.erb | 2 +- app/views/maps/index.html.erb | 16 +++++----- app/views/users/index.html.erb | 2 +- app/views/users/profile.html.erb | 1 + db/seeds.rb | 45 +++++++++++++++++++++++----- 9 files changed, 67 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 3dfdbd4f..5b72a59a 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem 'rake', '~> 12.3.2' gem 'skylight' gem "will_paginate", "3.1.7" -gem "will_paginate-bootstrap" +gem 'will_paginate-bootstrap4' gem "friendly_id" gem 'popper_js', '~> 1.11', '>= 1.11.1' @@ -47,6 +47,8 @@ end group :development, :test do gem "byebug" + gem 'faker' + gem 'pry-rails' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 4e0642a4..494d0e44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,10 +44,13 @@ GEM climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) + coderay (1.1.2) concurrent-ruby (1.1.5) docile (1.3.1) erubis (2.7.0) execjs (2.7.0) + faker (1.9.3) + i18n (>= 0.7) ffi (1.10.0) friendly_id (4.0.10.1) activerecord (>= 3.0, < 4.0) @@ -71,6 +74,7 @@ GEM mail (2.5.5) mime-types (~> 1.16) treetop (~> 1.4.8) + method_source (0.9.2) mime-types (1.25.1) mimemagic (0.3.0) mini_portile2 (2.4.0) @@ -98,6 +102,11 @@ GEM polyglot (0.3.5) popper_js (1.14.5) power_assert (1.1.4) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-rails (0.3.9) + pry (>= 0.10.4) rack (1.4.7) rack-cache (1.9.0) rack (>= 0.4) @@ -174,8 +183,8 @@ GEM execjs (>= 0.3.0, < 3) uuidtools (2.1.5) will_paginate (3.1.7) - will_paginate-bootstrap (1.0.2) - will_paginate (>= 3.0.3) + will_paginate-bootstrap4 (0.2.2) + will_paginate (~> 3.0, >= 3.0.0) PLATFORMS ruby @@ -185,6 +194,7 @@ DEPENDENCIES autoprefixer-rails aws-sdk (~> 1.5.7) byebug + faker friendly_id geokit-rails (= 1.1.4) httparty @@ -196,6 +206,7 @@ DEPENDENCIES paperclip (~> 4.3.7) passenger popper_js (~> 1.11, >= 1.11.1) + pry-rails rails (~> 3.2) rake (~> 12.3.2) rdiscount (= 2.2.0.1) @@ -212,7 +223,7 @@ DEPENDENCIES therubyracer uglifier will_paginate (= 3.1.7) - will_paginate-bootstrap + will_paginate-bootstrap4 RUBY VERSION ruby 2.4.6p354 diff --git a/app/assets/stylesheets/maps.css.scss b/app/assets/stylesheets/maps.css.scss index f0fa05e9..8e9c152a 100644 --- a/app/assets/stylesheets/maps.css.scss +++ b/app/assets/stylesheets/maps.css.scss @@ -32,6 +32,7 @@ html, body { } .map-list .map img { + overflow: hidden; max-height:300px; } diff --git a/app/views/map/_authors.html.erb b/app/views/map/_authors.html.erb index 8d1dfd7b..9a7cbea9 100644 --- a/app/views/map/_authors.html.erb +++ b/app/views/map/_authors.html.erb @@ -3,7 +3,7 @@ diff --git a/app/views/maps/_list.html.erb b/app/views/maps/_list.html.erb index 2c997011..0ebfc490 100644 --- a/app/views/maps/_list.html.erb +++ b/app/views/maps/_list.html.erb @@ -1,7 +1,7 @@
<% if map.warpables.length > 0 %> - + <% else %>
<% end %> diff --git a/app/views/maps/index.html.erb b/app/views/maps/index.html.erb index 7fe78a87..7923d2e5 100644 --- a/app/views/maps/index.html.erb +++ b/app/views/maps/index.html.erb @@ -18,13 +18,11 @@ Create a map
<% else %> -

- Create a map -

-

- Log in to create a map, or if you have privacy concerns, you may create a map anonymously. -

-
+
+

+ Log in to create a map, or if you have privacy concerns, you may create a map anonymously. +

+
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 5366b35d..6fa7b78b 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -24,5 +24,5 @@
- <%= will_paginate @maps, renderer: BootstrapPagination::Rails unless @unpaginated %> + <%= will_paginate @maps, list_classes: %w(pagination justify-content-center), previous_label: 'Prev', next_label: 'Next', renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %> diff --git a/app/views/users/profile.html.erb b/app/views/users/profile.html.erb index 893ba4e1..40b1494e 100644 --- a/app/views/users/profile.html.erb +++ b/app/views/users/profile.html.erb @@ -18,5 +18,6 @@ <%= render :partial => 'maps/list', :locals => {:map => map} %> <% end %> + <%= will_paginate @maps, list_classes: %w(pagination justify-content-center), previous_label: 'Prev', next_label: 'Next', renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %>
diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e85..9af6c58d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,38 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) +# Fake maps +users = User.all +p 'Now faking Maps....' +maps = [] +30.times do + map = Map.new( + name: Faker::Address.city, + lat: Faker::Address.latitude, + lon: Faker::Address.longitude, + location: Faker::Address.country, + description: Faker::Lorem.sentence, + slug: Faker::Lorem.word + ) + map.user = (users.sample) + map.author = map.user.login + map.save + maps. << map +end +p 'Done faking maps...' + + +# Fake maps images +p 'Adding Warbaples to maps' + +maps.each do |map| + image = map.warpables.new + image.id = Faker::Number.unique.between(10, 100) + image.history = Faker::Lorem.word + image.image_file_name = 'demo.png' + image.width = 500 + image.nodes = '1,3,4,5' + system("mkdir -p public/system/images/#{image.id}/original") + system("cp test/fixtures/demo.png public/system/images/#{image.id}/original/demo.png") + image.image_content_type = 'image/png' + image.save +end +p 'Done adding images to maps' +