]> git.openstreetmap.org Git - rails.git/blob - app/controllers/site_controller.rb
Remove the "We are changing the license" flash on the login page
[rails.git] / app / controllers / site_controller.rb
1 class SiteController < ApplicationController
2   layout 'site', :except => [:key, :permalink]
3   layout false, :only => [:key, :permalink]
4
5   before_filter :authorize_web
6   before_filter :set_locale
7   before_filter :require_user, :only => [:edit]
8
9   def permalink
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
14       new_params.delete :m
15       new_params[:mlat] = lat
16       new_params[:mlon] = lon
17     else
18       new_params[:lat] = lat
19       new_params[:lon] = lon
20     end
21     new_params[:zoom] = zoom
22     new_params[:controller] = 'site'
23     new_params[:action] = 'index'
24     redirect_to new_params
25   end
26
27   def key
28     expires_in 7.days, :public => true
29   end
30
31   def edit
32     editor = params[:editor] || @user.preferred_editor || DEFAULT_EDITOR
33
34     if editor == "remote"
35       render :action => :index
36     else
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
42
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
47
48       elsif params['bbox']
49         bbox = BoundingBox.from_bbox_params(params)
50
51         @lon = bbox.centre_lon
52         @lat = bbox.centre_lat
53         @zoom = 16
54       elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
55         bbox = BoundingBox.from_lon_lat_params(params)
56
57         @lon = bbox.centre_lon
58         @lat = bbox.centre_lat
59         @zoom = 16
60
61       elsif params['gpx']
62         @lon = Trace.find(params['gpx']).longitude
63         @lat = Trace.find(params['gpx']).latitude
64
65       elsif cookies.key?("_osm_location")
66         @lon, @lat, @zoom, layers = cookies["_osm_location"].split("|")
67
68       elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
69         @lon = @user.home_lon
70         @lat = @user.home_lat
71
72       else
73         #catch all.  Do nothing.  lat=nil, lon=nil
74         #Currently this results in potlatch starting up at 0,0 (Atlantic ocean).
75       end
76
77       @zoom = '17' if @zoom.nil?
78     end
79   end
80
81   def copyright
82     @locale = params[:copyright_locale] || I18n.locale
83   end
84
85   def preview
86     render :text => RichText.new(params[:format], params[:text]).to_html
87   end
88 end