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 render :action => 'index'
14 lon, lat, zoom = ShortLink::decode(params[:code])
15 new_params = params.clone
16 new_params.delete :code
17 if new_params.has_key? :m
19 new_params[:mlat] = lat
20 new_params[:mlon] = lon
22 new_params[:lat] = lat
23 new_params[:lon] = lon
25 new_params[:zoom] = zoom
26 new_params[:controller] = 'site'
27 new_params[:action] = 'index'
28 redirect_to new_params
32 expires_in 7.days, :public => true
36 editor = params[:editor] || @user.preferred_editor || DEFAULT_EDITOR
39 render :action => :index
41 # Decide on a lat lon to initialise potlatch with. Various ways of doing this
42 if params['lon'] and params['lat']
43 @lon = params['lon'].to_f
44 @lat = params['lat'].to_f
45 @zoom = params['zoom'].to_i
47 elsif params['mlon'] and params['mlat']
48 @lon = params['mlon'].to_f
49 @lat = params['mlat'].to_f
50 @zoom = params['zoom'].to_i
53 bbox = BoundingBox.from_bbox_params(params)
55 @lon = bbox.centre_lon
56 @lat = bbox.centre_lat
58 elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
59 bbox = BoundingBox.from_lon_lat_params(params)
61 @lon = bbox.centre_lon
62 @lat = bbox.centre_lat
66 @lon = Trace.find(params['gpx']).longitude
67 @lat = Trace.find(params['gpx']).latitude
69 elsif cookies.key?("_osm_location")
70 @lon, @lat, @zoom, layers = cookies["_osm_location"].split("|")
72 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
77 #catch all. Do nothing. lat=nil, lon=nil
78 #Currently this results in potlatch starting up at 0,0 (Atlantic ocean).
81 @zoom = '17' if @zoom.nil?
86 @locale = params[:copyright_locale] || I18n.locale
90 render :text => RichText.new(params[:format], params[:text]).to_html