Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merging rails3 branch

  • Loading branch information...
commit e7695fad12bc60c3462418633e04fc4bcc58c4fb 2 parents 6ebd26f + 25b30f0
@ryanb authored
Showing with 8,352 additions and 12,504 deletions.
  1. +2 −2 .gitignore
  2. +1 −0  .rspec
  3. +1 −0  .rvmrc
  4. +24 −0 Gemfile
  5. +132 −0 Gemfile.lock
  6. +2 −5 Rakefile
  7. +1 −8 app/controllers/application_controller.rb
  8. +1 −1  app/controllers/stamps_controller.rb
  9. +0 −1  app/helpers/application_helper.rb
  10. +23 −0 app/helpers/error_messages_helper.rb
  11. +4 −4 app/helpers/layout_helper.rb
  12. +2 −2 app/models/stamp.rb
  13. +1 −1  app/models/stamp_image.rb
  14. +3 −2 app/views/layouts/application.html.erb
  15. +1 −1  app/views/stamp_images/_form.html.erb
  16. +2 −2 app/views/stamps/_calendar.html.erb
  17. +1 −1  app/views/stamps/edit.html.erb
  18. +1 −1  app/views/stamps/edit_goal.html.erb
  19. +1 −1  app/views/stamps/index.html.erb
  20. +1 −1  app/views/user_sessions/new.html.erb
  21. +1 −1  app/views/users/_form.html.erb
  22. +2 −0  autotest/discover.rb
  23. +4 −0 config.ru
  24. +0 −1  config/app_config.example.yml
  25. +43 −0 config/application.rb
  26. +13 −110 config/boot.rb
  27. +28 −11 config/database.example.yml
  28. +7 −14 config/deploy.rb
  29. +4 −45 config/environment.rb
  30. +22 −13 config/environments/development.rb
  31. +41 −20 config/environments/production.rb
  32. +35 −32 config/environments/test.rb
  33. +28 −0 config/initializers/authlogic_fixes.rb
  34. +2 −2 config/initializers/backtrace_silencers.rb
  35. +0 −5 config/initializers/hoptoad.rb
  36. +6 −5 config/initializers/inflections.rb
  37. +1 −0  config/initializers/openid_store.rb
  38. +7 −0 config/initializers/secret_token.rb
  39. +3 −10 config/initializers/session_store.rb
  40. +1 −1  config/locales/en.yml
  41. +1 −1  config/preinitializer.rb
  42. +16 −13 config/routes.rb
  43. +7 −6 db/schema.rb
  44. +7 −0 db/seeds.rb
  45. +0 −2  doc/README_FOR_APP
  46. +1 −2  lib/authentication.rb
  47. 0  lib/tasks/.gitkeep
  48. +0 −182 lib/tasks/rspec.rake
  49. +0 −963 public/javascripts/controls.js
  50. +0 −973 public/javascripts/dragdrop.js
  51. +0 −1,128 public/javascripts/effects.js
  52. +7,179 −0 public/javascripts/jquery.js
  53. +167 −0 public/javascripts/jquery.min.js
  54. +0 −4,320 public/javascripts/prototype.js
  55. +163 −0 public/javascripts/rails.js
  56. 0  public/stylesheets/.gitkeep
  57. +0 −4 script/about
  58. +0 −6 script/autospec
  59. +0 −3  script/console
  60. +0 −3  script/dbconsole
  61. +0 −7 script/delayed_job
  62. +0 −3  script/destroy
  63. +0 −3  script/generate
  64. +0 −3  script/performance/benchmarker
  65. +0 −3  script/performance/profiler
  66. +0 −3  script/plugin
  67. +6 −0 script/rails
  68. +0 −3  script/runner
  69. +0 −3  script/server
  70. +0 −10 script/spec
  71. +0 −9 script/spec_server
  72. +2 −2 spec/controllers/favorites_controller_spec.rb
  73. +2 −2 spec/controllers/marks_controller_spec.rb
  74. +1 −1  spec/controllers/stamp_images_controller_spec.rb
  75. +3 −3 spec/controllers/stamps_controller_spec.rb
  76. +1 −1  spec/controllers/user_sessions_controller_spec.rb
  77. +2 −2 spec/controllers/users_controller_spec.rb
  78. +1 −1  spec/models/mark_spec.rb
  79. +2 −2 spec/models/user_spec.rb
  80. +21 −44 spec/spec_helper.rb
  81. +0 −9 test/performance/browsing_test.rb
  82. +0 −38 test/test_helper.rb
  83. 0  vendor/plugins/.gitkeep
  84. +0 −20 vendor/plugins/delayed_job/MIT-LICENSE
  85. +0 −107 vendor/plugins/delayed_job/README.textile
  86. +0 −22 vendor/plugins/delayed_job/Rakefile
  87. +0 −1  vendor/plugins/delayed_job/VERSION
  88. +0 −61 vendor/plugins/delayed_job/delayed_job.gemspec
  89. +0 −11 vendor/plugins/delayed_job/generators/delayed_job/delayed_job_generator.rb
  90. +0 −20 vendor/plugins/delayed_job/generators/delayed_job/templates/migration.rb
  91. +0 −7 vendor/plugins/delayed_job/generators/delayed_job/templates/script
  92. +0 −1  vendor/plugins/delayed_job/init.rb
  93. +0 −65 vendor/plugins/delayed_job/lib/delayed/command.rb
  94. +0 −271 vendor/plugins/delayed_job/lib/delayed/job.rb
  95. +0 −17 vendor/plugins/delayed_job/lib/delayed/message_sending.rb
  96. +0 −55 vendor/plugins/delayed_job/lib/delayed/performable_method.rb
  97. +0 −54 vendor/plugins/delayed_job/lib/delayed/worker.rb
  98. +0 −13 vendor/plugins/delayed_job/lib/delayed_job.rb
  99. +0 −26 vendor/plugins/delayed_job/recipes/delayed_job.rb
  100. +0 −42 vendor/plugins/delayed_job/spec/database.rb
  101. +0 −128 vendor/plugins/delayed_job/spec/delayed_method_spec.rb
  102. +0 −389 vendor/plugins/delayed_job/spec/job_spec.rb
  103. +0 −17 vendor/plugins/delayed_job/spec/story_spec.rb
  104. +0 −1  vendor/plugins/delayed_job/tasks/jobs.rake
  105. +0 −15 vendor/plugins/delayed_job/tasks/tasks.rb
  106. +0 −55 vendor/plugins/hoptoad_notifier/INSTALL
  107. +0 −22 vendor/plugins/hoptoad_notifier/MIT-LICENSE
  108. +0 −232 vendor/plugins/hoptoad_notifier/README
  109. +0 −30 vendor/plugins/hoptoad_notifier/Rakefile
  110. +0 −8 vendor/plugins/hoptoad_notifier/TESTING
  111. +0 −28 vendor/plugins/hoptoad_notifier/ginger_scenarios.rb
  112. +0 −1  vendor/plugins/hoptoad_notifier/install.rb
  113. +0 −418 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb
  114. +0 −26 vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb
  115. +0 −22 vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb
  116. +0 −28 vendor/plugins/hoptoad_notifier/script/integration_test.rb
  117. +0 −66 vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake
  118. +0 −148 vendor/plugins/hoptoad_notifier/test/configuration_test.rb
  119. +0 −393 vendor/plugins/hoptoad_notifier/test/controller_test.rb
  120. +0 −113 vendor/plugins/hoptoad_notifier/test/helper.rb
  121. +0 −131 vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb
  122. +0 −114 vendor/plugins/hoptoad_notifier/test/logger_test.rb
  123. +0 −191 vendor/plugins/hoptoad_notifier/test/notifier_test.rb
  124. +0 −1  vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore
  125. +0 −20 vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE
  126. +0 −50 vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile
  127. +0 −57 vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile
  128. +0 −42 vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger
  129. +0 −33 vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec
  130. +0 −21 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb
  131. +0 −20 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb
  132. +0 −56 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb
  133. +0 −24 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb
  134. +0 −7 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb
  135. +0 −7 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb
  136. +0 −50 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb
  137. +0 −14 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb
  138. +0 −7 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb
  139. +2 −0  vendor/plugins/open_id_authentication/CHANGELOG
  140. +9 −17 vendor/plugins/open_id_authentication/README
  141. +0 −22 vendor/plugins/open_id_authentication/Rakefile
  142. +0 −11 .../open_id_authentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
  143. +0 −20 vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb
  144. +0 −26 vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb
  145. +0 −11 ...ication/generators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb
  146. +7 −13 vendor/plugins/open_id_authentication/init.rb
  147. +53 −165 vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
  148. +0 −9 vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb
  149. +0 −55 vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb
  150. +0 −5 vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb
  151. +0 −23 vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb
  152. +0 −20 vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb
  153. +0 −30 vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake
  154. +0 −32 vendor/plugins/open_id_authentication/test/normalize_test.rb
  155. +0 −46 vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb
  156. +0 −14 vendor/plugins/open_id_authentication/test/status_test.rb
  157. +0 −17 vendor/plugins/open_id_authentication/test/test_helper.rb
  158. +7 −4 vendor/plugins/table_builder/README.rdoc
  159. +17 −0 vendor/plugins/table_builder/Rakefile
  160. +1 −0  vendor/plugins/table_builder/VERSION
  161. +0 −3  vendor/plugins/table_builder/init.rb
  162. +0 −1  vendor/plugins/table_builder/install.rb
  163. +4 −1 vendor/plugins/table_builder/lib/table_builder.rb
  164. +51 −39 vendor/plugins/table_builder/lib/table_builder/calendar_helper.rb
  165. +9 −8 vendor/plugins/table_builder/lib/table_builder/table_builder.rb
  166. 0  vendor/plugins/table_builder/{ → lib}/tasks/table_builder_tasks.rake
  167. +56 −0 vendor/plugins/table_builder/table_builder.gemspec
  168. +64 −36 vendor/plugins/table_builder/test/calendar_helper_test.rb
  169. +32 −34 vendor/plugins/table_builder/test/table_builder_test.rb
  170. +6 −2 vendor/plugins/table_builder/test/test_helper.rb
  171. +0 −1  vendor/plugins/table_builder/uninstall.rb
