Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: resolve/refinerycms
...
head fork: resolve/refinerycms
  • 8 commits
  • 24 files changed
  • 0 commit comments
  • 1 contributor
Showing with 495 additions and 618 deletions.
  1. +30 −3 Rakefile
  2. +1 −1  VERSION
  3. +1 −1  db/schema.rb
  4. +11 −7 public/stylesheets/refinery/application.css
  5. +0 −499 refinerycms.gemspec
  6. +2 −1  vendor/plugins/pages/app/views/admin/pages/_form.html.erb
  7. +20 −0 vendor/plugins/rails_indexes/MIT-LICENSE
  8. +46 −0 vendor/plugins/rails_indexes/README.textile
  9. +23 −0 vendor/plugins/rails_indexes/Rakefile
  10. +123 −104 vendor/plugins/{refinery → rails_indexes}/lib/indexer.rb
  11. +1 −1  vendor/plugins/{refinery/lib → rails_indexes}/tasks/indexer.rake
  12. +8 −0 vendor/plugins/rails_indexes/test/fixtures/app/controllers/users_controller.rb
  13. +5 −0 vendor/plugins/rails_indexes/test/fixtures/app/models/address.rb
  14. +11 −0 vendor/plugins/rails_indexes/test/fixtures/app/models/company.rb
  15. +4 −0 vendor/plugins/rails_indexes/test/fixtures/app/models/country.rb
  16. +3 −0  vendor/plugins/rails_indexes/test/fixtures/app/models/freelancer.rb
  17. +10 −0 vendor/plugins/rails_indexes/test/fixtures/app/models/gift.rb
  18. +3 −0  vendor/plugins/rails_indexes/test/fixtures/app/models/god.rb
  19. +16 −0 vendor/plugins/rails_indexes/test/fixtures/app/models/user.rb
  20. +9 −0 vendor/plugins/rails_indexes/test/fixtures/app/sweepers/user_sweeper.rb
  21. +46 −0 vendor/plugins/rails_indexes/test/fixtures/schema.rb
  22. +83 −0 vendor/plugins/rails_indexes/test/rails_indexes_test.rb
  23. +30 −0 vendor/plugins/rails_indexes/test/test_helper.rb
  24. +9 −1 vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb
