private
def do_create(file, tags, description, public)
+ # Sanitise the user's filename
name = file.original_filename.gsub(/[^a-zA-Z0-9.]/, '_')
+
+ # Get a temporary filename...
filename = "/tmp/#{rand}"
+ # ...and save the uploaded file to that location
File.open(filename, "w") { |f| f.write(file.read) }
- @trace = Trace.new({:name => name, :tagstring => tags,
- :description => description, :public => public})
- @trace.inserted = false
- @trace.user = @user
- @trace.timestamp = Time.now.getutc
-
+ # Create the trace object, falsely marked as already
+ # inserted to stop the import daemon trying to load it
+ @trace = Trace.new({
+ :name => name,
+ :tagstring => tags,
+ :description => description,
+ :public => public,
+ :inserted => true,
+ :user => @user,
+ :timestamp => Time.now.getutc
+ })
+
+ # Save the trace object
if @trace.save
+ # Rename the temporary file to the final name
FileUtils.mv(filename, @trace.trace_name)
+
+ # Clear the inserted flag to make the import daemon load the trace
+ @trace.inserted = false
+ @trace.save!
else
+ # Remove the file as we have failed to update the database
FileUtils.rm_f(filename)
end
<% end %>
<% if false %>
- <div id="donate">
+ <div id="donate" class="notice">
Support OpenStreetMap by
<a href="http://donate.openstreetmap.org/">donating</a>
to the Hardware Upgrade Fund.
<%= yield :left_menu %>
</div>
+ <div id="sotm" class="notice">
+ Come to the 2009 OpenStreetMap
+ Conference, <a href="http://www.stateofthemap.org">The State
+ of the Map</a>, July 10-12 in Amsterdam!
+ </div>
+
<%= yield :optionals %>
<center>
if (zoomlevel<7 ) { var imgname = 'keymapnik6.png'; }
else if (zoomlevel<13) { var imgname = 'keymapnik'+zoomlevel+'.png'; }
- else { var imgname = 'keymapnik13.png'; }
+ else if (zoomlevel<15) { var imgname = 'keymapnik13.png'; }
+ else { var imgname = 'keymapnik15.png'; }
updateSidebar("Map key", "<p><img src='images/"+imgname+"' /><\/p>");
openSidebar({ width: "210px" });
mimetype.assign = (
".css" => "text/css",
".gif" => "image/gif",
- ".html" => "text/html",
+ ".html" => "text/html; charset=utf-8",
".js" => "application/x-javascript",
".png" => "image/png",
".swf" => "application/x-shockwave-flash",
-<html xmlns="http://www.w3.org/1999/xhtml">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
+ <title>OpenStreetMap Embedded</title>
<style type="text/css">
+ html {
+ width: 100%;
+ height: 100%;
+ }
+ body {
+ width: 100%;
+ height: 100%;
+ margin: 0px;
+ }
#map {
width: 100%;
height: 100%;
bottom: 3px!important;
}
</style>
- <script src="http://openstreetmap.org/openlayers/OpenLayers.js"></script>
- <script src="http://openstreetmap.org/openlayers/OpenStreetMap.js"></script>
+ <script src="http://openstreetmap.org/openlayers/OpenLayers.js" type="text/javascript"></script>
+ <script src="http://openstreetmap.org/openlayers/OpenStreetMap.js" type="text/javascript"></script>
<script type="text/javascript">
+ <!--
var map, layer;
function init(){
map = new OpenLayers.Map ("map", {
map.addControl(new OpenLayers.Control.PanZoom());
}
}
+ // -->
</script>
</head>
+
<body onload="init()">
<div id="map"></div>
</body>
font-size: 14px;
}
-#donate {
+.notice {
width: 150px;
margin: 10px;
padding: 10px;
background: #ea0;
line-height: 1.2em;
text-align: left;
- font-size: 12px;
+ font-size: 14px;
}
.left_menu {
padding: 2px;
}
-/**State of the Map */
-
-#sotminfo {
- background: #99F;
- font-size: 11px;
- margin: 0px;
- padding: 0px;
- border: 1px solid #ccc;
- left: 0px;
- line-height: 1.2em;
- text-align: Left;
- font-weight: normal;
-}
-
-#sotminfo a:link {
- text-decoration: underline;
-}
-
-#sotminfo a:visited {
- text-decoration: underline;
-}
-
#permalink {
z-index:10000;
position:absolute;