From 979ae7dc27225fd678939e9b391f7a5ed79a544e Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 28 Aug 2005 12:54:47 +0000 Subject: [PATCH] Changed the shebang lines to #!/usr/bin/env ruby. This should work for all *nix based setups (Linux or Mac OS X), but Windows users will probably have to change it. Try this command at the command line, run inside the Tracks directory: {{{ ruby -i.bak -pe 'gsub!("#!/usr/bin/env ruby", "#!c:/ruby/bin/ruby")' public/dispatch.* script/* }}} I also failed to add the new user-related files and the new migrate task last time I committed, so those are added now. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@141 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/user_controller.rb | 11 ++++ tracks/app/helpers/user_helper.rb | 2 + .../db/migrate/5_add_project_description.rb | 9 +++ tracks/db/production_structure.sql | 56 +++++++++++++++++++ tracks/doc/CHANGELOG | 3 + tracks/doc/README_FOR_APP | 6 +- tracks/public/dispatch.cgi | 2 +- tracks/public/dispatch.fcgi | 2 +- tracks/script/benchmarker | 2 +- tracks/script/breakpointer | 2 +- tracks/script/console | 2 +- tracks/script/destroy | 2 +- tracks/script/generate | 2 +- tracks/script/profiler | 2 +- tracks/script/runner | 2 +- tracks/script/server | 2 +- .../test/functional/user_controller_test.rb | 18 ++++++ 17 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 tracks/app/controllers/user_controller.rb create mode 100644 tracks/app/helpers/user_helper.rb create mode 100644 tracks/db/migrate/5_add_project_description.rb create mode 100644 tracks/db/production_structure.sql create mode 100644 tracks/test/functional/user_controller_test.rb diff --git a/tracks/app/controllers/user_controller.rb b/tracks/app/controllers/user_controller.rb new file mode 100644 index 00000000..4e3e1812 --- /dev/null +++ b/tracks/app/controllers/user_controller.rb @@ -0,0 +1,11 @@ +class UserController < ApplicationController + scaffold :user + + def index + render_text "This will be our jumping-off point for managing user functions!" + end + + def admin + render_text "You'll only be allowed to go here if you're an administrator." + end +end \ No newline at end of file diff --git a/tracks/app/helpers/user_helper.rb b/tracks/app/helpers/user_helper.rb new file mode 100644 index 00000000..0147c3fe --- /dev/null +++ b/tracks/app/helpers/user_helper.rb @@ -0,0 +1,2 @@ +module UserHelper +end diff --git a/tracks/db/migrate/5_add_project_description.rb b/tracks/db/migrate/5_add_project_description.rb new file mode 100644 index 00000000..1591883f --- /dev/null +++ b/tracks/db/migrate/5_add_project_description.rb @@ -0,0 +1,9 @@ +class AddProjectDescription < ActiveRecord::Migration + def self.up + add_column :projects, :description, :text, :default => '' + end + + def self.down + remove_column :projects, :description + end +end diff --git a/tracks/db/production_structure.sql b/tracks/db/production_structure.sql new file mode 100644 index 00000000..80e8029a --- /dev/null +++ b/tracks/db/production_structure.sql @@ -0,0 +1,56 @@ +CREATE TABLE `contexts` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(255) NOT NULL default '', + `position` int(11) NOT NULL default '0', + `hide` tinyint(1) default '0', + `user_id` int(11) NOT NULL default '0', + PRIMARY KEY (`id`) +) TYPE=InnoDB; + +CREATE TABLE `notes` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL default '0', + `project_id` int(11) NOT NULL default '0', + `body` text, + `created_at` datetime default '0000-00-00 00:00:00', + `updated_at` datetime default '0000-00-00 00:00:00', + PRIMARY KEY (`id`) +) TYPE=InnoDB; + +CREATE TABLE `projects` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(255) NOT NULL default '', + `position` int(11) NOT NULL default '0', + `done` tinyint(1) default '0', + `user_id` int(11) NOT NULL default '0', + `description` text, + PRIMARY KEY (`id`) +) TYPE=InnoDB; + +CREATE TABLE `schema_info` ( + `version` int(11) default NULL +) TYPE=MyISAM; + +CREATE TABLE `todos` ( + `id` int(11) NOT NULL auto_increment, + `context_id` int(11) NOT NULL default '0', + `project_id` int(11) default NULL, + `description` varchar(255) NOT NULL default '', + `notes` text, + `done` tinyint(1) NOT NULL default '0', + `created_at` datetime default NULL, + `due` date default NULL, + `completed` datetime default NULL, + `user_id` int(11) NOT NULL default '0', + PRIMARY KEY (`id`) +) TYPE=InnoDB; + +CREATE TABLE `users` ( + `id` int(11) NOT NULL auto_increment, + `login` varchar(80) NOT NULL default '', + `password` varchar(40) NOT NULL default '', + `word` varchar(255) default NULL, + `is_admin` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`) +) TYPE=InnoDB; + diff --git a/tracks/doc/CHANGELOG b/tracks/doc/CHANGELOG index e5d159f0..b6a074d6 100644 --- a/tracks/doc/CHANGELOG +++ b/tracks/doc/CHANGELOG @@ -25,6 +25,9 @@ Wiki (deprecated - please use Trac): http://www.rousette.org.uk/projects/wiki/ 8. Modify signup to prevent is_admin being set by malicious user. Begin work on standardising layout for login controller. 9. BIGGEST NEW FEATURE: Tracks is now properly multi-user, thanks to the work of Nicholas Lee. Any new users that you sign up can't view any of your next actions, contexts, projects or notes, and they get a clean slate to add their own. Great Things are planned in this direction... 10. Projects now have a description field which you can edit in the form on [tracks_url]/projects. It's optional, but you can use it to remind you of the aims or purpose of the project. If you have a description, it's displayed in italics just under the project name. +11. Included a new rake task. Call it with rake setup_tracks at the command line. This automates a lot of the work of setting up tracks, like renaming the template files (*.tmpl). However, you need to make sure that you've copied database.yml.tmpl to database.yml before you run it (and added the correct settings to the file), because rake can't run without that file in place. The task is safe to run if you're upgrading, because it ignores already converted files. +12. Changed the shebang lines to #!/usr/bin/env ruby. This should work for all *nix based setups (Linux or Mac OS X), but Windows users will probably have to change it. Try this command at the command line, run inside the Tracks directory: + ruby -i.bak -pe 'gsub!("#!/usr/bin/env ruby", "#!c:/ruby/bin/ruby")' public/dispatch.* script/* == Version 1.03 diff --git a/tracks/doc/README_FOR_APP b/tracks/doc/README_FOR_APP index 132e6fed..4a11861c 100644 --- a/tracks/doc/README_FOR_APP +++ b/tracks/doc/README_FOR_APP @@ -46,7 +46,8 @@ In the following, I'm assuming that you're using MySQL and the built-in WEBrick * Check over the file config/settings.yml, and make sure that the settings are to your liking. * If you'd also like some example data to play with, you can import it from tracks_1.031_content.sql (in tracks/db). You don't have to use the example data, but if you don't, you'll need to visit http://YOURURL/contexts first to add a few contexts before you add any next actions. Note that no users are provided in the content file, so you'll need to visit the signup page (http://YOURURL/signup) to create some users. -* Check that the path to Ruby is correct in the tracks/public/dispatch.* files, and also /script/server. The default (#!/usr/bin/ruby) is fine for Mac OS X Tiger, but if you've installed Ruby yourself in /usr/local/bin, you'll need to change it. +* Check the shebang lines of the public/dispatch.* files and all the files in the script directory. They are set to #!/usr/bin/env ruby by default. This should work for all *nix based setups (Linux or Mac OS X), but Windows users will probably have to change it. Try this command at the command line, run inside the Tracks directory: + ruby -i.bak -pe 'gsub!("#!/usr/bin/env ruby", "#!c:/ruby/bin/ruby")' public/dispatch.* script/* * Run the following command at your command line (Important: If you already have an application running on WEBrick (Tracks or anything else), make sure that you stop the server, or run Tracks on a different port using the --port option): cd /PATHTO/TRACKS ruby script/server -e production @@ -73,7 +74,8 @@ In the following, I'm assuming that you're using MySQL and the built-in WEBrick * If this process reports errors that you can't fix, you'll need to adapt the instructions for manually loading the schema, given below for SQLite (schemas are also provided for MySQL and Postgresql). * Import your old contents, and check that it looks sensible. In particular, check that the 'user_id' field in the todos, contexts and projects tables have the value of '1' (i.e. they are owned by your admin user, who should have an id of 1). -* Check that the path to Ruby is correct in the tracks/public/dispatch.* files, and also /script/server. The default (#!/usr/bin/ruby) is fine for Mac OS X Tiger, but if you've installed Ruby yourself in /usr/local/bin, you'll need to change it. +* Check the shebang lines of the public/dispatch.* files and all the files in the script directory. They are set to #!/usr/bin/env ruby by default. This should work for all *nix based setups (Linux or Mac OS X), but Windows users will probably have to change it. Try this command at the command line, run inside the Tracks directory: + ruby -i.bak -pe 'gsub!("#!/usr/bin/env ruby", "#!c:/ruby/bin/ruby")' public/dispatch.* script/* * From here, follow the remaining steps for new users above to start the server. Don't forget that if you've deleted your users table, you'll need to re-create your users via /signup. Signup is now at http://0.0.0.0:3000/signup, and login at http://0.0.0.0:3000/login. ==== SQLite or SQLite3 diff --git a/tracks/public/dispatch.cgi b/tracks/public/dispatch.cgi index 3848806d..ce705d36 100755 --- a/tracks/public/dispatch.cgi +++ b/tracks/public/dispatch.cgi @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) diff --git a/tracks/public/dispatch.fcgi b/tracks/public/dispatch.fcgi index 3169ba26..664dbbbe 100755 --- a/tracks/public/dispatch.fcgi +++ b/tracks/public/dispatch.fcgi @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) diff --git a/tracks/script/benchmarker b/tracks/script/benchmarker index 2e323b66..4a0ea231 100755 --- a/tracks/script/benchmarker +++ b/tracks/script/benchmarker @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby if ARGV.empty? puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..." diff --git a/tracks/script/breakpointer b/tracks/script/breakpointer index dc3e8110..6375616b 100755 --- a/tracks/script/breakpointer +++ b/tracks/script/breakpointer @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby require 'rubygems' require_gem 'rails' require 'breakpoint_client' diff --git a/tracks/script/console b/tracks/script/console index a7b2cccf..e23abda3 100755 --- a/tracks/script/console +++ b/tracks/script/console @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb' require 'optparse' diff --git a/tracks/script/destroy b/tracks/script/destroy index 624049da..46cc786e 100755 --- a/tracks/script/destroy +++ b/tracks/script/destroy @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' require 'rails_generator' require 'rails_generator/scripts/destroy' diff --git a/tracks/script/generate b/tracks/script/generate index a104fc94..26447804 100755 --- a/tracks/script/generate +++ b/tracks/script/generate @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' require 'rails_generator' require 'rails_generator/scripts/generate' diff --git a/tracks/script/profiler b/tracks/script/profiler index 92cf8247..77c9fbef 100755 --- a/tracks/script/profiler +++ b/tracks/script/profiler @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby if ARGV.empty? $stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]" exit(1) diff --git a/tracks/script/runner b/tracks/script/runner index a9f705c1..009fe79c 100755 --- a/tracks/script/runner +++ b/tracks/script/runner @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby require 'optparse' options = { :environment => "development" } diff --git a/tracks/script/server b/tracks/script/server index 51eeab46..b7e3c801 100755 --- a/tracks/script/server +++ b/tracks/script/server @@ -1,4 +1,4 @@ -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby require 'webrick' require 'optparse' diff --git a/tracks/test/functional/user_controller_test.rb b/tracks/test/functional/user_controller_test.rb new file mode 100644 index 00000000..b97a404a --- /dev/null +++ b/tracks/test/functional/user_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'user_controller' + +# Re-raise errors caught by the controller. +class UserController; def rescue_action(e) raise e end; end + +class UserControllerTest < Test::Unit::TestCase + def setup + @controller = UserController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end