class AmfController < ApplicationController
require 'stringio'
+ before_filter :check_availability
+
# to log:
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
# no auth, the user does not exist or the password was wrong
response.headers["Status"] = "Unauthorized"
response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
- render_text(errormessage, 401) # :unauthorized
+ render :text => errormessage, :status => :unauthorized
+ return false
end
end
+ def check_availability
+ if API_READONLY
+ response.headers['Error'] = "Database offline for maintenance"
+ render :nothing => true, :status => :service_unavailable
+ return false
+ end
+ end
+
# Report and error to the user
# (If anyone ever fixes Rails so it can set a http status "reason phrase",
# rather than only a status code and having the web engine make up a
require 'xml/libxml'
before_filter :authorize, :only => [:create, :update, :delete]
+ before_filter :check_availability, :only => [:create, :update, :delete]
after_filter :compress_output
def create
require 'xml/libxml'
before_filter :authorize, :only => [:create, :update, :delete]
+ before_filter :check_availability, :only => [:create, :update, :delete]
after_filter :compress_output
def create
class SwfController < ApplicationController
+ before_filter :check_availability
# to log:
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
require 'xml/libxml'
before_filter :authorize, :only => [:create, :update, :delete]
+ before_filter :check_availability, :only => [:create, :update, :delete]
after_filter :compress_output
def create
</div>
<% end %>
+ <% if API_READONLY %>
+ <div id="alert">
+ The OpenStreetMap database is currently in read-only mode while
+ essential database maintenance work is carried out.
+ </div>
+ <% end %>
+
<div id="left_menu" class="left_menu">
<a href="http://wiki.openstreetmap.org">Help & Wiki</a><br />
<%= link_to "Users' diaries", {:controller => 'diary_entry', :action => 'list', :display_name => nil} %><br />
<a href="http://wiki.openstreetmap.org/index.php/Merchandise">Shop</a><br />
</div>
-
<%= yield :optionals %>
<div id="cclogo">
<center>
+<% if API_READONLY %>
+<p>The OpenStreetMap database is currently in read-only mode while
+ essential database maintenance work is carried out.
+</p>
+<% else %>
<%= render :partial => 'search' %>
<% if params['mlon'] and params['mlat'] %>
OpenStreetMap Flash editor. You can <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">download Flash Player from Adobe.com</a>.
<a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
- for editing OpenStreetMap.</div>
- <script type="text/javascript" src="/javascripts/swfobject.js"></script>
- <script type="text/javascript">
- var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "700", "600", "6", "#FFFFFF");
- function doSWF(lat,lon,sc) {
- fo.addVariable('lat',lat);
- fo.addVariable('long',lon);
- fo.addVariable('scale',sc);
- fo.addVariable('token','<%= @user.token %>');
- fo.write("mapcontent");
- }
+ for editing OpenStreetMap.
+</div>
+<script type="text/javascript" src="/javascripts/swfobject.js"></script>
+<script type="text/javascript">
+ var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "700", "600", "6", "#FFFFFF");
- doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
+ function doSWF(lat,lon,sc) {
+ fo.addVariable('lat',lat);
+ fo.addVariable('long',lon);
+ fo.addVariable('scale',sc);
+ fo.addVariable('token','<%= @user.token %>');
+ fo.write("mapcontent");
+ }
+ doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
</script>
+<% end %>
# inflect.uncountable %w( fish sheep )
# end
+# Set to true to put the API in read-only mode
+API_READONLY = false
+
# Include your application configuration below
SERVER_URL = ENV['OSM_SERVER_URL'] || 'www.openstreetmap.org'
font-size: 11px;\r
}\r
\r
+#alert {\r
+ width: 150px;\r
+ margin: 10px;\r
+ padding: 10px;\r
+ border: 1px solid #ccc;\r
+ background: #d00;\r
+ line-height: 1.2em;\r
+ text-align: left;\r
+ font-size: 14px;\r
+}\r
+\r
.left_menu {\r
width: 150px;\r
min-width: 150px;\r