1 class SiteController < ApplicationController
2 layout 'site', :except => [:key, :permalink]
3 layout false, :only => [:key, :permalink]
5 before_filter :authorize_web
6 before_filter :set_locale
7 before_filter :redirect_map_params, :only => [:index, :edit, :export]
8 before_filter :require_user, :only => [:edit, :welcome]
9 before_filter :require_oauth, :only => [:index]
12 unless STATUS == :database_readonly or STATUS == :database_offline
13 session[:location] ||= OSM::IPLocation(request.env['REMOTE_ADDR'])
18 lon, lat, zoom = ShortLink::decode(params[:code])
19 new_params = params.except(:code, :lon, :lat, :zoom)
21 if new_params.has_key? :m
23 new_params[:mlat] = lat
24 new_params[:mlon] = lon
27 new_params[:controller] = 'site'
28 new_params[:action] = 'index'
29 new_params[:anchor] = "map=#{zoom}/#{lat}/#{lon}"
31 redirect_to new_params
35 expires_in 7.days, :public => true
39 editor = preferred_editor
42 render :action => :index
46 @extra_body_class = "site-edit-#{editor}"
49 bbox = Node.find(params[:node]).bbox.to_unscaled
50 @lat = bbox.centre_lat
51 @lon = bbox.centre_lon
53 bbox = Way.find(params[:way]).bbox.to_unscaled
54 @lat = bbox.centre_lat
55 @lon = bbox.centre_lon
57 note = Note.find(params[:note])
61 trace = Trace.visible_to(@user).find(params[:gpx])
63 @lon = trace.longitude
68 @locale = params[:copyright_locale] || I18n.locale
75 render :text => RichText.new(params[:format], params[:text]).to_html
79 render "id", :layout => false
84 def redirect_map_params
87 if params[:lat] && params[:lon]
88 anchor << "map=#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
92 anchor << "layers=#{params.delete(:layers)}"
93 elsif params.delete(:notes) == 'yes'
98 redirect_to params.merge(:anchor => anchor.join('&'))