rails_port_0.5: Merge rails_port r4664.
This commit is contained in:
commit
0f91ad8966
9 changed files with 188 additions and 9 deletions
|
@ -120,6 +120,24 @@ class TraceController < ApplicationController
|
|||
render :nothing => true, :status => :not_found
|
||||
end
|
||||
|
||||
def edit
|
||||
@trace = Trace.find(params[:id])
|
||||
|
||||
if @user and @trace.user == @user
|
||||
if params[:trace]
|
||||
@trace.description = params[:trace][:description]
|
||||
@trace.tagstring = params[:trace][:tagstring]
|
||||
if @trace.save
|
||||
redirect_to :action => 'view'
|
||||
end
|
||||
end
|
||||
else
|
||||
render :nothing, :status => :forbidden
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :nothing => true, :status => :not_found
|
||||
end
|
||||
|
||||
def delete
|
||||
trace = Trace.find(params[:id])
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module TraceHelper
|
||||
def link_to_tag(tag)
|
||||
if @action == "mine"
|
||||
return link_to tag, :tag => tag
|
||||
return link_to(tag, :tag => tag)
|
||||
else
|
||||
return link_to tag, :tag => tag, :display_name => @display_name
|
||||
return link_to(tag, :tag => tag, :display_name => @display_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
43
app/views/trace/edit.rhtml
Normal file
43
app/views/trace/edit.rhtml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<h2><%= @title %></h2>
|
||||
|
||||
<img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :display_name => @trace.user.display_name %>">
|
||||
|
||||
<% form_for :trace, @trace do |f| %>
|
||||
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Filename:</td>
|
||||
<td><%= @trace.name %> (<%= link_to 'download', :controller => 'trace', :action => 'data', :id => @trace.id %>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Uploaded at:</td>
|
||||
<td><%= @trace.timestamp %></td>
|
||||
</tr>
|
||||
<% if @trace.inserted? %>
|
||||
<tr>
|
||||
<td>Points:</td>
|
||||
<td><%= @trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %></td></tr>
|
||||
<tr>
|
||||
<td>Start coordinate:</td>
|
||||
<td><div class="geo" style="display: inline"><span class="latitude"><%= @trace.latitude %></span>; <span class="longitude"><%= @trace.longitude %></span></div> (<%=link_to 'map', :controller => 'site', :action => 'index', :lat => @trace.latitude, :lon => @trace.longitude, :zoom => 14 %> / <%=link_to 'edit', :controller => 'site', :action => 'edit', :lat => @trace.latitude, :lon => @trace.longitude, :gpx=> @trace.id, :zoom => 14 %>)</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td>Owner:</td>
|
||||
<td><%= link_to @trace.user.display_name, {:controller => 'user', :action => 'view', :display_name => @trace.user.display_name} %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Description:</td>
|
||||
<td><%= f.text_field :description %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tags:</td>
|
||||
<td><%= f.text_field :tagstring %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<%= submit_tag 'Save Changes' %>
|
||||
|
||||
<% end %>
|
|
@ -50,6 +50,9 @@
|
|||
<td><%= button_to 'Make this track public permanently', :controller => 'trace', :action => 'make_public', :id => @trace.id %></td>
|
||||
<% end %>
|
||||
<% if @trace.user.id == @user.id %>
|
||||
<td><%= button_to 'Edit this track', :controller => 'trace', :action => 'edit', :id => @trace.id %></td>
|
||||
<% end %>
|
||||
<% if @trace.user.id == @user.id %>
|
||||
<td><%= button_to 'Delete this track', :controller => 'trace', :action => 'delete', :id => @trace.id %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
|
@ -73,6 +73,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect '/traces/mine/tag/:tag', :controller => 'trace', :action => 'mine'
|
||||
map.connect '/traces/mine/tag/:tag/page/:page', :controller => 'trace', :action => 'mine'
|
||||
map.connect '/trace/create', :controller => 'trace', :action => 'create'
|
||||
map.connect '/trace/:id/edit', :controller => 'trace', :action => 'edit'
|
||||
map.connect '/trace/:id/delete', :controller => 'trace', :action => 'delete'
|
||||
map.connect '/trace/:id/make_public', :controller => 'trace', :action => 'make_public'
|
||||
map.connect '/user/:display_name/traces', :controller => 'trace', :action => 'list'
|
||||
|
|
114
db/migrate/006_tile_nodes.rb
Normal file
114
db/migrate/006_tile_nodes.rb
Normal file
|
@ -0,0 +1,114 @@
|
|||
class TileNodes < ActiveRecord::Migration
|
||||
def self.upgrade_table(from_table, to_table)
|
||||
execute <<-END_SQL
|
||||
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
|
||||
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
|
||||
user_id, visible, tags, timestamp,
|
||||
tile_for_point(CAST(ROUND(latitude * 10000000) AS UNSIGNED),
|
||||
CAST(ROUND(longitude * 10000000) AS UNSIGNED))
|
||||
FROM #{from_table}
|
||||
END_SQL
|
||||
end
|
||||
|
||||
def self.downgrade_table(from_table, to_table)
|
||||
execute <<-END_SQL
|
||||
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp)
|
||||
SELECT id, latitude / 10000000, longitude / 10000000,
|
||||
user_id, visible, tags, timestamp
|
||||
FROM #{from_table}
|
||||
END_SQL
|
||||
end
|
||||
|
||||
def self.up
|
||||
rename_table "current_nodes", "current_nodes_v5"
|
||||
|
||||
create_table "current_nodes", innodb_table do |t|
|
||||
t.column "id", :bigint, :limit => 64, :null => false
|
||||
t.column "latitude", :integer, :null => false
|
||||
t.column "longitude", :integer, :null => false
|
||||
t.column "user_id", :bigint, :limit => 20, :null => false
|
||||
t.column "visible", :boolean, :null => false
|
||||
t.column "tags", :text, :default => "", :null => false
|
||||
t.column "timestamp", :datetime, :null => false
|
||||
t.column "tile", :integer, :null => false
|
||||
end
|
||||
|
||||
add_primary_key "current_nodes", ["id"]
|
||||
add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
|
||||
add_index "current_nodes", ["tile"], :name => "current_nodes_tile_idx"
|
||||
|
||||
change_column "current_nodes", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
|
||||
change_column "current_nodes", "tile", :integer, :null => false, :unsigned => true
|
||||
|
||||
upgrade_table "current_nodes_v5", "current_nodes"
|
||||
|
||||
drop_table "current_nodes_v5"
|
||||
|
||||
rename_table "nodes", "nodes_v5"
|
||||
|
||||
create_table "nodes", myisam_table do |t|
|
||||
t.column "id", :bigint, :limit => 64, :null => false
|
||||
t.column "latitude", :integer, :null => false
|
||||
t.column "longitude", :integer, :null => false
|
||||
t.column "user_id", :bigint, :limit => 20, :null => false
|
||||
t.column "visible", :boolean, :null => false
|
||||
t.column "tags", :text, :default => "", :null => false
|
||||
t.column "timestamp", :datetime, :null => false
|
||||
t.column "tile", :integer, :null => false
|
||||
end
|
||||
|
||||
add_index "nodes", ["id"], :name => "nodes_uid_idx"
|
||||
add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
|
||||
add_index "nodes", ["tile"], :name => "nodes_tile_idx"
|
||||
|
||||
change_column "nodes", "tile", :integer, :null => false, :unsigned => true
|
||||
|
||||
upgrade_table "nodes_v5", "nodes"
|
||||
|
||||
drop_table "nodes_v5"
|
||||
end
|
||||
|
||||
def self.down
|
||||
rename_table "current_nodes", "current_nodes_v6"
|
||||
|
||||
create_table "current_nodes", innodb_table do |t|
|
||||
t.column "id", :bigint, :limit => 64, :null => false
|
||||
t.column "latitude", :double, :null => false
|
||||
t.column "longitude", :double, :null => false
|
||||
t.column "user_id", :bigint, :limit => 20, :null => false
|
||||
t.column "visible", :boolean, :null => false
|
||||
t.column "tags", :text, :default => "", :null => false
|
||||
t.column "timestamp", :datetime, :null => false
|
||||
end
|
||||
|
||||
add_primary_key "current_nodes", ["id"]
|
||||
add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx"
|
||||
add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
|
||||
|
||||
change_column "current_nodes", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
|
||||
|
||||
downgrade_table "current_nodes_v6", "current_nodes"
|
||||
|
||||
drop_table "current_nodes_v6"
|
||||
|
||||
rename_table "nodes", "nodes_v6"
|
||||
|
||||
create_table "nodes", myisam_table do |t|
|
||||
t.column "id", :bigint, :limit => 64, :null => false
|
||||
t.column "latitude", :double, :null => false
|
||||
t.column "longitude", :double, :null => false
|
||||
t.column "user_id", :bigint, :limit => 20, :null => false
|
||||
t.column "visible", :boolean, :null => false
|
||||
t.column "tags", :text, :default => "", :null => false
|
||||
t.column "timestamp", :datetime, :null => false
|
||||
end
|
||||
|
||||
add_index "nodes", ["id"], :name => "nodes_uid_idx"
|
||||
add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
|
||||
add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
|
||||
|
||||
downgrade_table "nodes_v6", "nodes"
|
||||
|
||||
drop_table "nodes_v6"
|
||||
end
|
||||
end
|
|
@ -5,9 +5,9 @@ class RemoveSegments < ActiveRecord::Migration
|
|||
have_segs = select_value("SELECT count(*) FROM current_segments").to_i != 0
|
||||
|
||||
if have_segs
|
||||
prefix = File.join Dir.tmpdir, "007_remove_segments.#{$$}."
|
||||
prefix = File.join Dir.tmpdir, "008_remove_segments.#{$$}."
|
||||
|
||||
cmd = "db/migrate/007_remove_segments_helper"
|
||||
cmd = "db/migrate/008_remove_segments_helper"
|
||||
src = "#{cmd}.cc"
|
||||
if not File.exists? cmd or File.mtime(cmd) < File.mtime(src) then
|
||||
system 'c++ -O3 -Wall `mysql_config --cflags --libs` ' +
|
|
@ -34,9 +34,9 @@ static T parse(const char *str) {
|
|||
static void exit_mysql_err(MYSQL *mysql) {
|
||||
const char *err = mysql_error(mysql);
|
||||
if (err) {
|
||||
fprintf(stderr, "007_remove_segments_helper: MySQL error: %s\n", err);
|
||||
fprintf(stderr, "008_remove_segments_helper: MySQL error: %s\n", err);
|
||||
} else {
|
||||
fprintf(stderr, "007_remove_segments_helper: MySQL error\n");
|
||||
fprintf(stderr, "008_remove_segments_helper: MySQL error\n");
|
||||
}
|
||||
abort();
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -45,9 +45,9 @@ static void exit_mysql_err(MYSQL *mysql) {
|
|||
static void exit_stmt_err(MYSQL_STMT *stmt) {
|
||||
const char *err = mysql_stmt_error(stmt);
|
||||
if (err) {
|
||||
fprintf(stderr, "007_remove_segments_helper: MySQL stmt error: %s\n", err);
|
||||
fprintf(stderr, "008_remove_segments_helper: MySQL stmt error: %s\n", err);
|
||||
} else {
|
||||
fprintf(stderr, "007_remove_segments_helper: MySQL stmt error\n");
|
||||
fprintf(stderr, "008_remove_segments_helper: MySQL stmt error\n");
|
||||
}
|
||||
abort();
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -615,7 +615,7 @@ int main(int argc, char **argv) {
|
|||
char *tempfn;
|
||||
|
||||
if (argc != 8) {
|
||||
printf("Usage: 007_remove_segments_helper host user passwd database port socket prefix\n");
|
||||
printf("Usage: 008_remove_segments_helper host user passwd database port socket prefix\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue