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
44 render :action => :index
48 @extra_body_class = "site-edit-#{editor}"
51 bbox = Node.find(params[:node]).bbox.to_unscaled
52 @lat = bbox.centre_lat
53 @lon = bbox.centre_lon
55 bbox = Way.find(params[:way]).bbox.to_unscaled
56 @lat = bbox.centre_lat
57 @lon = bbox.centre_lon
59 note = Note.find(params[:note])
63 trace = Trace.visible_to(@user).find(params[:gpx])
65 @lon = trace.longitude
70 @locale = params[:copyright_locale] || I18n.locale
83 render :text => RichText.new(params[:format], params[:text]).to_html
87 render "id", :layout => false
92 def redirect_browse_params
94 redirect_to node_path(params[:node])
96 redirect_to way_path(params[:way])
97 elsif params[:relation]
98 redirect_to relation_path(params[:relation])
100 redirect_to browse_note_path(params[:note])
104 def redirect_map_params
107 if params[:lat] && params[:lon]
108 anchor << "map=#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
112 anchor << "layers=#{params.delete(:layers)}"
113 elsif params.delete(:notes) == 'yes'
118 redirect_to params.merge(:anchor => anchor.join('&'))