Ajout d'une carte des prochains événements et des lugs, pour l'instant non cliquable

This commit is contained in:
echarp 2014-04-28 00:33:21 +02:00
parent ad0f8aa066
commit 92105b0b9c
15 changed files with 109 additions and 1 deletions

2
.gitignore vendored
View File

@ -94,3 +94,5 @@ capybara-*html
# vendor/extensions dummy applications.
vendor/extensions/**/spec/dummy
# exuberant-ctags
tags

View File

@ -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'

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View 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

View File

@ -0,0 +1,3 @@
#map
width: 100%
height: 40em

View 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

View File

@ -0,0 +1,2 @@
module MapsHelper
end

View File

@ -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

View 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

View File

@ -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

View File

@ -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'

View File

@ -0,0 +1,9 @@
require 'test_helper'
class MapsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class MapHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class MapsHelperTest < ActionView::TestCase
end