]> git.openstreetmap.org Git - rails.git/blob - app/controllers/site_controller.rb
Removed bogus attempt to look up the previous version
[rails.git] / app / controllers / site_controller.rb
1 class SiteController < ApplicationController
2   layout 'site', :except => [:key, :permalink]
3
4   before_filter :authorize_web
5   before_filter :set_locale
6   before_filter :require_user, :only => [:edit]
7
8   def export
9     render :action => 'index'
10   end
11
12   def permalink
13     lon, lat, zoom = ShortLink::decode(params[:code])
14     new_params = params.clone
15     new_params.delete :code
16     if new_params.has_key? :m
17       new_params.delete :m
18       new_params[:mlat] = lat
19       new_params[:mlon] = lon
20     else
21       new_params[:lat] = lat
22       new_params[:lon] = lon
23     end
24     new_params[:zoom] = zoom
25     new_params[:controller] = 'site'
26     new_params[:action] = 'index'
27     redirect_to new_params
28   end
29
30   def key
31     expires_in 7.days, :public => true
32   end
33
34   def edit
35     editor = params[:editor] || @user.preferred_editor || DEFAULT_EDITOR
36
37     if editor == "remote"
38       render :action => :index
39     else
40       # Decide on a lat lon to initialise potlatch with. Various ways of doing this
41       if params['lon'] and params['lat']
42         @lon = params['lon'].to_f
43         @lat = params['lat'].to_f
44         @zoom = params['zoom'].to_i
45
46       elsif params['mlon'] and params['mlat']
47         @lon = params['mlon'].to_f
48         @lat = params['mlat'].to_f
49         @zoom = params['zoom'].to_i
50
51       elsif params['bbox']
52         bbox = BoundingBox.from_bbox_params(params)
53
54         @lon = bbox.centre_lon
55         @lat = bbox.centre_lat
56         @zoom = 16
57       elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
58         bbox = BoundingBox.from_lon_lat_params(params)
59
60         @lon = bbox.centre_lon
61         @lat = bbox.centre_lat
62         @zoom = 16
63
64       elsif params['gpx']
65         @lon = Trace.find(params['gpx']).longitude
66         @lat = Trace.find(params['gpx']).latitude
67
68       elsif cookies.key?("_osm_location")
69         @lon, @lat, @zoom, layers = cookies["_osm_location"].split("|")
70
71       elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
72         @lon = @user.home_lon
73         @lat = @user.home_lat
74
75       else
76         #catch all.  Do nothing.  lat=nil, lon=nil
77         #Currently this results in potlatch starting up at 0,0 (Atlantic ocean).
78       end
79
80       @zoom = '17' if @zoom.nil?
81     end
82   end
83 end