Permalink
Browse files

First pass at turning bumble into a rails 3 engine

  • Loading branch information...
1 parent fcfc699 commit 2bc156a64bcdc96d89bb1e6f2ab6f44d470c2e64 @andrew committed Jun 5, 2011
Showing with 293 additions and 6,772 deletions.
  1. +3 −16 Gemfile
  2. +0 −107 Gemfile.lock
  3. +0 −25 README
  4. +1 −7 Rakefile
  5. +3 −0 Readme.mdown
  6. +1 −1 app/controllers/{application_controller.rb → bumble_controller.rb}
  7. +80 −48 app/controllers/comments_controller.rb
  8. +1 −1 app/controllers/password_resets_controller.rb
  9. +26 −42 app/controllers/posts_controller.rb
  10. +13 −9 app/controllers/user_sessions_controller.rb
  11. +33 −10 app/controllers/users_controller.rb
  12. +7 −4 app/helpers/{application_helper.rb → bumble_helper.rb}
  13. +1 −1 app/models/comment.rb
  14. +3 −3 app/models/post.rb
  15. +2 −2 app/views/layouts/{application.html.haml → bumble.html.haml}
  16. +1 −1 app/views/posts/edit.html.haml
  17. +1 −1 app/views/users/show.html.haml
  18. +31 −0 bumble.gemspec
  19. +0 −4 config.ru
  20. +0 −42 config/application.rb
  21. +0 −13 config/boot.rb
  22. +0 −23 config/database.yml.example
  23. +0 −5 config/environment.rb
  24. +0 −28 config/environments/development.rb
  25. +0 −49 config/environments/production.rb
  26. +0 −37 config/environments/test.rb
  27. +0 −7 config/initializers/backtrace_silencers.rb
  28. +7 −1 config/initializers/bumble.rb
  29. +0 −19 config/initializers/new_rails_defaults.rb
  30. +0 −7 config/initializers/secret_token.rb
  31. +0 −8 config/initializers/session_store.rb
  32. +0 −5 config/locales/en.yml
  33. +7 −3 config/routes.rb
  34. +0 −9 config/schedule.rb
  35. +0 −10 config/sitemap.rb
  36. +0 −20 config/sphinx.yml
  37. +0 −11 db/migrate/20100424203226_turn_exisiting_images_into_assets.rb
  38. +0 −67 db/schema.rb
  39. +0 −2 doc/README_FOR_APP
  40. +18 −0 lib/bumble.rb
  41. +3 −0 lib/bumble/version.rb
  42. +10 −0 lib/generators/bumble/assets_generator.rb
  43. +40 −0 lib/generators/bumble/migrations_generator.rb
  44. 0 {tmp → lib/generators/bumble/templates/assets/images}/.gitignore
  45. 0 {public → lib/generators/bumble/templates/assets}/images/close.png
  46. 0 {public → lib/generators/bumble/templates/assets}/images/email.png
  47. 0 {public → lib/generators/bumble/templates/assets}/images/feed.png
  48. 0 {public → lib/generators/bumble/templates/assets}/images/image.png
  49. 0 {public → lib/generators/bumble/templates/assets}/images/loading.gif
  50. 0 {public → lib/generators/bumble/templates/assets}/images/preview.png
  51. 0 {public → lib/generators/bumble/templates/assets}/images/shortcut.png
  52. 0 {public → lib/generators/bumble/templates/assets}/images/youtube.png
  53. 0 {public → lib/generators/bumble/templates/assets}/javascripts/admin.js
  54. 0 public/javascripts/application.js → lib/generators/bumble/templates/assets/javascripts/bumble.js
  55. 0 {public → lib/generators/bumble/templates/assets}/javascripts/iphone.js
  56. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.autogrow.js
  57. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.cookie.js
  58. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.form.js
  59. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.hint.js
  60. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.jgrow.js
  61. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.js
  62. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.ui.core.js
  63. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.ui.tabs.js
  64. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.ui.widget.js
  65. 0 {public → lib/generators/bumble/templates/assets}/javascripts/jquery.validate.js
  66. 0 {public → lib/generators/bumble/templates/assets}/javascripts/modernizr.js
  67. 0 {public → lib/generators/bumble/templates/assets}/javascripts/ui.core.js
  68. 0 {public → lib/generators/bumble/templates/assets}/javascripts/ui.tabs.js
  69. 0 ..._approved_to_comments.rb → lib/generators/bumble/templates/migrations/add_approved_to_comments.rb
  70. 0 ...23085933_add_delta_to_posts.rb → lib/generators/bumble/templates/migrations/add_delta_to_posts.rb
  71. 0 ...073651_add_missing_indexes.rb → lib/generators/bumble/templates/migrations/add_missing_indexes.rb
  72. 0 ...090719154022_add_url_to_users.rb → lib/generators/bumble/templates/migrations/add_url_to_users.rb
  73. 0 ...ate/20100424192311_create_assets.rb → lib/generators/bumble/templates/migrations/create_assets.rb
  74. 0 ...20090617194117_create_comments.rb → lib/generators/bumble/templates/migrations/create_comments.rb
  75. 0 ...grate/20090617192039_create_posts.rb → lib/generators/bumble/templates/migrations/create_posts.rb
  76. 0 ...grate/20090616230112_create_users.rb → lib/generators/bumble/templates/migrations/create_users.rb
  77. +1 −1 ...7_full_text_search_1272184797.rb → lib/generators/bumble/templates/migrations/full_text_search.rb
  78. +0 −12 lib/tasks/coverage.rake
  79. 0 log/.gitignore
  80. +0 −25 public/404.html
  81. +0 −25 public/422.html
  82. +0 −25 public/500.html
  83. BIN public/favicon.ico
  84. 0 public/images/.gitignore
  85. +0 −7 public/robots.txt
  86. 0 public/stylesheets/sass/{application.sass → bumble.sass}
  87. +0 −4 script/about
  88. +0 −3 script/console
  89. +0 −3 script/dbconsole
  90. +0 −3 script/destroy
  91. +0 −3 script/generate
  92. +0 −3 script/performance/benchmarker
  93. +0 −3 script/performance/profiler
  94. +0 −3 script/plugin
  95. +0 −6 script/rails
  96. +0 −3 script/runner
  97. +0 −3 script/server
  98. 0 test/fixtures/.gitignore
  99. 0 test/integration/.gitignore
  100. +0 −5 test/unit/helpers/application_helper_test.rb
  101. +0 −20 vendor/plugins/dynamic_form/MIT-LICENSE
  102. +0 −13 vendor/plugins/dynamic_form/README
  103. +0 −10 vendor/plugins/dynamic_form/Rakefile
  104. +0 −12 vendor/plugins/dynamic_form/dynamic_form.gemspec
  105. +0 −1 vendor/plugins/dynamic_form/init.rb
  106. +0 −300 vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb
  107. +0 −8 vendor/plugins/dynamic_form/lib/action_view/locale/en.yml
  108. +0 −5 vendor/plugins/dynamic_form/lib/dynamic_form.rb
  109. +0 −42 vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb
  110. +0 −370 vendor/plugins/dynamic_form/test/dynamic_form_test.rb
  111. +0 −9 vendor/plugins/dynamic_form/test/test_helper.rb
  112. +0 −148 vendor/plugins/make_resourceful/DEFAULTS
  113. +0 −7 vendor/plugins/make_resourceful/LICENSE
  114. +0 −240 vendor/plugins/make_resourceful/README
  115. +0 −31 vendor/plugins/make_resourceful/Rakefile
  116. +0 −1 vendor/plugins/make_resourceful/VERSION
  117. +0 −87 vendor/plugins/make_resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb
  118. +0 −5 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/controller.rb
  119. +0 −10 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/fixtures.yml
  120. +0 −57 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb
  121. +0 −2 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/helper.rb
  122. +0 −13 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/migration.rb
  123. +0 −2 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/model.rb
  124. +0 −7 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/unit_test.rb
  125. +0 −5 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view__form.haml
  126. +0 −11 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_edit.haml
  127. +0 −5 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_index.haml
  128. +0 −9 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_new.haml
  129. +0 −12 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_partial.haml
  130. +0 −14 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_show.haml
  131. +0 −3 vendor/plugins/make_resourceful/init.rb
  132. +0 −55 vendor/plugins/make_resourceful/lib/resourceful/base.rb
  133. +0 −380 vendor/plugins/make_resourceful/lib/resourceful/builder.rb
  134. +0 −396 vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb
  135. +0 −101 vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb
  136. +0 −51 vendor/plugins/make_resourceful/lib/resourceful/default/callbacks.rb
  137. +0 −118 vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb
  138. +0 −137 vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb
  139. +0 −84 vendor/plugins/make_resourceful/lib/resourceful/maker.rb
  140. +0 −33 vendor/plugins/make_resourceful/lib/resourceful/response.rb
  141. +0 −181 vendor/plugins/make_resourceful/lib/resourceful/serialize.rb
  142. +0 −474 vendor/plugins/make_resourceful/spec/accessors_spec.rb
  143. +0 −310 vendor/plugins/make_resourceful/spec/actions_spec.rb
  144. +0 −12 vendor/plugins/make_resourceful/spec/base_spec.rb
  145. +0 −332 vendor/plugins/make_resourceful/spec/builder_spec.rb
  146. +0 −71 vendor/plugins/make_resourceful/spec/callbacks_spec.rb
  147. +0 −393 vendor/plugins/make_resourceful/spec/integration_spec.rb
  148. +0 −91 vendor/plugins/make_resourceful/spec/maker_spec.rb
  149. +0 −37 vendor/plugins/make_resourceful/spec/response_spec.rb
  150. +0 −314 vendor/plugins/make_resourceful/spec/responses_spec.rb
  151. +0 −37 vendor/plugins/make_resourceful/spec/rspec-rails/LICENSE
  152. +0 −113 vendor/plugins/make_resourceful/spec/rspec-rails/redirect_to.rb
  153. +0 −90 vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb
  154. +0 −133 vendor/plugins/make_resourceful/spec/serialize_spec.rb
  155. +0 −307 vendor/plugins/make_resourceful/spec/spec_helper.rb
  156. +0 −278 vendor/plugins/make_resourceful/spec/urls_spec.rb
