1 class SiteController < ApplicationController
3 layout :map_layout, :only => [:index, :export]
5 before_filter :authorize_web
6 before_filter :set_locale
7 before_filter :redirect_browse_params, :only => :index
8 before_filter :redirect_map_params, :only => [:index, :edit, :export]
9 before_filter :require_user, :only => [:edit, :welcome]
10 before_filter :require_oauth, :only => [:index]
13 unless STATUS == :database_readonly or STATUS == :database_offline
14 session[:location] ||= OSM::IPLocation(request.env['REMOTE_ADDR'])
19 lon, lat, zoom = ShortLink::decode(params[:code])
20 new_params = params.except(:code, :lon, :lat, :zoom)
22 if new_params.has_key? :m
24 new_params[:mlat] = lat
25 new_params[:mlon] = lon
28 new_params[:controller] = 'site'
29 new_params[:action] = 'index'
30 new_params[:anchor] = "map=#{zoom}/#{lat}/#{lon}"
32 redirect_to new_params
36 expires_in 7.days, :public => true
37 render :layout => false
41 editor = preferred_editor
45 render :action => :index
50 bbox = Node.find(params[:node]).bbox.to_unscaled
51 @lat = bbox.centre_lat
52 @lon = bbox.centre_lon
54 bbox = Way.find(params[:way]).bbox.to_unscaled
55 @lat = bbox.centre_lat
56 @lon = bbox.centre_lon
58 note = Note.find(params[:note])
62 trace = Trace.visible_to(@user).find(params[:gpx])
64 @lon = trace.longitude
69 @locale = params[:copyright_locale] || I18n.locale
82 render :text => RichText.new(params[:format], params[:text]).to_html
86 render "id", :layout => false
91 def redirect_browse_params
93 redirect_to node_path(params[:node])
95 redirect_to way_path(params[:way])
96 elsif params[:relation]
97 redirect_to relation_path(params[:relation])
99 redirect_to browse_note_path(params[:note])
101 redirect_to search_path(:query => params[:query])
105 def redirect_map_params
108 if params[:lat] && params[:lon]
109 anchor << "map=#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
113 anchor << "layers=#{params.delete(:layers)}"
114 elsif params.delete(:notes) == 'yes'
119 redirect_to params.merge(:anchor => anchor.join('&'))