View
33 Rakefile
@@ -1,15 +1,42 @@
# 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 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
-
+
require 'tasks/rails'
desc 'Removes trailing whitespace'
task :whitespace do
sh %{find . -name '*.*rb' -exec sed -i '' 's/\t/ /g' {} \\; -exec sed -i '' 's/ *$//g' {} \\; }
end
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |s|
+ s.name = %q{refinerycms}
+ s.description = %q{A beautiful open source Ruby on Rails content manager for small business. Easy to extend, easy to use, lightweight and all wrapped up in a super slick UI.}
+ s.summary = %q{A beautiful open source Ruby on Rails content manager for small business.}
+ s.email = %q{info@refinerycms.com}
+ s.homepage = %q{http://refinerycms.com}
+ s.authors = ["Resolve Digital", "David Jones", "Philip Arndt"]
+ s.extra_rdoc_files = %w(README CONTRIBUTORS LICENSE)
+ end
+
+ namespace :version do
+ namespace :bump do
+ desc "Bump the gemspec by a build version."
+ task :build => [:version_required, :version] do
+ version = Jeweler::VersionHelper.new(RAILS_ROOT)
+ version.update_to(version.major, version.minor, version.patch, ((version.build || 0).to_i + 1))
+ version.write
+ $stdout.puts "Updated version: #{version.to_s}"
+ end
+ end
+ end
+rescue LoadError
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
+end
View
2  VERSION
@@ -1 +1 @@
-0.0.0
+0.9.5.20
View
2  db/schema.rb
@@ -1,4 +1,4 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file,
+# 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.
#
View
18 public/stylesheets/refinery/application.css
@@ -11,31 +11,35 @@
float: right;
width: 360px;
}
-
.inquiries form label {
width: 150px;
float: left;
}
.inquiries form input {
-
+
}
.inquiries form input, .inquiries form textarea {
-
+
}
.inquiries form textarea {
-
+
}
.inquiries form .actions {
margin-left: 150px;
}
-
.inquiries form .actions input {
}
-
.inquiries .field {
margin: 12px 0px;
}
-
.inquiries form {
padding-top: 12px;
+}
+.page_not_live {
+ border: 1px solid #A00027;
+ color: #A00027;
+ background: #FFB1B1;
+ padding:3px 9px;
+ font-weight:bold;
+ width:auto;
}
View
499 refinerycms.gemspec
@@ -1,499 +0,0 @@
-Gem::Specification.new do |s|
- s.name = %q{refinerycms}
- s.version = "0.9.5.19"
-
- s.authors = ["Resolve Digital", "David Jones", "Philip Arndt"]
- s.date = %q{2009-12-01}
-
- s.description = %q{A beautiful open source Ruby on Rails content manager for small business. Easy to extend, easy to use, lightweight and all wrapped up in a super slick UI.}
- s.summary = %q{A beautiful open source Ruby on Rails content manager for small business.}
-
- s.email = %q{info@refinerycms.com}
- s.extra_rdoc_files = ["README", "CONTRIBUTORS", "LICENSE"]
- s.executables = ["refinery", "refinery-override", "refinery-update-core"]
- s.default_executable = %q{refinery}
- s.homepage = %q{http://refinerycms.com}
- s.rubygems_version = %q{1.3.4}
- s.files = [
- "CONTRIBUTORS",
- "LICENSE",
- "README",
- "Rakefile",
- "app/controllers/admin/base_controller.rb",
- "app/controllers/application.rb",
- "app/controllers/application_controller.rb",
- "app/helpers/application_helper.rb",
- "bin/refinery",
- "bin/refinery-override",
- "bin/refinery-update-core",
- "config/amazon_s3.yml",
- "config/boot.rb",
- "config/database.yml.example",
- "config/environment.rb",
- "config/environments/development.rb",
- "config/environments/production.rb",
- "config/environments/test.rb",
- "config/initializers/inflections.rb",
- "config/initializers/mime_types.rb",
- "config/preinitializer.rb",
- "config/rackspace_cloudfiles.yml",
- "config/routes.rb",
- "db/migrate/20091029034951_remove_blurb_from_news_items.rb",
- "db/migrate/20091109012126_add_missing_indexes.rb",
- "db/migrate/20091130040711_add_down_for_maintenance_page.rb",
- "db/schema.rb",
- "db/seeds.rb",
- "lib/refinery_initializer.rb",
- "public/.htaccess",
- "public/404.html",
- "public/422.html",
- "public/500.html",
- "public/favicon.ico",
- "public/images/lightbox/bullet.gif",
- "public/images/lightbox/close.gif",
- "public/images/lightbox/closelabel.gif",
- "public/images/lightbox/donate-button.gif",
- "public/images/lightbox/download-icon.gif",
- "public/images/lightbox/loading.gif",
- "public/images/lightbox/nextlabel.gif",
- "public/images/lightbox/prevlabel.gif",
- "public/images/refinery/add.gif",
- "public/images/refinery/add.png",
- "public/images/refinery/admin_bg.png",
- "public/images/refinery/ajax-loader.gif",
- "public/images/refinery/branch-end.gif",
- "public/images/refinery/branch-start.gif",
- "public/images/refinery/branch.gif",
- "public/images/refinery/cross.gif",
- "public/images/refinery/deactive-gradient.gif",
- "public/images/refinery/delete.gif",
- "public/images/refinery/drag.gif",
- "public/images/refinery/edit.gif",
- "public/images/refinery/header-background.gif",
- "public/images/refinery/header_background.png",
- "public/images/refinery/hover-gradient.jpg",
- "public/images/refinery/icons/accept.png",
- "public/images/refinery/icons/add.png",
- "public/images/refinery/icons/application_edit.png",
- "public/images/refinery/icons/application_go.png",
- "public/images/refinery/icons/arrow_left.png",
- "public/images/refinery/icons/arrow_switch.png",
- "public/images/refinery/icons/arrow_up.png",
- "public/images/refinery/icons/bin_closed.png",
- "public/images/refinery/icons/cancel.png",
- "public/images/refinery/icons/cog_add.png",
- "public/images/refinery/icons/cog_edit.png",
- "public/images/refinery/icons/cross.png",
- "public/images/refinery/icons/delete.png",
- "public/images/refinery/icons/edit.png",
- "public/images/refinery/icons/email_edit.png",
- "public/images/refinery/icons/email_go.png",
- "public/images/refinery/icons/email_open.png",
- "public/images/refinery/icons/eye.png",
- "public/images/refinery/icons/help.png",
- "public/images/refinery/icons/image_add.png",
- "public/images/refinery/icons/image_edit.png",
- "public/images/refinery/icons/layout_add.png",
- "public/images/refinery/icons/layout_edit.png",
- "public/images/refinery/icons/page_add.png",
- "public/images/refinery/icons/page_edit.png",
- "public/images/refinery/icons/page_link.png",
- "public/images/refinery/icons/page_white_edit.png",
- "public/images/refinery/icons/page_white_put.png",
- "public/images/refinery/icons/reorder.png",
- "public/images/refinery/icons/tick.png",
- "public/images/refinery/icons/user.png",
- "public/images/refinery/icons/user_add.png",
- "public/images/refinery/icons/user_comment.png",
- "public/images/refinery/icons/user_edit.png",
- "public/images/refinery/info.gif",
- "public/images/refinery/logo-large.png",
- "public/images/refinery/logo-medium.png",
- "public/images/refinery/logo-small-medium.png",
- "public/images/refinery/logo-small.png",
- "public/images/refinery/logo.png",
- "public/images/refinery/m-tools.gif",
- "public/images/refinery/magnifier.png",
- "public/images/refinery/nav-3-background.gif",
- "public/images/refinery/page_bg.png",
- "public/images/refinery/resolve-digital.gif",
- "public/images/refinery/resolve_digital_footer_logo.png",
- "public/images/refinery/search.gif",
- "public/images/refinery/shad_blcorner.png",
- "public/images/refinery/shad_bottom.png",
- "public/images/refinery/shad_brcorner.png",
- "public/images/refinery/shad_tlcorner.png",
- "public/images/refinery/shad_trcorner.png",
- "public/images/refinery/tableft.gif",
- "public/images/refinery/tabright.gif",
- "public/images/refinery/tick.gif",
- "public/images/thickbox/cross.png",
- "public/images/thickbox/loadingAnimation.gif",
- "public/images/thickbox/macFFBgHack.png",
- "public/images/wymeditor/skins/refinery/blockquote.png",
- "public/images/wymeditor/skins/refinery/center.png",
- "public/images/wymeditor/skins/refinery/css.png",
- "public/images/wymeditor/skins/refinery/h1.png",
- "public/images/wymeditor/skins/refinery/h2.png",
- "public/images/wymeditor/skins/refinery/h3.png",
- "public/images/wymeditor/skins/refinery/h4.png",
- "public/images/wymeditor/skins/refinery/h5.png",
- "public/images/wymeditor/skins/refinery/h6.png",
- "public/images/wymeditor/skins/refinery/icons.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-blockquote.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-h1.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-h2.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-h3.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-h4.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-h5.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-h6.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-p.png",
- "public/images/wymeditor/skins/refinery/iframe/lbl-pre.png",
- "public/images/wymeditor/skins/refinery/justify.png",
- "public/images/wymeditor/skins/refinery/left.png",
- "public/images/wymeditor/skins/refinery/paragraph.png",
- "public/images/wymeditor/skins/refinery/right.png",
- "public/images/wymeditor/skins/wymeditor_icon.png",
- "public/javascripts/application.js",
- "public/javascripts/builder.js",
- "public/javascripts/controls.js",
- "public/javascripts/dragdrop.js",
- "public/javascripts/effects.js",
- "public/javascripts/fastinit.js",
- "public/javascripts/jquery/GPL-LICENSE.txt",
- "public/javascripts/jquery/jquery.js",
- "public/javascripts/jquery/MIT-LICENSE.txt",
- "public/javascripts/lightbox.js",
- "public/javascripts/livepipe.js",
- "public/javascripts/prototype.js",
- "public/javascripts/refinery/admin.js",
- "public/javascripts/refinery/boot_wym.js",
- "public/javascripts/refinery/dialog.js",
- "public/javascripts/refinery/parse_url.js",
- "public/javascripts/refinery/prototype.enhancements.js",
- "public/javascripts/refinery/tooltips.js",
- "public/javascripts/scriptaculous.js",
- "public/javascripts/slider.js",
- "public/javascripts/tabs.js",
- "public/javascripts/thickbox.js",
- "public/javascripts/wymeditor/jquery.refinery.wymeditor.js",
- "public/javascripts/wymeditor/lang/ca.js",
- "public/javascripts/wymeditor/lang/cs.js",
- "public/javascripts/wymeditor/lang/de.js",
- "public/javascripts/wymeditor/lang/en.js",
- "public/javascripts/wymeditor/lang/es.js",
- "public/javascripts/wymeditor/lang/fa.js",
- "public/javascripts/wymeditor/lang/fr.js",
- "public/javascripts/wymeditor/lang/he.js",
- "public/javascripts/wymeditor/lang/hu.js",
- "public/javascripts/wymeditor/lang/it.js",
- "public/javascripts/wymeditor/lang/nb.js",
- "public/javascripts/wymeditor/lang/nl.js",
- "public/javascripts/wymeditor/lang/nn.js",
- "public/javascripts/wymeditor/lang/pl.js",
- "public/javascripts/wymeditor/lang/pt-br.js",
- "public/javascripts/wymeditor/lang/pt.js",
- "public/javascripts/wymeditor/lang/ru.js",
- "public/javascripts/wymeditor/lang/sv.js",
- "public/javascripts/wymeditor/lang/tr.js",
- "public/javascripts/wymeditor/lang/zh_cn.js",
- "public/javascripts/wymeditor/skins/refinery/skin.js",
- "public/robots.txt",
- "public/stylesheets/application.css",
- "public/stylesheets/formatting.css",
- "public/stylesheets/home.css",
- "public/stylesheets/ie6.css",
- "public/stylesheets/ie7.css",
- "public/stylesheets/lightbox.css",
- "public/stylesheets/refinery/application.css",
- "public/stylesheets/refinery/formatting.css",
- "public/stylesheets/refinery/home.css",
- "public/stylesheets/refinery/refinery.css",
- "public/stylesheets/refinery/theme.css",
- "public/stylesheets/refinery/thickbox.css",
- "public/stylesheets/refinery/tooltips.css",
- "public/stylesheets/theme.css",
- "public/stylesheets/wymeditor/skins/refinery/skin.css",
- "public/stylesheets/wymeditor/skins/refinery/wymiframe.css",
- "public/wymeditor/GPL-license.txt",
- "public/wymeditor/MIT-license.txt",
- "public/wymeditor/README",
- "script/about",
- "script/console",
- "script/dbconsole",
- "script/destroy",
- "script/generate",
- "script/performance/benchmarker",
- "script/performance/profiler",
- "script/performance/request",
- "script/plugin",
- "script/process/inspector",
- "script/process/reaper",
- "script/process/spawner",
- "script/runner",
- "script/server",
- "vendor/plugins/acts_as_indexed/CHANGELOG",
- "vendor/plugins/acts_as_indexed/init.rb",
- "vendor/plugins/acts_as_indexed/lib/acts_as_indexed.rb",
- "vendor/plugins/acts_as_indexed/lib/search_atom.rb",
- "vendor/plugins/acts_as_indexed/lib/search_index.rb",
- "vendor/plugins/acts_as_indexed/lib/will_paginate_search.rb",
- "vendor/plugins/acts_as_indexed/MIT-LICENSE",
- "vendor/plugins/acts_as_indexed/Rakefile",
- "vendor/plugins/acts_as_indexed/README.rdoc",
- "vendor/plugins/acts_as_indexed/test/abstract_unit.rb",
- "vendor/plugins/acts_as_indexed/test/acts_as_indexed_test.rb",
- "vendor/plugins/acts_as_indexed/test/database.yml",
- "vendor/plugins/acts_as_indexed/test/fixtures/post.rb",
- "vendor/plugins/acts_as_indexed/test/fixtures/posts.yml",
- "vendor/plugins/acts_as_indexed/test/schema.rb",
- "vendor/plugins/acts_as_tree/init.rb",
- "vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb",
- "vendor/plugins/acts_as_tree/Rakefile",
- "vendor/plugins/acts_as_tree/README",
- "vendor/plugins/acts_as_tree/test/abstract_unit.rb",
- "vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb",
- "vendor/plugins/acts_as_tree/test/database.yml",
- "vendor/plugins/acts_as_tree/test/fixtures/mixin.rb",
- "vendor/plugins/acts_as_tree/test/fixtures/mixins.yml",
- "vendor/plugins/acts_as_tree/test/schema.rb",
- "vendor/plugins/attachment_fu/amazon_s3.yml.tpl",
- "vendor/plugins/attachment_fu/CHANGELOG",
- "vendor/plugins/attachment_fu/init.rb",
- "vendor/plugins/attachment_fu/install.rb",
- "vendor/plugins/attachment_fu/lib/geometry.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/cloud_file_backend.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/core_image_processor.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/gd2_processor.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb",
- "vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb",
- "vendor/plugins/attachment_fu/LICENSE",
- "vendor/plugins/attachment_fu/rackspace_cloudfiles.yml.tpl",
- "vendor/plugins/attachment_fu/Rakefile",
- "vendor/plugins/attachment_fu/README",
- "vendor/plugins/attachment_fu/test/backends/db_file_test.rb",
- "vendor/plugins/attachment_fu/test/backends/file_system_test.rb",
- "vendor/plugins/attachment_fu/test/backends/remote/cloudfiles_test.rb",
- "vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb",
- "vendor/plugins/attachment_fu/test/base_attachment_tests.rb",
- "vendor/plugins/attachment_fu/test/basic_test.rb",
- "vendor/plugins/attachment_fu/test/database.yml",
- "vendor/plugins/attachment_fu/test/extra_attachment_test.rb",
- "vendor/plugins/attachment_fu/test/fixtures/attachment.rb",
- "vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png",
- "vendor/plugins/attachment_fu/test/fixtures/files/foo.txt",
- "vendor/plugins/attachment_fu/test/fixtures/files/rails.png",
- "vendor/plugins/attachment_fu/test/geometry_test.rb",
- "vendor/plugins/attachment_fu/test/processors/core_image_test.rb",
- "vendor/plugins/attachment_fu/test/processors/gd2_test.rb",
- "vendor/plugins/attachment_fu/test/processors/image_science_test.rb",
- "vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb",
- "vendor/plugins/attachment_fu/test/processors/rmagick_test.rb",
- "vendor/plugins/attachment_fu/test/schema.rb",
- "vendor/plugins/attachment_fu/test/test_helper.rb",
- "vendor/plugins/attachment_fu/test/validation_test.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/color.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/effects.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/perspective.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/quality.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/scale.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/watermark.rb",
- "vendor/plugins/attachment_fu/vendor/red_artisan/core_image/processor.rb",
- "vendor/plugins/authentication/app/controllers/admin/users_controller.rb",
- "vendor/plugins/authentication/app/controllers/sessions_controller.rb",
- "vendor/plugins/authentication/app/controllers/users_controller.rb",
- "vendor/plugins/authentication/app/helpers/sessions_helper.rb",
- "vendor/plugins/authentication/app/helpers/users_helper.rb",
- "vendor/plugins/authentication/app/models/user.rb",
- "vendor/plugins/authentication/app/models/user_mailer.rb",
- "vendor/plugins/authentication/app/models/user_observer.rb",
- "vendor/plugins/authentication/app/models/user_plugin.rb",
- "vendor/plugins/authentication/app/views/admin/users/_form.html.erb",
- "vendor/plugins/authentication/app/views/admin/users/edit.html.erb",
- "vendor/plugins/authentication/app/views/admin/users/index.html.erb",
- "vendor/plugins/authentication/app/views/admin/users/new.html.erb",
- "vendor/plugins/authentication/app/views/sessions/new.html.erb",
- "vendor/plugins/authentication/app/views/user_mailer/activation.html.erb",
- "vendor/plugins/authentication/app/views/user_mailer/signup_notification.html.erb",
- "vendor/plugins/authentication/app/views/users/new.html.erb",
- "vendor/plugins/authentication/config/routes.rb",
- "vendor/plugins/authentication/rails/init.rb",
- "vendor/plugins/authentication/lib/authenticated_system.rb",
- "vendor/plugins/authentication/lib/authenticated_test_helper.rb",
- "vendor/plugins/authentication/Rakefile",
- "vendor/plugins/authentication/README",
- "vendor/plugins/authentication/test/fixtures/users.yml",
- "vendor/plugins/authentication/test/functional/admin/base_controller_test.rb",
- "vendor/plugins/authentication/test/functional/admin/dashboard_controller_test.rb",
- "vendor/plugins/authentication/test/functional/admin/pages_controller_test.rb",
- "vendor/plugins/authentication/test/functional/sessions_controller_test.rb",
- "vendor/plugins/authentication/test/functional/users_controller_test.rb",
- "vendor/plugins/authentication/test/test_helper.rb",
- "vendor/plugins/authentication/test/unit/user_mailer_test.rb",
- "vendor/plugins/authentication/test/unit/user_test.rb",
- "vendor/plugins/dashboard/app/controllers/admin/dashboard_controller.rb",
- "vendor/plugins/dashboard/app/helpers/admin/dashboard_helper.rb",
- "vendor/plugins/dashboard/app/views/admin/dashboard/_recent_activity.html.erb",
- "vendor/plugins/dashboard/app/views/admin/dashboard/index.html.erb",
- "vendor/plugins/dashboard/config/routes.rb",
- "vendor/plugins/dashboard/rails/init.rb",
- "vendor/plugins/images/app/controllers/admin/images_controller.rb",
- "vendor/plugins/images/app/helpers/admin/images_helper.rb",
- "vendor/plugins/images/app/models/image.rb",
- "vendor/plugins/images/app/views/admin/images/_form.html.erb",
- "vendor/plugins/images/app/views/admin/images/_grid_view.html.erb",
- "vendor/plugins/images/app/views/admin/images/_list_view.html.erb",
- "vendor/plugins/images/app/views/admin/images/_list_view_image.html.erb",
- "vendor/plugins/images/app/views/admin/images/edit.html.erb",
- "vendor/plugins/images/app/views/admin/images/index.html.erb",
- "vendor/plugins/images/app/views/admin/images/insert.html.erb",
- "vendor/plugins/images/app/views/admin/images/new.html.erb",
- "vendor/plugins/images/config/routes.rb",
- "vendor/plugins/images/rails/init.rb",
- "vendor/plugins/images/lib/tasks/images.rake",
- "vendor/plugins/inquiries/app/controllers/admin/inquiries_controller.rb",
- "vendor/plugins/inquiries/app/controllers/admin/inquiry_settings_controller.rb",
- "vendor/plugins/inquiries/app/controllers/inquiries_controller.rb",
- "vendor/plugins/inquiries/app/helpers/inquiries_helper.rb",
- "vendor/plugins/inquiries/app/models/inquiry.rb",
- "vendor/plugins/inquiries/app/models/inquiry_mailer.rb",
- "vendor/plugins/inquiries/app/models/inquiry_setting.rb",
- "vendor/plugins/inquiries/app/views/admin/inquiries/_inquiry.html.erb",
- "vendor/plugins/inquiries/app/views/admin/inquiries/index.html.erb",
- "vendor/plugins/inquiries/app/views/admin/inquiries/show.html.erb",
- "vendor/plugins/inquiries/app/views/admin/inquiry_settings/_confirmation_email_form.html.erb",
- "vendor/plugins/inquiries/app/views/admin/inquiry_settings/_notification_recipients_form.html.erb",
- "vendor/plugins/inquiries/app/views/admin/inquiry_settings/edit.html.erb",
- "vendor/plugins/inquiries/app/views/admin/inquiry_settings/index.html.erb",
- "vendor/plugins/inquiries/app/views/inquiries/new.html.erb",
- "vendor/plugins/inquiries/app/views/inquiries/thank_you.html.erb",
- "vendor/plugins/inquiries/app/views/inquiry_mailer/confirmation.html.erb",
- "vendor/plugins/inquiries/app/views/inquiry_mailer/notification.html.erb",
- "vendor/plugins/inquiries/config/routes.rb",
- "vendor/plugins/inquiries/rails/init.rb",
- "vendor/plugins/news/app/controllers/admin/news_items_controller.rb",
- "vendor/plugins/news/app/controllers/news_items_controller.rb",
- "vendor/plugins/news/app/models/news_item.rb",
- "vendor/plugins/news/app/views/admin/news_items/_form.html.erb",
- "vendor/plugins/news/app/views/admin/news_items/_news_item.html.erb",
- "vendor/plugins/news/app/views/admin/news_items/edit.html.erb",
- "vendor/plugins/news/app/views/admin/news_items/index.html.erb",
- "vendor/plugins/news/app/views/admin/news_items/new.html.erb",
- "vendor/plugins/news/app/views/news_items/_recent_posts.html.erb",
- "vendor/plugins/news/app/views/news_items/index.html.erb",
- "vendor/plugins/news/app/views/news_items/show.html.erb",
- "vendor/plugins/news/config/routes.rb",
- "vendor/plugins/news/rails/init.rb",
- "vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb",
- "vendor/plugins/pages/app/controllers/admin/page_parts_controller.rb",
- "vendor/plugins/pages/app/controllers/admin/pages_controller.rb",
- "vendor/plugins/pages/app/controllers/pages_controller.rb",
- "vendor/plugins/pages/app/helpers/pages_helper.rb",
- "vendor/plugins/pages/app/models/page.rb",
- "vendor/plugins/pages/app/models/page_part.rb",
- "vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb",
- "vendor/plugins/pages/app/views/admin/page_dialogs/link_to.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/_form.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/_list.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/_page_part_field.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/_sortable_list.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/edit.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/index.html.erb",
- "vendor/plugins/pages/app/views/admin/pages/new.html.erb",
- "vendor/plugins/pages/app/views/pages/home.html.erb",
- "vendor/plugins/pages/app/views/pages/show.html.erb",
- "vendor/plugins/pages/config/routes.rb",
- "vendor/plugins/pages/rails/init.rb",
- "vendor/plugins/refinery/app/controllers/admin/refinery_core_controller.rb",
- "vendor/plugins/refinery/app/views/admin/_head.html.erb",
- "vendor/plugins/refinery/app/views/admin/_menu.html.erb",
- "vendor/plugins/refinery/app/views/layouts/admin.html.erb",
- "vendor/plugins/refinery/app/views/layouts/application.html.erb",
- "vendor/plugins/refinery/app/views/shared/_content_page.html.erb",
- "vendor/plugins/refinery/app/views/shared/_footer.html.erb",
- "vendor/plugins/refinery/app/views/shared/_google_analytics.html.erb",
- "vendor/plugins/refinery/app/views/shared/_header.html.erb",
- "vendor/plugins/refinery/app/views/shared/_ie6check.html.erb",
- "vendor/plugins/refinery/app/views/shared/_menu.html.erb",
- "vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb",
- "vendor/plugins/refinery/app/views/shared/_message.html.erb",
- "vendor/plugins/refinery/app/views/shared/_submenu.html.erb",
- "vendor/plugins/refinery/app/views/shared/_submenu_branch.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_continue_editing.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_error_messages_for.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_form_actions.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_make_sortable.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_search.html.erb",
- "vendor/plugins/refinery/app/views/shared/admin/_sortable_list.html.erb",
- "vendor/plugins/refinery/app/views/welcome.html.erb",
- "vendor/plugins/refinery/app/views/wymiframe.html.erb",
- "vendor/plugins/refinery/config/routes.rb",
- "vendor/plugins/refinery/rails/init.rb",
- "vendor/plugins/refinery/lib/crud.rb",
- "vendor/plugins/refinery/lib/generators/refinery/install.rb",
- "vendor/plugins/refinery/lib/generators/refinery/Rakefile",
- "vendor/plugins/refinery/lib/generators/refinery/README",
- "vendor/plugins/refinery/lib/generators/refinery/refinery_generator.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/config/routes.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/controller.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/rails/init.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/migration.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/model.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/public_controller.rb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_form.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_singular_name.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_sortable_list.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/edit.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/index.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/new.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/index.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/templates/views/show.html.erb",
- "vendor/plugins/refinery/lib/generators/refinery/USAGE",
- "vendor/plugins/refinery/lib/indexer.rb",
- "vendor/plugins/refinery/lib/refinery/activity.rb",
- "vendor/plugins/refinery/lib/refinery/admin_base_controller.rb",
- "vendor/plugins/refinery/lib/refinery/application_controller.rb",
- "vendor/plugins/refinery/lib/refinery/application_helper.rb",
- "vendor/plugins/refinery/lib/refinery/form_helpers.rb",
- "vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb",
- "vendor/plugins/refinery/lib/refinery/initializer.rb",
- "vendor/plugins/refinery/lib/refinery/link_renderer.rb",
- "vendor/plugins/refinery/lib/refinery/plugin.rb",
- "vendor/plugins/refinery/lib/refinery/plugins.rb",
- "vendor/plugins/refinery/lib/refinery.rb",
- "vendor/plugins/refinery/lib/tasks/indexer.rake",
- "vendor/plugins/refinery/lib/tasks/refinery.rake",
- "vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb",
- "vendor/plugins/refinery_dialogs/app/views/admin/dialogs/show.html.erb",
- "vendor/plugins/refinery_dialogs/app/views/layouts/admin_dialog.html.erb",
- "vendor/plugins/refinery_dialogs/config/routes.rb",
- "vendor/plugins/refinery_dialogs/rails/init.rb",
- "vendor/plugins/refinery_settings/app/controllers/admin/refinery_settings_controller.rb",
- "vendor/plugins/refinery_settings/app/models/refinery_setting.rb",
- "vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_form.html.erb",
- "vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_make_sortable.html.erb",
- "vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_refinery_setting.html.erb",
- "vendor/plugins/refinery_settings/app/views/admin/refinery_settings/edit.html.erb",
- "vendor/plugins/refinery_settings/app/views/admin/refinery_settings/index.html.erb",
- "vendor/plugins/refinery_settings/app/views/admin/refinery_settings/new.html.erb",
- "vendor/plugins/refinery_settings/config/routes.rb",
- "vendor/plugins/refinery_settings/rails/init.rb",
- "vendor/plugins/resources/app/controllers/admin/resources_controller.rb",
- "vendor/plugins/resources/app/models/resource.rb",
- "vendor/plugins/resources/app/views/admin/resources/_form.html.erb",
- "vendor/plugins/resources/app/views/admin/resources/_resource.html.erb",
- "vendor/plugins/resources/app/views/admin/resources/edit.html.erb",
- "vendor/plugins/resources/app/views/admin/resources/index.html.erb",
- "vendor/plugins/resources/app/views/admin/resources/insert.html.erb",
- "vendor/plugins/resources/app/views/admin/resources/new.html.erb",
- "vendor/plugins/resources/config/routes.rb",
- "vendor/plugins/resources/rails/init.rb"
- ]
-end
View
3  vendor/plugins/pages/app/views/admin/pages/_form.html.erb
@@ -60,7 +60,8 @@
{
:f => f,
:field => :custom_title_image_id,
- :image => @page.custom_title_image
+ :image => @page.custom_title_image,
+ :toggle_image_display => false
}
%>
</div>
View
20 vendor/plugins/rails_indexes/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 [name of plugin creator]
+
+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
46 vendor/plugins/rails_indexes/README.textile
@@ -0,0 +1,46 @@
+h1. Rails Indexes
+
+Rails indexes is a small package of 2 rake tasks that scan your application models and displays a list of columns that _probably_ should be indexed.
+
+note: there should be mode fields depending on your application design and custom queries.
+
+h2. Installation
+
+as a rails plugin:
+<pre>script/plugin install git://github.com/eladmeidar/rails_indexes.git</pre>
+
+h2. Usage
+
+<del>Display a simple report:</del>
+<pre><del>rake db:show_me_some_indexes</del></pre>
+ - *deprecated*
+
+Display a migration for adding/removing all necessary indexes based on associations:
+<pre>rake db:show_me_a_migration</pre>
+
+Display a migration for adding/removing all necessary indexes based on AR::Base#find calls (including: find, find_by, find_all_by, find_by_x_and_y, find_all_by_x_and_y):
+<pre>rake db:show_me_ar_find_indexes</pre>
+
+Note that it would probably make more sense running those tasks on production, where you *actually* need those indexes to be added.
+
+* Add an option to create a migration that adds all the needed indexes.
+* Add an option to scan the application root tree for #find, #find_all_by and #find_by to get some more index-required columns.
+
+h2. Tests
+
+Requires SQLite3 installed, then just:
+<pre>rake</pre>
+to run the tests
+
+h4. Author:
+
+Elad Meidar
+"http://blog.eizesus.com":http://blog.eizesus.com
+
+Thanks:
+Eric Davis,
+"http://littlestreamsoftware.com":http://littlestreamsoftware.com
+
+Released under the same license as Ruby. No Support. No Warranty, no Pain.
+
+
View
23 vendor/plugins/rails_indexes/Rakefile
@@ -0,0 +1,23 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Testing the rails indexes plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the rails_indexes plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'RailsIndexes'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
227 vendor/plugins/refinery/lib/indexer.rb → vendor/plugins/rails_indexes/lib/indexer.rb
@@ -1,16 +1,15 @@
module Indexer
-
-
+
def self.sortalize(array)
Marshal.load(Marshal.dump(array)).each do |element|
element.sort! if element.is_a?(Array)
end
end
-
+
def self.check_for_indexes(migration_format = false)
model_names = []
- Dir.chdir(Rails.root) do
- model_names = Dir["**/app/models/*.rb"].collect {|filename| File.basename(filename) }.uniq
+ Dir.chdir(Rails.root) do
+ model_names = Dir["**/app/models/**/*.rb"].collect {|filename| File.basename(filename) }.uniq
end
model_classes = []
@@ -25,58 +24,45 @@ def self.check_for_indexes(migration_format = false)
# No-op
end
end
- puts "Found #{model_classes.size} Models"
-
- @indexes_required = Hash.new([])
+
@index_migrations = Hash.new([])
model_classes.each do |class_name|
- # check if this is an STI child instance
+ # check if this is an STI child instance
if class_name.base_class.name != class_name.name && (class_name.column_names.include?(class_name.base_class.inheritance_column) || class_name.column_names.include?(class_name.inheritance_column))
+
# add the inharitance column on the parent table
- if !(migration_format)
- @indexes_required[class_name.base_class.table_name] += [class_name.inheritance_column].sort unless @indexes_required[class_name.base_class.table_name].include?([class_name.inheritance_column].sort)
- else
- # index migration for STI should require both the primary key and the inheritance_column in a composite index.
- @index_migrations[class_name.base_class.table_name] += [[class_name.inheritance_column, class_name.base_class.primary_key].sort] unless @index_migrations[class_name.base_class.table_name].include?([class_name.base_class.inheritance_column].sort)
- end
+ # index migration for STI should require both the primary key and the inheritance_column in a composite index.
+ @index_migrations[class_name.base_class.table_name] += [[class_name.inheritance_column, class_name.base_class.primary_key].sort] unless @index_migrations[class_name.base_class.table_name].include?([class_name.base_class.inheritance_column].sort)
end
-
+ #puts "class name: #{class_name}"
class_name.reflections.each_pair do |reflection_name, reflection_options|
+ #puts "reflection => #{reflection_name}"
case reflection_options.macro
when :belongs_to
# polymorphic?
- @table_name = class_name.table_name.to_s #(reflection_options.options.has_key?(:class_name) ? reflection_options.options[:class_name].constantize.table_name : )
+ @table_name = class_name.table_name.to_s
if reflection_options.options.has_key?(:polymorphic) && (reflection_options.options[:polymorphic] == true)
poly_type = "#{reflection_options.name.to_s}_type"
poly_id = "#{reflection_options.name.to_s}_id"
- if !(migration_format)
- @indexes_required[@table_name.to_s] += [poly_type, poly_id].sort unless @indexes_required[@table_name.to_s].include?([poly_type, poly_id].sort)
- else
-
- @index_migrations[@table_name.to_s] += [[poly_type, poly_id].sort] unless @index_migrations[@table_name.to_s].include?([poly_type, poly_id].sort)
- end
+
+ @index_migrations[@table_name.to_s] += [[poly_type, poly_id].sort] unless @index_migrations[@table_name.to_s].include?([poly_type, poly_id].sort)
else
foreign_key = reflection_options.options[:foreign_key] ||= reflection_options.primary_key_name
-
- if !(migration_format)
- @indexes_required[@table_name.to_s] += [foreign_key] unless @indexes_required[@table_name.to_s].include?(foreign_key)
- else
@index_migrations[@table_name.to_s] += [foreign_key] unless @index_migrations[@table_name.to_s].include?(foreign_key)
- end
end
when :has_and_belongs_to_many
table_name = reflection_options.options[:join_table] ||= [class_name.table_name, reflection_name.to_s].sort.join('_')
association_foreign_key = reflection_options.options[:association_foreign_key] ||= "#{reflection_name.to_s.singularize}_id"
foreign_key = reflection_options.options[:foreign_key] ||= "#{class_name.name.tableize.singularize}_id"
+
+ composite_keys = [association_foreign_key, foreign_key]
+
+ @index_migrations[table_name.to_s] += [composite_keys] unless @index_migrations[table_name].include?(composite_keys)
+ @index_migrations[table_name.to_s] += [composite_keys.reverse] unless @index_migrations[table_name].include?(composite_keys.reverse)
- if !(migration_format)
- @indexes_required[table_name.to_s] += [association_foreign_key, foreign_key].sort unless @indexes_required[table_name].include?([association_foreign_key, foreign_key].sort)
- else
- @index_migrations[table_name.to_s] += [[association_foreign_key, foreign_key].sort] unless @index_migrations[table_name].include?([association_foreign_key, foreign_key].sort)
- end
else
#nothing
end
@@ -84,60 +70,79 @@ def self.check_for_indexes(migration_format = false)
end
@missing_indexes = {}
- @indexes_required.each do |table_name, foreign_keys|
+
+ @index_migrations.each do |table_name, foreign_keys|
unless foreign_keys.blank?
- existing_indexes = ActiveRecord::Base.connection.indexes(table_name.to_sym).collect(&:columns)
- keys_to_add = self.sortalize(foreign_keys.uniq) - self.sortalize(existing_indexes)
+ existing_indexes = ActiveRecord::Base.connection.indexes(table_name.to_sym).collect {|index| index.columns.size > 1 ? index.columns : index.columns.first}
+ keys_to_add = foreign_keys.uniq - existing_indexes #self.sortalize(foreign_keys.uniq) - self.sortalize(existing_indexes)
@missing_indexes[table_name] = keys_to_add unless keys_to_add.empty?
end
end
- if !(migration_format)
- @missing_indexes
- else
- @index_migrations
- end
+
+ @missing_indexes
end
def self.scan_finds
file_names = []
- Dir.chdir(Rails.root) do
+
+ Dir.chdir(Rails.root) do
file_names = Dir["**/app/**/*.rb"].uniq.reject {|file_with_path| file_with_path.include?('test')}
end
- puts "Found #{file_names.size} files."
-
@indexes_required = Hash.new([])
- file_names.each do |file_name|
+ file_names.each do |file_name|
current_file = File.open(File.join(Rails.root, file_name), 'r')
current_file.each do |line|
- find_regexp = Regexp.new(/([A-Z]{1}[A-Za-z]+).(find){1}((_all){0,1}(_by_){0,1}([A-Za-z_]+))?\(([0-9A-Za-z"\':=>. \[\]{},]*)\)/)
+
+ # by default, try to add index on primary key, based on file name
+ # this will fail if the file isnot a model file
+
+ begin
+ current_model_name = File.basename(file_name).sub(/\.rb$/,'').camelize
+ rescue
+ # NO-OP
+ end
+
+ klass = current_model_name.split('::').inject(Object){ |klass,part| klass.const_get(part) } rescue nil
+ if klass.present? && klass < ActiveRecord::Base && !klass.abstract_class?
+ current_model = current_model_name.constantize
+ primary_key = current_model.primary_key
+ table_name = current_model.table_name
+ @indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
+ end
+
+ find_regexp = Regexp.new(/([A-Z]{1}[A-Za-z]+|self).(find){1}((_all){0,1}(_by_){0,1}([A-Za-z_]+))?\(([0-9A-Za-z"\':=>. \[\]{},]*)\)/)
if matches = find_regexp.match(line)
model_name, column_names, options = matches[1], matches[6], matches[7]
- # puts "Model: #{model_name}, columns: #{column_names}, options: #{options}"
-
- if model_name.respond_to?(:constantize)
- if model_name.constantize.respond_to?(:table_name)
- table_name = model_name.constantize.table_name
+
+ if model_name == "self"
+ model_name = File.basename(file_name).sub(/\.rb$/,'').camelize
+ table_name = model_name.constantize.table_name
+ else
+ if model_name.respond_to?(:constantize)
+ if model_name.constantize.respond_to?(:table_name)
+ table_name = model_name.constantize.table_name
+ else
+ #puts "Unable to get the table_name for #{model_name.to_s}. it could be an ActiveResource"
+ next
+ end
else
- puts "Unable to get the table_name for #{model_name.to_s}. it could be an ActiveResource"
+ #puts "Unable to constantize #{model_name.to_s}, if you are sure that #{model_name.to_s} is a valid class name, please file an issue on\nhttp://github.com/eladmeidar/rails_indexes\nPlease supply the relevant code as well, thanks. =)"
next
end
- else
- puts "Unable to constantize #{model_name.to_s}, if you are sure that #{model_name.to_s} is a valid class name, please file an issue on\nhttp://github.com/eladmeidar/rails_indexes\nPlease supply the relevant code as well, thanks. =)"
- next
end
-
- if column_names.blank?
- primary_key = model_name.constantize.primary_key
- @indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
- else
+
+ primary_key = model_name.constantize.primary_key
+ @indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
+
+ if column_names.present?
column_names = column_names.split('_and_')
# remove find_by_sql references.
- # column_names.delete("sql")
+ column_names.delete("sql")
column_names = model_name.constantize.column_names & column_names
@@ -146,30 +151,40 @@ def self.scan_finds
column_name = column_names.first
@indexes_required[table_name] += [column_name] unless @indexes_required[table_name].include?(column_name)
else
- @indexes_required[table_name] += [column_names.sort] unless @indexes_required[table_name].include?(column_names.sort)
+ @indexes_required[table_name] += [column_names] unless @indexes_required[table_name].include?(column_names)
+ @indexes_required[table_name] += [column_names.reverse] unless @indexes_required[table_name].include?(column_names.reverse)
end
end
end
end
end
+
@missing_indexes = {}
@indexes_required.each do |table_name, foreign_keys|
- unless foreign_keys.blank?
- existing_indexes = ActiveRecord::Base.connection.indexes(table_name.to_sym).collect(&:columns)
- keys_to_add = self.sortalize(foreign_keys.uniq) - self.sortalize(existing_indexes)
- @missing_indexes[table_name] = keys_to_add unless keys_to_add.empty?
+ unless foreign_keys.blank?
+ begin
+ if ActiveRecord::Base.connection.tables.include?(table_name.to_s)
+ existing_indexes = ActiveRecord::Base.connection.indexes(table_name.to_sym).collect {|index| index.columns.size > 1 ? index.columns : index.columns.first}
+ keys_to_add = self.sortalize(foreign_keys.uniq) - self.sortalize(existing_indexes)
+ @missing_indexes[table_name] = keys_to_add unless keys_to_add.empty?
+ else
+ puts "BUG: table '#{table_name.to_s}' does not exist, please report this bug."
+ end
+ rescue Exception => e
+ puts "ERROR: #{e}"
+ end
end
end
-
+
@indexes_required
end
-
- def self.key_exists?(table,key_columns)
+
+ def self.key_exists?(table,key_columns)
result = (key_columns.to_a - ActiveRecord::Base.connection.indexes(table).map { |i| i.columns }.flatten)
result.empty?
end
-
+
def self.simple_migration
migration_format = true
missing_indexes = check_for_indexes(migration_format)
@@ -189,14 +204,14 @@ def self.simple_migration
add << "add_index :#{table_name}, :#{key}"
remove << "remove_index :#{table_name}, :#{key}"
end
-
+
end
end
-
- migration = <<EOM
+
+ migration = <<EOM
class AddMissingIndexes < ActiveRecord::Migration
def self.up
-
+
# These indexes were found by searching for AR::Base finds on your application
# It is strongly recommanded that you will consult a professional DBA about your infrastucture and implemntation before
# changing your database in that matter.
@@ -207,10 +222,10 @@ def self.up
# http://www.railstutor.org
# http://guides.rubyonrails.org
-
+
#{add.uniq.join("\n ")}
end
-
+
def self.down
#{remove.uniq.join("\n ")}
end
@@ -221,39 +236,40 @@ def self.down
puts migration
end
end
-
+
def self.indexes_list
check_for_indexes.each do |table_name, keys_to_add|
puts "Table '#{table_name}' => #{keys_to_add.to_sentence}"
end
end
-
- def self.ar_find_indexes
+
+ def self.ar_find_indexes(migration_mode=true)
find_indexes = self.scan_finds
-
- unless find_indexes.keys.empty?
- add = []
- remove = []
- find_indexes.each do |table_name, keys_to_add|
- keys_to_add.each do |key|
- next if key_exists?(table_name,key)
- next if key.blank?
- if key.is_a?(Array)
- keys = key.collect {|k| ":#{k}"}
- add << "add_index :#{table_name}, [#{keys.join(', ')}]"
- remove << "remove_index :#{table_name}, :column => [#{keys.join(', ')}]"
- else
- add << "add_index :#{table_name}, :#{key}"
- remove << "remove_index :#{table_name}, :#{key}"
+
+ if migration_mode
+ unless find_indexes.keys.empty?
+ add = []
+ remove = []
+ find_indexes.each do |table_name, keys_to_add|
+ keys_to_add.each do |key|
+ next if key_exists?(table_name,key)
+ next if key.blank?
+ if key.is_a?(Array)
+ keys = key.collect {|k| ":#{k}"}
+ add << "add_index :#{table_name}, [#{keys.join(', ')}]"
+ remove << "remove_index :#{table_name}, :column => [#{keys.join(', ')}]"
+ else
+ add << "add_index :#{table_name}, :#{key}"
+ remove << "remove_index :#{table_name}, :#{key}"
+ end
+
end
-
end
- end
-
- migration = <<EOM
+
+ migration = <<EOM
class AddFindsMissingIndexes < ActiveRecord::Migration
def self.up
-
+
# These indexes were found by searching for AR::Base finds on your application
# It is strongly recommanded that you will consult a professional DBA about your infrastucture and implemntation before
# changing your database in that matter.
@@ -263,7 +279,7 @@ def self.up
# http://www.railsmentors.org
# http://www.railstutor.org
# http://guides.rubyonrails.org
-
+
#{add.uniq.join("\n ")}
end
@@ -272,9 +288,12 @@ def self.down
end
end
EOM
-
- puts "## Drop this into a file in db/migrate ##"
- puts migration
+
+ puts "## Drop this into a file in db/migrate ##"
+ puts migration
+ end
end
+ else
+ find_indexes
end
-end
+end
View
2  ...r/plugins/refinery/lib/tasks/indexer.rake → .../plugins/rails_indexes/tasks/indexer.rake
@@ -1,4 +1,4 @@
-require File.join(REFINERY_ROOT, %w(vendor plugins refinery lib indexer.rb))
+require File.join(File.dirname(__FILE__), "../lib/indexer.rb")
namespace :db do
desc "collect indexes based on AR::Base.find calls."
View
8 vendor/plugins/rails_indexes/test/fixtures/app/controllers/users_controller.rb
@@ -0,0 +1,8 @@
+class UsersController < ActionController::Base
+
+
+ def index
+ @freelancer = Freelancer.find_all_by_name(param[:name])
+ @user = User.find(1)
+ end
+end
View
5 vendor/plugins/rails_indexes/test/fixtures/app/models/address.rb
@@ -0,0 +1,5 @@
+class Address < ActiveRecord::Base
+
+ belongs_to :addressable, :polymorphic => true
+ belongs_to :country
+end
View
11 vendor/plugins/rails_indexes/test/fixtures/app/models/company.rb
@@ -0,0 +1,11 @@
+class Company < ActiveRecord::Base
+
+ belongs_to :owner, :foreign_key => 'owner_id', :class_name => 'User'
+ belongs_to :country
+
+ has_one :address, :as => :addressable
+
+ has_many :users
+
+ has_and_belongs_to_many :freelancers
+end
View
4 vendor/plugins/rails_indexes/test/fixtures/app/models/country.rb
@@ -0,0 +1,4 @@
+class Country < ActiveRecord::Base
+ has_many :addresses
+ has_many :companies
+end
View
3  vendor/plugins/rails_indexes/test/fixtures/app/models/freelancer.rb
@@ -0,0 +1,3 @@
+class Freelancer < ActiveRecord::Base
+ has_and_belongs_to_many :companies
+end
View
10 vendor/plugins/rails_indexes/test/fixtures/app/models/gift.rb
@@ -0,0 +1,10 @@
+class Gift < ActiveRecord::Base
+
+ set_primary_key :custom_primary_key
+ has_and_belongs_to_many :users, :join_table => "purchases", :association_foreign_key => 'buyer_id', :foreign_key => 'present_id'
+
+ def search_all(name, price)
+ Gift.find_all_by_name_and_price(name, price)
+ end
+
+end
View
3  vendor/plugins/rails_indexes/test/fixtures/app/models/god.rb
@@ -0,0 +1,3 @@
+class God < ActiveRecord::Base
+ self.abstract_class = true
+end
View
16 vendor/plugins/rails_indexes/test/fixtures/app/models/user.rb
@@ -0,0 +1,16 @@
+class User < ActiveRecord::Base
+
+ has_one :company, :foreign_key => 'owner_id'
+ has_one :address, :as => :addressable
+
+ has_and_belongs_to_many :users, :join_table => "purchases", :association_foreign_key => 'present_id', :foreign_key => 'buyer_id'
+
+
+ def search_via_email(email = "user@domain.com")
+ self.find_by_email(email)
+ end
+
+ def search_via_email_and_name(email, name)
+ self.find_by_email_and_name(email, name)
+ end
+end
View
9 vendor/plugins/rails_indexes/test/fixtures/app/sweepers/user_sweeper.rb
@@ -0,0 +1,9 @@
+class UserSweeper < ActionController::Caching::Sweeper
+ # This sweeper is going to keep an eye on the Product model
+ observe User
+
+ # If our sweeper detects that a Product was created call this
+ def after_create(product)
+ logger.info "Sweeped!"
+ end
+end
View
46 vendor/plugins/rails_indexes/test/fixtures/schema.rb
@@ -0,0 +1,46 @@
+ActiveRecord::Schema.define do
+ create_table "users", :force => true do |t|
+ t.column "name", :text
+ t.column "email", :text
+ end
+
+ create_table "companies", :force => true do |t|
+ t.column "name", :text
+ t.column "owned_id", :integer
+ t.column "country_id", :integer
+ end
+
+ add_index :companies, :country_id
+
+ create_table "addresses", :force => true do |t|
+ t.column "addressable_type", :string
+ t.column "addressable_id", :integer
+ t.column "address", :text
+ t.column "country_id", :integer
+ end
+
+ create_table "freelancers", :force => true do |t|
+ t.column "name", :string
+ t.column "price_per_hour", :integer
+ end
+
+ create_table "companies_freelancers", :force => true do |t|
+ t.column "freelancer_id", :integer
+ t.column "company_id", :integer
+ end
+
+ create_table "gifts", :force => true do |t|
+ t.column "custom_primary_key", :integer
+ t.column "name", :string
+ t.column "price", :integer
+ end
+
+ create_table "purchases", :force => true do |t|
+ t.column "present_id", :integer
+ t.column "buyer_id", :integer
+ end
+
+ create_table "countries", :force => true do |t|
+ t.column "name", :string
+ end
+end
View
83 vendor/plugins/rails_indexes/test/rails_indexes_test.rb
@@ -0,0 +1,83 @@
+require 'test_helper'
+
+class RailsIndexesTest < ActiveSupport::TestCase
+
+ test "relationship indexes are found" do
+ @relationship_indexes = Indexer.check_for_indexes
+
+ assert @relationship_indexes.size > 0
+
+ assert @relationship_indexes.has_key?("companies")
+ assert @relationship_indexes.has_key?("companies_freelancers")
+ assert @relationship_indexes.has_key?("addresses")
+ assert @relationship_indexes.has_key?("purchases")
+ end
+
+ # should add 2 composite indexes or each pair
+ test "has_and_belongs_to_many" do
+ @relationship_indexes = Indexer.check_for_indexes(true)
+
+ assert @relationship_indexes["companies_freelancers"].include?(["company_id", "freelancer_id"])
+ assert @relationship_indexes["companies_freelancers"].include?(["freelancer_id", "company_id"])
+ end
+
+ test "has_and_belongs_to_many with custom columns" do
+ @relationship_indexes = Indexer.check_for_indexes(true)
+
+ assert @relationship_indexes["purchases"].include?(["present_id", "buyer_id"])
+ assert @relationship_indexes["purchases"].include?(["buyer_id", "present_id"])
+ end
+
+ test "belongs_to" do
+ @relationship_indexes = Indexer.check_for_indexes(true)
+ assert @relationship_indexes["addresses"].include?("country_id")
+ end
+
+ test "belongs_to with a custom foreign key" do
+ @relationship_indexes = Indexer.check_for_indexes(true)
+ assert @relationship_indexes["companies"].include?("owner_id")
+ end
+
+ test "should not add an already existing index" do
+ @relationship_indexes = Indexer.check_for_indexes(true)
+ assert !(@relationship_indexes["companies"].include?("country_id"))
+ end
+
+ test "default find_by indexes for primary keys" do
+ @find_by_indexes = Indexer.ar_find_indexes(false)
+
+ # Default added the primary key for each table
+ assert @find_by_indexes.has_key?("users")
+ assert @find_by_indexes.has_key?("companies")
+ assert @find_by_indexes.has_key?("gifts")
+ assert @find_by_indexes.has_key?("freelancers")
+ assert @find_by_indexes.has_key?("countries")
+ end
+
+ test "default find_by indexes for custom primary keys" do
+ @find_by_indexes = Indexer.ar_find_indexes(false)
+
+ assert @find_by_indexes["gifts"].include?("custom_primary_key")
+ end
+
+ test "find_by indexes for self.find_by_email_and_name" do
+ @find_by_indexes = Indexer.ar_find_indexes(false)
+
+ assert @find_by_indexes["users"].include?(["name", "email"])
+ assert @find_by_indexes["users"].include?(["email", "name"])
+ end
+
+ test "find_by indexes for Gift.find_all_by_name_and_price" do
+ @find_by_indexes = Indexer.ar_find_indexes(false)
+
+ assert @find_by_indexes["gifts"].include?(["name", "price"])
+ assert @find_by_indexes["gifts"].include?(["price", "name"])
+ end
+
+ test "find_by indexes from UsersController" do
+ @find_by_indexes = Indexer.ar_find_indexes(false)
+
+ assert @find_by_indexes["freelancers"].include?("name")
+
+ end
+end
View
30 vendor/plugins/rails_indexes/test/test_helper.rb
@@ -0,0 +1,30 @@
+require 'rubygems'
+
+require 'test/unit'
+
+require 'activerecord'
+require 'active_record/fixtures'
+require 'active_support'
+require 'active_support/test_case'
+require 'action_controller'
+
+require 'indexer'
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "sqlite3",
+ :database => ":memory:"
+)
+
+class Rails
+ def self.root
+ "test/fixtures/"
+ end
+end
+
+load 'test/fixtures/schema.rb'
+
+# Load models
+Dir['test/fixtures/app/models/**/*.rb'].each { |f| require f }
+
+# load controllers
+Dir['test/fixtures/app/controllers/**/*.rb'].each { |f| require f }
View
10 vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb
@@ -1,5 +1,6 @@
+<%= link_to "Show", "", :id => "current_image_toggler" if (toggle_image_display ||= false) %>
<%= f.hidden_field field %>
-<div>
+<div id='current_image_container'<%= " style='display: none'" if (toggle_image_display ||= false) %>>
<a id='current_image_link' href="<%= insert_admin_images_url %>?thickbox=true&amp;modal=true&amp;titlebar=true&amp;field=<%= f.object.class.name.underscore.downcase %>_<%= field %>&amp;update_image=current_picked_image&amp;callback=picked_image_changed&amp;thumbnail=&amp;KeepThis=true&amp;TB_iframe=true&amp;width=<%= width ||= 950 %>&amp;height=<%= height ||= 510 %>" style='border: 0px' title='Change <%= (description ||= "image").titleize %>' name='Change <%= (description ||= "image").titleize %>' class='thickbox'>
<% unless image.nil? %>
<%= image_fu image, nil, {:class => "brown_border", :id => "current_picked_image"} %>
@@ -37,6 +38,13 @@
this.hide();
e.stop();
});
+<% if toggle_image_display ||= false -%>
+ jQuery('#current_image_toggler').click(function(e){
+ jQuery(this).html((jQuery(this).html() == 'Show' ? 'Hide' : 'Show'));
+ jQuery("#current_image_container").toggle();
+ e.preventDefault();
+ });
+<% end -%>
});
</script>
<% end %>

No commit comments for this range

Something went wrong with that request. Please try again.