View
4 .gitignore
@@ -1,7 +1,7 @@
+.bundle
+db/*.sqlite3
log/*.log
tmp/**/*
-*.sqlite3
database.yml
-app_config.yml
public/assets
config/session_secret.txt
View
1  .rspec
@@ -0,0 +1 @@
+--colour
View
1  .rvmrc
@@ -0,0 +1 @@
+rvm use 1.9.2-p0
View
24 Gemfile
@@ -0,0 +1,24 @@
+source 'http://rubygems.org'
+
+gem "rails", "3.0.3"
+gem "mysql2"
+gem "authlogic"
+gem "authlogic-oid", :require => "authlogic_openid"
+gem "ruby-openid", :require => "openid"
+gem "rack-openid", :require => "rack/openid"
+gem "paperclip"
+gem "rmagick", :require => "RMagick"
+gem "jquery-rails"
+gem "whenever", :require => false
+
+group :development, :test do
+ gem "mocha"
+ gem "rspec-rails"
+ gem "factory_girl_rails"
+ gem "autotest"
+ gem "autotest-rails"
+end
+
+group :development do
+ gem "nifty-generators"
+end
View
132 Gemfile.lock
@@ -0,0 +1,132 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ ZenTest (4.4.1)
+ aaronh-chronic (0.3.9)
+ abstract (1.0.0)
+ actionmailer (3.0.3)
+ actionpack (= 3.0.3)
+ mail (~> 2.2.9)
+ actionpack (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.13)
+ rack-test (~> 0.5.6)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ activesupport (3.0.3)
+ arel (2.0.6)
+ authlogic (2.1.6)
+ activesupport
+ authlogic-oid (1.0.4)
+ authlogic
+ autotest (4.4.6)
+ ZenTest (>= 4.4.1)
+ autotest-rails (4.1.0)
+ ZenTest
+ builder (2.1.2)
+ diff-lcs (1.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ factory_girl (1.3.2)
+ factory_girl_rails (1.0)
+ factory_girl (~> 1.3)
+ rails (>= 3.0.0.beta4)
+ i18n (0.5.0)
+ jquery-rails (0.2.6)
+ rails (~> 3.0)
+ thor (~> 0.14.4)
+ mail (2.2.12)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mocha (0.9.10)
+ rake
+ mysql2 (0.2.6)
+ nifty-generators (0.4.2)
+ paperclip (2.3.6)
+ activerecord
+ activesupport
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-openid (1.2.0)
+ rack (>= 1.1.0)
+ ruby-openid (>= 2.1.8)
+ rack-test (0.5.6)
+ rack (>= 1.0)
+ rails (3.0.3)
+ actionmailer (= 3.0.3)
+ actionpack (= 3.0.3)
+ activerecord (= 3.0.3)
+ activeresource (= 3.0.3)
+ activesupport (= 3.0.3)
+ bundler (~> 1.0)
+ railties (= 3.0.3)
+ railties (3.0.3)
+ actionpack (= 3.0.3)
+ activesupport (= 3.0.3)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ rmagick (2.13.1)
+ rspec (2.2.0)
+ rspec-core (~> 2.2)
+ rspec-expectations (~> 2.2)
+ rspec-mocks (~> 2.2)
+ rspec-core (2.2.1)
+ rspec-expectations (2.2.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.2.0)
+ rspec-rails (2.2.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.2.0)
+ ruby-openid (2.1.8)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+ whenever (0.6.2)
+ aaronh-chronic (>= 0.3.9)
+ activesupport (>= 2.3.4)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ authlogic
+ authlogic-oid
+ autotest
+ autotest-rails
+ factory_girl_rails
+ jquery-rails
+ mocha
+ mysql2
+ nifty-generators
+ paperclip
+ rack-openid
+ rails (= 3.0.3)
+ rmagick
+ rspec-rails
+ ruby-openid
+ whenever
View
7 Rakefile
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
-
+require File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'tasks/rails'
+Dailystamp::Application.load_tasks
View
9 app/controllers/application_controller.rb
@@ -1,13 +1,6 @@
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
class ApplicationController < ActionController::Base
include Authentication
- helper :all # include all helpers, all the time
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
-
- # Scrub sensitive parameters from your log
- filter_parameter_logging :password
+ protect_from_forgery
before_filter :set_user_time_zone
View
2  app/controllers/stamps_controller.rb
@@ -11,7 +11,7 @@ def index
def show
@stamp = Stamp.find(params[:id])
- @date = params[:month] ? Date.parse(params[:month]) : Time.zone.today
+ @date = params[:month] ? Date.new(*params[:month].split("-").map(&:to_i)) : Time.zone.today
raise "Date is too far in the future" if @date.to_time > 5.years.from_now
if current_user && @stamp.user_id == current_user.id
current_user.current_stamp_id = @stamp.id
View
1  app/helpers/application_helper.rb
@@ -1,4 +1,3 @@
-# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def mark_image(mark, size = 70)
options = {:size => "#{size}x#{size}", :class => "mark"}
View
23 app/helpers/error_messages_helper.rb
@@ -0,0 +1,23 @@
+module ErrorMessagesHelper
+ # Render error messages for the given objects. The :message and :header_message options are allowed.
+ def error_messages_for(*objects)
+ options = objects.extract_options!
+ options[:header_message] ||= "Invalid Fields"
+ options[:message] ||= "Correct the following errors and try again."
+ messages = objects.compact.map { |o| o.errors.full_messages }.flatten
+ unless messages.empty?
+ content_tag(:div, :class => "error_messages") do
+ list_items = messages.map { |msg| content_tag(:li, msg) }
+ content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
+ end
+ end
+ end
+
+ module FormBuilderAdditions
+ def error_messages(options = {})
+ @template.error_messages_for(@object, options)
+ end
+ end
+end
+
+ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
View
8 app/helpers/layout_helper.rb
@@ -4,18 +4,18 @@
# helper :layout
module LayoutHelper
def title(page_title, show_title = true)
- @content_for_title = page_title.to_s
+ content_for(:title) { h(page_title.to_s) }
@show_title = show_title
end
-
+
def show_title?
@show_title
end
-
+
def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args) }
end
-
+
def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
View
4 app/models/stamp.rb
@@ -9,8 +9,8 @@ class Stamp < ActiveRecord::Base
attr_accessible :name, :private, :color, :stamp_image_id, :goal_score, :goal_reward
validates_presence_of :name
- named_scope :non_private, :conditions => ["private != ?", true]
- named_scope :recent, :conditions => "score_cache > 0", :order => "updated_at desc"
+ scope :non_private, where("private != ?", true)
+ scope :recent, where("score_cache > 0").order("updated_at desc")
before_create :default_goal
View
2  app/models/stamp_image.rb
@@ -18,7 +18,7 @@ def generate_graphics
def generate_graphic_for_color(color)
source = Magick::Image.read(photo.path).first
- stamp_overlay = Magick::Image.read("#{RAILS_ROOT}/public/images/stamp_image_overlay.png").first
+ stamp_overlay = Magick::Image.read("#{Rails.root}/public/images/stamp_image_overlay.png").first
source.resize_to_fill!(stamp_overlay.columns, stamp_overlay.rows)
source = source.quantize(256, Magick::GRAYColorspace).contrast(true)
source.composite!(stamp_overlay, Magick::CenterGravity, 0, 0, Magick::OverCompositeOp)
View
5 app/views/layouts/application.html.erb
@@ -2,9 +2,10 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
- <title><%= h(yield(:title) || "Untitled") %></title>
+ <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
<%= stylesheet_link_tag "application" %>
- <%= javascript_include_tag "jquery-1.3.2.min" %>
+ <%= javascript_include_tag :defaults %>
+ <%= csrf_meta_tag %>
<%= yield(:head) %>
</head>
<body>
View
2  app/views/stamp_images/_form.html.erb
@@ -1,4 +1,4 @@
-<% form_for @stamp_image, :html => { :multipart => true } do |f| %>
+<%= form_for @stamp_image, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<p><strong><%= f.label :photo, "Choose an image for your stamp:" %></strong></p>
<p><%= f.file_field :photo %></p>
View
4 app/views/stamps/_calendar.html.erb
@@ -3,9 +3,9 @@
<%=h @date.strftime("%B %Y") %>
<%= link_to ">", :month => (@date.end_of_month+1).strftime("%Y-%m") %>
</h2>
-<% calendar_for(@stamp.marks, :year => @date.year, :month => @date.month, :today => Time.zone.today) do |calendar| %>
+<%= calendar_for(@stamp.marks, :year => @date.year, :month => @date.month, :today => Time.zone.today) do |calendar| %>
<%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') %>
- <% calendar.day(:day_method => :marked_on, :id => "day_%Y%m%d") do |day, marks| %>
+ <%= calendar.day(:day_method => :marked_on, :id => "day_%Y%m%d") do |day, marks| %>
<% if day.month == @date.month %>
<% if marks.first %>
<%= mark_image(marks.first) %>
View
2  app/views/stamps/edit.html.erb
@@ -5,7 +5,7 @@
<%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
<% end %>
-<% form_for @stamp do |f| %>
+<%= form_for @stamp do |f| %>
<%= f.error_messages %>
<p><%= f.text_field :name %></p>
<p><%= f.check_box :private %> <%= f.label :private, "Keep this stamp private" %></p>
View
2  app/views/stamps/edit_goal.html.erb
@@ -1,7 +1,7 @@
<% title "Change Goal" %>
<% stylesheet "generic", "edit_goal" %>
-<% form_for @stamp do |f| %>
+<%= form_for @stamp do |f| %>
<div id="suggestions">
<h3>suggestions</h3>
<ul>
View
2  app/views/stamps/index.html.erb
@@ -26,7 +26,7 @@
<div id="main">
<h2>What do you want to do daily?</h2>
- <% form_for @stamp do |f| %>
+ <%= form_for @stamp do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :color %>
<p><%= f.text_field :name, :size => 30 %> <%= f.submit "Get Started" %></p>
View
2  app/views/user_sessions/new.html.erb
@@ -3,7 +3,7 @@
<p>Don't have an account? <%= link_to "Sign up!", signup_path %></p>
-<% form_for @user_session do |f| %>
+<%= form_for @user_session, :as => :user_session, :url => { :action => "create" } do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :username %><br />
View
2  app/views/users/_form.html.erb
@@ -1,4 +1,4 @@
-<% form_for @user do |f| %>
+<%= form_for @user do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :username %><br />
View
2  autotest/discover.rb
@@ -0,0 +1,2 @@
+Autotest.add_discovery { "rails" }
+Autotest.add_discovery { "rspec2" }
View
4 config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Dailystamp::Application
View
1  config/app_config.example.yml
@@ -1 +0,0 @@
-hoptoad_key: 123456789 # replace with real key
View
43 config/application.rb
@@ -0,0 +1,43 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Dailystamp
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ config.autoload_paths += %W(#{config.root}/lib)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+ config.time_zone = "Pacific Time (US & Canada)"
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+ end
+end
View
123 config/boot.rb
@@ -1,110 +1,13 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
-
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
-
-module Rails
- class << self
- def boot!
- unless booted?
- preinitialize
- pick_boot.run
- end
- end
-
- def booted?
- defined? Rails::Initializer
- end
-
- def pick_boot
- (vendor_rails? ? VendorBoot : GemBoot).new
- end
-
- def vendor_rails?
- File.exist?("#{RAILS_ROOT}/vendor/rails")
- end
-
- def preinitialize
- load(preinitializer_path) if File.exist?(preinitializer_path)
- end
-
- def preinitializer_path
- "#{RAILS_ROOT}/config/preinitializer.rb"
- end
- end
-
- class Boot
- def run
- load_initializer
- Rails::Initializer.run(:set_load_path)
- end
- end
-
- class VendorBoot < Boot
- def load_initializer
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
- Rails::Initializer.run(:install_gem_spec_stubs)
- Rails::GemDependency.add_frozen_gem_path
- end
- end
-
- class GemBoot < Boot
- def load_initializer
- self.class.load_rubygems
- load_rails_gem
- require 'initializer'
- end
-
- def load_rails_gem
- if version = self.class.gem_version
- gem 'rails', version
- else
- gem 'rails'
- end
- rescue Gem::LoadError => load_error
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
- exit 1
- end
-
- class << self
- def rubygems_version
- Gem::RubyGemsVersion rescue nil
- end
-
- def gem_version
- if defined? RAILS_GEM_VERSION
- RAILS_GEM_VERSION
- elsif ENV.include?('RAILS_GEM_VERSION')
- ENV['RAILS_GEM_VERSION']
- else
- parse_gem_version(read_environment_rb)
- end
- end
-
- def load_rubygems
- require 'rubygems'
- min_version = '1.3.1'
- unless rubygems_version >= min_version
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
- exit 1
- end
-
- rescue LoadError
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
- exit 1
- end
-
- def parse_gem_version(text)
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
- end
-
- private
- def read_environment_rb
- File.read("#{RAILS_ROOT}/config/environment.rb")
- end
- end
- end
-end
-
-# All that for this:
-Rails.boot!
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+begin
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+rescue Bundler::GemNotFound => e
+ STDERR.puts e.message
+ STDERR.puts "Try running `bundle install`."
+ exit!
+end if File.exist?(gemfile)
View
39 config/database.example.yml
@@ -1,22 +1,39 @@
-# SQLite version 3.x
-# gem install sqlite3-ruby (not necessary on OS X Leopard)
+# MySQL. Versions 4.1 and 5.0 are recommended.
+#
+# Install the MySQL driver:
+# gem install mysql2
+#
+# And be sure to use new-style password hashing:
+# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
- adapter: sqlite3
- database: db/development.sqlite3
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: dailystamp_development
pool: 5
- timeout: 5000
+ username: root
+ password:
+ socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
- adapter: sqlite3
- database: db/test.sqlite3
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: dailystamp_test
pool: 5
- timeout: 5000
+ username: root
+ password:
+ socket: /tmp/mysql.sock
production:
- adapter: sqlite3
- database: db/production.sqlite3
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: dailystamp_production
pool: 5
- timeout: 5000
+ username: root
+ password:
+ socket: /var/run/mysqld/mysqld.sock
View
21 config/deploy.rb
@@ -1,4 +1,8 @@
-set :application, "dailystamp.com"
+set :whenever_command, "bundle exec whenever"
+require "bundler/capistrano"
+require "whenever/capistrano"
+
+set :application, "beta.dailystamp.com"
role :app, application
role :web, application
role :db, application, :primary => true
@@ -7,7 +11,6 @@
set :deploy_to, "/var/apps/dailystamp"
set :deploy_via, :remote_cache
set :use_sudo, false
-set :ssh_options, { :forward_agent => true }
set :scm, "git"
set :repository, "git://github.com/ryanb/dailystamp.git"
@@ -18,7 +21,7 @@
task :restart, :roles => :web do
run "touch #{deploy_to}/current/tmp/restart.txt"
end
-
+
desc "Do nothing on startup so we don't get a script/spin error."
task :start do
puts "You may need to restart Apache."
@@ -27,9 +30,7 @@
desc "Symlink extra configs and folders."
task :symlink_extras do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
- run "ln -nfs #{shared_path}/config/app_config.yml #{release_path}/config/app_config.yml"
run "ln -nfs #{shared_path}/config/session_secret.txt #{release_path}/config/session_secret.txt"
- run "ln -nfs #{shared_path}/db/production.sqlite3 #{release_path}/db/production.sqlite3"
run "ln -nfs #{shared_path}/assets #{release_path}/public/assets"
end
@@ -38,18 +39,11 @@
run "mkdir #{shared_path}/assets"
run "mkdir #{shared_path}/config"
run "mkdir #{shared_path}/db"
- run "mkdir #{shared_path}/db/sphinx"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
- put File.read("config/app_config.example.yml"), "#{shared_path}/config/app_config.yml"
put File.read("config/session_secret.example.txt"), "#{shared_path}/config/session_secret.txt"
puts "Now edit the config files and fill assets folder in #{shared_path}."
end
-
- desc "Update the crontab file"
- task :update_crontab, :roles => :db do
- run "cd #{release_path} && whenever --update-crontab #{application}"
- end
-
+
desc "Make sure there is something to deploy"
task :check_revision, :roles => :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
@@ -64,4 +58,3 @@
after "deploy", "deploy:cleanup" # keeps only last 5 releases
after "deploy:setup", "deploy:setup_shared"
after "deploy:update_code", "deploy:symlink_extras"
-# after "deploy:symlink", "deploy:update_crontab"
View
49 config/environment.rb
@@ -1,46 +1,5 @@
-# Be sure to restart your server when you modify this file
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-Rails::Initializer.run do |config|
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration should go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded.
-
- # Add additional load paths for your own custom dirs
- # config.load_paths += %W( #{RAILS_ROOT}/extras )
-
- # Specify gems that this application depends on and have them installed with rake gems:install
- # config.gem "bj"
- # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
- # config.gem "sqlite3-ruby", :lib => "sqlite3"
- # config.gem "aws-s3", :lib => "aws/s3"
- config.gem "authlogic"
- config.gem "paperclip"
- config.gem "rmagick", :lib => "RMagick"
- config.gem "authlogic-oid", :lib => "authlogic_openid"
- config.gem "ruby-openid", :lib => "openid"
-
- # Only load the plugins named here, in the order given (default is alphabetical).
- # :all can be used as a placeholder for all plugins not explicitly named
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
- # Skip frameworks you're not going to use. To use Rails without a database,
- # you must remove the Active Record framework.
- # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
-
- # Activate observers that should always be running
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
-
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names.
- config.time_zone = 'Pacific Time (US & Canada)'
-
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
- # config.i18n.default_locale = :de
-end
+# Initialize the rails application
+Dailystamp::Application.initialize!
View
35 config/environments/development.rb
@@ -1,17 +1,26 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Dailystamp::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# In the development environment your application's code is reloaded on
-# every request. This slows down response time but is perfect for development
-# since you don't have to restart the webserver when you make code changes.
-config.cache_classes = false
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the webserver when you make code changes.
+ config.cache_classes = false
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_view.debug_rjs = true
-config.action_controller.perform_caching = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+end
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
View
61 config/environments/production.rb
@@ -1,28 +1,49 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Dailystamp::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
-# Full error reports are disabled and caching is turned on
-config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
-config.action_view.cache_template_loading = true
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
-# See everything in the log (default is :info)
-config.log_level = :warn
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-# Use a different cache store in production
-# config.cache_store = :mem_cache_store
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
-# Enable threaded mode
-# config.threadsafe!
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # Enable serving of images, stylesheets, and javascripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
View
67 config/environments/test.rb
@@ -1,32 +1,35 @@
-# Settings specified here will take precedence over those in config/environment.rb
-
-# The test environment is used exclusively to run your application's
-# test suite. You never need to work with it otherwise. Remember that
-# your test database is "scratch space" for the test suite and is wiped
-# and recreated between test runs. Don't rely on the data there!
-config.cache_classes = true
-
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
-
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
-config.action_view.cache_template_loading = true
-
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
-
-# Tell Action Mailer not to deliver emails to the real world.
-# The :test delivery method accumulates sent emails in the
-# ActionMailer::Base.deliveries array.
-config.action_mailer.delivery_method = :test
-
-# Use SQL instead of Active Record's schema dumper when creating the test database.
-# This is necessary if your schema can't be completely dumped by the schema dumper,
-# like if you have constraints or database-specific column types
-# config.active_record.schema_format = :sql
-
-config.gem 'thoughtbot-factory_girl', :version => '>= 1.1.1', :lib => 'factory_girl', :source => 'http://gems.github.com'
-config.gem "rspec", :lib => false, :version => ">= 1.2.0"
-config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0"
+Dailystamp::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
View
28 config/initializers/authlogic_fixes.rb
@@ -0,0 +1,28 @@
+# See https://github.com/mreinsch/authlogic_openid/commit/9b802c347f5addebcbce945af3b5f80b3ee7b214
+# and http://stackoverflow.com/questions/2092694/authlogic-openid-error-uninitialized-constant-openidauthenticationinvalidopeni
+module AuthlogicOpenid
+ module ActsAsAuthentic
+ module Methods
+ def openid_identifier=(value)
+ write_attribute(:openid_identifier, value.blank? ? nil : OpenID.normalize_url(value))
+ reset_persistence_token if openid_identifier_changed?
+ rescue OpenID::DiscoveryFailure => e
+ @openid_error = e.message
+ end
+ end
+ end
+end
+
+module AuthlogicOpenid
+ module Session
+ module Methods
+ def openid_identifier=(value)
+ @openid_identifier = value.blank? ? nil : OpenID.normalize_url(value)
+ @openid_error = nil
+ rescue OpenID::DiscoveryFailure => e
+ @openid_identifier = nil
+ @openid_error = e.message
+ end
+ end
+ end
+end
View
4 config/initializers/backtrace_silencers.rb
@@ -3,5 +3,5 @@
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
-# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
-# Rails.backtrace_cleaner.remove_silencers!
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
View
5 config/initializers/hoptoad.rb
@@ -1,5 +0,0 @@
-if APP_CONFIG['hoptoad_key']
- HoptoadNotifier.configure do |config|
- config.api_key = APP_CONFIG['hoptoad_key']
- end
-end
View
11 config/initializers/inflections.rb
@@ -1,10 +1,11 @@
# Be sure to restart your server when you modify this file.
-# Add new inflection rules using the following format
+# Add new inflection rules using the following format
# (all these examples are active by default):
ActiveSupport::Inflector.inflections do |inflect|
- # inflect.plural /(ox)$/i, '\1en'
- inflect.singular /(cache)s$/i, '\1'
- # inflect.irregular 'person', 'people'
- # inflect.uncountable %w( fish sheep )
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+ inflect.singular /(cache)s/i, '\1'
end
View
1  config/initializers/openid_store.rb
@@ -0,0 +1 @@
+OpenIdAuthentication.store = :file
View
7 config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Dailystamp::Application.config.secret_token = File.read(Rails.root.join("config/session_secret.txt"))
View
13 config/initializers/session_store.rb
@@ -1,15 +1,8 @@
# Be sure to restart your server when you modify this file.
-# Your secret key for verifying cookie session data integrity.
-# If you change this key, all old sessions will become invalid!
-# Make sure the secret is at least 30 characters and all random,
-# no regular words or you'll be exposed to dictionary attacks.
-ActionController::Base.session = {
- :key => '_dailystamp_session2',
- :secret => File.read(Rails.root.join("config", "session_secret.txt")).strip
-}
+Dailystamp::Application.config.session_store :cookie_store, :key => '_dailystamp_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
-# (create the session table with "rake db:sessions:create")
-# ActionController::Base.session_store = :active_record_store
+# (create the session table with "rails generate session_migration")
+# Dailystamp::Application.config.session_store :active_record_store
View
2  config/locales/en.yml
@@ -2,4 +2,4 @@
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
- hello: "Hello world"
+ hello: "Hello world"
View
2  config/preinitializer.rb
@@ -1,3 +1,3 @@
# load app_config.yml
require 'yaml'
-APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/app_config.yml"))
+APP_CONFIG = YAML.load(File.read("#{Rails.root}/config/app_config.yml"))
View
29 config/routes.rb
@@ -1,16 +1,19 @@
-ActionController::Routing::Routes.draw do |map|
- map.resources :favorites
-
- map.signup 'signup', :controller => 'users', :action => 'new'
- map.logout 'logout', :controller => 'user_sessions', :action => 'destroy'
- map.login 'login', :controller => 'user_sessions', :action => 'new'
- map.home 'home', :controller => 'stamps', :action => 'index', :no_redirect => "true"
+Dailystamp::Application.routes.draw do
+ root :to => 'stamps#index'
- map.resources :user_sessions
- map.resources :users
- map.resources :stamp_images
- map.resources :marks
- map.resources :stamps, :member => { :edit_goal => :get }
+ match 'signup' => 'users#new', :as => 'signup'
+ match 'logout' => 'user_sessions#destroy', :as => 'logout'
+ match 'login' => 'user_sessions#new', :as => 'login'
+ match 'home' => 'stamps#index', :as => 'home', :no_redirect => 'true'
- map.root :stamps
+ resources :user_sessions
+ resources :users
+ resources :favorites
+ resources :stamp_images
+ resources :marks
+ resources :stamps do
+ member do
+ get :edit_goal
+ end
+ end
end
View
13 db/schema.rb
@@ -1,10 +1,11 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file,
-# please use the migrations feature of Active Record to incrementally modify your database, and
-# then regenerate this schema definition.
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
#
-# Note that this schema.rb definition is the authoritative source for your database schema. If you need
-# to create the application database on another system, you should be using db:schema:load, not running
-# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
View
7 db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Mayor.create(:name => 'Daley', :city => cities.first)
View
2  doc/README_FOR_APP
@@ -1,2 +0,0 @@
-Use this README file to introduce your application and point to useful places in the API for learning more.
-Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
View
3  lib/authentication.rb
@@ -17,7 +17,6 @@
module Authentication
def self.included(controller)
controller.send :helper_method, :current_user, :logged_in?, :redirect_to_target_or_default
- controller.filter_parameter_logging :password
end
def current_user_session
@@ -50,6 +49,6 @@ def redirect_to_target_or_default(default)
private
def store_target_location
- session[:return_to] = request.request_uri
+ session[:return_to] = request.url
end
end
View
0  lib/tasks/.gitkeep
No changes.
View
182 lib/tasks/rspec.rake
@@ -1,182 +0,0 @@
-gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
-rspec_gem_dir = nil
-Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
- rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
-end
-rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
-
-if rspec_gem_dir && (test ?d, rspec_plugin_dir)
- raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
-end
-
-if rspec_gem_dir
- $LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
-elsif File.exist?(rspec_plugin_dir)
- $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
-end
-
-# Don't load rspec if running "rake gems:*"
-unless ARGV.any? {|a| a =~ /^gems/}
-
-begin
- require 'spec/rake/spectask'
-rescue MissingSourceFile
- module Spec
- module Rake
- class SpecTask
- def initialize(name)
- task name do
- # if rspec-rails is a configured gem, this will output helpful material and exit ...
- require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
-
- # ... otherwise, do this:
- raise <<-MSG
-
-#{"*" * 80}
-* You are trying to run an rspec rake task defined in
-* #{__FILE__},
-* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
-#{"*" * 80}
-MSG
- end
- end
- end
- end
- end
-end
-
-Rake.application.instance_variable_get('@tasks').delete('default')
-
-spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
-task :noop do
-end
-
-task :default => :spec
-task :stats => "spec:statsetup"
-
-desc "Run all specs in spec directory (excluding plugin specs)"
-Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*_spec.rb']
-end
-
-namespace :spec do
- desc "Run all specs in spec directory with RCov (excluding plugin specs)"
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*_spec.rb']
- t.rcov = true
- t.rcov_opts = lambda do
- IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
- end
- end
-
- desc "Print Specdoc for all specs (excluding plugin specs)"
- Spec::Rake::SpecTask.new(:doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['spec/**/*_spec.rb']
- end
-
- desc "Print Specdoc for all plugin examples"
- Spec::Rake::SpecTask.new(:plugin_doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
- end
-
- [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
- desc "Run the code examples in spec/#{sub}"
- Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
- end
- end
-
- desc "Run the code examples in vendor/plugins (except RSpec's own)"
- Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
- end
-
- namespace :plugins do
- desc "Runs the examples for rspec_on_rails"
- Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
- end
- end
-
- # Setup specs for stats
- task :statsetup do
- require 'code_statistics'
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
- ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
- ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
- ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
- ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
- ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
- ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
- ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
- ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
- ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
- ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
- ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
- end
-
- namespace :db do
- namespace :fixtures do
- desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
- task :load => :environment do
- ActiveRecord::Base.establish_connection(Rails.env)
- base_dir = File.join(Rails.root, 'spec', 'fixtures')
- fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
-
- require 'active_record/fixtures'
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
- end
- end
- end
- end
-
- namespace :server do
- daemonized_server_pid = File.expand_path("#{RAILS_ROOT}/tmp/pids/spec_server.pid")
-
- desc "start spec_server."
- task :start do
- if File.exist?(daemonized_server_pid)
- $stderr.puts "spec_server is already running."
- else
- $stderr.puts %Q{Starting up spec_server ...}
- FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
- system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
- end
- end
-
- desc "stop spec_server."
- task :stop do
- unless File.exist?(daemonized_server_pid)
- $stderr.puts "No server running."
- else
- $stderr.puts "Shutting down spec_server ..."
- system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
- File.delete(daemonized_server_pid)
- end
- end
-
- desc "restart spec_server."
- task :restart => [:stop, :start]
-
- desc "check if spec server is running"
- task :status do
- if File.exist?(daemonized_server_pid)
- $stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
- else
- $stderr.puts "No server running."
- end
- end
- end
-end
-
-end
View
963 public/javascripts/controls.js
@@ -1,963 +0,0 @@
-// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
-// Contributors:
-// Richard Livsey
-// Rahul Bhargava
-// Rob Wills
-//
-// script.aculo.us is freely distributable under the terms of an MIT-style license.
-// For details, see the script.aculo.us web site: http://script.aculo.us/
-
-// Autocompleter.Base handles all the autocompletion functionality
-// that's independent of the data source for autocompletion. This
-// includes drawing the autocompletion menu, observing keyboard
-// and mouse events, and similar.
-//
-// Specific autocompleters need to provide, at the very least,
-// a getUpdatedChoices function that will be invoked every time
-// the text inside the monitored textbox changes. This method
-// should get the text for which to provide autocompletion by
-// invoking this.getToken(), NOT by directly accessing
-// this.element.value. This is to allow incremental tokenized
-// autocompletion. Specific auto-completion logic (AJAX, etc)
-// belongs in getUpdatedChoices.
-//
-// Tokenized incremental autocompletion is enabled automatically
-// when an autocompleter is instantiated with the 'tokens' option
-// in the options parameter, e.g.:
-// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
-// will incrementally autocomplete with a comma as the token.
-// Additionally, ',' in the above example can be replaced with
-// a token array, e.g. { tokens: [',', '\n'] } which
-// enables autocompletion on multiple tokens. This is most
-// useful when one of the tokens is \n (a newline), as it
-// allows smart autocompletion after linebreaks.
-
-if(typeof Effect == 'undefined')
- throw("controls.js requires including script.aculo.us' effects.js library");
-
-var Autocompleter = { };
-Autocompleter.Base = Class.create({
- baseInitialize: function(element, update, options) {
- element = $(element);
- this.element = element;
- this.update = $(update);
- this.hasFocus = false;
- this.changed = false;
- this.active = false;
- this.index = 0;
- this.entryCount = 0;
- this.oldElementValue = this.element.value;
-
- if(this.setOptions)
- this.setOptions(options);
- else
- this.options = options || { };
-
- this.options.paramName = this.options.paramName || this.element.name;
- this.options.tokens = this.options.tokens || [];
- this.options.frequency = this.options.frequency || 0.4;
- this.options.minChars = this.options.minChars || 1;
- this.options.onShow = this.options.onShow ||
- function(element, update){
- if(!update.style.position || update.style.position=='absolute') {
- update.style.position = 'absolute';
- Position.clone(element, update, {
- setHeight: false,
- offsetTop: element.offsetHeight
- });
- }
- Effect.Appear(update,{duration:0.15});
- };
- this.options.onHide = this.options.onHide ||
- function(element, update){ new Effect.Fade(update,{duration:0.15}) };
-
- if(typeof(this.options.tokens) == 'string')
- this.options.tokens = new Array(this.options.tokens);
- // Force carriage returns as token delimiters anyway
- if (!this.options.tokens.include('\n'))
- this.options.tokens.push('\n');
-
- this.observer = null;
-
- this.element.setAttribute('autocomplete','off');
-
- Element.hide(this.update);
-
- Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
- Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
- },
-
- show: function() {
- if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
- if(!this.iefix &&
- (Prototype.Browser.IE) &&
- (Element.getStyle(this.update, 'position')=='absolute')) {
- new Insertion.After(this.update,
- '<iframe id="' + this.update.id + '_iefix" '+
- 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
- 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
- this.iefix = $(this.update.id+'_iefix');
- }
- if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
- },
-
- fixIEOverlapping: function() {
- Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
- this.iefix.style.zIndex = 1;
- this.update.style.zIndex = 2;
- Element.show(this.iefix);
- },
-
- hide: function() {
- this.stopIndicator();
- if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
- if(this.iefix) Element.hide(this.iefix);
- },
-
- startIndicator: function() {
- if(this.options.indicator) Element.show(this.options.indicator);
- },
-
- stopIndicator: function() {
- if(this.options.indicator) Element.hide(this.options.indicator);
- },
-
- onKeyPress: function(event) {
- if(this.active)
- switch(event.keyCode) {
- case Event.KEY_TAB:
- case Event.KEY_RETURN:
- this.selectEntry();
- Event.stop(event);
- case Event.KEY_ESC:
- this.hide();
- this.active = false;
- Event.stop(event);
- return;
- case Event.KEY_LEFT:
- case Event.KEY_RIGHT:
- return;
- case Event.KEY_UP:
- this.markPrevious();
- this.render();
- Event.stop(event);
- return;
- case Event.KEY_DOWN:
- this.markNext();
- this.render();
- Event.stop(event);
- return;
- }
- else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
- (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
-
- this.changed = true;
- this.hasFocus = true;
-
- if(this.observer) clearTimeout(this.observer);
- this.observer =
- setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
- },
-
- activate: function() {
- this.changed = false;
- this.hasFocus = true;
- this.getUpdatedChoices();
- },
-
- onHover: function(event) {
- var element = Event.findElement(event, 'LI');
- if(this.index != element.autocompleteIndex)
- {
- this.index = element.autocompleteIndex;
- this.render();
- }
- Event.stop(event);
- },
-
- onClick: function(event) {
- var element = Event.findElement(event, 'LI');
- this.index = element.autocompleteIndex;
- this.selectEntry();
- this.hide();
- },
-
- onBlur: function(event) {
- // needed to make click events working
- setTimeout(this.hide.bind(this), 250);
- this.hasFocus = false;
- this.active = false;
- },
-
- render: function() {
- if(this.entryCount > 0) {
- for (var i = 0; i < this.entryCount; i++)
- this.index==i ?
- Element.addClassName(this.getEntry(i),"selected") :
- Element.removeClassName(this.getEntry(i),"selected");
- if(this.hasFocus) {
- this.show();
- this.active = true;
- }
- } else {
- this.active = false;
- this.hide();
- }
- },
-
- markPrevious: function() {
- if(this.index > 0) this.index--;
- else this.index = this.entryCount-1;
- this.getEntry(this.index).scrollIntoView(true);
- },
-
- markNext: function() {
- if(this.index < this.entryCount-1) this.index++;
- else this.index = 0;
- this.getEntry(this.index).scrollIntoView(false);
- },
-
- getEntry: function(index) {
- return this.update.firstChild.childNodes[index];
- },
-
- getCurrentEntry: function() {
- return this.getEntry(this.index);
- },
-
- selectEntry: function() {
- this.active = false;
- this.updateElement(this.getCurrentEntry());
- },
-
- updateElement: function(selectedElement) {
- if (this.options.updateElement) {
- this.options.updateElement(selectedElement);
- return;
- }
- var value = '';
- if (this.options.select) {
- var nodes = $(selectedElement).select('.' + this.options.select) || [];
- if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
- } else
- value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
-
- var bounds = this.getTokenBounds();
- if (bounds[0] != -1) {
- var newValue = this.element.value.substr(0, bounds[0]);
- var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
- if (whitespace)
- newValue += whitespace[0];
- this.element.value = newValue + value + this.element.value.substr(bounds[1]);
- } else {
- this.element.value = value;
- }
- this.oldElementValue = this.element.value;
- this.element.focus();
-
- if (this.options.afterUpdateElement)
- this.options.afterUpdateElement(this.element, selectedElement);
- },
-
- updateChoices: function(choices) {
- if(!this.changed && this.hasFocus) {
- this.update.innerHTML = choices;
- Element.cleanWhitespace(this.update);
- Element.cleanWhitespace(this.update.down());
-
- if(this.update.firstChild && this.update.down().childNodes) {
- this.entryCount =
- this.update.down().childNodes.length;
- for (var i = 0; i < this.entryCount; i++) {
- var entry = this.getEntry(i);
- entry.autocompleteIndex = i;
- this.addObservers(entry);
- }
- } else {
- this.entryCount = 0;
- }
-
- this.stopIndicator();
- this.index = 0;
-
- if(this.entryCount==1 && this.options.autoSelect) {
- this.selectEntry();
- this.hide();
- } else {
- this.render();
- }
- }
- },
-
- addObservers: function(element) {
- Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
- Event.observe(element, "click", this.onClick.bindAsEventListener(this));
- },
-
- onObserverEvent: function() {
- this.changed = false;
- this.tokenBounds = null;
- if(this.getToken().length>=this.options.minChars) {
- this.getUpdatedChoices();
- } else {
- this.active = false;
- this.hide();
- }
- this.oldElementValue = this.element.value;
- },
-
- getToken: function() {
- var bounds = this.getTokenBounds();
- return this.element.value.substring(bounds[0], bounds[1]).strip();
- },
-
- getTokenBounds: function() {
- if (null != this.tokenBounds) return this.tokenBounds;
- var value = this.element.value;
- if (value.strip().empty()) return [-1, 0];
- var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
- var offset = (diff == this.oldElementValue.length ? 1 : 0);
- var prevTokenPos = -1, nextTokenPos = value.length;
- var tp;
- for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
- tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
- if (tp > prevTokenPos) prevTokenPos = tp;
- tp = value.indexOf(this.options.tokens[index], diff + offset);
- if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
- }
- return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
- }
-});
-
-Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
- var boundary = Math.min(newS.length, oldS.length);
- for (var index = 0; index < boundary; ++index)
- if (newS[index] != oldS[index])
- return index;
- return boundary;
-};
-
-Ajax.Autocompleter = Class.create(Autocompleter.Base, {
- initialize: function(element, update, url, options) {
- this.baseInitialize(element, update, options);
- this.options.asynchronous = true;
- this.options.onComplete = this.onComplete.bind(this);
- this.options.defaultParams = this.options.parameters || null;
- this.url = url;
- },
-
- getUpdatedChoices: function() {
- this.startIndicator();
-
- var entry = encodeURIComponent(this.options.paramName) + '=' +
- encodeURIComponent(this.getToken());
-
- this.options.parameters = this.options.callback ?
- this.options.callback(this.element, entry) : entry;
-
- if(this.options.defaultParams)
- this.options.parameters += '&' + this.options.defaultParams;
-
- new Ajax.Request(this.url, this.options);
- },
-
- onComplete: function(request) {
- this.updateChoices(request.responseText);
- }
-});
-
-// The local array autocompleter. Used when you'd prefer to
-// inject an array of autocompletion options into the page, rather
-// than sending out Ajax queries, which can be quite slow sometimes.
-//
-// The constructor takes four parameters. The first two are, as usual,
-// the id of the monitored textbox, and id of the autocompletion menu.
-// The third is the array you want to autocomplete from, and the fourth
-// is the options block.
-//
-// Extra local autocompletion options:
-// - choices - How many autocompletion choices to offer
-//
-// - partialSearch - If false, the autocompleter will match entered
-// text only at the beginning of strings in the
-// autocomplete array. Defaults to true, which will
-// match text at the beginning of any *word* in the
-// strings in the autocomplete array. If you want to
-// search anywhere in the string, additionally set
-// the option fullSearch to true (default: off).
-//
-// - fullSsearch - Search anywhere in autocomplete array strings.
-//
-// - partialChars - How many characters to enter before triggering
-// a partial match (unlike minChars, which defines
-// how many characters are required to do any match
-// at all). Defaults to 2.
-//
-// - ignoreCase - Whether to ignore case when autocompleting.
-// Defaults to true.
-//
-// It's possible to pass in a custom function as the 'selector'
-// option, if you prefer to write your own autocompletion logic.
-// In that case, the other options above will not apply unless
-// you support them.
-
-Autocompleter.Local = Class.create(Autocompleter.Base, {
- initialize: function(element, update, array, options) {
- this.baseInitialize(element, update, options);
- this.options.array = array;
- },
-
- getUpdatedChoices: function() {
- this.updateChoices(this.options.selector(this));
- },
-
- setOptions: function(options) {
- this.options = Object.extend({
- choices: 10,
- partialSearch: true,
- partialChars: 2,
- ignoreCase: true,
- fullSearch: false,
- selector: function(instance) {
- var ret = []; // Beginning matches
- var partial = []; // Inside matches
- var entry = instance.getToken();
- var count = 0;
-
- for (var i = 0; i < instance.options.array.length &&
- ret.length < instance.options.choices ; i++) {
-
- var elem = instance.options.array[i];
- var foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
- elem.indexOf(entry);
-
- while (foundPos != -1) {
- if (foundPos == 0 && elem.length != entry.length) {
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
- elem.substr(entry.length) + "</li>");
- break;
- } else if (entry.length >= instance.options.partialChars &&
- instance.options.partialSearch && foundPos != -1) {
- if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
- partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
- elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
- foundPos + entry.length) + "</li>");
- break;
- }
- }
-
- foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
- elem.indexOf(entry, foundPos + 1);
-
- }
- }
- if (partial.length)
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
- return "<ul>" + ret.join('') + "</ul>";
- }
- }, options || { });
- }
-});
-
-// AJAX in-place editor and collection editor
-// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
-
-// Use this if you notice weird scrolling problems on some browsers,
-// the DOM might be a bit confused when this gets called so do this
-// waits 1 ms (with setTimeout) until it does the activation
-Field.scrollFreeActivate = function(field) {
- setTimeout(function() {
- Field.activate(field);
- }, 1);
-};
-
-Ajax.InPlaceEditor = Class.create({
- initialize: function(element, url, options) {
- this.url = url;
- this.element = element = $(element);
- this.prepareOptions();
- this._controls = { };
- arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
- Object.extend(this.options, options || { });
- if (!this.options.formId && this.element.id) {
- this.options.formId = this.element.id + '-inplaceeditor';
- if ($(this.options.formId))
- this.options.formId = '';
- }
- if (this.options.externalControl)
- this.options.externalControl = $(this.options.externalControl);
- if (!this.options.externalControl)
- this.options.externalControlOnly = false;
- this._originalBackground = this.element.getStyle('background-color') || 'transparent';
- this.element.title = this.options.clickToEditText;
- this._boundCancelHandler = this.handleFormCancellation.bind(this);
- this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
- this._boundFailureHandler = this.handleAJAXFailure.bind(this);
- this._boundSubmitHandler = this.handleFormSubmission.bind(this);
- this._boundWrapperHandler = this.wrapUp.bind(this);
- this.registerListeners();
- },
- checkForEscapeOrReturn: function(e) {
- if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
- if (Event.KEY_ESC == e.keyCode)
- this.handleFormCancellation(e);
- else if (Event.KEY_RETURN == e.keyCode)
- this.handleFormSubmission(e);
- },
- createControl: function(mode, handler, extraClasses) {
- var control = this.options[mode + 'Control'];
- var text = this.options[mode + 'Text'];
- if ('button' == control) {
- var btn = document.createElement('input');
- btn.type = 'submit';
- btn.value = text;
- btn.className = 'editor_' + mode + '_button';
- if ('cancel' == mode)
- btn.onclick = this._boundCancelHandler;
- this._form.appendChild(btn);
- this._controls[mode] = btn;
- } else if ('link' == control) {
- var link = document.createElement('a');
- link.href = '#';
- link.appendChild(document.createTextNode(text));
- link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
- link.className = 'editor_' + mode + '_link';
- if (extraClasses)
- link.className += ' ' + extraClasses;
- this._form.appendChild(link);
- this._controls[mode] = link;
- }
- },
- createEditField: function() {
- var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
- var fld;