Add iD editor
iD sources live in vendor/assets/iD, and are managed with vendorer, using the "rewrite" functionality to replace relative paths in the CSS with <%= asset_path(…) %> directives. To avoid needing to namespace all of its CSS classes, iD is embedded via an iframe. To setup, edit application.yml to include an `id_key` key. (It can use the same consumer key as P2 if you like.)
10
Vendorfile
|
@ -37,4 +37,14 @@ folder 'vendor/assets' do
|
||||||
file 'ohauth.js'
|
file 'ohauth.js'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
folder 'iD' do
|
||||||
|
from 'git://github.com/systemed/iD', :branch => 'embed' do
|
||||||
|
folder 'iD/img', 'dist/img'
|
||||||
|
file 'iD.css.erb', 'dist/iD.css' do |path|
|
||||||
|
rewrite(path) { |content| content.gsub(/url\('?(img\/[^')]+)'?\)/, 'url(<%= asset_path("iD/\1") %>)') }
|
||||||
|
end
|
||||||
|
file 'iD.js', 'dist/iD.js'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1784,3 +1784,11 @@ a.button.submit {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rules for the iD editor
|
||||||
|
*/
|
||||||
|
.id-embed {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
|
@ -65,4 +65,8 @@ class SiteController < ApplicationController
|
||||||
def preview
|
def preview
|
||||||
render :text => RichText.new(params[:format], params[:text]).to_html
|
render :text => RichText.new(params[:format], params[:text]).to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def id_iframe
|
||||||
|
render "id_iframe", :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
34
app/views/site/_id.html.erb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<% if defined? ID_KEY %>
|
||||||
|
<iframe frameBorder="0" id="id-embed" class="id-embed"></iframe>
|
||||||
|
<% token = @user.access_token(ID_KEY) %>
|
||||||
|
<script>
|
||||||
|
var keys = {
|
||||||
|
'<%= request.protocol + request.host_with_port %>': {
|
||||||
|
oauth_consumer_key: "<%= token.client_application.key %>",
|
||||||
|
oauth_secret: "<%= token.client_application.secret %>",
|
||||||
|
oauth_token: "<%= token.token %>",
|
||||||
|
oauth_token_secret: "<%= token.secret %>"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var coord = {};
|
||||||
|
<% if @lat && @lon && @zoom -%>
|
||||||
|
coord.lat = <%= @lat %>;
|
||||||
|
coord.lon = <%= @lon %>;
|
||||||
|
coord.zoom = <%= @zoom %>;
|
||||||
|
<% else -%>
|
||||||
|
var params = OSM.mapParams();
|
||||||
|
coord.lat = params.lat;
|
||||||
|
coord.lon = params.lon;
|
||||||
|
coord.zoom = params.zoom;
|
||||||
|
<% end -%>
|
||||||
|
var url = 'id_iframe#map=' + coord.zoom + '/' + coord.lon + '/' + coord.lat +
|
||||||
|
'&preauth=' + JSON.stringify(keys);
|
||||||
|
$('#id-embed').attr('src', url);
|
||||||
|
</script>
|
||||||
|
<% else%>
|
||||||
|
<script type="text/javascript">alert("<%= t 'site.edit.id_not_configured' %>")</script>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
</script>
|
37
app/views/site/id_iframe.html.erb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<%= stylesheet_link_tag 'iD' %>
|
||||||
|
<!--[if !IE || gte IE 9]><!-->
|
||||||
|
<%= javascript_include_tag 'iD' %>
|
||||||
|
<!-- <![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id='id-container'></div>
|
||||||
|
<script>
|
||||||
|
if (typeof iD == 'undefined') {
|
||||||
|
document.getElementById('id-container').innerHTML = 'This editor is supported ' +
|
||||||
|
'in Firefox, Chrome, Safari, Opera, and Internet Explorer 9 and above. ' +
|
||||||
|
'Please upgrade your browser or use Potlatch 2 to edit the map.';
|
||||||
|
document.getElementById('id-container').className = 'unsupported';
|
||||||
|
} else {
|
||||||
|
var qs = iD.util.stringQs(location.hash);
|
||||||
|
if (qs.preauth) {
|
||||||
|
var preauth = JSON.parse(qs.preauth);
|
||||||
|
|
||||||
|
var id = iD()
|
||||||
|
.embed(true)
|
||||||
|
.imagePath("/assets/iD/img/"); <%# Can't use asset_path('id/img/') in production. %>
|
||||||
|
|
||||||
|
id.connection()
|
||||||
|
.url(Object.keys(preauth)[0])
|
||||||
|
.keys(preauth);
|
||||||
|
|
||||||
|
d3.select('#id-container')
|
||||||
|
.call(id.ui());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -62,6 +62,7 @@ OpenStreetMap::Application.configure do
|
||||||
config.assets.precompile += %w( large-rtl.css small-rtl.css print-rtl.css )
|
config.assets.precompile += %w( large-rtl.css small-rtl.css print-rtl.css )
|
||||||
config.assets.precompile += %w( browse.css leaflet-all.css leaflet.ie.css )
|
config.assets.precompile += %w( browse.css leaflet-all.css leaflet.ie.css )
|
||||||
config.assets.precompile += %w( embed.js embed.css )
|
config.assets.precompile += %w( embed.js embed.css )
|
||||||
|
config.assets.precompile += %w( iD.js iD.css )
|
||||||
|
|
||||||
# Disable delivery errors, bad email addresses will be ignored
|
# Disable delivery errors, bad email addresses will be ignored
|
||||||
# config.action_mailer.raise_delivery_errors = false
|
# config.action_mailer.raise_delivery_errors = false
|
||||||
|
|
|
@ -78,6 +78,8 @@ defaults: &defaults
|
||||||
#potlatch2_key: ""
|
#potlatch2_key: ""
|
||||||
# OAuth consumer key for the web site
|
# OAuth consumer key for the web site
|
||||||
#oauth_key: ""
|
#oauth_key: ""
|
||||||
|
# OAuth consumer key for iD
|
||||||
|
#id_key: ""
|
||||||
# Whether to require users to view the CTs before continuing to edit...
|
# Whether to require users to view the CTs before continuing to edit...
|
||||||
require_terms_seen: false
|
require_terms_seen: false
|
||||||
# Whether to require users to agree to the CTs before editing
|
# Whether to require users to agree to the CTs before editing
|
||||||
|
|
|
@ -85,6 +85,9 @@ en:
|
||||||
potlatch:
|
potlatch:
|
||||||
name: "Potlatch 1"
|
name: "Potlatch 1"
|
||||||
description: "Potlatch 1 (in-browser editor)"
|
description: "Potlatch 1 (in-browser editor)"
|
||||||
|
id:
|
||||||
|
name: "iD"
|
||||||
|
description: "iD (in-browser editor)"
|
||||||
potlatch2:
|
potlatch2:
|
||||||
name: "Potlatch 2"
|
name: "Potlatch 2"
|
||||||
description: "Potlatch 2 (in-browser editor)"
|
description: "Potlatch 2 (in-browser editor)"
|
||||||
|
@ -1312,6 +1315,7 @@ en:
|
||||||
potlatch_unsaved_changes: "You have unsaved changes. (To save in Potlatch, you should deselect the current way or point, if editing in live mode, or click save if you have a save button.)"
|
potlatch_unsaved_changes: "You have unsaved changes. (To save in Potlatch, you should deselect the current way or point, if editing in live mode, or click save if you have a save button.)"
|
||||||
potlatch2_not_configured: "Potlatch 2 has not been configured - please see http://wiki.openstreetmap.org/wiki/The_Rails_Port#Potlatch_2 for more information"
|
potlatch2_not_configured: "Potlatch 2 has not been configured - please see http://wiki.openstreetmap.org/wiki/The_Rails_Port#Potlatch_2 for more information"
|
||||||
potlatch2_unsaved_changes: "You have unsaved changes. (To save in Potlatch 2, you should click save.)"
|
potlatch2_unsaved_changes: "You have unsaved changes. (To save in Potlatch 2, you should click save.)"
|
||||||
|
id_not_configured: "iD has not been configured"
|
||||||
no_iframe_support: "Your browser doesn't support HTML iframes, which are necessary for this feature."
|
no_iframe_support: "Your browser doesn't support HTML iframes, which are necessary for this feature."
|
||||||
sidebar:
|
sidebar:
|
||||||
search_results: Search Results
|
search_results: Search Results
|
||||||
|
|
|
@ -131,6 +131,7 @@ OpenStreetMap::Application.routes.draw do
|
||||||
match '/logout' => 'user#logout', :via => [:get, :post]
|
match '/logout' => 'user#logout', :via => [:get, :post]
|
||||||
match '/offline' => 'site#offline', :via => :get
|
match '/offline' => 'site#offline', :via => :get
|
||||||
match '/key' => 'site#key', :via => :get
|
match '/key' => 'site#key', :via => :get
|
||||||
|
match '/id_iframe' => 'site#id_iframe', :via => :get
|
||||||
match '/user/new' => 'user#new', :via => :get
|
match '/user/new' => 'user#new', :via => :get
|
||||||
match '/user/terms' => 'user#terms', :via => [:get, :post]
|
match '/user/terms' => 'user#terms', :via => [:get, :post]
|
||||||
match '/user/save' => 'user#save', :via => :post
|
match '/user/save' => 'user#save', :via => :post
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Editors
|
module Editors
|
||||||
ALL_EDITORS = [ "potlatch", "potlatch2", "remote" ]
|
ALL_EDITORS = [ "potlatch", "potlatch2", "id", "remote" ]
|
||||||
RECOMMENDED_EDITORS = [ "potlatch2", "remote" ]
|
RECOMMENDED_EDITORS = [ "id", "potlatch2", "remote" ]
|
||||||
end
|
end
|
||||||
|
|
4320
vendor/assets/iD/iD.css.erb
vendored
Normal file
70963
vendor/assets/iD/iD.js
vendored
Normal file
BIN
vendor/assets/iD/iD/img/background-pattern-1.png
vendored
Normal file
After Width: | Height: | Size: 89 B |
BIN
vendor/assets/iD/iD/img/background-pattern-opacity.png
vendored
Normal file
After Width: | Height: | Size: 90 B |
BIN
vendor/assets/iD/iD/img/bing_maps.png
vendored
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
vendor/assets/iD/iD/img/cursor-draw-connect-line.png
vendored
Normal file
After Width: | Height: | Size: 452 B |
BIN
vendor/assets/iD/iD/img/cursor-draw-connect-line2x.png
vendored
Normal file
After Width: | Height: | Size: 832 B |
BIN
vendor/assets/iD/iD/img/cursor-draw-connect-vertex.png
vendored
Normal file
After Width: | Height: | Size: 227 B |
BIN
vendor/assets/iD/iD/img/cursor-draw-connect-vertex2x.png
vendored
Normal file
After Width: | Height: | Size: 412 B |
BIN
vendor/assets/iD/iD/img/cursor-draw.png
vendored
Normal file
After Width: | Height: | Size: 190 B |
BIN
vendor/assets/iD/iD/img/cursor-draw2x.png
vendored
Normal file
After Width: | Height: | Size: 351 B |
BIN
vendor/assets/iD/iD/img/cursor-grab.png
vendored
Normal file
After Width: | Height: | Size: 441 B |
BIN
vendor/assets/iD/iD/img/cursor-grab2x.png
vendored
Normal file
After Width: | Height: | Size: 851 B |
BIN
vendor/assets/iD/iD/img/cursor-grabbing.png
vendored
Normal file
After Width: | Height: | Size: 328 B |
BIN
vendor/assets/iD/iD/img/cursor-grabbing2x.png
vendored
Normal file
After Width: | Height: | Size: 627 B |
BIN
vendor/assets/iD/iD/img/cursor-pointer.png
vendored
Normal file
After Width: | Height: | Size: 364 B |
BIN
vendor/assets/iD/iD/img/cursor-pointer2x.png
vendored
Normal file
After Width: | Height: | Size: 685 B |
BIN
vendor/assets/iD/iD/img/cursor-pointing.png
vendored
Normal file
After Width: | Height: | Size: 352 B |
BIN
vendor/assets/iD/iD/img/cursor-pointing2x.png
vendored
Normal file
After Width: | Height: | Size: 665 B |
BIN
vendor/assets/iD/iD/img/cursor-select-acting.png
vendored
Normal file
After Width: | Height: | Size: 226 B |
BIN
vendor/assets/iD/iD/img/cursor-select-acting2x.png
vendored
Normal file
After Width: | Height: | Size: 376 B |
BIN
vendor/assets/iD/iD/img/cursor-select-add.png
vendored
Normal file
After Width: | Height: | Size: 303 B |
BIN
vendor/assets/iD/iD/img/cursor-select-add2x.png
vendored
Normal file
After Width: | Height: | Size: 603 B |
BIN
vendor/assets/iD/iD/img/cursor-select-area.png
vendored
Normal file
After Width: | Height: | Size: 282 B |
BIN
vendor/assets/iD/iD/img/cursor-select-area2x.png
vendored
Normal file
After Width: | Height: | Size: 515 B |
BIN
vendor/assets/iD/iD/img/cursor-select-line.png
vendored
Normal file
After Width: | Height: | Size: 335 B |
BIN
vendor/assets/iD/iD/img/cursor-select-line2x.png
vendored
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
vendor/assets/iD/iD/img/cursor-select-point.png
vendored
Normal file
After Width: | Height: | Size: 354 B |
BIN
vendor/assets/iD/iD/img/cursor-select-point2x.png
vendored
Normal file
After Width: | Height: | Size: 685 B |
BIN
vendor/assets/iD/iD/img/cursor-select-remove.png
vendored
Normal file
After Width: | Height: | Size: 290 B |
BIN
vendor/assets/iD/iD/img/cursor-select-remove2x.png
vendored
Normal file
After Width: | Height: | Size: 568 B |
BIN
vendor/assets/iD/iD/img/cursor-select-split.png
vendored
Normal file
After Width: | Height: | Size: 297 B |
BIN
vendor/assets/iD/iD/img/cursor-select-split2x.png
vendored
Normal file
After Width: | Height: | Size: 566 B |
BIN
vendor/assets/iD/iD/img/cursor-select-vertex.png
vendored
Normal file
After Width: | Height: | Size: 305 B |
BIN
vendor/assets/iD/iD/img/cursor-select-vertex2x.png
vendored
Normal file
After Width: | Height: | Size: 611 B |
BIN
vendor/assets/iD/iD/img/feature-icons.png
vendored
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
vendor/assets/iD/iD/img/loader-black.gif
vendored
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
vendor/assets/iD/iD/img/loader-white.gif
vendored
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
vendor/assets/iD/iD/img/loader_bg.gif
vendored
Normal file
After Width: | Height: | Size: 606 B |
BIN
vendor/assets/iD/iD/img/logo.png
vendored
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
vendor/assets/iD/iD/img/mini-loader.gif
vendored
Normal file
After Width: | Height: | Size: 287 B |
BIN
vendor/assets/iD/iD/img/pattern/cemetery.png
vendored
Normal file
After Width: | Height: | Size: 292 B |
BIN
vendor/assets/iD/iD/img/pattern/construction.png
vendored
Normal file
After Width: | Height: | Size: 280 B |
BIN
vendor/assets/iD/iD/img/pattern/dots.png
vendored
Normal file
After Width: | Height: | Size: 222 B |
BIN
vendor/assets/iD/iD/img/pattern/farmland.png
vendored
Normal file
After Width: | Height: | Size: 206 B |
BIN
vendor/assets/iD/iD/img/pattern/orchard.png
vendored
Normal file
After Width: | Height: | Size: 339 B |
BIN
vendor/assets/iD/iD/img/pattern/vineyard.png
vendored
Normal file
After Width: | Height: | Size: 354 B |
BIN
vendor/assets/iD/iD/img/pattern/wetland.png
vendored
Normal file
After Width: | Height: | Size: 301 B |
2242
vendor/assets/iD/iD/img/sprite.svg
vendored
Normal file
After Width: | Height: | Size: 160 KiB |