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
55 bbox = Way.find(params[:way]).bbox.to_unscaled
56 @lat = bbox.centre_lat
57 @lon = bbox.centre_lon
60 note = Note.find(params[:note])
65 trace = Trace.visible_to(@user).find(params[:gpx])
67 @lon = trace.longitude
73 @locale = params[:copyright_locale] || I18n.locale
86 render :text => RichText.new(params[:format], params[:text]).to_html
90 render "id", :layout => false
95 def redirect_browse_params
97 redirect_to node_path(params[:node])
99 redirect_to way_path(params[:way])
100 elsif params[:relation]
101 redirect_to relation_path(params[:relation])
103 redirect_to browse_note_path(params[:note])
105 redirect_to search_path(:query => params[:query])
109 def redirect_map_params
112 if params[:lat] && params[:lon]
113 anchor << "map=#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
117 anchor << "layers=#{params.delete(:layers)}"
118 elsif params.delete(:notes) == 'yes'
123 redirect_to params.merge(:anchor => anchor.join('&'))