From 594ed4ca639742c4e109966328cc24ec88786711 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Mon, 29 Dec 2008 14:58:53 -0500 Subject: [PATCH 1/6] Don't re-generate remember token if we already have one. This should allow you to stay logged in on two devices at the same time. Closes #812. --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6c0302cc..6da8bf2c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -202,7 +202,7 @@ class User < ActiveRecord::Base # These create and unset the fields required for remembering users between browser closes def remember_me self.remember_token_expires_at = 2.weeks.from_now.utc - self.remember_token = self.class.sha1("#{login}--#{remember_token_expires_at}") + self.remember_token ||= self.class.sha1("#{login}--#{remember_token_expires_at}") save(false) end From 2eb9151d2eae00b662192e094066cf1399bbc278 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Fri, 2 Jan 2009 01:54:56 -0500 Subject: [PATCH 2/6] Fix failing specs --- spec/models/todo_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 5cc542f0..d2ec9263 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -170,7 +170,7 @@ describe Todo do it 'is starred if tag is "starred"' do todo = create_todo todo.should_not be_starred - todo.add_tag('starred') + todo._add_tags('starred') todo.reload todo.should be_starred end @@ -178,7 +178,7 @@ describe Todo do describe 'when toggling star flag' do it 'toggles to not starred when starred' do todo = create_todo - todo.add_tag('starred') + todo._add_tags('starred') todo.should be_starred todo.toggle_star! todo.reload From b86c7341ff9e2b23f7a66535c925078dfbf7f3b5 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Fri, 2 Jan 2009 02:22:06 -0500 Subject: [PATCH 3/6] Change mobile login form to post to proper URL for OpenID login. Resolves #810. --- app/views/login/login_mobile.html.erb | 2 +- spec/views/login/login_mobile.html.erb_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 spec/views/login/login_mobile.html.erb_spec.rb diff --git a/app/views/login/login_mobile.html.erb b/app/views/login/login_mobile.html.erb index f3ff6511..a2b7cd94 100644 --- a/app/views/login/login_mobile.html.erb +++ b/app/views/login/login_mobile.html.erb @@ -39,7 +39,7 @@

...or login with an Open ID:

