Ajout d'une carte des prochains événements et des lugs, pour l'instant non cliquable
This commit is contained in:
parent
ad0f8aa066
commit
92105b0b9c
2
.gitignore
vendored
2
.gitignore
vendored
@ -94,3 +94,5 @@ capybara-*html
|
||||
# vendor/extensions dummy applications.
|
||||
vendor/extensions/**/spec/dummy
|
||||
|
||||
# exuberant-ctags
|
||||
tags
|
||||
|
3
Gemfile
3
Gemfile
@ -69,6 +69,9 @@ gem 'simple_calendar', github: 'echarp/simple_calendar'
|
||||
# Markdown display
|
||||
gem 'redcarpet'
|
||||
|
||||
# Carte openstreetmap
|
||||
gem 'openlayers-rails'
|
||||
|
||||
group :development do
|
||||
gem 'guard-livereload'
|
||||
gem 'guard-bundler'
|
||||
|
@ -196,6 +196,8 @@ GEM
|
||||
multi_json (1.9.2)
|
||||
mysql2 (0.3.15)
|
||||
nio4r (1.0.0)
|
||||
openlayers-rails (0.0.4)
|
||||
railties (>= 3.1)
|
||||
orm_adapter (0.5.0)
|
||||
polyglot (0.3.4)
|
||||
pry (0.9.12.6)
|
||||
@ -293,6 +295,7 @@ DEPENDENCIES
|
||||
jquery-turbolinks
|
||||
modernizr-rails
|
||||
mysql2
|
||||
openlayers-rails
|
||||
polyamorous!
|
||||
quiet_assets
|
||||
rails (~> 4.1.0.rc1)
|
||||
|
BIN
app/assets/images/team.png
Normal file
BIN
app/assets/images/team.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
18
app/assets/javascripts/maps.js.coffee
Normal file
18
app/assets/javascripts/maps.js.coffee
Normal file
@ -0,0 +1,18 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
|
||||
#= require openlayers-rails
|
||||
|
||||
$(document).ready ->
|
||||
map = new OpenLayers.Map 'map'
|
||||
layer = new OpenLayers.Layer.WMS 'OpenLayers WMS',
|
||||
'http://vmap0.tiles.osgeo.org/wms/vmap0', {
|
||||
layers: 'basic'
|
||||
}
|
||||
map.addLayer layer
|
||||
map.setCenter new OpenLayers.LonLat(2.5, 47), 6
|
||||
map.addControl new OpenLayers.Control.LayerSwitcher()
|
||||
|
||||
map.addLayer eventsLayer
|
||||
map.addLayer lugsLayer
|
3
app/assets/stylesheets/maps.css.sass
Normal file
3
app/assets/stylesheets/maps.css.sass
Normal file
@ -0,0 +1,3 @@
|
||||
#map
|
||||
width: 100%
|
||||
height: 40em
|
19
app/controllers/maps_controller.rb
Normal file
19
app/controllers/maps_controller.rb
Normal file
@ -0,0 +1,19 @@
|
||||
class MapsController < ApplicationController
|
||||
def index
|
||||
@events = Event
|
||||
if (params[:region] && params[:region].present? && params[:region] != 'all')
|
||||
@events = @events.region(params[:region])
|
||||
end
|
||||
@events = @events.tag(params[:tag]) if (params[:tag])
|
||||
|
||||
@events = @events.where('start_time > ?', 360.days.ago).order :id
|
||||
|
||||
@cities_event = @events.collect { |event|
|
||||
City.find_by_majname event.city.gsub('-', ' ').upcase
|
||||
}.uniq.keep_if { |city| city }
|
||||
|
||||
@cities_lug = Lug.all.collect { |lug|
|
||||
City.find_by_majname lug.city.gsub('-', ' ').upcase
|
||||
}.uniq.keep_if { |city| city }
|
||||
end
|
||||
end
|
2
app/helpers/maps_helper.rb
Normal file
2
app/helpers/maps_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module MapsHelper
|
||||
end
|
@ -65,7 +65,7 @@
|
||||
= link_to t('.propose'), new_event_path
|
||||
= link_to t('.rss'), regions_url
|
||||
= link_to t('.ical'), icallist_regions_url
|
||||
= link_to t('.map'), users_url
|
||||
= link_to t('.map'), maps_url
|
||||
= link_to t('.tags'), tags_url
|
||||
= link_to t('.infos'), users_url
|
||||
= link_to t('.stats'), stats_regions_url
|
||||
|
31
app/views/maps/index.html.haml
Normal file
31
app/views/maps/index.html.haml
Normal file
@ -0,0 +1,31 @@
|
||||
%h2=t '.title'
|
||||
|
||||
#map
|
||||
|
||||
:javascript
|
||||
var eventsLayer = new OpenLayers.Layer.Markers("#{t '.events'}");
|
||||
eventsLayer.setVisibility(true);
|
||||
var iconSize = new OpenLayers.Size(20, 20);
|
||||
var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);
|
||||
|
||||
- for city in @cities_event
|
||||
:coffee
|
||||
marker = new OpenLayers.Marker(
|
||||
new OpenLayers.LonLat(#{city.longitude}, #{city.latitude})
|
||||
#new OpenLayers.Icon(<<iconURL>>, iconSize, iconOffset)
|
||||
)
|
||||
eventsLayer.addMarker marker
|
||||
|
||||
:javascript
|
||||
var lugsLayer = new OpenLayers.Layer.Markers("#{t '.lugs'}");
|
||||
lugsLayer.setVisibility(true);
|
||||
var iconSize = new OpenLayers.Size(20, 20);
|
||||
var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);
|
||||
|
||||
- for city in @cities_lug
|
||||
:coffee
|
||||
marker = new OpenLayers.Marker(
|
||||
new OpenLayers.LonLat(#{city.longitude}, #{city.latitude})
|
||||
new OpenLayers.Icon("/assets/team.png", iconSize, iconOffset)
|
||||
)
|
||||
lugsLayer.addMarker marker
|
@ -164,6 +164,11 @@ fr:
|
||||
title: Ajout d'une note de modération
|
||||
actions:
|
||||
added: La note a bien été ajoutée, merci!
|
||||
maps:
|
||||
index:
|
||||
title: Carte des évènements
|
||||
events: Évènements
|
||||
lugs: Lugs
|
||||
users:
|
||||
sign_in:
|
||||
title: Identification
|
||||
|
@ -1,4 +1,8 @@
|
||||
Rails.application.routes.draw do
|
||||
get 'maps/index'
|
||||
|
||||
get 'map/index'
|
||||
|
||||
resources :users
|
||||
resources :events
|
||||
resources :moderations do
|
||||
@ -9,6 +13,7 @@ Rails.application.routes.draw do
|
||||
get 'stats', on: :collection
|
||||
end
|
||||
resources :tags, only: [ :index, :show ]
|
||||
resources :maps, only: [:index]
|
||||
|
||||
get 'ical.php' => 'events#index', format: :ics
|
||||
get ':format.php' => 'events#index'
|
||||
|
9
test/controllers/maps_controller_test.rb
Normal file
9
test/controllers/maps_controller_test.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MapsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
4
test/helpers/map_helper_test.rb
Normal file
4
test/helpers/map_helper_test.rb
Normal file
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MapHelperTest < ActionView::TestCase
|
||||
end
|
4
test/helpers/maps_helper_test.rb
Normal file
4
test/helpers/maps_helper_test.rb
Normal file
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MapsHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in New Issue
Block a user