From: Tom Hughes Date: Thu, 20 Sep 2012 15:01:24 +0000 (+0100) Subject: Merge branch 'master' into openstreetbugs X-Git-Tag: live~6058^2~103 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/4d91fe3dd95c1058cb8d24fd4c900223e30b9059?hp=-c Merge branch 'master' into openstreetbugs Conflicts: Gemfile app/helpers/application_helper.rb app/views/site/index.html.erb --- 4d91fe3dd95c1058cb8d24fd4c900223e30b9059 diff --combined Gemfile index 25b10fe7b,ad2f04c29..5193881af --- a/Gemfile +++ b/Gemfile @@@ -24,14 -24,11 +24,12 @@@ gem 'composite_primary_keys', '>= 5.0.8 gem 'http_accept_language', '>= 1.0.2' gem 'paperclip', '~> 2.0' gem 'deadlock_retry', '>= 1.2.0' + gem 'i18n-js', '>= 3.0.0.rc2' +gem 'jsonify-rails' # We need ruby-openid 2.2.0 or later for ruby 1.9 support gem 'ruby-openid', '>= 2.2.0' - # Browser detection support - gem 'browser' - # Markdown formatting support gem 'redcarpet' diff --combined Gemfile.lock index 158694564,1ec7948d1..666b6a094 --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -31,9 -31,8 +31,8 @@@ GE multi_json (~> 1.0) arel (3.0.2) bigdecimal (1.1.0) - browser (0.1.4) -- builder (3.0.0) -- cocaine (0.2.1) ++ builder (3.0.3) ++ cocaine (0.3.0) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@@ -55,18 -54,15 +54,20 @@@ http_accept_language (1.0.2) httpauth (0.1) httpclient (2.2.7) -- i18n (0.6.0) ++ i18n (0.6.1) + i18n-js (3.0.0.rc2) + i18n iconv (0.1) journey (1.0.4) -- jquery-rails (2.1.1) ++ jquery-rails (2.1.2) railties (>= 3.1.0, < 5.0) thor (~> 0.14) json (1.7.5) + jsonify (0.3.1) + multi_json (~> 1.0) + jsonify-rails (0.3.2) + actionpack + jsonify (< 0.4.0) jwt (0.1.5) multi_json (>= 1.0) libv8 (3.3.10.4) @@@ -75,13 -71,13 +76,13 @@@ i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) -- memcached (1.4.3) ++ memcached (1.4.5) mime-types (1.19) -- minitest (3.3.0) ++ minitest (3.4.0) multi_json (1.3.6) multipart-post (1.1.5) nokogiri (1.5.5) -- oauth (0.4.6) ++ oauth (0.4.7) oauth-plugin (0.4.1) multi_json oauth (~> 0.4.4) @@@ -100,7 -96,7 +101,7 @@@ activesupport (>= 2.3.2) cocaine (>= 0.0.2) mime-types -- pg (0.14.0) ++ pg (0.14.1) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@@ -120,7 -116,7 +121,7 @@@ activesupport (= 3.2.8) bundler (~> 1.0) railties (= 3.2.8) -- rails-i18n (0.6.5) ++ rails-i18n (0.6.6) i18n (~> 0.5) railties (3.2.8) actionpack (= 3.2.8) @@@ -150,14 -146,14 +151,14 @@@ libv8 (~> 3.3.10) thor (0.16.0) tilt (1.3.3) -- timecop (0.4.5) ++ timecop (0.5.1) treetop (1.4.10) polyglot polyglot (>= 0.3.1) tzinfo (0.3.33) -- uglifier (1.2.7) ++ uglifier (1.3.0) execjs (>= 0.3.0) -- multi_json (~> 1.3) ++ multi_json (~> 1.0, >= 1.0.2) validates_email_format_of (1.5.3) PLATFORMS @@@ -166,7 -162,6 +167,6 @@@ DEPENDENCIES SystemTimer (>= 1.1.3) bigdecimal - browser coffee-rails (~> 3.2.1) composite_primary_keys (>= 5.0.8) deadlock_retry (>= 1.2.0) @@@ -174,9 -169,9 +174,10 @@@ htmlentities http_accept_language (>= 1.0.2) httpclient + i18n-js (>= 3.0.0.rc2) iconv jquery-rails + jsonify-rails libxml-ruby (>= 2.0.5) memcached (>= 1.4.1) minitest diff --combined app/assets/javascripts/application.js index 311798aa5,e345f3074..71eb71711 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@@ -2,23 -2,45 +2,46 @@@ //= require jquery_ujs //= require jquery.autogrowtextarea //= require jquery.timers + //= require jquery.cookie + //= require augment + //= require openlayers + //= require i18n/translations + //= require globals + //= require params + //= require piwik + //= require browse + //= require export + //= require map + //= require key + //= require menu + //= require sidebar + //= require richtext + //= require resize ++//= require notes + + function zoomPrecision(zoom) { + var decimals = Math.pow(10, Math.floor(zoom/3)); + return function(x) { + return Math.round(x * decimals) / decimals; + }; + } /* * Called as the user scrolls/zooms around to aniplate hrefs of the * view tab and various other links */ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) { - var decimals = Math.pow(10, Math.floor(zoom/3)); + var toPrecision = zoomPrecision(zoom); var node; - lat = Math.round(lat * decimals) / decimals; - lon = Math.round(lon * decimals) / decimals; + lat = toPrecision(lat); + lon = toPrecision(lon); if (minlon) { - minlon = Math.round(minlon * decimals) / decimals; - minlat = Math.round(minlat * decimals) / decimals; - maxlon = Math.round(maxlon * decimals) / decimals; - maxlat = Math.round(maxlat * decimals) / decimals; + minlon = toPrecision(minlon); + minlat = toPrecision(minlat); + maxlon = toPrecision(maxlon); + maxlat = toPrecision(maxlat); } $(".geolink").each(function (index, link) { @@@ -40,25 -62,21 +63,21 @@@ args[objtype] = objid; } - var classes = $(link).attr("class").split(" "); - - $(classes).each(function (index, classname) { - if (match = classname.match(/^minzoom([0-9]+)$/)) { - var minzoom = match[1]; + var minzoom = $(link).data("minzoom"); + if (minzoom) { var name = link.id.replace(/anchor$/, ""); $(link).off("click.minzoom"); if (zoom >= minzoom) { - $(link).attr("title", i18n("javascripts.site." + name + "_tooltip")); + $(link).attr("title", I18n.t("javascripts.site." + name + "_tooltip")); $(link).removeClass("disabled"); } else { - $(link).on("click.minzoom", function () { alert(i18n("javascripts.site." + name + "_zoom_alert")); return false; }); - $(link).attr("title", i18n("javascripts.site." + name + "_disabled_tooltip")); + $(link).on("click.minzoom", function () { alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false; }); + $(link).attr("title", I18n.t("javascripts.site." + name + "_disabled_tooltip")); $(link).addClass("disabled"); } - } - }); + } link.href = setArgs(link.href, args); }); @@@ -144,26 -162,6 +163,6 @@@ function setArgs(url, args) return url.replace(/\?.*$/, "") + "?" + queryitems.join("&"); } - /* - * Called to interpolate JavaScript variables in strings using a - * similar syntax to rails I18n string interpolation - the only - * difference is that [[foo]] is the placeholder syntax instead - * of {{foo}} which allows the same string to be processed by both - * rails and then later by javascript. - */ - function i18n(string, keys) { - string = i18n_strings[string] || string; - - for (var key in keys) { - var re_key = '\\[\\[' + key + '\\]\\]'; - var re = new RegExp(re_key, "g"); - - string = string.replace(re, keys[key]); - } - - return string; - } - /* * Called to interlace the bits in x and y, making a Morton code. */ @@@ -208,62 -206,18 +207,18 @@@ function makeShortCode(lat, lon, zoom) } /* - * Click handler to switch a rich text control to preview mode + * Forms which have been cached by rails may have he wrong + * authenticity token, so patch up any forms with the correct + * token taken from the page header. */ - function previewRichtext(event) { - var editor = $(this).parents(".richtext_container").find("textarea"); - var preview = $(this).parents(".richtext_container").find(".richtext_preview"); - var width = editor.outerWidth() - preview.outerWidth() + preview.innerWidth(); - var minHeight = editor.outerHeight() - preview.outerHeight() + preview.innerHeight(); - - if (preview.contents().length == 0) { - preview.oneTime(500, "loading", function () { - preview.addClass("loading"); - }); - - preview.load(editor.attr("data-preview-url"), { text: editor.val() }, function () { - preview.stopTime("loading"); - preview.removeClass("loading"); - }); - } - - editor.hide(); - preview.width(width); - preview.css("min-height", minHeight + "px"); - preview.show(); - - $(this).siblings(".richtext_doedit").prop("disabled", false); - $(this).prop("disabled", true); - - event.preventDefault(); - } - - /* - * Click handler to switch a rich text control to edit mode - */ - function editRichtext(event) { - var editor = $(this).parents(".richtext_container").find("textarea"); - var preview = $(this).parents(".richtext_container").find(".richtext_preview"); - - preview.hide(); - editor.show(); - - $(this).siblings(".richtext_dopreview").prop("disabled", false); - $(this).prop("disabled", true); - - event.preventDefault(); - } + $(document).ready(function () { + var auth_token = $("meta[name=csrf-token]").attr("content"); + $("form input[name=authenticity_token]").val(auth_token); + }); /* - * Setup any rich text controls + * Enable auto expansion for all text areas */ $(document).ready(function () { - $(".richtext_preview").hide(); - $(".richtext_content textarea").change(function () { - $(this).parents(".richtext_container").find(".richtext_preview").empty(); - }); - $(".richtext_doedit").prop("disabled", true); - $(".richtext_dopreview").prop("disabled", false); - $(".richtext_doedit").click(editRichtext); - $(".richtext_dopreview").click(previewRichtext); + $("textarea").autoGrow(); }); diff --combined app/assets/stylesheets/common.css.scss index f2f16ec85,0f7100481..c897e1184 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@@ -64,6 -64,10 +64,10 @@@ h2 margin: 25px 0 5px 0; } + #logo img { + border: 0px; + } + #logo h1 { font-size: 18px; line-height: 20px; @@@ -83,6 -87,10 +87,10 @@@ display: none; } + #small-title img { + border: 0px; + } + /* Rules for the introductory text displayed in the left sidebar to new users */ .sidebar-copy { @@@ -322,9 -330,16 +330,16 @@@ padding: 5px 10px; text-decoration: none; color: #333; + -webkit-transition: color 200ms ease-in; + -moz-transition: color 200ms ease-in; + -o-transition: color 200ms ease-in; + transition: color 200ms ease-in; } - #tabnav a:link.active, #tabnav a:visited.active { + body.site-index #tabnav a#viewanchor, + body.site-edit #tabnav a#editanchor, + body.changeset-list #tabnav a#historyanchor, + body.site-export #tabnav a#exportanchor { border-bottom: 1px solid #aaa; background: #9ed485; color: #000; @@@ -383,6 -398,7 +398,7 @@@ #map { margin: 0px; + border: 0px; padding: 0px; } @@@ -496,7 -512,10 +512,10 @@@ padding-right: 5px; } - #mapkey .mapkey-table-key { + #mapkey .mapkey-table-key img { + display: block; + margin-left: auto; + margin-right: auto; } #mapkey .mapkey-table-value { @@@ -595,9 -614,9 +614,9 @@@ bottom: 0px; } - #content.site_index, - #content.site_edit, - #content.site_export { + .site-index #content, + .site-edit #content, + .site-export #content { border: 0px; padding: 0px; } @@@ -635,7 -654,7 +654,7 @@@ /* Rules for the home page */ - .site_index #map { + .site-index #map { position: absolute; top: 0px; bottom: 0px; @@@ -643,7 -662,7 +662,7 @@@ right: 0px; } - .site_export #map { + .site-export #map { position: absolute; top: 0px; bottom: 0px; @@@ -653,12 -672,13 +672,13 @@@ /* Rules for the edit page */ - .site_edit #map { + .site-edit #map { position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; + overflow: hidden; } /* Rules for the changeset list shown by the history tab etc */ @@@ -718,23 -738,6 +738,23 @@@ table.browse_details th white-space: nowrap; } +td.browse_comments { + padding: 0px; +} + +td.browse_comments table { + border-collapse: collapse; +} + +td.browse_comments table td { + padding-bottom: 10px; +} + +td.browse_comments table td span.by { + font-size: small; + color: #999999; +} + #browse_map { width: 250px; } @@@ -941,14 -944,14 +961,14 @@@ p#contributorGuidance /* Rules for the user view */ - .user_view .user_map { + .user-view .user_map { position: relative; width: 400px; height: 400px; border: 1px solid #ccc; } - .user_view .user_map p#no_home_location { + .user-view .user_map p#no_home_location { position: absolute; top: 0px; bottom: 0px; diff --combined app/controllers/browse_controller.rb index 73f0940d8,e3833a7d1..2c22a9b83 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@@ -1,5 -1,5 +1,5 @@@ class BrowseController < ApplicationController - layout 'site' + layout 'site', :except => [ :start ] before_filter :authorize_web before_filter :set_locale @@@ -7,11 -7,6 +7,6 @@@ around_filter :web_timeout, :except => [:start] def start - @max_features = case - when browser.ie? && browser.version.to_i < 8 then 100 - when browser.ie? && browser.version.to_i < 9 then 500 - else 2000 - end end def relation @@@ -84,13 -79,4 +79,13 @@@ rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end + + def note + @type = "note" + @note = Note.find(params[:id]) + @next = Note.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @note.id }] ) + @prev = Note.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @note.id }] ) + rescue ActiveRecord::RecordNotFound + render :action => "not_found", :status => :not_found + end end diff --combined app/helpers/application_helper.rb index e6a1e58e6,e0c299ca5..fb422cc17 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@@ -9,14 -9,6 +9,6 @@@ module ApplicationHelpe end end - def html_escape_unicode(text) - chars = ActiveSupport::Multibyte::Unicode.u_unpack(text).map do |c| - c < 127 ? c.chr : "&##{c.to_s};" - end - - return chars.join("") - end - def rss_link_to(*args) return link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), Hash[*args], { :class => "rsssmall" }); end @@@ -25,17 -17,6 +17,6 @@@ return link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), Hash[*args], { :class => "rsssmall" }); end - def javascript_strings - js = "" - - js << "\n" - - return raw(js) - end - def style_rules css = "" @@@ -106,33 -87,4 +87,16 @@@ end end end + + def friendly_date(date) + content_tag(:span, time_ago_in_words(date), :title => l(date, :format => :friendly)) + end + + def note_author(object, link_options = {}) + if object.author.nil? + h(object.author_name) + else + link_to h(object.author_name), link_options.merge({:controller => "user", :action => "view", :display_name => object.author_name}) + end + end - - private - - def javascript_strings_for_key(key) - js = "" - value = I18n.t(key, :locale => "en") - - if value.is_a?(String) - js << "i18n_strings['#{key}'] = '" << escape_javascript(t(key)) << "';\n" - else - value.each_key do |k| - js << javascript_strings_for_key("#{key}.#{k}") - end - end - - return js - end end diff --combined app/models/user.rb index e126adb98,3b2a12ca0..889c40451 --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -12,8 -12,6 +12,8 @@@ class User < ActiveRecord::Bas has_many :tokens, :class_name => "UserToken" has_many :preferences, :class_name => "UserPreference" has_many :changesets, :order => 'created_at DESC' + has_many :note_comments, :foreign_key => :author_id + has_many :notes, :through => :note_comments has_many :client_applications has_many :oauth_tokens, :class_name => "OauthToken", :order => "authorized_at desc", :include => [:client_application] @@@ -200,6 -198,7 +200,7 @@@ self.image = nil self.email_valid = false self.new_email = nil + self.openid_url = nil self.status = "deleted" self.save end diff --combined app/views/browse/_map.html.erb index d8ca30a15,6dba6cff3..44823218b --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@@ -1,22 -1,15 +1,19 @@@ - <%= javascript_include_tag 'openlayers.js' %> - <%= javascript_include_tag 'map.js' %> -
- <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %> + <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible? %>
<%= t 'browse.map.loading' %> + <% if map.instance_of? Note -%> + <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :notes => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %> + <% else -%> <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %> + <% end -%>
<%= link_to(h(t("browse.map.edit.area")) + content_tag(:span, "▾", :class => "menuicon"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %> - <% unless map.instance_of? Changeset %> + <% unless map.instance_of? Changeset or map.instance_of? Note %>
<%= link_to(t("browse.map.larger." + map.class.to_s.downcase), { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %>
@@@ -43,10 -36,8 +40,8 @@@
-<% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %> +<% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible? %>