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 :require_user, :only => [:edit]
10 lon, lat, zoom = ShortLink::decode(params[:code])
11 new_params = params.clone
12 new_params.delete :code
13 if new_params.has_key? :m
15 new_params[:mlat] = lat
16 new_params[:mlon] = lon
18 new_params[:lat] = lat
19 new_params[:lon] = lon
21 new_params[:zoom] = zoom
22 new_params[:controller] = 'site'
23 new_params[:action] = 'index'
24 redirect_to new_params
28 expires_in 7.days, :public => true
32 editor = params[:editor] || @user.preferred_editor || DEFAULT_EDITOR
35 render :action => :index
37 # Decide on a lat lon to initialise potlatch with. Various ways of doing this
38 if params['lon'] and params['lat']
39 @lon = params['lon'].to_f
40 @lat = params['lat'].to_f
41 @zoom = params['zoom'].to_i
43 elsif params['mlon'] and params['mlat']
44 @lon = params['mlon'].to_f
45 @lat = params['mlat'].to_f
46 @zoom = params['zoom'].to_i
49 bbox = BoundingBox.from_bbox_params(params)
51 @lon = bbox.centre_lon
52 @lat = bbox.centre_lat
54 elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
55 bbox = BoundingBox.from_lon_lat_params(params)
57 @lon = bbox.centre_lon
58 @lat = bbox.centre_lat
62 @lon = Trace.find(params['gpx']).longitude
63 @lat = Trace.find(params['gpx']).latitude
65 elsif cookies.key?("_osm_location")
66 @lon, @lat, @zoom, layers = cookies["_osm_location"].split("|")
68 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
73 #catch all. Do nothing. lat=nil, lon=nil
74 #Currently this results in potlatch starting up at 0,0 (Atlantic ocean).
77 @zoom = '17' if @zoom.nil?
82 @locale = params[:copyright_locale] || I18n.locale
86 render :text => RichText.new(params[:format], params[:text]).to_html