tournament 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -0
- data/Manifest.txt +241 -2
- data/README.txt +152 -12
- data/Rakefile +9 -6
- data/bin/benchmark_pool +0 -0
- data/bin/gui.rb +3 -1
- data/bin/picker +0 -0
- data/bin/pool +139 -15
- data/lib/tournament/bracket.rb +33 -50
- data/lib/tournament/entry.rb +3 -0
- data/lib/tournament/pool.rb +144 -93
- data/lib/tournament/scoring_strategy.rb +69 -0
- data/lib/tournament/webgui_installer.rb +109 -0
- data/tasks/ann.rake +19 -14
- data/tasks/bones.rake +6 -25
- data/tasks/gem.rake +46 -36
- data/tasks/git.rake +41 -0
- data/tasks/jamis.rb +589 -0
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +18 -11
- data/tasks/{doc.rake → rdoc.rake} +12 -9
- data/tasks/rubyforge.rake +12 -12
- data/tasks/setup.rb +121 -80
- data/tasks/spec.rake +12 -13
- data/tasks/svn.rake +15 -11
- data/tasks/test.rake +6 -6
- data/test/test_tournament.rb +8 -0
- data/test/test_webgui_installer.rb +64 -0
- data/webgui/README +256 -0
- data/webgui/Rakefile +10 -0
- data/webgui/app/controllers/admin_controller.rb +61 -0
- data/webgui/app/controllers/application.rb +25 -0
- data/webgui/app/controllers/entry_controller.rb +97 -0
- data/webgui/app/controllers/pool_controller.rb +4 -0
- data/webgui/app/controllers/reports_controller.rb +7 -0
- data/webgui/app/controllers/sessions_controller.rb +43 -0
- data/webgui/app/controllers/teams_controller.rb +75 -0
- data/webgui/app/controllers/users_controller.rb +57 -0
- data/webgui/app/helpers/admin_helper.rb +2 -0
- data/webgui/app/helpers/application_helper.rb +3 -0
- data/webgui/app/helpers/entry_helper.rb +2 -0
- data/webgui/app/helpers/pool_helper.rb +2 -0
- data/webgui/app/helpers/reports_helper.rb +2 -0
- data/webgui/app/helpers/sessions_helper.rb +2 -0
- data/webgui/app/helpers/teams_helper.rb +2 -0
- data/webgui/app/helpers/users_helper.rb +93 -0
- data/webgui/app/models/entry.rb +42 -0
- data/webgui/app/models/pool.rb +141 -0
- data/webgui/app/models/region.rb +3 -0
- data/webgui/app/models/role.rb +4 -0
- data/webgui/app/models/seeding.rb +4 -0
- data/webgui/app/models/team.rb +6 -0
- data/webgui/app/models/user.rb +98 -0
- data/webgui/app/models/user_mailer.rb +25 -0
- data/webgui/app/views/admin/bracket.html.erb +3 -0
- data/webgui/app/views/admin/entries.html.erb +25 -0
- data/webgui/app/views/admin/index.html.erb +17 -0
- data/webgui/app/views/admin/pool.html.erb +53 -0
- data/webgui/app/views/entry/index.html.erb +16 -0
- data/webgui/app/views/entry/print.erb +1 -0
- data/webgui/app/views/entry/print.html.erb +1 -0
- data/webgui/app/views/entry/show.html.erb +1 -0
- data/webgui/app/views/layouts/bracket.html.erb +37 -0
- data/webgui/app/views/layouts/default.html.erb +62 -0
- data/webgui/app/views/layouts/print.html.erb +12 -0
- data/webgui/app/views/layouts/report.html.erb +38 -0
- data/webgui/app/views/pool/index.html.erb +36 -0
- data/webgui/app/views/reports/_report.html.erb +11 -0
- data/webgui/app/views/reports/show.html.erb +12 -0
- data/webgui/app/views/sessions/new.html.erb +21 -0
- data/webgui/app/views/shared/_admins.html.erb +8 -0
- data/webgui/app/views/shared/_bracket.html.erb +1296 -0
- data/webgui/app/views/teams/choose.html.erb +57 -0
- data/webgui/app/views/user_mailer/activation.erb +3 -0
- data/webgui/app/views/user_mailer/signup_notification.erb +8 -0
- data/webgui/app/views/users/_user_bar.html.erb +8 -0
- data/webgui/app/views/users/new.html.erb +19 -0
- data/webgui/config/boot.rb +109 -0
- data/webgui/config/database.yml +22 -0
- data/webgui/config/environment.rb +78 -0
- data/webgui/config/environments/development.rb +29 -0
- data/webgui/config/environments/production.rb +24 -0
- data/webgui/config/environments/test.rb +22 -0
- data/webgui/config/initializers/inflections.rb +10 -0
- data/webgui/config/initializers/mime_types.rb +5 -0
- data/webgui/config/initializers/new_rails_defaults.rb +17 -0
- data/webgui/config/initializers/pool.rb +33 -0
- data/webgui/config/initializers/site_keys.rb +38 -0
- data/webgui/config/locales/en.yml +5 -0
- data/webgui/config/routes.rb +56 -0
- data/webgui/db/development.sqlite3 +0 -0
- data/webgui/db/migrate/20090216015836_create_entries.rb +13 -0
- data/webgui/db/migrate/20090217001611_add_tie_break_to_entry.rb +9 -0
- data/webgui/db/migrate/20090217004039_create_users.rb +23 -0
- data/webgui/db/migrate/20090217014940_relate_entry_and_user.rb +10 -0
- data/webgui/db/migrate/20090218024350_create_roles.rb +17 -0
- data/webgui/db/migrate/20090218024657_add_postition_to_roles.rb +9 -0
- data/webgui/db/migrate/20090218025240_add_admin_role.rb +10 -0
- data/webgui/db/migrate/20090225022928_create_pools.rb +16 -0
- data/webgui/db/migrate/20090225030346_associate_pool_and_entry.rb +9 -0
- data/webgui/db/migrate/20090225072358_change_pool_data_column.rb +9 -0
- data/webgui/db/migrate/20090225072849_add_completed_to_entries.rb +9 -0
- data/webgui/db/migrate/20090225074149_add_pool_id_index_to_entries.rb +9 -0
- data/webgui/db/migrate/20090225084414_add_user_id_to_pool.rb +9 -0
- data/webgui/db/migrate/20090226021913_add_active_to_pools.rb +9 -0
- data/webgui/db/migrate/20090226142240_rename_bracket_column_to_data.rb +9 -0
- data/webgui/db/migrate/20090301014710_create_teams.rb +84 -0
- data/webgui/db/migrate/20090301025902_add_more_teams.rb +16 -0
- data/webgui/db/migrate/20090301041526_create_seedings.rb +16 -0
- data/webgui/db/migrate/20090301090511_create_regions.rb +14 -0
- data/webgui/db/migrate/teams.txt +347 -0
- data/webgui/db/pool.yml +408 -0
- data/webgui/db/schema.rb +91 -0
- data/webgui/db/test.sqlite3 +0 -0
- data/webgui/doc/README_FOR_APP +5 -0
- data/webgui/lib/authenticated_system.rb +189 -0
- data/webgui/lib/authenticated_test_helper.rb +11 -0
- data/webgui/lib/form_object.rb +70 -0
- data/webgui/lib/pdf_helper.rb +47 -0
- data/webgui/lib/prince.rb +74 -0
- data/webgui/lib/saves_picks.rb +23 -0
- data/webgui/lib/tasks/admin.rake +10 -0
- data/webgui/public/404.html +30 -0
- data/webgui/public/422.html +30 -0
- data/webgui/public/500.html +33 -0
- data/webgui/public/dispatch.cgi +10 -0
- data/webgui/public/dispatch.fcgi +24 -0
- data/webgui/public/dispatch.rb +10 -0
- data/webgui/public/favicon.ico +0 -0
- data/webgui/public/images/2009FinalFour.png +0 -0
- data/webgui/public/images/rails.png +0 -0
- data/webgui/public/javascripts/application.js +2 -0
- data/webgui/public/javascripts/bracket.js +73 -0
- data/webgui/public/javascripts/controls.js +963 -0
- data/webgui/public/javascripts/dragdrop.js +973 -0
- data/webgui/public/javascripts/effects.js +1128 -0
- data/webgui/public/javascripts/prototype.js +4320 -0
- data/webgui/public/robots.txt +5 -0
- data/webgui/public/stylesheets/bracket-print.css +39 -0
- data/webgui/public/stylesheets/bracket.css +125 -0
- data/webgui/public/stylesheets/main.css +144 -0
- data/webgui/public/stylesheets/prince.css +6 -0
- data/webgui/public/stylesheets/prince_landscape.css +1 -0
- data/webgui/script/about +4 -0
- data/webgui/script/console +3 -0
- data/webgui/script/dbconsole +3 -0
- data/webgui/script/destroy +3 -0
- data/webgui/script/generate +3 -0
- data/webgui/script/performance/benchmarker +3 -0
- data/webgui/script/performance/profiler +3 -0
- data/webgui/script/performance/request +3 -0
- data/webgui/script/plugin +3 -0
- data/webgui/script/process/inspector +3 -0
- data/webgui/script/process/reaper +3 -0
- data/webgui/script/process/spawner +3 -0
- data/webgui/script/runner +3 -0
- data/webgui/script/server +3 -0
- data/webgui/test/fixtures/entries.yml +10 -0
- data/webgui/test/fixtures/pools.yml +14 -0
- data/webgui/test/fixtures/regions.yml +11 -0
- data/webgui/test/fixtures/roles.yml +11 -0
- data/webgui/test/fixtures/roles_users.yml +3 -0
- data/webgui/test/fixtures/seedings.yml +12 -0
- data/webgui/test/fixtures/teams.yml +3051 -0
- data/webgui/test/fixtures/users.yml +44 -0
- data/webgui/test/functional/admin_controller_test.rb +8 -0
- data/webgui/test/functional/entry_controller_test.rb +27 -0
- data/webgui/test/functional/pool_controller_test.rb +8 -0
- data/webgui/test/functional/reports_controller_test.rb +8 -0
- data/webgui/test/functional/sessions_controller_test.rb +82 -0
- data/webgui/test/functional/teams_controller_test.rb +216 -0
- data/webgui/test/functional/users_controller_test.rb +88 -0
- data/webgui/test/performance/browsing_test.rb +9 -0
- data/webgui/test/test_helper.rb +38 -0
- data/webgui/test/unit/entry_test.rb +8 -0
- data/webgui/test/unit/pool_test.rb +8 -0
- data/webgui/test/unit/region_test.rb +8 -0
- data/webgui/test/unit/role_test.rb +8 -0
- data/webgui/test/unit/seeding_test.rb +8 -0
- data/webgui/test/unit/team_test.rb +10 -0
- data/webgui/test/unit/user_mailer_test.rb +31 -0
- data/webgui/test/unit/user_test.rb +109 -0
- data/webgui/vendor/plugins/auto_complete/README +23 -0
- data/webgui/vendor/plugins/auto_complete/Rakefile +22 -0
- data/webgui/vendor/plugins/auto_complete/init.rb +2 -0
- data/webgui/vendor/plugins/auto_complete/lib/auto_complete.rb +47 -0
- data/webgui/vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb +143 -0
- data/webgui/vendor/plugins/auto_complete/test/auto_complete_test.rb +67 -0
- data/webgui/vendor/plugins/enumerations_mixin/ATTENTION +15 -0
- data/webgui/vendor/plugins/enumerations_mixin/LICENSE +20 -0
- data/webgui/vendor/plugins/enumerations_mixin/README_ENUMERATIONS +163 -0
- data/webgui/vendor/plugins/enumerations_mixin/init.rb +21 -0
- data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +177 -0
- data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/aggregations/has_enumerated.rb +60 -0
- data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/virtual_enumerations.rb +68 -0
- data/webgui/vendor/plugins/enumerations_mixin/virtual_enumerations_sample.rb +76 -0
- data/webgui/vendor/plugins/restful_authentication/.gitignore +21 -0
- data/webgui/vendor/plugins/restful_authentication/CHANGELOG +68 -0
- data/webgui/vendor/plugins/restful_authentication/README.textile +224 -0
- data/webgui/vendor/plugins/restful_authentication/Rakefile +32 -0
- data/webgui/vendor/plugins/restful_authentication/TODO +15 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/USAGE +1 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/authenticated_generator.rb +478 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/lib/insert_routes.rb +54 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/_model_partial.html.erb +8 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/activation.erb +3 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_system.rb +189 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb +22 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb +43 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/helper.rb +2 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/login.html.erb +16 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/mailer.rb +25 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb +26 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb +83 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb +85 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb +93 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper_spec.rb +158 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb +11 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb +19 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.erb +8 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/site_keys.rb +38 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb +90 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb +102 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb +139 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb +198 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/fixtures/users.yml +60 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb +141 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/models/user_spec.rb +290 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories.rb +22 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb +81 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb +49 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb +179 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb +171 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/user_steps.rb +153 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/accounts.story +186 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/sessions.story +134 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/functional_test.rb +82 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/mailer_test.rb +31 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/model_functional_test.rb +93 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/unit_test.rb +164 -0
- data/webgui/vendor/plugins/restful_authentication/init.rb +1 -0
- data/webgui/vendor/plugins/restful_authentication/install.rb +1 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authentication/by_cookie_token.rb +82 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authentication/by_password.rb +64 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authentication.rb +40 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb +63 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authorization/stateful_roles.rb +62 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authorization.rb +14 -0
- data/webgui/vendor/plugins/restful_authentication/lib/trustification/email_validation.rb +20 -0
- data/webgui/vendor/plugins/restful_authentication/lib/trustification.rb +14 -0
- data/webgui/vendor/plugins/restful_authentication/notes/AccessControl.txt +2 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Authentication.txt +5 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Authorization.txt +154 -0
- data/webgui/vendor/plugins/restful_authentication/notes/RailsPlugins.txt +78 -0
- data/webgui/vendor/plugins/restful_authentication/notes/SecurityFramework.graffle +0 -0
- data/webgui/vendor/plugins/restful_authentication/notes/SecurityFramework.png +0 -0
- data/webgui/vendor/plugins/restful_authentication/notes/SecurityPatterns.txt +163 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Tradeoffs.txt +126 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Trustification.txt +49 -0
- data/webgui/vendor/plugins/restful_authentication/rails/init.rb +3 -0
- data/webgui/vendor/plugins/restful_authentication/restful-authentication.gemspec +33 -0
- data/webgui/vendor/plugins/restful_authentication/tasks/auth.rake +33 -0
- metadata +288 -8
- data/tasks/annotations.rake +0 -22
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'active_record/validations'
|
2
|
+
|
3
|
+
# This class can be used as a container of form submitted values. It
|
4
|
+
# includes an ActiveRecord errors object so that it is compatible with Rails form
|
5
|
+
# tag helpers and the highlighting of form fields that are in error. It also
|
6
|
+
# mixes in ActiveRecord::Validations so all the validates_* methods are available.
|
7
|
+
#
|
8
|
+
# Example
|
9
|
+
# ----------------------------------
|
10
|
+
# class MyObject < FormObject
|
11
|
+
# attr_accessor :field1, :field2, :field3
|
12
|
+
# validates_presence_of :field1
|
13
|
+
# validates_length_of :field2, :within => (0..5)
|
14
|
+
# validates_format_of :field3, :with => /^[0-9]+$/
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# form_data = MyObject.new
|
18
|
+
# form_data.valid? <= returns false unless field1, field2, field3 are set appropriately
|
19
|
+
#
|
20
|
+
# In controller actions, you can create an instance of your object using the params hash:
|
21
|
+
#
|
22
|
+
# @my_object = MyObject.new(params[:my_object])
|
23
|
+
#
|
24
|
+
# Instances of FormObject can be used by the form_for helper to generate
|
25
|
+
# form fields with fancy error highlighting.
|
26
|
+
class FormObject
|
27
|
+
|
28
|
+
def initialize(attrs = {})
|
29
|
+
unless attrs.nil?
|
30
|
+
attrs.each do |name, value|
|
31
|
+
self.send("#{name}=", value) if self.respond_to?("#{name}=".to_sym)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Does nothing
|
37
|
+
def save
|
38
|
+
end
|
39
|
+
|
40
|
+
# Does nothing
|
41
|
+
def save!
|
42
|
+
end
|
43
|
+
|
44
|
+
# Always returns true
|
45
|
+
def new_record?
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
# Updates an attribute
|
50
|
+
def update_attribute(name, value)
|
51
|
+
self.send("#{name}=", value) if self.respond_to?("#{name}=".to_sym)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Needed to display field specific error messages. Override in subclass
|
55
|
+
# if you don't want the attribute name capitalized when displaying
|
56
|
+
# a field error message.
|
57
|
+
def self.human_attribute_name(attr_name)
|
58
|
+
return attr_name.capitalize
|
59
|
+
end
|
60
|
+
|
61
|
+
# Add validation methods
|
62
|
+
include ActiveRecord::Validations
|
63
|
+
|
64
|
+
# Dynamically loads the class with the given name or fully qualified path.
|
65
|
+
# Example class_get("Foo") or class_get("Bar::Baz::Bip")
|
66
|
+
def self.class_get(class_name_or_path)
|
67
|
+
klass = class_name_or_path.split(/::/).inject(Object) { |k, n| k.const_get(n) }
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Uses Prince library to create pdfs
|
2
|
+
module PdfHelper
|
3
|
+
require 'prince'
|
4
|
+
|
5
|
+
def self.prince_available?
|
6
|
+
p = Prince.new()
|
7
|
+
p.exe_path !~ /no prince/
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
# Makes a pdf, returns it as data...
|
12
|
+
def make_pdf(template_path, pdf_name, landscape=false)
|
13
|
+
prince = Prince.new()
|
14
|
+
# Sets style sheets on PDF renderer.
|
15
|
+
prince.add_style_sheets(
|
16
|
+
"#{RAILS_ROOT}/public/stylesheets/main.css",
|
17
|
+
"#{RAILS_ROOT}/public/stylesheets/bracket.css",
|
18
|
+
"#{RAILS_ROOT}/public/stylesheets/bracket-print.css",
|
19
|
+
"#{RAILS_ROOT}/public/stylesheets/prince.css"
|
20
|
+
)
|
21
|
+
prince.add_style_sheets("#{RAILS_ROOT}/public/stylesheets/prince_landscape.css") if landscape
|
22
|
+
# Render the estimate to a big html string.
|
23
|
+
# Set RAILS_ASSET_ID to blank string or rails appends some time after
|
24
|
+
# to prevent file caching, fucking up local - disk requests.
|
25
|
+
old_rails_asset_id = ENV["RAILS_ASSET_ID"]
|
26
|
+
begin
|
27
|
+
ENV["RAILS_ASSET_ID"] = ''
|
28
|
+
html_string = render_to_string(:template => template_path, :layout => 'print.html')
|
29
|
+
# Make all paths relative, on disk paths...
|
30
|
+
html_string.gsub!("src=\"", "src=\"#{RAILS_ROOT}/public")
|
31
|
+
# Send the generated PDF file from our html string.
|
32
|
+
return prince.pdf_from_string(html_string)
|
33
|
+
ensure
|
34
|
+
ENV["RAILS_ASSET_ID"] = old_rails_asset_id
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Makes and sends a pdf to the browser
|
39
|
+
#
|
40
|
+
def make_and_send_pdf(template_path, pdf_name, landscape=false)
|
41
|
+
send_data(
|
42
|
+
make_pdf(template_path, pdf_name, landscape),
|
43
|
+
:filename => pdf_name,
|
44
|
+
:type => 'application/pdf'
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Prince XML Ruby interface.
|
2
|
+
# http://www.princexml.com
|
3
|
+
#
|
4
|
+
# Library by Subimage Interactive - http://www.subimage.com
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# USAGE
|
8
|
+
# -----------------------------------------------------------------------------
|
9
|
+
# prince = Prince.new()
|
10
|
+
# html_string = render_to_string(:template => 'some_document')
|
11
|
+
# send_data(
|
12
|
+
# prince.pdf_from_string(html_string),
|
13
|
+
# :filename => 'some_document.pdf'
|
14
|
+
# :type => 'application/pdf'
|
15
|
+
# )
|
16
|
+
#
|
17
|
+
|
18
|
+
class Prince
|
19
|
+
|
20
|
+
attr_accessor :exe_path, :style_sheets, :log_file
|
21
|
+
|
22
|
+
# Initialize method
|
23
|
+
#
|
24
|
+
def initialize()
|
25
|
+
# Finds where the application lives, so we can call it.
|
26
|
+
@exe_path = defined?(PRINCE_PATH) ? PRINCE_PATH : `which prince`.chomp
|
27
|
+
@style_sheets = ''
|
28
|
+
@log_file = "#{RAILS_ROOT}/log/prince.log"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Sets stylesheets...
|
32
|
+
# Can pass in multiple paths for css files.
|
33
|
+
#
|
34
|
+
def add_style_sheets(*sheets)
|
35
|
+
for sheet in sheets do
|
36
|
+
@style_sheets << " -s #{sheet} "
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns fully formed executable path with any command line switches
|
41
|
+
# we've set based on our variables.
|
42
|
+
#
|
43
|
+
def exe_path
|
44
|
+
# Add any standard cmd line arguments we need to pass
|
45
|
+
@exe_path << " --input=html --server --log=#{@log_file} "
|
46
|
+
@exe_path << @style_sheets
|
47
|
+
return @exe_path
|
48
|
+
end
|
49
|
+
|
50
|
+
# Makes a pdf from a passed in string.
|
51
|
+
#
|
52
|
+
# Returns PDF as a stream, so we can use send_data to shoot
|
53
|
+
# it down the pipe using Rails.
|
54
|
+
#
|
55
|
+
def pdf_from_string(string)
|
56
|
+
path = self.exe_path()
|
57
|
+
# Don't spew errors to the standard out...and set up to take IO
|
58
|
+
# as input and output
|
59
|
+
path << ' --silent - -o -'
|
60
|
+
|
61
|
+
# Show the command used...
|
62
|
+
#logger.info "\n\nPRINCE XML PDF COMMAND"
|
63
|
+
#logger.info path
|
64
|
+
#logger.info ''
|
65
|
+
|
66
|
+
# Actually call the prince command, and pass the entire data stream back.
|
67
|
+
pdf = IO.popen(path, "w+")
|
68
|
+
pdf.puts(string)
|
69
|
+
pdf.close_write
|
70
|
+
output = pdf.gets(nil)
|
71
|
+
pdf.close_read
|
72
|
+
return output
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SavesPicks
|
2
|
+
def save_picks(entry)
|
3
|
+
bracket = entry.bracket
|
4
|
+
picks = params[:picks]
|
5
|
+
logger.debug("PICKS: #{picks}")
|
6
|
+
picks.split(//).each_with_index do |pick, idx|
|
7
|
+
round, game = bracket.round_and_game(idx+1)
|
8
|
+
logger.debug("Round #{round} game #{game} pick #{pick} idx #{idx}")
|
9
|
+
if pick != '0'
|
10
|
+
pick = pick.to_i - 1
|
11
|
+
team = bracket.matchup(round, game)[pick]
|
12
|
+
logger.debug(" --> Team = #{team.name}")
|
13
|
+
bracket.set_winner(round, game, team)
|
14
|
+
else
|
15
|
+
bracket.set_winner(round, game, Tournament::Bracket::UNKNOWN_TEAM)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
logger.debug("SAVING ENTRY PARAMS: #{params[:entry].inspect}")
|
19
|
+
entry.attributes = params[:entry]
|
20
|
+
logger.debug("DONE SAVING ENTRY PARAMS")
|
21
|
+
entry.completed = true if bracket.complete?
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :admin do
|
2
|
+
desc 'Create admin user.'
|
3
|
+
task :create, [:login, :email, :name, :password] => [:environment] do |t, args|
|
4
|
+
user_attributes = [:login, :email, :name, :password].inject({}) do |hash, var|
|
5
|
+
raise "Got blank task parameter #{var.inspect}" unless args.send(var)
|
6
|
+
hash.merge!(var => args.send(var))
|
7
|
+
end
|
8
|
+
User.create_admin_user(user_attributes)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/404.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
27
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>The change you wanted was rejected (422)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/422.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>The change you wanted was rejected.</h1>
|
27
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>We're sorry, but something went wrong (500)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/500.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>We're sorry, but something went wrong.</h1>
|
27
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
28
|
+
<p><small>(If you're the administrator of this website, then please read
|
29
|
+
the log file "<%=h RAILS_ENV %>.log"
|
30
|
+
to find out what went wrong.)</small></p>
|
31
|
+
</div>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/ruby1.8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
4
|
+
|
5
|
+
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
|
6
|
+
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
|
7
|
+
require "dispatcher"
|
8
|
+
|
9
|
+
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
10
|
+
Dispatcher.dispatch
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/ruby1.8
|
2
|
+
#
|
3
|
+
# You may specify the path to the FastCGI crash log (a log of unhandled
|
4
|
+
# exceptions which forced the FastCGI instance to exit, great for debugging)
|
5
|
+
# and the number of requests to process before running garbage collection.
|
6
|
+
#
|
7
|
+
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
|
8
|
+
# and the GC period is nil (turned off). A reasonable number of requests
|
9
|
+
# could range from 10-100 depending on the memory footprint of your app.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
# # Default log path, normal GC behavior.
|
13
|
+
# RailsFCGIHandler.process!
|
14
|
+
#
|
15
|
+
# # Default log path, 50 requests between GC.
|
16
|
+
# RailsFCGIHandler.process! nil, 50
|
17
|
+
#
|
18
|
+
# # Custom log path, normal GC behavior.
|
19
|
+
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
|
20
|
+
#
|
21
|
+
require File.dirname(__FILE__) + "/../config/environment"
|
22
|
+
require 'fcgi_handler'
|
23
|
+
|
24
|
+
RailsFCGIHandler.process!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/ruby1.8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
4
|
+
|
5
|
+
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
|
6
|
+
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
|
7
|
+
require "dispatcher"
|
8
|
+
|
9
|
+
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
10
|
+
Dispatcher.dispatch
|
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1,73 @@
|
|
1
|
+
var made_changes = false;
|
2
|
+
function submitPicks(form) {
|
3
|
+
var picks = '';
|
4
|
+
for(var i = 65; i < 128; ++i) {
|
5
|
+
var elem = $('' + i)
|
6
|
+
var idx = i - 65;
|
7
|
+
if ((team = elem.readAttribute('team')) != '') {
|
8
|
+
var t2 = $('' + (idx * 2 + 2)).readAttribute('team');
|
9
|
+
if (t2 == team) {
|
10
|
+
picks += '2';
|
11
|
+
} else {
|
12
|
+
picks += '1';
|
13
|
+
}
|
14
|
+
} else {
|
15
|
+
picks += '0';
|
16
|
+
}
|
17
|
+
}
|
18
|
+
$('picks').value = '' + picks;
|
19
|
+
return true
|
20
|
+
}
|
21
|
+
function pick(elem) {
|
22
|
+
made_changes = true;
|
23
|
+
elem = $(elem)
|
24
|
+
var idx = parseInt(elem.id)
|
25
|
+
var team = elem.readAttribute('team');
|
26
|
+
if (team == '') {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
var other_team = $('' + other_idx(idx)).readAttribute('team')
|
30
|
+
//alert ("idx = " + idx + " next idx = " + next_idx(idx) + " team = " + team);
|
31
|
+
|
32
|
+
var next_elem = $('' + next_idx(idx));
|
33
|
+
//alert ("next_elem = " + next_elem)
|
34
|
+
if (next_elem) {
|
35
|
+
set_team(next_elem, team);
|
36
|
+
if (other_team != '') {
|
37
|
+
// walk the tree of next games looking for winner
|
38
|
+
// that is not the selected winner and set to null
|
39
|
+
while (next_elem = $('' + next_idx(next_elem.id))) {
|
40
|
+
next_team = next_elem.readAttribute('team');
|
41
|
+
//alert ("next_elem = " + next_elem.id + " next team = " + next_team)
|
42
|
+
if (next_team != '' && next_team == other_team) {
|
43
|
+
next_elem.setAttribute('team', '');
|
44
|
+
next_elem.innerHTML = ' ';
|
45
|
+
next_elem.onmouseover = null;
|
46
|
+
next_elem.onmouseout = null;
|
47
|
+
} else {
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
function set_team(elem, team) {
|
55
|
+
elem.setAttribute('team', team);
|
56
|
+
elem.innerHTML = team;
|
57
|
+
elem.onmouseover = function () {
|
58
|
+
this.style.backgroundColor='black';
|
59
|
+
this.style.color = 'white';
|
60
|
+
}
|
61
|
+
elem.onmouseout = function () {
|
62
|
+
this.style.backgroundColor='';
|
63
|
+
this.style.color = '';
|
64
|
+
}
|
65
|
+
elem.addClassName('pendingpick');
|
66
|
+
elem.removeClassName('missedpick');
|
67
|
+
}
|
68
|
+
function other_idx(idx) {
|
69
|
+
return idx % 2 == 0 ? idx - 1 : idx + 1
|
70
|
+
}
|
71
|
+
function next_idx(idx) {
|
72
|
+
return Math.floor((idx-1)/2) + 65;
|
73
|
+
}
|