View
19 Gemfile
@@ -1,17 +1,4 @@
-source :rubygems
+source "http://rubygems.org"
-gem 'rails', '3.0.4'
-gem 'will_paginate', '~>3.0.pre2'
-gem 'gravtastic', '~>2.1.3'
-gem 'authlogic', '~>2.1.1'
-gem 'rdiscount'
-gem 'haml', '~>3.0.0'
-gem 'texticle'
-gem 'paperclip', '2.3.4'
-gem 'pg'
-gem 'aws-s3'
-gem 'permalink_fu'
-
-group :production do
- gem 'hassle', :git => 'git://github.com/koppen/hassle.git'
-end
+# Specify your gem's dependencies in bumble.gemspec
+gemspec
View
107 Gemfile.lock
@@ -1,107 +0,0 @@
-GIT
- remote: git://github.com/koppen/hassle.git
- revision: 97512c65f4c6fa34a4d4e284c416e8e6ebecbd44
- specs:
- hassle (0.0.1)
- haml
- rack
-
-GEM
- remote: http://rubygems.org/
- specs:
- abstract (1.0.0)
- actionmailer (3.0.4)
- actionpack (= 3.0.4)
- mail (~> 2.2.15)
- actionpack (3.0.4)
- activemodel (= 3.0.4)
- activesupport (= 3.0.4)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.4)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.13)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.4)
- activesupport (= 3.0.4)
- builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.4)
- activemodel (= 3.0.4)
- activesupport (= 3.0.4)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activeresource (3.0.4)
- activemodel (= 3.0.4)
- activesupport (= 3.0.4)
- activesupport (3.0.4)
- arel (2.0.8)
- authlogic (2.1.6)
- activesupport
- aws-s3 (0.6.2)
- builder
- mime-types
- xml-simple
- builder (2.1.2)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- gravtastic (2.1.3)
- haml (3.0.25)
- i18n (0.5.0)
- mail (2.2.15)
- activesupport (>= 2.3.6)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.16)
- paperclip (2.3.4)
- activerecord
- activesupport
- permalink_fu (1.0.0)
- pg (0.10.1)
- polyglot (0.3.1)
- rack (1.2.1)
- rack-mount (0.6.13)
- rack (>= 1.0.0)
- rack-test (0.5.7)
- rack (>= 1.0)
- rails (3.0.4)
- actionmailer (= 3.0.4)
- actionpack (= 3.0.4)
- activerecord (= 3.0.4)
- activeresource (= 3.0.4)
- activesupport (= 3.0.4)
- bundler (~> 1.0)
- railties (= 3.0.4)
- railties (3.0.4)
- actionpack (= 3.0.4)
- activesupport (= 3.0.4)
- rake (>= 0.8.7)
- thor (~> 0.14.4)
- rake (0.8.7)
- rdiscount (1.6.8)
- texticle (1.0.4.20101004123327)
- thor (0.14.6)
- treetop (1.4.9)
- polyglot (>= 0.3.1)
- tzinfo (0.3.24)
- will_paginate (3.0.pre2)
- xml-simple (1.0.14)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- authlogic (~> 2.1.1)
- aws-s3
- gravtastic (~> 2.1.3)
- haml (~> 3.0.0)
- hassle!
- paperclip (= 2.3.4)
- permalink_fu
- pg
- rails (= 3.0.4)
- rdiscount
- texticle
- will_paginate (~> 3.0.pre2)
View
25 README
@@ -1,25 +0,0 @@
-Bumble - A ruby tumblog
-
-Homepage: http://teabass.com/
-Author: Andrew Nesbitt (http://teabass.com)
-Github: http://github.com/andrew/bumble
-
-Copyright (c) 2008 Andrew Nesbitt
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
View
8 Rakefile
@@ -1,7 +1 @@
-# 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.expand_path('../config/application', __FILE__)
-require 'rake'
-
-Bumble::Application.load_tasks
+require 'bundler/gem_tasks'
View
3 Readme.mdown
@@ -0,0 +1,3 @@
+# Bumble
+
+Blogging plugin provided as a rails engine
View
2 app/controllers/application_controller.rb → app/controllers/bumble_controller.rb
@@ -1,4 +1,4 @@
-class ApplicationController < ActionController::Base
+class BumbleController < ActionController::Base
protect_from_forgery
helper_method :current_user_session, :current_user, :iphone?
View
128 app/controllers/comments_controller.rb
@@ -1,67 +1,99 @@
-class CommentsController < ApplicationController
+class CommentsController < BumbleController
before_filter :require_user, :only => [:edit, :update, :destroy]
- make_resourceful do
- actions :all
- belongs_to :post
- before :create do
- current_object.user = current_user
- end
-
- response_for :index do |format|
- format.html { redirect_to post_path(parent_object, :anchor => 'comments') }
- format.atom {}
- format.js { render current_objects }
- end
+ def create
+ @post = Post.find(params[:post_id])
+ @comment = Comment.new(params[:comment])
+ @comment.user = current_user
+ @comment.request = request
+ @comment.post = @post
- response_for :show do |format|
- format.html { redirect_to post_path(parent_object, :anchor => dom_id(current_object)) }
- end
-
- response_for :destroy do |format|
- format.html do
- flash[:notice] = 'Record deleted!'
- redirect_to post_path(parent_object)
- end
- end
-
- response_for :update do |format|
- format.html do
- flash[:notice] = 'Save successful!'
- redirect_to post_path(parent_object, :anchor => dom_id(current_object))
+ if @comment.save
+ respond_to do |format|
+ format.html do
+ if @comment.approved?
+ flash[:notice] = 'Create successful!'
+ else
+ flash[:notice] = "Your comment looks like spam, it will show up once it's been approved."
+ end
+ redirect_to post_path(@post, :anchor => dom_id(@comment))
+ end
+ format.js do
+ if @comment.approved?
+ render @comment, :content_type => :html
+ else
+ render :text => "Your comment looks like spam, it will show up once it's been approved.", :status => 406, :content_type => :html
+ end
+ end
end
- end
-
- response_for :create do |format|
- format.html do
- flash[:notice] = 'Create successful!'
- redirect_to post_path(parent_object, :anchor => dom_id(current_object))
+ else
+ respond_to do |format|
+ format.html { render :action => "new" }
+ format.js { render :text => @comment.errors.full_messages.join(', ').capitalize, :status => 403, :content_type => :html }
end
- format.js { render current_object, :content_type => :html }
end
-
- response_for :create_fails do |format|
- format.html { render :action => "new" }
- format.js { render :text => current_object.errors.full_messages.join(', ').capitalize, :status => 403, :content_type => :html }
+ end
+
+ def index
+ @post = Post.find(params[:post_id])
+ @comments = @post.comments
+ respond_to do |format|
+ format.html { redirect_to post_path(@post, :anchor => 'comments') }
+ format.atom {}
+ format.js { render @comments }
end
-
- response_for :destroy do |format|
+ end
+
+ def destroy
+ @comment = Comment.find(params[:id])
+ @comment.destroy
+ respond_to do |format|
format.html do
flash[:notice] = 'Record deleted!'
- redirect_to post_path(current_object.post)
+ redirect_to post_path(@comment.post)
end
format.js { render :nothing => true }
end
end
+
+ def update
+ @post = Post.find(params[:post_id])
+ @comment = Comment.find(params[:id])
+ if @comment.update_attributes(params[:comment])
+ respond_to do |format|
+ format.html do
+ flash[:notice] = 'Save successful!'
+ redirect_to post_path(@post, :anchor => dom_id(@comment))
+ end
+ end
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def edit
+ @comment = Comment.find(params[:id])
+ end
+
+ def new
+ @comment = Comment.new
+ end
- private
+ def show
+ @comment = Comment.find(params[:id])
+ redirect_to post_path(@comment.post, :anchor => dom_id(@comment))
+ end
- def parent_model
- current_user ? super : Post.published.all_public
+ def approve
+ @comment = Comment.find(params[:id])
+ @comment.mark_as_ham!
+ redirect_to post_path(@comment.post, :anchor => dom_id(@comment))
end
- def parent_object
- @parent_object ||= parent_model.find_by_permalink_or_id(params["#{parent_name}_id"])
+ def reject
+ @comment = Comment.find(params[:id])
+ @comment.mark_as_spam!
+ redirect_to post_path(@comment.post, :anchor => dom_id(@comment))
end
-end
+end
View
2 app/controllers/password_resets_controller.rb
@@ -1,4 +1,4 @@
-class PasswordResetsController < ApplicationController
+class PasswordResetsController < BumbleController
before_filter :load_user_using_perishable_token, :only => [:edit, :update]
def create
View
68 app/controllers/posts_controller.rb
@@ -1,14 +1,14 @@
-class PostsController < ApplicationController
+class PostsController < BumbleController
before_filter :require_user, :except => [:index, :show, :search, :sitemap]
- make_resourceful do
- actions :all
-
- before :show do
- fresh_when(:etag => [current_object, current_object.comments]) unless current_user
- end
-
- response_for :destroy do |format|
+ def new
+ @post = build_object
+ end
+
+ def destroy
+ @post = Post.find(params[:id])
+ @post.destroy
+ respond_to do |format|
format.html do
flash[:notice] = "Record deleted!"
redirect_to posts_path
@@ -17,16 +17,21 @@ class PostsController < ApplicationController
end
end
+ def show
+ @post = current_model.find_by_permalink_or_id(params[:id])
+ fresh_when(:etag => [@post, @post.comments]) unless current_user
+ end
+
def index
respond_to do |format|
format.html do
- @posts = Post.paginate :page => params[:page],
+ @posts = current_model.paginate :page => params[:page],
:order => 'published_at DESC',
:per_page => per_page
fresh_when(:etag => [@posts, Comment.last]) unless current_user
end
format.atom do
- @posts = Post.find(:all,
+ @posts = current_model.find(:all,
:order => 'published_at DESC',
:limit => 50)
end
@@ -35,29 +40,28 @@ def index
def create
build_object
- load_object
- current_object.user = current_user
+ @post.user = current_user
if params[:commit] == "Preview"
- current_object.valid?
+ @post.valid?
respond_to do |format|
- format.js { render :partial => 'preview', :locals => {:post => current_object}, :content_type => :html }
+ format.js { render :partial => 'preview', :locals => {:post => @post}, :content_type => :html }
format.html do
flash[:notice] = 'Create successful!'
redirect_to posts_path
end
end
else
- if current_object.save
+ if @post.save
respond_to do |format|
- format.js { render :partial => 'post', :locals => {:post => current_object}, :content_type => :html }
+ format.js { render :partial => 'post', :locals => {:post => @post}, :content_type => :html }
format.html do
flash[:notice] = 'Create successful!'
- redirect_to post_path(current_object)
+ redirect_to post_path(@post)
end
end
else
respond_to do |format|
- format.js { render :text => current_object.errors.full_messages.join(', ').capitalize, :status => 403, :content_type => :html }
+ format.js { render :text => @post.errors.full_messages.join(', ').capitalize, :status => 403, :content_type => :html }
format.html { render :action => "new" }
end
end
@@ -74,31 +78,15 @@ def search
end
end
- def sitemap
- expires_in 1.hour, :public => true
- Sitemap::Routes.parse
- respond_to do |format|
- format.xml do
- render :xml => Sitemap::Routes.results.to_xml
- end
- end
- end
-
private
def build_object
Post.types.each do |t|
if params.include?(t.downcase)
- @current_object = Object.const_get(t).new(params[t.downcase])
+ @post = Object.const_get(t).new(params[t.downcase])
end
end
- @current_object ||= Blog.new
- end
-
- def current_objects
- @current_object ||= current_model.paginate :page => params[:page],
- :order => 'published_at DESC',
- :per_page => per_page
+ @post ||= Blog.new
end
def per_page
@@ -110,10 +98,6 @@ def current_model_name
end
def current_model
- current_user ? super : Post.published.all_public
- end
-
- def current_object
- @current_object ||= current_model.find_by_permalink_or_id(params[:id])
+ current_user ? Post.scoped : Post.published.all_public
end
end
View
22 app/controllers/user_sessions_controller.rb
@@ -1,12 +1,16 @@
-class UserSessionsController < ApplicationController
- make_resourceful do
- actions :new, :create
-
- response_for :create do |format|
- format.html do
- flash[:notice] = 'Logged in successfully'
- redirect_back_or_default root_path
- end
+class UserSessionsController < BumbleController
+
+ def new
+ @user_session = UserSession.new
+ end
+
+ def create
+ @user_session = UserSession.new
+ if @user_session.save
+ flash[:notice] = 'Logged in successfully'
+ redirect_back_or_default root_path
+ else
+ render :action => 'new'
end
end
View
43 app/controllers/users_controller.rb
@@ -1,9 +1,38 @@
-class UsersController < ApplicationController
+class UsersController < BumbleController
before_filter :require_user, :except => [:activate]
- make_resourceful do
- actions :all, :except => :create
- member_actions :delete
+ def new
+ @user = User.new
+ end
+
+ def edit
+ @user = User.find(params[:id])
+ end
+
+ def index
+ @users = User.paginate(:page => params[:page])
+ end
+
+ def destroy
+ @user = User.find(params[:id])
+ @user.destroy
+ respond_to do |format|
+ format.html do
+ flash[:notice] = "User Deleted"
+ redirect_to users_path
+ end
+ end
+ end
+
+ def update
+ @user = User.find(params[:id])
+ @user.update_attributes(params[:user])
+ if @user.save
+ flash[:notice] = 'User updated successfully'
+ redirect_to posts_path
+ else
+ render :action => 'edit'
+ end
end
def create
@@ -28,10 +57,4 @@ def activate
render :action => :new
end
end
-
- private
-
- def current_objects
- @current_object ||= current_model.paginate :page => params[:page]
- end
end
View
11 app/helpers/application_helper.rb → app/helpers/bumble_helper.rb
@@ -1,4 +1,4 @@
-module ApplicationHelper
+module BumbleHelper
def markdown(text)
text.blank? ? "" : sanitize(RDiscount.new(text).to_html, :tags => %w(a p pre code b strong em i strike ul ol li blockquote br))
end
@@ -22,18 +22,21 @@ def page_title
end
def page_description
- escape_once((@page_description || 'The website of Andrew Nesbitt, a web developer from London. Expect to find posts and links about technology, the web, ruby, rails, html, css, jquery and random cat pictures.'))
+ escape_once((@page_description || 'TODO'))
end
def youtube_embed(link, width = 500, height = 300)
- link.gsub(/http:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/) do
- youtube_id = $2
+ matches = link.match(/http:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/)
+ youtube_id = matches[2]
+ if youtube_id
content_tag :object, :width => width, :height => height, :data => "http://www.youtube.com/v/#{youtube_id}" do
tag(:param, :name => 'movie', :value => "http://www.youtube.com/v/#{youtube_id}") +
tag(:param, :name => 'allowFullScreen', :value => 'true') +
tag(:param, :name => 'allowscriptaccess', :value => 'always') +
tag(:embed, :src => "http://www.youtube.com/v/#{youtube_id}", :type => 'application/x-shockwave-flash', :allowscriptaccess => 'always', :allowfullscreen => 'true', :width => width, :height => height)
end
+ else
+ link_to link, link
end
end
View
2 app/models/comment.rb
@@ -1,5 +1,5 @@
class Comment < ActiveRecord::Base
-
+ include Gravtastic
belongs_to :post # TODO , :counter_cache => true
belongs_to :user
View
6 app/models/post.rb
@@ -9,7 +9,7 @@ class Post < ActiveRecord::Base
validates_presence_of :user, :published_at
- before_validation_on_create :format_published_at
+ before_validation :format_published_at
def asset
assets.first
@@ -20,7 +20,7 @@ def to_param
end
def self.types
- Dir["#{RAILS_ROOT}/app/models/posts/*.rb"].each { |f| require_dependency f }
+ Dir[File.expand_path('../posts',__FILE__)+'/*.rb'].each { |f| require_dependency f }
self.subclasses.collect(&:to_s).sort
end
@@ -52,6 +52,6 @@ def title
end
def format_published_at
- self.published_at = Time.now if self.published_at < Time.now
+ self.published_at = Time.now if self.published_at.nil?
end
end
View
4 app/views/layouts/application.html.haml → app/views/layouts/bumble.html.haml
@@ -10,8 +10,8 @@
- if protect_against_forgery?
:javascript
var AUTH_TOKEN=#{form_authenticity_token.inspect};
- = stylesheet_link_tag('application', :media => 'screen, print')
- = javascript_include_tag 'jquery', 'jquery.validate', 'jquery.form', 'jquery.hint', 'jquery.autogrow', 'modernizr', 'application'
+ = stylesheet_link_tag('bumble', :media => 'screen, print')
+ = javascript_include_tag 'jquery', 'jquery.validate', 'jquery.form', 'jquery.hint', 'jquery.autogrow', 'modernizr', 'bumble'
- if current_user
= javascript_include_tag 'jquery.cookie', 'jquery.ui.core', 'jquery.ui.widget', 'jquery.ui.tabs', 'admin'
- if iphone?
View
2 app/views/posts/edit.html.haml
@@ -2,7 +2,7 @@
Editing
= @post.class.to_s.downcase
-- form_for :post, :url => post_path(@post), :html => {:method => :put} do |form|
+- form_for @post, :url => post_path(@post), :html => {:method => :put} do |form|
= render :partial => "posts/forms/#{@post.class.to_s.downcase}", :locals => {:form => form}
= render form
= form.submit "Update"
View
2 app/views/users/show.html.haml
@@ -3,4 +3,4 @@
%p
= link_to "Edit User", edit_user_path
|
- = link_to "Delete User", user_path, :class => :delete
+ = link_to "Delete User", delete_user_path
View
31 bumble.gemspec
@@ -0,0 +1,31 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "bumble/version"
+
+Gem::Specification.new do |s|
+ s.name = "bumble"
+ s.version = Bumble::VERSION
+ s.authors = ["Andrew Nesbitt"]
+ s.email = ["andrewnez@gmail.com"]
+ s.homepage = ""
+ s.summary = %q{Rails 3 Tumblog Engine}
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ s.add_dependency(%q<rails>, ["3.0.7"])
+ s.add_dependency(%q<will_paginate>, ["~>3.0.pre2"])
+ s.add_dependency(%q<gravtastic>, ["~>2.1.3"])
+ s.add_dependency(%q<authlogic>, ["~>2.1.1"])
+ s.add_dependency(%q<rdiscount>, ["1.6.8"])
+ s.add_dependency(%q<haml>, ["~>3.1.1"])
+ s.add_dependency(%q<texticle>, ["~>1.0.4"])
+ s.add_dependency(%q<paperclip>, ["2.3.4"])
+ s.add_dependency(%q<pg>, ["~>0.10.1"])
+ s.add_dependency(%q<aws-s3>, ["~>0.6.2"])
+ s.add_dependency(%q<dynamic_form>, ["1.1.4"])
+ s.add_dependency(%q<sass>, ["~>3.1.2"])
+ s.add_dependency(%q<akismetor>)
+end
View
4 config.ru
@@ -1,4 +0,0 @@
-# This file is used by Rack-based servers to start the application.
-
-require ::File.expand_path('../config/environment', __FILE__)
-run Bumble::Application
View
42 config/application.rb
@@ -1,42 +0,0 @@
-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 Bumble
- 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}/app/models/posts)
-
- # 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)'
-
- # 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, :password_confirmation]
- end
-end
View
13 config/boot.rb
@@ -1,13 +0,0 @@
-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
23 config/database.yml.example
@@ -1,23 +0,0 @@
-development:
- adapter: mysql
- database: bumble_development
- username: root
- password:
- encoding: utf8
-
-# 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: mysql
- database: bumble_test
- username: root
- password:
- encoding: utf8
-
-production:
- adapter: mysql
- database: bumble_production
- username: root
- password: password
- encoding: utf8
View
5 config/environment.rb
@@ -1,5 +0,0 @@
-# Load the rails application
-require File.expand_path('../application', __FILE__)
-
-# Initialize the rails application
-Bumble::Application.initialize!
View
28 config/environments/development.rb
@@ -1,28 +0,0 @@
-Bumble::Application.configure do
- # Settings specified here will take precedence over those in config/environment.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
-
- # 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_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
-
- config.action_mailer.default_url_options = { :host => 'localhost' }
-end
-
View
49 config/environments/production.rb
@@ -1,49 +0,0 @@
-Bumble::Application.configure do
- # Settings specified here will take precedence over those in config/environment.rb
-
- # 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.consider_all_requests_local = false
- config.action_controller.perform_caching = true
-
- # Specifies the header that your server uses for sending files
- config.action_dispatch.x_sendfile_header = "X-Sendfile"
-
- # For nginx:
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-
- # If you have no front-end server that supports something like X-Sendfile,
- # just comment this out and Rails will serve the files
-
- # See everything in the log (default is :info)
- # config.log_level = :debug
-
- # Use a different logger for distributed setups
- # config.logger = SyslogLogger.new
-
- # 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 = true
-
- # 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
37 config/environments/test.rb
@@ -1,37 +0,0 @@
-Bumble::Application.configure do
- # 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.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
-
- config.action_mailer.default_url_options = { :host => 'localhost' }
-end
View
7 config/initializers/backtrace_silencers.rb
@@ -1,7 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# 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 to debug a problem that might stem from framework code.
-# Rails.backtrace_cleaner.remove_silencers!
View
8 config/initializers/bumble.rb
@@ -1,3 +1,9 @@
# Configure the options for you site here
DOMAIN = 'example.com'
-CONTACT_EMAIL = 'you@example.com'
+CONTACT_EMAIL = 'you@example.com'
+
+Rails.application.config.action_mailer.default_url_options = { :host => DOMAIN }
+
+SASS_PATH = File.join(File.dirname(__FILE__), *%w[.. .. public stylesheets sass])
+CSS_PATH = File.expand_path(File.join(Rails.root, %w[public stylesheets]))
+::Sass::Plugin.add_template_location(SASS_PATH, CSS_PATH)
View
19 config/initializers/new_rails_defaults.rb
@@ -1,19 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# These settings change the behavior of Rails 2 apps and will be defaults
-# for Rails 3. You can remove this initializer when Rails 3 is released.
-
-if defined?(ActiveRecord)
- # Include Active Record class name as root for JSON serialized output.
- ActiveRecord::Base.include_root_in_json = true
-
- # Store the full class name (including module namespace) in STI type column.
- ActiveRecord::Base.store_full_sti_class = true
-end
-
-# Use ISO 8601 format for JSON serialized times and dates.
-ActiveSupport.use_standard_json_time_format = true
-
-# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
-# if you're including raw json in an HTML page.
-ActiveSupport.escape_html_entities_in_json = false
View
7 config/initializers/secret_token.rb
@@ -1,7 +0,0 @@
-# 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.
-Bumble::Application.config.secret_token = '8e1436768ea9510367a0c8c345ea0c46b678c4f8210230a496559c106f4e87aecca16af277336fce626cb813fbc6261100fefbe1bb9054a0df4da32d8e51e203'
View
8 config/initializers/session_store.rb
@@ -1,8 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-Bumble::Application.config.session_store :cookie_store, :key => '_Bumble_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")
-# Bumble::Application.config.session_store :active_record_store
View
5 config/locales/en.yml
@@ -1,5 +0,0 @@
-# Sample localization file for English. Add more files in this directory for other locales.
-# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
-
-en:
- hello: "Hello world"
View
10 config/routes.rb
@@ -1,5 +1,5 @@
-Bumble::Application.routes.draw do
- match 'sitemap.xml' => 'posts#sitemap', :as => :sitemap
+Rails.application.routes.draw do
+ # match 'sitemap.xml' => 'posts#sitemap', :as => :sitemap
resources :posts do
collection do
@@ -16,7 +16,11 @@
end
resources :password_resets
- resources :users
+ resources :users do
+ member do
+ get :delete
+ end
+ end
match '/login' => 'user_sessions#new', :as => :login, :via => 'get'
match '/logout' => 'user_sessions#destroy', :as => :logout
resource :user_session
View
9 config/schedule.rb
@@ -1,9 +0,0 @@
-# reindex the database
-every 1.day, :at => '3:30 am' do
- rake "thinking_sphinx:rebuild"
-end
-
-# recreate the sitemap
-every 1.day, :at => '4:30 am' do
- rake "sitemap:refresh"
-end
View
10 config/sitemap.rb
@@ -1,10 +0,0 @@
-# Set the host name for URL creation
-SitemapGenerator::Sitemap.default_host = "http://#{DOMAIN}"
-
-SitemapGenerator::Sitemap.add_links do |sitemap|
- sitemap.add posts_path, :priority => 0.7, :changefreq => 'daily'
-
- Post.published.all_public.find(:all).each do |p|
- sitemap.add post_path(p), :lastmod => p.updated_at
- end
-end
View
20 config/sphinx.yml
@@ -1,20 +0,0 @@
-development:
- max_matches: 200
- enable_star: 1
- min_infix_len: 3
- sql_range_step: 10000000
- port: 3312
- # uncomment for passenger
- # bin_path: '/usr/local/bin'
-test:
- max_matches: 200
- enable_star: 1
- min_infix_len: 3
- sql_range_step: 10000000
- port: 3313
-production:
- max_matches: 200
- enable_star: 1
- min_infix_len: 3
- sql_range_step: 10000000
- port: 3314
View
11 db/migrate/20100424203226_turn_exisiting_images_into_assets.rb
@@ -1,11 +0,0 @@
-class TurnExisitingImagesIntoAssets < ActiveRecord::Migration
- def self.up
- Image.all.each do |image|
- image.assets.create(:attachment_url => image.image_url)
- end
- end
-
- def self.down
- Asset.delete_all
- end
-end
View
67 db/schema.rb
@@ -1,67 +0,0 @@
-# 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
-# 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.
-
-ActiveRecord::Schema.define(:version => 20090723085933) do
-
- create_table "comments", :force => true do |t|
- t.text "body"
- t.integer "post_id"
- t.integer "user_id"
- t.string "author_name"
- t.string "author_email"
- t.string "author_url"
- t.datetime "deleted_at"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "posts", :force => true do |t|
- t.string "title"
- t.string "link_url"
- t.string "image_url"
- t.text "video_embed"
- t.text "description"
- t.text "quote"
- t.string "permalink"
- t.integer "user_id"
- t.string "type"
- t.boolean "publicly_viewable", :default => true
- t.datetime "published_at"
- t.datetime "deleted_at"
- t.string "via"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.boolean "delta", :default => true, :null => false
- end
-
- create_table "users", :force => true do |t|
- t.string "email", :null => false
- t.string "crypted_password", :null => false
- t.string "password_salt", :null => false
- t.string "persistence_token", :null => false
- t.integer "login_count", :default => 0, :null => false
- t.integer "failed_login_count", :default => 0, :null => false
- t.datetime "last_request_at"
- t.datetime "current_login_at"
- t.datetime "last_login_at"
- t.string "current_login_ip"
- t.string "last_login_ip"
- t.string "perishable_token"
- t.datetime "deleted_at"
- t.datetime "activated_at"
- t.string "first_name"
- t.string "last_name"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "url"
- end
-
-end
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
18 lib/bumble.rb
@@ -0,0 +1,18 @@
+require 'bumble/version'
+require 'pathname'
+require 'rails'
+require 'haml'
+require 'authlogic'
+require 'texticle'
+require 'will_paginate'
+require 'gravtastic'
+require 'dynamic_form'
+require 'paperclip'
+require 'rdiscount'
+require 'akismetor'
+
+module Bumble
+ class Engine < Rails::Engine
+ config.autoload_paths << File.expand_path("../../app/models/posts", __FILE__)
+ end
+end
View
3 lib/bumble/version.rb
@@ -0,0 +1,3 @@
+module Bumble
+ VERSION = "0.1.0"
+end
View
10 lib/generators/bumble/assets_generator.rb
@@ -0,0 +1,10 @@
+module Bumble
+ class AssetsGenerator < Rails::Generators::Base
+ source_root File.expand_path('../templates/assets', __FILE__)
+
+ def regenerate
+ directory "images", "public/images"
+ directory "javascripts", "public/javascripts"
+ end
+ end
+end
View
40 lib/generators/bumble/migrations_generator.rb
@@ -0,0 +1,40 @@
+module Bumble
+ class MigrationsGenerator < Rails::Generators::Base
+
+ source_root File.expand_path('../templates', __FILE__)
+
+ include Rails::Generators::Migration
+
+ def generate_migrations
+ generate_migration('create_users')
+ generate_migration('create_posts')
+ generate_migration('create_comments')
+ generate_migration('add_url_to_users')
+ generate_migration('add_delta_to_posts')
+ generate_migration('add_approved_to_comments')
+ generate_migration('add_missing_indexes')
+ generate_migration('create_assets')
+ generate_migration('full_text_search')
+ end
+
+ private
+
+ def generate_migration(name)
+ begin
+ migration_template "migrations/#{name}.rb", "db/migrate/#{name}.rb"
+ sleep 1 # to make sure all migrations have a different number
+ rescue
+ puts "Skiping migration: #{name}"
+ end
+ end
+
+ # Implement the required interface for Rails::Generators::Migration.
+ def self.next_migration_number(dirname) #:nodoc:
+ if ActiveRecord::Base.timestamped_migrations
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
+ else
+ "%.3d" % (current_migration_number(dirname) + 1)
+ end
+ end
+ end
+end
View
0 tmp/.gitignore → ...bumble/templates/assets/images/.gitignore
File renamed without changes.
View
0 public/images/close.png → .../bumble/templates/assets/images/close.png
File renamed without changes
View
0 public/images/email.png → .../bumble/templates/assets/images/email.png
File renamed without changes
View
0 public/images/feed.png → ...s/bumble/templates/assets/images/feed.png
File renamed without changes
View
0 public/images/image.png → .../bumble/templates/assets/images/image.png
File renamed without changes
View
0 public/images/loading.gif → ...umble/templates/assets/images/loading.gif
File renamed without changes
View
0 public/images/preview.png → ...umble/templates/assets/images/preview.png
File renamed without changes
View
0 public/images/shortcut.png → ...mble/templates/assets/images/shortcut.png
File renamed without changes
View
0 public/images/youtube.png → ...umble/templates/assets/images/youtube.png
File renamed without changes
View
0 public/javascripts/admin.js → ...ble/templates/assets/javascripts/admin.js
File renamed without changes.
View
0 public/javascripts/application.js → ...le/templates/assets/javascripts/bumble.js
File renamed without changes.
View
0 public/javascripts/iphone.js → ...le/templates/assets/javascripts/iphone.js
File renamed without changes.
View
0 public/javascripts/jquery.autogrow.js → ...tes/assets/javascripts/jquery.autogrow.js
File renamed without changes.
View
0 public/javascripts/jquery.cookie.js → ...lates/assets/javascripts/jquery.cookie.js
File renamed without changes.
View
0 public/javascripts/jquery.form.js → ...mplates/assets/javascripts/jquery.form.js
File renamed without changes.
View
0 public/javascripts/jquery.hint.js → ...mplates/assets/javascripts/jquery.hint.js
File renamed without changes.
View
0 public/javascripts/jquery.jgrow.js → ...plates/assets/javascripts/jquery.jgrow.js
File renamed without changes.
View
0 public/javascripts/jquery.js → ...le/templates/assets/javascripts/jquery.js
File renamed without changes.
View
0 public/javascripts/jquery.ui.core.js → ...ates/assets/javascripts/jquery.ui.core.js
File renamed without changes.
View
0 public/javascripts/jquery.ui.tabs.js → ...ates/assets/javascripts/jquery.ui.tabs.js
File renamed without changes.
View
0 public/javascripts/jquery.ui.widget.js → ...es/assets/javascripts/jquery.ui.widget.js
File renamed without changes.
View
0 public/javascripts/jquery.validate.js → ...tes/assets/javascripts/jquery.validate.js
File renamed without changes.
View
0 public/javascripts/modernizr.js → ...templates/assets/javascripts/modernizr.js
File renamed without changes.
View
0 public/javascripts/ui.core.js → ...e/templates/assets/javascripts/ui.core.js
File renamed without changes.
View
0 public/javascripts/ui.tabs.js → ...e/templates/assets/javascripts/ui.tabs.js
File renamed without changes.
View
0 ...0091031211132_add_approved_to_comments.rb → ...es/migrations/add_approved_to_comments.rb
File renamed without changes.
View
0 ...rate/20090723085933_add_delta_to_posts.rb → ...emplates/migrations/add_delta_to_posts.rb
File renamed without changes.
View
0 ...ate/20100420073651_add_missing_indexes.rb → ...mplates/migrations/add_missing_indexes.rb
File renamed without changes.
View
0 ...igrate/20090719154022_add_url_to_users.rb → .../templates/migrations/add_url_to_users.rb
File renamed without changes.
View
0 db/migrate/20100424192311_create_assets.rb → ...ble/templates/migrations/create_assets.rb
File renamed without changes.
View
0 db/migrate/20090617194117_create_comments.rb → ...e/templates/migrations/create_comments.rb
File renamed without changes.
View
0 db/migrate/20090617192039_create_posts.rb → ...mble/templates/migrations/create_posts.rb
File renamed without changes.
View
0 db/migrate/20090616230112_create_users.rb → ...mble/templates/migrations/create_users.rb
File renamed without changes.
View
2 ...0425080457_full_text_search_1272184797.rb → .../templates/migrations/full_text_search.rb
@@ -1,4 +1,4 @@
-class FullTextSearch1272184797 < ActiveRecord::Migration
+class FullTextSearch < ActiveRecord::Migration
def self.up
ActiveRecord::Base.connection.execute(<<-'eosql')
DROP index IF EXISTS posts_fts_idx
View
12 lib/tasks/coverage.rake
@@ -1,12 +0,0 @@
-namespace :test do
- desc 'Measures test coverage'
- task :coverage do
- rm_f "coverage"
- rm_f "coverage.data"
- rcov = 'rcov test/test_helper.rb --rails --aggregate coverage.data --text-summary -Ilib -x \gem'
- system("#{rcov} --no-html test/unit/*_test.rb")
- system("#{rcov} --no-html test/functional/*_test.rb")
- system("#{rcov} --html test/integration/*_test.rb")
- system("open coverage/index.html") if PLATFORM['darwin']
- end
-end
View
0 log/.gitignore
No changes.
View
25 public/404.html
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
- <link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
- <title>Bumble | Page not found (404)</title>
- </head>
- <body>
- <div id='header'>
- <h1><a href="/" rel="home">Bumble</a></h1>
- </div>
- <div id='content'>
- <div class='blank'>
- <h2>Page not found</h2>
- <p>The page you were looking for doesn't exist, you may have mistyped the address or the page may have moved.</p>
- <p><a href='/'>Return to the Homepage</a></p>
- </div>
- </div>
- <div id='footer'>
- <a href="#header" class="up" title="Back to top">&#x2191;</a>
- Powered by
- <a href="http://github.com/andrew/bumble">Bumble</a>
- </div>
- </body>
-</html>
View
25 public/422.html
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
- <link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
- <title>Bumble.com | Change rejected (422)</title>
- </head>
- <body>
- <div id='header'>
- <h1><a href="/" rel="home">Bumble</a></h1>
- </div>
- <div id='content'>
- <div class='blank'>
- <h2>Change Rejected</h2>
- <p>Maybe you tried to change something you didn't have access to.</p>
- <p><a href='/'>Return to the Homepage</a></p>
- </div>
- </div>
- <div id='footer'>
- <a href="#header" class="up" title="Back to top">&#x2191;</a>
- Powered by
- <a href="http://github.com/andrew/bumble">Bumble</a>
- </div>
- </body>
-</html>
View
25 public/500.html
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
- <link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
- <title>Bumble.com | Application Error (500)</title>
- </head>
- <body>
- <div id='header'>
- <h1><a href="/" rel="home">Bumble</a></h1>
- </div>
- <div id='content'>
- <div class='blank'>
- <h2>Application Error</h2>
- <p>Something went wrong! We've been notified about this issue and we'll take a look at it shortly.</p>
- <p><a href='/'>Return to the Homepage</a></p>
- </div>
- </div>
- <div id='footer'>
- <a href="#header" class="up" title="Back to top">&#x2191;</a>
- Powered by
- <a href="http://github.com/andrew/bumble">Bumble</a>
- </div>
- </body>
-</html>
View
BIN public/favicon.ico
Binary file not shown.
View
0 public/images/.gitignore
No changes.
View
7 public/robots.txt
@@ -1,7 +0,0 @@
-# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
-#
-# To ban all spiders from the entire site uncomment the next two lines:
-# User-Agent: *
-# Disallow: /
-
-Sitemap: http://yourdomain.com/sitemap_index.xml.gz
View
0 public/stylesheets/sass/application.sass → public/stylesheets/sass/bumble.sass
File renamed without changes.
View
4 script/about
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
-require 'commands/about'
View
3 script/console
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/console'
View
3 script/dbconsole
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/dbconsole'
View
3 script/destroy
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/destroy'
View
3 script/generate
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/generate'
View
3 script/performance/benchmarker
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/performance/benchmarker'
View
3 script/performance/profiler
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/performance/profiler'
View
3 script/plugin
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/plugin'
View
6 script/rails
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
-
-APP_PATH = File.expand_path('../../config/application', __FILE__)
-require File.expand_path('../../config/boot', __FILE__)
-require 'rails/commands'
View
3 script/runner
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/runner'
View
3 script/server
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/server'
View
0 test/fixtures/.gitignore
No changes.
View
0 test/integration/.gitignore
No changes.
View
5 test/unit/helpers/application_helper_test.rb
@@ -1,5 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../test_helper.rb")
-
-class ApplicationHelperTest < ActionView::TestCase
-
-end
View
20 vendor/plugins/dynamic_form/MIT-LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2010 David Heinemeier Hansson
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
13 vendor/plugins/dynamic_form/README
@@ -1,13 +0,0 @@
-DynamicForm
-===========
-
-DynamicForm holds a few helpers method to help you deal with your models, they are:
-
-* input(record, method, options = {})
-* form(record, options = {})
-* error_message_on(object, method, options={})
-* error_messages_for(record, options={})
-
-It also adds f.error_messages and f.error_messages_on to your form builders.
-
-Copyright (c) 2010 David Heinemeier Hansson, released under the MIT license
View
10 vendor/plugins/dynamic_form/Rakefile
@@ -1,10 +0,0 @@
-require 'rake/testtask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the active_model_helper plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
-end
View
12 vendor/plugins/dynamic_form/dynamic_form.gemspec
@@ -1,12 +0,0 @@
-Gem::Specification.new do |s|
- s.name = 'dynamic_form'
- s.version = '1.0.0'
- s.author = 'David Heinemeier Hansson'
- s.email = 'david@loudthinking.com'
- s.summary = 'Deprecated dynamic form helpers: input, form, error_messages_for, error_messages_on'
-
- s.add_dependency('rails', '>= 3.0.0')
-
- s.files = Dir['lib/**/*']
- s.require_path = 'lib'
-end
View
1 vendor/plugins/dynamic_form/init.rb
@@ -1 +0,0 @@
-require 'dynamic_form'
View
300 vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb
@@ -1,300 +0,0 @@
-require 'action_view/helpers'
-require 'active_support/i18n'
-require 'active_support/core_ext/enumerable'
-require 'active_support/core_ext/object/blank'
-
-module ActionView
- module Helpers
- # The Active Record Helper makes it easier to create forms for records kept in instance variables. The most far-reaching is the +form+
- # method that creates a complete form for all the basic content types of the record (not associations or aggregations, though). This
- # is a great way of making the record quickly available for editing, but likely to prove lackluster for a complicated real-world form.
- # In that case, it's better to use the +input+ method and the specialized +form+ methods in link:classes/ActionView/Helpers/FormHelper.html
- module DynamicForm
- # Returns a default input tag for the type of object returned by the method. For example, if <tt>@post</tt>
- # has an attribute +title+ mapped to a +VARCHAR+ column that holds "Hello World":
- #
- # input("post", "title")
- # # => <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
- def input(record_name, method, options = {})
- InstanceTag.new(record_name, method, self).to_tag(options)
- end
-
- # Returns an entire form with all needed input tags for a specified Active Record object. For example, if <tt>@post</tt>
- # has attributes named +title+ of type +VARCHAR+ and +body+ of type +TEXT+ then
- #
- # form("post")
- #
- # would yield a form like the following (modulus formatting):
- #
- # <form action='/posts/create' method='post'>
- # <p>
- # <label for="post_title">Title</label><br />
- # <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
- # </p>
- # <p>
- # <label for="post_body">Body</label><br />
- # <textarea cols="40" id="post_body" name="post[body]" rows="20"></textarea>
- # </p>
- # <input name="commit" type="submit" value="Create" />
- # </form>
- #
- # It's possible to specialize the form builder by using a different action name and by supplying another
- # block renderer. For example, if <tt>@entry</tt> has an attribute +message+ of type +VARCHAR+ then
- #
- # form("entry",
- # :action => "sign",
- # :input_block => Proc.new { |record, column|
- # "#{column.human_name}: #{input(record, column.name)}<br />"
- # })
- #
- # would yield a form like the following (modulus formatting):
- #
- # <form action="/entries/sign" method="post">
- # Message:
- # <input id="entry_message" name="entry[message]" size="30" type="text" /><br />
- # <input name="commit" type="submit" value="Sign" />
- # </form>
- #
- # It's also possible to add additional content to the form by giving it a block, such as:
- #
- # form("entry", :action => "sign") do |form|
- # form << content_tag("b", "Department")
- # form << collection_select("department", "id", @departments, "id", "name")
- # end
- #
- # The following options are available:
- #
- # * <tt>:action</tt> - The action used when submitting the form (default: +create+ if a new record, otherwise +update+).
- # * <tt>:input_block</tt> - Specialize the output using a different block, see above.
- # * <tt>:method</tt> - The method used when submitting the form (default: +post+).
- # * <tt>:multipart</tt> - Whether to change the enctype of the form to "multipart/form-data", used when uploading a file (default: +false+).
- # * <tt>:submit_value</tt> - The text of the submit button (default: "Create" if a new record, otherwise "Update").
- def form(record_name, options = {})
- record = instance_variable_get("@#{record_name}")
- record = convert_to_model(record)
-
- options = options.symbolize_keys
- options[:action] ||= record.persisted? ? "update" : "create"
- action = url_for(:action => options[:action], :id => record)
-
- submit_value = options[:submit_value] || options[:action].gsub(/[^\w]/, '').capitalize
-
- contents = form_tag({:action => action}, :method =>(options[:method] || 'post'), :enctype => options[:multipart] ? 'multipart/form-data': nil)
- contents.safe_concat hidden_field(record_name, :id) if record.persisted?
- contents.safe_concat all_input_tags(record, record_name, options)
- yield contents if block_given?
- contents.safe_concat submit_tag(submit_value)
- contents.safe_concat('</form>')
- end
-
- # Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
- # This error message is wrapped in a <tt>DIV</tt> tag by default or with <tt>:html_tag</tt> if specified,
- # which can be extended to include a <tt>:prepend_text</tt> and/or <tt>:append_text</tt> (to properly explain
- # the error), and a <tt>:css_class</tt> to style it accordingly. +object+ should either be the name of an
- # instance variable or the actual object. The method can be passed in either as a string or a symbol.
- # As an example, let's say you have a model <tt>@post</tt> that has an error message on the +title+ attribute:
- #
- # <%= error_message_on "post", "title" %>
- # # => <div class="formError">can't be empty</div>
- #
- # <%= error_message_on @post, :title %>
- # # => <div class="formError">can't be empty</div>
- #
- # <%= error_message_on "post", "title",
- # :prepend_text => "Title simply ",
- # :append_text => " (or it won't work).",
- # :html_tag => "span",
- # :css_class => "inputError" %>
- # # => <span class="inputError">Title simply can't be empty (or it won't work).</span>
- def error_message_on(object, method, *args)
- options = args.extract_options!
- unless args.empty?
- ActiveSupport::Deprecation.warn('error_message_on takes an option hash instead of separate ' +
- 'prepend_text, append_text, html_tag, and css_class arguments', caller)
-
- options[:prepend_text] = args[0] || ''
- options[:append_text] = args[1] || ''
- options[:html_tag] = args[2] || 'div'
- options[:css_class] = args[3] || 'formError'
- end
- options.reverse_merge!(:prepend_text => '', :append_text => '', :html_tag => 'div', :css_class => 'formError')
-
- object = convert_to_model(object)
-
- if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) &&
- (errors = obj.errors[method]).presence
- content_tag(options[:html_tag],
- (options[:prepend_text].html_safe << errors.first).safe_concat(options[:append_text]),
- :class => options[:css_class]
- )
- else
- ''
- end
- end
-
- # Returns a string with a <tt>DIV</tt> containing all of the error messages for the objects located as instance variables by the names
- # given. If more than one object is specified, the errors for the objects are displayed in the order that the object names are
- # provided.
- #
- # This <tt>DIV</tt> can be tailored by the following options:
- #
- # * <tt>:header_tag</tt> - Used for the header of the error div (default: "h2").
- # * <tt>:id</tt> - The id of the error div (default: "errorExplanation").
- # * <tt>:class</tt> - The class of the error div (default: "errorExplanation").
- # * <tt>:object</tt> - The object (or array of objects) for which to display errors,
- # if you need to escape the instance variable convention.
- # * <tt>:object_name</tt> - The object name to use in the header, or any text that you prefer.
- # If <tt>:object_name</tt> is not set, the name of the first object will be used.
- # * <tt>:header_message</tt> - The message in the header of the error div. Pass +nil+
- # or an empty string to avoid the header message altogether. (Default: "X errors
- # prohibited this object from being saved").
- # * <tt>:message</tt> - The explanation message after the header message and before
- # the error list. Pass +nil+ or an empty string to avoid the explanation message
- # altogether. (Default: "There were problems with the following fields:").
- #
- # To specify the display for one object, you simply provide its name as a parameter.
- # For example, for the <tt>@user</tt> model:
- #
- # error_messages_for 'user'
- #
- # You can also supply an object:
- #
- # error_messages_for @user
- #
- # This will use the last part of the model name in the presentation. For instance, if
- # this is a MyKlass::User object, this will use "user" as the name in the String. This
- # is taken from MyKlass::User.model_name.human, which can be overridden.
- #
- # To specify more than one object, you simply list them; optionally, you can add an extra <tt>:object_name</tt> parameter, which
- # will be the name used in the header message:
- #
- # error_messages_for 'user_common', 'user', :object_name => 'user'
- #
- # You can also use a number of objects, which will have the same naming semantics
- # as a single object.
- #
- # error_messages_for @user, @post
- #
- # If the objects cannot be located as instance variables, you can add an extra <tt>:object</tt> parameter which gives the actual
- # object (or array of objects to use):
- #
- # error_messages_for 'user', :object => @question.user
- #
- # NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
- # you need is significantly different from the default presentation, it makes plenty of sense to access the <tt>object.errors</tt>
- # instance yourself and set it up. View the source of this method to see how easy it is.
- def error_messages_for(*params)
- options = params.extract_options!.symbolize_keys
-
- objects = Array.wrap(options.delete(:object) || params).map do |object|
- object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
- object = convert_to_model(object)
-
- if object.class.respond_to?(:model_name)
- options[:object_name] ||= object.class.model_name.human.downcase
- end
-
- object
- end
-
- objects.compact!
- count = objects.inject(0) {|sum, object| sum + object.errors.count }
-
- unless count.zero?
- html = {}
- [:id, :class].each do |key|
- if options.include?(key)
- value = options[key]
- html[key] = value unless value.blank?
- else
- html[key] = 'errorExplanation'
- end
- end
- options[:object_name] ||= params.first
-
- I18n.with_options :locale => options[:locale], :scope => [:errors, :template] do |locale|
- header_message = if options.include?(:header_message)
- options[:header_message]
- else
- locale.t :header, :count => count, :model => options[:object_name].to_s.gsub('_', ' ')
- end
-
- message = options.include?(:message) ? options[:message] : locale.t(:body)
-
- error_messages = objects.sum do |object|
- object.errors.full_messages.map do |msg|
- content_tag(:li, msg)
- end
- end.join.html_safe
-
- contents = ''
- contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
- contents << content_tag(:p, message) unless message.blank?
- contents << content_tag(:ul, error_messages)
-
- content_tag(:div, contents.html_safe, html)
- end
- else
- ''
- end
- end
-
- private
-
- def all_input_tags(record, record_name, options)
- input_block = options[:input_block] || default_input_block
- record.class.content_columns.collect{ |column| input_block.call(record_name, column) }.join("\n")
- end
-
- def default_input_block
- Proc.new { |record, column| %(<p><label for="#{record}_#{column.name}">#{column.human_name}</label><br />#{input(record, column.name)}</p>) }
- end
-
- module InstanceTagMethods
- def to_tag(options = {})
- case column_type
- when :string
- field_type = @method_name.include?("password") ? "password" : "text"
- to_input_field_tag(field_type, options)
- when :text
- to_text_area_tag(options)
- when :integer, :float, :decimal
- to_input_field_tag("text", options)
- when :date
- to_date_select_tag(options)
- when :datetime, :timestamp
- to_datetime_select_tag(options)
- when :time
- to_time_select_tag(options)
- when :boolean
- to_boolean_select_tag(options)
- end
- end
-
- def column_type
- object.send(:column_for_attribute, @method_name).type
- end
- end
-
- module FormBuilderMethods
- def error_message_on(method, *args)
- @template.error_message_on(@object || @object_name, method, *args)
- end
-
- def error_messages(options = {})
- @template.error_messages_for(@object_name, objectify_options(options))
- end
- end
- end
-
- class InstanceTag
- include DynamicForm::InstanceTagMethods
- end
-
- class FormBuilder
- include DynamicForm::FormBuilderMethods
- end