From: Tom Hughes Date: Thu, 8 Mar 2012 18:23:27 +0000 (+0000) Subject: Merge branch 'master' into openstreetbugs X-Git-Tag: live~5120^2~120 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/e660e609661edadc1ed5ad49d6e83e936b2f91cd Merge branch 'master' into openstreetbugs Conflicts: Gemfile Gemfile.lock lib/migrate.rb --- e660e609661edadc1ed5ad49d6e83e936b2f91cd diff --cc Gemfile index 0f867f3d5,c1bb2f50b..65de156e1 --- a/Gemfile +++ b/Gemfile @@@ -17,9 -17,14 +17,15 @@@ gem 'rinku', '>= 1.2.2', :require => 'r gem 'oauth-plugin', '>= 0.4.0.pre7' gem 'open_id_authentication', '>= 1.1.0' gem 'validates_email_format_of', '>= 1.5.1' - gem 'composite_primary_keys', '>= 4.1.1' + gem 'composite_primary_keys', '>= 5.0.0' + gem 'http_accept_language', '>= 1.0.2' + gem 'paperclip', '~> 2.0' + gem 'deadlock_retry', '>= 1.2.0' +gem 'jsonify-rails' + # Character conversion support for ruby 1.8 + gem 'iconv', :platforms => :ruby_18 + # Load libxml support for XML parsing and generation gem 'libxml-ruby', '>= 2.0.5', :require => 'libxml' diff --cc Gemfile.lock index 482d9c3ed,4709cd195..e212d1003 --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -39,31 -39,31 +39,36 @@@ GE coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.1.3) - composite_primary_keys (4.1.1) - activerecord (~> 3.1) + coffee-script-source (1.2.0) + composite_primary_keys (5.0.1) + activerecord (~> 3.2.0) + deadlock_retry (1.2.0) dynamic_form (1.1.4) erubis (2.7.0) - execjs (1.2.9) + execjs (1.3.0) multi_json (~> 1.0) - faraday (0.7.5) - addressable (~> 2.2.6) - multipart-post (~> 1.1.3) - rack (< 2, >= 1.1.0) + faraday (0.7.6) + addressable (~> 2.2) + multipart-post (~> 1.1) + rack (~> 1.1) hike (1.2.1) - httpclient (2.2.3) + http_accept_language (1.0.2) + httpclient (2.2.4) i18n (0.6.0) - jquery-rails (1.0.18) - railties (~> 3.0) + iconv (0.1) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) thor (~> 0.14) - json (1.6.1) - jsonify (0.2.0) - jsonify-rails (0.2.0) + json (1.6.5) ++ jsonify (0.3.1) ++ multi_json (~> 1.0) ++ jsonify-rails (0.3.1) + actionpack - jsonify (>= 0.2.0) ++ jsonify (>= 0.3.1) libv8 (3.3.10.4) libxml-ruby (2.2.2) - mail (2.3.0) - mail (2.4.1) ++ mail (2.4.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) @@@ -79,18 -78,21 +83,21 @@@ oauth (~> 0.4.4) oauth2 rack - oauth2 (0.5.1) - faraday (~> 0.7.4) - multi_json (~> 1.0.3) + oauth2 (0.5.2) + faraday (~> 0.7) + multi_json (~> 1.0) open_id_authentication (1.1.0) rack-openid (~> 1.3) - pg (0.11.0) + paperclip (2.7.0) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) + cocaine (>= 0.0.2) + mime-types + pg (0.13.2) polyglot (0.3.3) - rack (1.3.5) - rack-cache (1.1) + rack (1.4.1) - rack-cache (1.1) ++ rack-cache (1.2) rack (>= 0.4) - rack-mount (0.8.3) - rack (>= 1.0.0) rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) @@@ -143,8 -141,8 +146,8 @@@ treetop (1.4.10) polyglot polyglot (>= 0.3.1) -- tzinfo (0.3.31) - uglifier (1.1.0) ++ tzinfo (0.3.32) + uglifier (1.2.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) validates_email_format_of (1.5.3) @@@ -154,25 -152,26 +157,27 @@@ PLATFORM DEPENDENCIES SystemTimer (>= 1.1.3) - coffee-rails (~> 3.1.0) - composite_primary_keys (>= 4.1.1) + coffee-rails (~> 3.2.1) + composite_primary_keys (>= 5.0.0) + deadlock_retry (>= 1.2.0) dynamic_form + http_accept_language (>= 1.0.2) httpclient + iconv jquery-rails + jsonify-rails libxml-ruby (>= 2.0.5) - memcache-client - memcached + memcached (>= 1.4.1) oauth-plugin (>= 0.4.0.pre7) open_id_authentication (>= 1.1.0) + paperclip (~> 2.0) pg - rails (= 3.1.3) - rails-i18n-updater + rails (= 3.2.2) + rails-i18n (>= 0.5.1) rinku (>= 1.2.2) - rmagick sanitize - sass-rails (~> 3.1.0) + sass-rails (~> 3.2.3) therubyracer timecop - uglifier + uglifier (>= 1.0.3) validates_email_format_of (>= 1.5.1) diff --cc app/views/site/index.html.erb index 7d7d5a163,0c47227f8..884896109 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@@ -18,9 -18,8 +18,9 @@@
diff --cc app/views/user/view.html.erb index 0c6968be8,1729f6818..edf290c7b --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@@ -21,11 -21,11 +21,13 @@@ | <%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %> | + <%= link_to t('user.view.my comments' ), :controller => 'diary_entry', :action => 'comments', :display_name => @this_user.display_name %> + | <%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %> | - <%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %> + <%= link_to t('user.view.my traces'), :controller => 'trace', :action=> 'mine' %> + | + <%= link_to t('user.view.my notes'), :controller => 'note', :action=> 'mine' %> | <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %> | diff --cc config/locales/en.yml index 58965def1,c431de33e..3e9908bb5 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -1664,8 -1669,8 +1687,9 @@@ en new diary entry: new diary entry my edits: my edits my traces: my traces + my notes: my map notes my settings: my settings + my comments: my comments oauth settings: oauth settings blocks on me: blocks on me blocks by me: blocks by me diff --cc config/routes.rb index 62c263f0d,89f7e1951..fb4fcd426 --- a/config/routes.rb +++ b/config/routes.rb @@@ -104,10 -87,9 +104,11 @@@ OpenStreetMap::Application.routes.draw match '/user/:display_name/edits' => 'changeset#list' match '/user/:display_name/edits/feed' => 'changeset#feed', :format => :atom match '/browse/friends' => 'changeset#list', :friends => true + match '/browse/nearby' => 'changeset#list', :nearby => true match '/browse/changesets' => 'changeset#list' match '/browse/changesets/feed' => 'changeset#feed', :format => :atom + match '/browse/note/:id' => 'browse#note', :id => /\d+/ + match '/user/:display_name/notes' => 'note#mine' match '/browse' => 'changeset#list' # web site diff --cc lib/migrate.rb index 8f7e635f1,7549add2a..75e047815 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@@ -42,184 -42,89 +42,102 @@@ module ActiveRecor end end - if defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) - class MysqlAdapter - alias_method :old_native_database_types, :native_database_types - - def native_database_types - types = old_native_database_types - types[:bigint] = { :name => "bigint", :limit => 20 } - types[:double] = { :name => "double" } - types[:integer_pk] = { :name => "integer DEFAULT NULL auto_increment PRIMARY KEY" } - types[:bigint_pk] = { :name => "bigint(20) DEFAULT NULL auto_increment PRIMARY KEY" } - types[:bigint_pk_64] = { :name => "bigint(64) DEFAULT NULL auto_increment PRIMARY KEY" } - types[:bigint_auto_64] = { :name => "bigint(64) DEFAULT NULL auto_increment" } - types[:bigint_auto_11] = { :name => "bigint(11) DEFAULT NULL auto_increment" } - types[:bigint_auto_20] = { :name => "bigint(20) DEFAULT NULL auto_increment" } - types[:four_byte_unsigned] = { :name=> "integer unsigned" } - types[:inet] = { :name=> "integer unsigned" } - - enumerations.each do |e,v| - types[e.to_sym]= { :name => "enum('#{v.join '\',\''}')" } - end - - types - end - - def change_column(table_name, column_name, type, options = {}) - unless options_include_default?(options) - options[:default] = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")["Default"] - - unless type == :string or type == :text - options.delete(:default) if options[:default] = ""; - end - end - - change_column_sql = "ALTER TABLE #{table_name} CHANGE #{column_name} #{column_name} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - add_column_options!(change_column_sql, options) - execute(change_column_sql) - end - - def myisam_table - return { :id => false, :force => true, :options => "ENGINE=MyIsam" } - end - - def innodb_table - return { :id => false, :force => true, :options => "ENGINE=InnoDB" } - end - - def innodb_option - return "ENGINE=InnoDB" - end - - def change_engine (table_name, engine) - execute "ALTER TABLE #{table_name} ENGINE = #{engine}" - end - - def add_fulltext_index (table_name, column) - execute "CREATE FULLTEXT INDEX `#{table_name}_#{column}_idx` ON `#{table_name}` (`#{column}`)" - end - - def enumerations - @enumerations ||= Hash.new - end - - def create_enumeration (enumeration_name, values) - enumerations[enumeration_name] = values - end - - def drop_enumeration (enumeration_name) - enumerations.delete(enumeration_name) - end + class PostgreSQLAdapter + alias_method :old_native_database_types, :native_database_types + + def native_database_types + types = old_native_database_types + types[:double] = { :name => "double precision" } + types[:integer_pk] = { :name => "serial PRIMARY KEY" } + types[:bigint_pk] = { :name => "bigserial PRIMARY KEY" } + types[:bigint_pk_64] = { :name => "bigserial PRIMARY KEY" } + types[:bigint_auto_64] = { :name => "bigint" } #fixme: need autoincrement? + types[:bigint_auto_11] = { :name => "bigint" } #fixme: need autoincrement? + types[:bigint_auto_20] = { :name => "bigint" } #fixme: need autoincrement? + types[:four_byte_unsigned] = { :name => "bigint" } # meh + types[:inet] = { :name=> "inet" } + + enumerations.each_key do |e| + types[e.to_sym]= { :name => e } + end + + types + end - def alter_primary_key(table_name, new_columns) - execute("alter table #{table_name} drop primary key, add primary key (#{new_columns.join(',')})") - end + def myisam_table + return { :id => false, :force => true, :options => ""} + end - def interval_constant(interval) - "'#{interval}'" - end + def innodb_table + return { :id => false, :force => true, :options => ""} end - end - if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) - class PostgreSQLAdapter - alias_method :old_native_database_types, :native_database_types - - def native_database_types - types = old_native_database_types - types[:double] = { :name => "double precision" } - types[:integer_pk] = { :name => "serial PRIMARY KEY" } - types[:bigint_pk] = { :name => "bigserial PRIMARY KEY" } - types[:bigint_pk_64] = { :name => "bigserial PRIMARY KEY" } - types[:bigint_auto_64] = { :name => "bigint" } #fixme: need autoincrement? - types[:bigint_auto_11] = { :name => "bigint" } #fixme: need autoincrement? - types[:bigint_auto_20] = { :name => "bigint" } #fixme: need autoincrement? - types[:four_byte_unsigned] = { :name => "bigint" } # meh - types[:inet] = { :name=> "inet" } - - enumerations.each_key do |e| - types[e.to_sym]= { :name => e } - end - - types - end + def innodb_option + return "" + end - def myisam_table - return { :id => false, :force => true, :options => ""} - end + def change_engine (table_name, engine) + end - def innodb_table - return { :id => false, :force => true, :options => ""} - end + def add_fulltext_index (table_name, column) + execute "CREATE INDEX #{table_name}_#{column}_idx on #{table_name} (#{column})" + end - def innodb_option - return "" - end + def enumerations + @enumerations ||= Hash.new + end - def change_engine (table_name, engine) - end - def create_enumeration (enumeration_name, values) ++ def create_enumeration(enumeration_name, values) + enumerations[enumeration_name] = values - execute "create type #{enumeration_name} as enum ('#{values.join '\',\''}')" ++ execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')" + end - def add_fulltext_index (table_name, column) - execute "CREATE INDEX #{table_name}_#{column}_idx on #{table_name} (#{column})" - end - def drop_enumeration (enumeration_name) - execute "drop type #{enumeration_name}" ++ def drop_enumeration(enumeration_name) ++ execute "DROP TYPE #{enumeration_name}" + enumerations.delete(enumeration_name) + end - def enumerations - @enumerations ||= Hash.new - end ++ def rename_enumeration(old_name, new_name) ++ execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" ++ end + - def create_enumeration(enumeration_name, values) - enumerations[enumeration_name] = values - execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')" - end + def alter_primary_key(table_name, new_columns) - execute "alter table #{table_name} drop constraint #{table_name}_pkey; alter table #{table_name} add primary key (#{new_columns.join(',')})" ++ execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{table_name}_pkey" ++ execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{new_columns.join(',')})" + end - def drop_enumeration(enumeration_name) - execute "DROP TYPE #{enumeration_name}" - enumerations.delete(enumeration_name) - end + def interval_constant(interval) + "'#{interval}'::interval" + end - def rename_enumeration(old_name, new_name) - execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" - end + def add_index(table_name, column_name, options = {}) + column_names = Array(column_name) + index_name = index_name(table_name, :column => column_names) - def alter_primary_key(table_name, new_columns) - execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{table_name}_pkey" - execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{new_columns.join(',')})" + if Hash === options # legacy support, since this param was a string + index_type = options[:unique] ? "UNIQUE" : "" + index_name = options[:name] || index_name + index_method = options[:method] || "BTREE" + else + index_type = options end - def interval_constant(interval) - "'#{interval}'::interval" + quoted_column_names = column_names.map { |e| quote_column_name(e) } + if Hash === options and options[:lowercase] + quoted_column_names = quoted_column_names.map { |e| "LOWER(#{e})" } end + quoted_column_names = quoted_column_names.join(", ") - def add_index(table_name, column_name, options = {}) - column_names = Array(column_name) - index_name = index_name(table_name, :column => column_names) - - if Hash === options # legacy support, since this param was a string - index_type = options[:unique] ? "UNIQUE" : "" - index_name = options[:name] || index_name - index_method = options[:method] || "BTREE" - else - index_type = options - end - - quoted_column_names = column_names.map { |e| quote_column_name(e) } - if Hash === options and options[:lowercase] - quoted_column_names = quoted_column_names.map { |e| "LOWER(#{e})" } - end - quoted_column_names = quoted_column_names.join(", ") - - execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} USING #{index_method} (#{quoted_column_names})" - end + execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} USING #{index_method} (#{quoted_column_names})" end + + def rename_index(table_name, old_name, new_name) + execute "ALTER INDEX #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" + end + + def rename_sequence(table_name, old_name, new_name) + execute "ALTER SEQUENCE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" + end end end end