diff --git a/.gitignore b/.gitignore index 6c092987..d2b8b614 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,6 @@ config/amazon_s3.yml config/initializers/recaptcha.rb config/config.yml config/initializers/site_keys.rb -Gemfile.lock vendor/bundle app/assets/bower_components app/assets/node_modules @@ -43,6 +42,6 @@ todo.txt .sass-cache .byebug_history coverage_report/ -test/reports/ +test/reports/* yarn-error.log diff --git a/vendor/assets/images/image.png b/app/assets/images/image.png similarity index 100% rename from vendor/assets/images/image.png rename to app/assets/images/image.png diff --git a/app/assets/stylesheets/style.scss b/app/assets/stylesheets/style.scss index c5d05b8b..5d131e17 100644 --- a/app/assets/stylesheets/style.scss +++ b/app/assets/stylesheets/style.scss @@ -30,14 +30,18 @@ It was originally created by Caroline Hadilaksono: http://www.hadilaksono.com background-attachment: fixed; background-repeat: no-repeat; background-size: cover; +} .text-block { - height: 350px; - width: 500px; + margin-bottom: 5px; + padding-top:30px; + padding-bottom:50px; background-color: white; display: inline-block; - // font-family: Verdana; //Nunito; // 'Ubuntu', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; + .btn { + width: 45%; + font-size: 1em; + } } -} .jumbotron { margin-bottom: 1rem; @@ -45,7 +49,6 @@ It was originally created by Caroline Hadilaksono: http://www.hadilaksono.com .jumbotron-text { text-shadow: 1px 1px 2px #080707; - // color: white; } .map-list .map-img { @@ -232,11 +235,6 @@ label small { letter-spacing: -0.2px; } -.icon-landing { - width: 120px; - height: 120px; - object-fit: contain; -} .item-description { font-size: 18px; @@ -247,42 +245,6 @@ label small { color: #a2aaad; } -.blue-background { - background-color: #17a2b8; - width: 1000px; -} - -.section-blue-background { - max-height: 100px; - background-color: #17a2b8; - margin: 20px 0; - color: white; -} - -.section-blue-background a { - display: flex; - justify-content: center; - font-size: 26px; - font-weight: 500; - font-style: normal; - font-stretch: normal; - line-height: 1.17; - letter-spacing: -0.5px; - color: #ffffff; - padding: 30px 0 40px 0; - justify-content: center !important; -} - -.section-blue-background a:hover { - color: #ffffff; - text-decoration: none; -} - -@media(max-width: 360px) { - #get-started-button { - margin-bottom: 10px; - } -} #info { .fa-stack { @@ -294,3 +256,10 @@ label small { padding-bottom: 20px; } } +#all-maps { + img { + display: block; + width: 200px; + height: 200px; + } +} diff --git a/app/controllers/front_ui_controller.rb b/app/controllers/front_ui_controller.rb index 1fbda548..60b1f210 100644 --- a/app/controllers/front_ui_controller.rb +++ b/app/controllers/front_ui_controller.rb @@ -1,4 +1,6 @@ # Shadow Controller for the new front page +require 'will_paginate/array' + class FrontUiController < ApplicationController protect_from_forgery except: :save_location @@ -18,9 +20,11 @@ class FrontUiController < ApplicationController lat = session[:lat] lon = session[:lon] @nearby_maps = Map.maps_nearby(lat: lat, lon: lon, dist: 10) + .page(params[:page]) + .per_page(12) end - @all_mappers = Map.featured_authors + @all_mappers = Map.featured_authors.paginate(page: params[:page], per_page: 12) end def save_location @@ -33,4 +37,13 @@ class FrontUiController < ApplicationController end def about; end + + def gallery + @maps = Map.page(params[:page]) + .per_page(20) + .where(archived: false, password: '') + .order('updated_at DESC') + .group('maps.id') + @authors = Map.featured_authors.paginate(page: params[:page], per_page: 20) + end end diff --git a/app/helpers/front_ui_helper.rb b/app/helpers/front_ui_helper.rb index 84928372..271b272a 100644 --- a/app/helpers/front_ui_helper.rb +++ b/app/helpers/front_ui_helper.rb @@ -1,5 +1,13 @@ module FrontUiHelper def profile_image(author) - author.maps.last.warpables.last.image.url + author.warpables.last.image.url + end + + def anonymous(maps) + maps.anonymous + end + + def featured(maps) + maps.featured end end diff --git a/app/models/map.rb b/app/models/map.rb index dd560eea..861d7e2d 100755 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -47,6 +47,10 @@ class Map < ActiveRecord::Base author == "" || user_id.zero? end + def self.anonymous + Map.where(user_id: 0) + end + def self.bbox(minlat, minlon, maxlat, maxlon) Map.where(['lat > ? AND lat < ? AND lon > ? AND lon < ?', minlat, maxlat, minlon, maxlon]) diff --git a/app/models/user.rb b/app/models/user.rb index 55e03666..0274d6bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,6 +5,7 @@ class User < ActiveRecord::Base has_many :tags has_many :comments has_many :exports + has_many :warpables, through: :maps validates_presence_of :login validates_length_of :login, within: 3..40 diff --git a/app/views/front_ui/_featured_mappers.html.erb b/app/views/front_ui/_featured_mappers.html.erb index f0a72122..1c99d96f 100644 --- a/app/views/front_ui/_featured_mappers.html.erb +++ b/app/views/front_ui/_featured_mappers.html.erb @@ -14,3 +14,5 @@ <% end %> +
+<%= will_paginate mappers, list_classes: %w(pagination justify-content-center), previous_label: 'Prev', next_label: 'Next', renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %> diff --git a/app/views/front_ui/_maps.html.erb b/app/views/front_ui/_maps.html.erb index 545e47d8..6e399591 100644 --- a/app/views/front_ui/_maps.html.erb +++ b/app/views/front_ui/_maps.html.erb @@ -1,30 +1,32 @@
- <% maps.each do |map| %> -
-
- - <% if map.warpables.length > 0 %> - <%= map.name %> - <% else %> - Map without image - <% end %> - -
- <%= truncate(map.location, :length => 32, separator: ' ') %> -

<%= map.name %>

-

- <% if map.user %> - by <%= map.user.login %> - <% else %> - by anonymous - <% end %> -

-
-
<%= pluralize(map.warpables.length, "image") %>
-
<%= pluralize(map.comments.length, "comment") %>
-
+ <% maps.each do |map| %> +
+
+ + <% if map.warpables.length > 0 %> + <%= map.name %> + <% else %> + Map without image + <% end %> + +
+ <%= truncate(map.location, :length => 32, separator: ' ') %> +

<%= map.name %>

+

+ <% if map.user %> + by <%= map.user.login %> + <% else %> + by anonymous + <% end %> +

+
+
<%= pluralize(map.warpables.length, "image") %>
+
<%= pluralize(map.comments.length, "comment") %>
+
+
+
-
-
- <% end %> -
\ No newline at end of file + <% 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/app/views/front_ui/gallery.html.erb b/app/views/front_ui/gallery.html.erb new file mode 100644 index 00000000..aa9175d2 --- /dev/null +++ b/app/views/front_ui/gallery.html.erb @@ -0,0 +1,40 @@ +
+

Maps Gallery

+

+ +
+ +
+ +
+ <%= render :partial => 'maps', :locals => { :maps => @maps } %> +
+
+ <%= render :partial => 'maps', :locals => { :maps => anonymous(@maps) } %> +
+
+ <%= render :partial => 'featured_mappers', :locals => { :mappers => @authors } %> +
+
+ +
diff --git a/app/views/front_ui/index.html.erb b/app/views/front_ui/index.html.erb index 5e8f16ca..c92e6149 100644 --- a/app/views/front_ui/index.html.erb +++ b/app/views/front_ui/index.html.erb @@ -8,43 +8,47 @@ <%= javascript_include_tag('/lib/leaflet-spin/example/leaflet.spin.min.js') %> -
-
-
-

MapKnitter

-

A Community Atlas hosted by PublicLab

+
+
+
+

MapKnitter

+

A Community Atlas hosted by PublicLab

Use a kite, balloon, pole, or drone to take an aerial photo and tell your own visual story of the place. Learn more

- <%#

%>

- Get a mapping kit + Get a mapping kit - Add your images + Add your images

+
<%= link_to 'Nearby Maps', 'front_ui/nearby_mappers' %> <% if @mappers.any? %> - <%#
%> -
-

Featured Mappers

-
- <%= render :partial => 'featured_mappers', :locals => { :mappers => @mappers } %> - +
+

Featured Mappers

+
+ <%= render :partial => 'featured_mappers', :locals => { :mappers => @mappers } %> <% end %> +
+ <% if session[:lat].present? %> + More nearby people & maps + <% else %> + View all maps + <% end %> +
+

-

Aerial Mapping kits

+

Aerial Mapping kits

@@ -85,15 +89,15 @@
-
-
-

Balloon Mapping Activities

- -
-
-

Balloon Mapping Questions

- -
+
+
+

Balloon Mapping Activities

+ +
+
+

Balloon Mapping Questions

+ +
diff --git a/app/views/front_ui/nearby_mappers.html.erb b/app/views/front_ui/nearby_mappers.html.erb index 107eac1e..61a3718b 100644 --- a/app/views/front_ui/nearby_mappers.html.erb +++ b/app/views/front_ui/nearby_mappers.html.erb @@ -1,13 +1,13 @@ <% if @nearby_maps.any? %> -
-

Maps near you

-
- <%= render :partial => 'maps', :locals => { :maps => @nearby_maps } %> -
+
+

Maps near you

+
+ <%= render :partial => 'maps', :locals => { :maps => @nearby_maps } %> +
<% end %>
-

Featured Mappers

-
+

Featured Mappers

+
-<%= render :partial => 'featured_mappers', :locals => { :mappers => @all_mappers } %> \ No newline at end of file +<%= render :partial => 'featured_mappers', :locals => { :mappers => @all_mappers } %> diff --git a/app/views/layouts/knitter2.html.erb b/app/views/layouts/knitter2.html.erb index 00418df5..465d7887 100644 --- a/app/views/layouts/knitter2.html.erb +++ b/app/views/layouts/knitter2.html.erb @@ -82,7 +82,7 @@ - + Post diff --git a/config/routes.rb b/config/routes.rb index 2cd51415..34f83efe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ Mapknitter::Application.routes.draw do get 'front-page' => 'front_ui#index' get 'mappers' => 'front_ui#nearby_mappers' + get 'gallery' => 'front_ui#gallery' post "save_location" => 'front_ui#save_location' get 'about' => 'front_ui#about' get 'all_maps' => 'front_ui#all_maps' diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index 9c3ddce8..00000000 --- a/db/schema.rb +++ /dev/null @@ -1,162 +0,0 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20190420025012) do - - create_table "annotations", :force => true do |t| - t.integer "map_id" - t.integer "user_id" - t.string "annotation_type" - t.string "text" - t.string "style" - t.string "coordinates" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "comments", :force => true do |t| - t.string "user_id" - t.string "body" - t.integer "map_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exports", :force => true do |t| - t.integer "map_id", :default => 0 - t.integer "size", :default => 0 - t.integer "width", :default => 0 - t.integer "height", :default => 0 - t.float "cm_per_pixel", :default => 0.0 - t.string "status", :default => "none" - t.boolean "tms", :default => false - t.boolean "jpg", :default => false - t.boolean "geotiff", :default => false - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "zip", :default => false, :null => false - t.text "bands_string", :null => false - t.string "export_type", :default => "normal", :null => false - t.integer "user_id", :default => 0 - t.string "export_url" - end - - create_table "maps", :force => true do |t| - t.string "name", :default => "" - t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0 - t.integer "version", :default => 1 - t.string "password", :default => "" - t.text "styles" - t.datetime "created_at" - t.datetime "updated_at" - t.text "description" - t.string "author", :default => "anonymous" - t.decimal "zoom", :precision => 15, :scale => 10, :default => 2.0 - t.string "location", :default => "" - t.string "static_data", :default => "" - t.boolean "vectors", :default => false, :null => false - t.string "tiles", :default => "google", :null => false - t.string "email", :default => "", :null => false - t.boolean "archived", :default => false, :null => false - t.text "tile_url" - t.text "tile_layer" - t.string "license", :default => "copyright" - t.integer "user_id", :default => 0 - t.boolean "anon_annotatable", :default => false - t.string "slug" - end - - add_index "maps", ["slug"], :name => "index_maps_on_slug", :unique => true - - create_table "nodes", :force => true do |t| - t.string "color", :default => "red" - t.string "author", :default => "anonymous" - t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0 - t.integer "way_id", :default => 0 - t.integer "order", :default => 0 - t.datetime "created_at" - t.datetime "updated_at" - t.string "name", :default => "" - t.string "description", :default => "" - t.integer "map_id", :default => 0 - t.integer "way_order", :default => 0 - t.text "body" - end - - create_table "tags", :force => true do |t| - t.string "user_id" - t.string "name" - t.integer "map_id" - t.integer "warpable_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "tags", ["map_id"], :name => "index_tags_on_map_id" - add_index "tags", ["user_id"], :name => "index_tags_on_user_id" - add_index "tags", ["warpable_id"], :name => "index_tags_on_warpable_id" - - create_table "users", :force => true do |t| - t.string "login", :limit => 40 - t.string "name", :limit => 100, :default => "" - t.string "email", :limit => 100 - t.string "crypted_password", :limit => 40 - t.string "salt", :limit => 40 - t.string "identity_url" - t.string "role", :limit => 40, :default => "basic" - t.datetime "created_at" - t.datetime "updated_at" - t.string "remember_token", :limit => 40 - t.datetime "remember_token_expires_at" - end - - add_index "users", ["login"], :name => "index_users_on_login", :unique => true - - create_table "warpables", :force => true do |t| - t.integer "parent_id" - t.string "image_content_type" - t.string "image_file_name" - t.string "thumbnail" - t.integer "image_file_size" - t.integer "width" - t.integer "height" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "map_id", :default => 0 - t.string "nodes", :default => "" - t.boolean "locked", :default => false, :null => false - t.boolean "deleted", :default => false, :null => false - t.text "history", :null => false - t.float "cm_per_pixel", :default => 0.0, :null => false - end - - create_table "ways", :force => true do |t| - t.string "color", :default => "red" - t.string "author", :default => "anonymous" - t.decimal "lat1", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lat2", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon1", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon2", :precision => 20, :scale => 10, :default => 0.0 - t.datetime "created_at" - t.datetime "updated_at" - t.string "name", :default => "" - t.string "description", :default => "" - t.boolean "complete", :default => true - t.integer "map_id", :default => 0 - t.text "body" - end - -end - diff --git a/test/reports/TEST-ExportTest.xml b/test/reports/TEST-ExportTest.xml deleted file mode 100644 index 6c6d2d3a..00000000 --- a/test/reports/TEST-ExportTest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/test/reports/TEST-MapTest.xml b/test/reports/TEST-MapTest.xml deleted file mode 100644 index 9a15a2d1..00000000 --- a/test/reports/TEST-MapTest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/reports/TEST-MapsControllerTest.xml b/test/reports/TEST-MapsControllerTest.xml deleted file mode 100644 index b67e87d3..00000000 --- a/test/reports/TEST-MapsControllerTest.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Failure: -test_should_render_new_if_map_not_created(Minitest::Result) [/home/k/.rvm/gems/ruby-2.4.6/gems/actionpack-4.2.11.1/lib/action_dispatch/routing/route_set.rb:234]: -ActionView::Template::Error: No route matches {:action=>"index", :controller=>"warpables", :map_id=>nil} missing required keys: [:map_id] - app/views/images/_new.html.erb:13:in `_app_views_images__new_html_erb___582794143336601479_47432368697160' - app/views/layouts/knitter2.html.erb:195:in `_app_views_layouts_knitter__html_erb__1554220659803257588_47432335059940' - app/controllers/maps_controller.rb:41:in `create' - test/functional/maps_controller_test.rb:151:in `block in <class:MapsControllerTest>' - - - - - - - - - - - - - - - - - - - - diff --git a/test/reports/TEST-UserTest.xml b/test/reports/TEST-UserTest.xml deleted file mode 100644 index 4aea8b0d..00000000 --- a/test/reports/TEST-UserTest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/test/unit/helpers/front_ui_helper_test.rb b/test/unit/helpers/front_ui_helper_test.rb index 9027ee5e..3c72b5f7 100644 --- a/test/unit/helpers/front_ui_helper_test.rb +++ b/test/unit/helpers/front_ui_helper_test.rb @@ -1,4 +1,21 @@ require 'test_helper' class FrontUiHelperTest < ActionView::TestCase + def setup + @user = users(:quentin) + @maps = Map.all + end + + test 'should return profile_image' do + last_image = @user.warpables.last.image + assert_equal last_image.url, profile_image(@user) + end + + test 'should return anonymous maps' do + assert_equal @maps.anonymous, anonymous(@maps) + end + + test 'should return featured maps' do + assert_equal @maps.featured, featured(@maps) + end end diff --git a/test/unit/map_test.rb b/test/unit/map_test.rb index dd5fbd9f..ae63f7f2 100644 --- a/test/unit/map_test.rb +++ b/test/unit/map_test.rb @@ -27,7 +27,7 @@ class MapTest < ActiveSupport::TestCase assert_not_nil map.comments assert_not_nil map.user assert_not_nil map.private - assert_not_nil map.anonymous? + assert_not map.anonymous? assert_not_nil map.images_histogram assert_not_nil map.grouped_images_histogram(10) assert_not_nil map.nearby_maps(100) # in degrees lat/lon @@ -117,4 +117,11 @@ class MapTest < ActiveSupport::TestCase assert map.add_tag('test', User.first) assert map.has_tag('test') end + + test 'anonymous' do + map = Map.create(name: 'Nakuru', lat: '-0.3030988', lon: '36.080026', location: 'Kenya' ) + + assert_includes(Map.anonymous, map) + assert map.anonymous? + end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 40e2c67b..1612c84d 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -39,6 +39,14 @@ class UserTest < ActiveSupport::TestCase assert_equal map.updated_at, user.last_action end + test 'warpables through maps relationship' do + user = users(:quentin) + map_images = user.maps.map(&:warpables) + + assert_equal Warpable::ActiveRecord_Associations_CollectionProxy, user.warpables.class + assert_equal map_images.flatten, user.warpables + end + # def test_should_authenticate_user # assert_equal users(:quentin), User.authenticate('quentin', 'monkey') # end diff --git a/vendor/assets/images/drone.png b/vendor/assets/images/drone.png deleted file mode 100644 index 75d4dc2f..00000000 Binary files a/vendor/assets/images/drone.png and /dev/null differ diff --git a/vendor/assets/images/kite.png b/vendor/assets/images/kite.png deleted file mode 100644 index d4a71e13..00000000 Binary files a/vendor/assets/images/kite.png and /dev/null differ diff --git a/vendor/assets/images/kite2.jpg b/vendor/assets/images/kite2.jpg deleted file mode 100644 index 1cada5bc..00000000 Binary files a/vendor/assets/images/kite2.jpg and /dev/null differ diff --git a/vendor/assets/images/selfie-stick.png b/vendor/assets/images/selfie-stick.png deleted file mode 100644 index b1c63494..00000000 Binary files a/vendor/assets/images/selfie-stick.png and /dev/null differ diff --git a/vendor/assets/images/user.png b/vendor/assets/images/user.png deleted file mode 100644 index 84d289e5..00000000 Binary files a/vendor/assets/images/user.png and /dev/null differ