- <% form_tag formatted_open_id_begin_path(:format => 'm') do %> + <% form_tag formatted_login_path(:format => 'm') do %> diff --git a/spec/views/login/login_mobile.html.erb_spec.rb b/spec/views/login/login_mobile.html.erb_spec.rb new file mode 100644 index 00000000..5abca9f6 --- /dev/null +++ b/spec/views/login/login_mobile.html.erb_spec.rb @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/login.m" do + it "should render without an error" do + render :action => 'login/login_mobile.html.erb', :layout => 'mobile.m.erb' + response.should_not have_tag("div#Application-Trace") + end +end From 3864c9e37a59ff492fe4c3ea6ca97172e4126dd8 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sat, 3 Jan 2009 17:57:57 -0500 Subject: [PATCH 4/6] Update footer links for new website location --- app/views/shared/_footer.rhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_footer.rhtml b/app/views/shared/_footer.rhtml index 21ef0340..95fd3a78 100644 --- a/app/views/shared/_footer.rhtml +++ b/app/views/shared/_footer.rhtml @@ -1,3 +1,3 @@ From a1a8260f1099225db7e445609ff989f0e2c097e9 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Sun, 4 Jan 2009 17:14:03 -0500 Subject: [PATCH 5/6] Added an example of capistrano deployment recipes for deploying to a remote web host running Phusion Passenger (aka mod_rails), which is probably the easiest Rails deployment environment to configure. --- .gitignore | 1 + Capfile | 2 + config/deploy.rb-example | 101 +++++++++++++++++++++++++++++++++++++++ lib/tasks/database.rake | 27 +++++++++++ 4 files changed, 131 insertions(+) create mode 100644 Capfile create mode 100644 config/deploy.rb-example create mode 100644 lib/tasks/database.rake diff --git a/.gitignore b/.gitignore index 433e85a0..937d8f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.tmproj config/database.yml config/environment.rb +config/deploy.rb log tmp db/data.yml diff --git a/Capfile b/Capfile new file mode 100644 index 00000000..0402d1a1 --- /dev/null +++ b/Capfile @@ -0,0 +1,2 @@ +load 'deploy' if respond_to?(:namespace) # cap2 differentiator +load 'config/deploy' \ No newline at end of file diff --git a/config/deploy.rb-example b/config/deploy.rb-example new file mode 100644 index 00000000..77c7475f --- /dev/null +++ b/config/deploy.rb-example @@ -0,0 +1,101 @@ +############################################################# +# This file is designed as a starting point to use +# capistrano to deploy the trunk of tracks to a webhost +# where it is served using Phusion Passenger. For more +# info on getting started with Passenger, see +# http://www.modrails.com/ +############################################################# + + +############################################################# +# Application +############################################################# + +set :application, "tracks" +set :deploy_to, "/var/www/apps/tracks" + +############################################################# +# Settings +############################################################# + +default_run_options[:pty] = true +ssh_options[:forward_agent] = true +set :use_sudo, true +set :scm_verbose, true +set :rails_env, "production" + +############################################################# +# Servers +############################################################# + +#set :user, "your_login_name_on_your_webhost_if_different_from_local" +set :domain, "tracks.yoursite.com" +server domain, :app, :web +role :db, domain, :primary => true + +############################################################# +# Git +############################################################# + +set :scm, :git +set :branch, "master" +set :repository, "git://github.com/bsag/tracks.git" +set :deploy_via, :remote_cache + +############################################################# +# Passenger +############################################################# + +namespace :deploy do + desc "Symlink config files" + task :before_symlink do + run "rm #{release_path}/public/.htaccess" #not compatible with Passenger + run "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml" + run "ln -s #{shared_path}/config/environment.rb #{release_path}/config/environment.rb" + end + + # Restart passenger on deploy + desc "Restarting mod_rails with restart.txt" + task :restart, :roles => :app, :except => { :no_release => true } do + run "touch #{current_path}/tmp/restart.txt" + end + + [:start, :stop].each do |t| + desc "#{t} task is a no-op with mod_rails" + task t, :roles => :app do ; end + end + +end + +namespace :db do + desc 'Dumps the production database to db/production_data.sql on the remote server' + task :remote_db_dump, :roles => :db, :only => { :primary => true } do + run "cd #{deploy_to}/#{current_dir} && " + + "rake RAILS_ENV=#{rails_env} db:dump_sql --trace" + end + + desc 'Downloads db/production_data.sql from the remote production environment to your local machine' + task :remote_db_download, :roles => :db, :only => { :primary => true } do + execute_on_servers(options) do |servers| + self.sessions[servers.first].sftp.connect do |tsftp| + tsftp.download!("#{deploy_to}/#{current_dir}/db/production_data.sql", "db/production_data.sql") + end + end + end + + desc 'Cleans up data dump file' + task :remote_db_cleanup, :roles => :db, :only => { :primary => true } do + execute_on_servers(options) do |servers| + self.sessions[servers.first].sftp.connect do |tsftp| + tsftp.remove! "#{deploy_to}/#{current_dir}/db/production_data.sql" + end + end + end + + desc 'Dumps, downloads and then cleans up the production data dump' + task :remote_db_runner do + remote_db_dump + remote_db_download + remote_db_cleanup + end +end \ No newline at end of file diff --git a/lib/tasks/database.rake b/lib/tasks/database.rake new file mode 100644 index 00000000..eb02a45f --- /dev/null +++ b/lib/tasks/database.rake @@ -0,0 +1,27 @@ +require 'rake' + +namespace :db do + desc "Dump the current SQLite3 or MySQL database to a sql file" + task :dump_sql do + load 'config/environment.rb' + abcs = ActiveRecord::Base.configurations + case abcs[RAILS_ENV]["adapter"] + when 'mysql' + ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) + File.open("db/#{RAILS_ENV}_data.sql", "w+") do |f| + if abcs[RAILS_ENV]["password"].blank? + f << `mysqldump -h #{abcs[RAILS_ENV]["host"]} -u #{abcs[RAILS_ENV]["username"]} #{abcs[RAILS_ENV]["database"]}` + else + f << `mysqldump -h #{abcs[RAILS_ENV]["host"]} -u #{abcs[RAILS_ENV]["username"]} -p#{abcs[RAILS_ENV]["password"]} #{abcs[RAILS_ENV]["database"]}` + end + end + when 'sqlite3' + ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) + File.open("db/#{RAILS_ENV}_data.sql", "w+") do |f| + f << `sqlite3 #{abcs[RAILS_ENV]["database"]} .dump` + end + else + raise "Task not supported by '#{abcs[RAILS_ENV]['adapter']}'" + end + end +end \ No newline at end of file From cfe4a482e11890be4bae79f001d7f1df4d2e12f1 Mon Sep 17 00:00:00 2001 From: bsag Date: Mon, 5 Jan 2009 18:51:32 +0000 Subject: [PATCH 6/6] Corrected the information about setting up the doc/manual submodule. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 8d3c1883..8f080e2c 100644 --- a/README +++ b/README @@ -14,7 +14,7 @@ All the documentation for Tracks can be found within the /doc directory. It contains a manual in HTML (manual.html) or PDF format (manual.pdf), and this includes full instructions for both new installations and upgrades from older installations of Tracks. The instructions might appear long and intimidatingly complex, but that is mostly because of the number of different platforms supported, and the different configurations which can be used (e.g. running Tracks on your local computer or on a remote server). If you choose the appropriate section for your situation (installation vs. upgrade), and use the easiest (recommended) method, you should find the instructions easy to follow. If you encounter problems, try searching the wiki, forum or mailing list (URLs above), and ask a question if you cannot find a solution to your problem. -If you checked out Tracks from the GitHub repository, the manual is not provided by default and is in its own git submodule. To checkout the manual's source files, type "git submodule update --init doc/manual". From then on, you should be able to issue the command "git pull" in the doc/manual directory to update the manual with the latest changes. +If you checked out Tracks from the GitHub repository, the manual is not provided by default and is in its own git submodule. To checkout the manual's source files, type "git submodule init doc/manual & git submodule update doc/manual". From then on, you should be able to issue the command "git pull" in the doc/manual directory to update the manual with the latest changes. For those upgrading, change notes are available in /doc/CHANGELOG. If you are thinking about contributing towards the development of Tracks, please read /doc/README_DEVELOPERS for general information, or /doc/tracks_api_wrapper.rb for information on Tracks' API.