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
43 render :action => :index
47 @extra_body_class = "site-edit-#{editor}"
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
76 render :text => RichText.new(params[:format], params[:text]).to_html
80 render "id", :layout => false
85 def redirect_map_params
88 if params[:lat] && params[:lon]
89 anchor << "map=#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
93 anchor << "layers=#{params.delete(:layers)}"
94 elsif params.delete(:notes) == 'yes'
99 redirect_to params.merge(:anchor => anchor.join('&'))