Permalink
Browse files

works with Sprockets in Rails 3.1

  • Loading branch information...
1 parent bd751f4 commit 420f710232ea3cfbcaca961d8e0bbc17309bb3b6 Francis Hwang committed Sep 11, 2011
Showing with 1,097 additions and 74 deletions.
  1. +2 −1 config/routes.rb
  2. +17 −1 lib/admin_assistant.rb
  3. +5 −3 lib/admin_assistant/helper.rb
  4. +9 −3 lib/admin_assistant/init.rb
  5. +0 −4 rails_3_0/.gitignore
  6. +1 −1 rails_3_0/Rakefile
  7. +1 −1 rails_3_0/app/views/layouts/application.html.erb
  8. +1 −1 rails_3_0/config.ru
  9. +1 −1 rails_3_0/config/application.rb
  10. +1 −1 rails_3_0/config/environment.rb
  11. +1 −1 rails_3_0/config/environments/development.rb
  12. +1 −1 rails_3_0/config/environments/production.rb
  13. +1 −1 rails_3_0/config/environments/test.rb
  14. +1 −1 rails_3_0/config/initializers/secret_token.rb
  15. +2 −2 rails_3_0/config/initializers/session_store.rb
  16. +1 −1 rails_3_0/config/routes.rb
  17. +6 −4 rails_3_0/test/integration/admin/blog_posts3_integration_test.rb
  18. +6 −4 rails_3_0/test/integration/admin/blog_posts_integration_test.rb
  19. +23 −2 rails_3_1/Gemfile
  20. +51 −27 rails_3_1/Gemfile.lock
  21. +0 −1 rails_3_1/README
  22. +261 −0 rails_3_1/README
  23. +0 −1 rails_3_1/Rakefile
  24. +7 −0 rails_3_1/Rakefile
  25. +0 −1 rails_3_1/app
  26. BIN rails_3_1/app/assets/images/rails.png
  27. +12 −0 rails_3_1/app/assets/javascripts/admin.js
  28. +9 −0 rails_3_1/app/assets/javascripts/application.js
  29. +2 −0 rails_3_1/app/assets/stylesheets/admin-activescaffold.css
  30. +2 −0 rails_3_1/app/assets/stylesheets/admin.css
  31. +6 −0 rails_3_1/app/assets/stylesheets/application.css
  32. +1 −0 rails_3_1/app/controllers
  33. +1 −0 rails_3_1/app/helpers
  34. 0 rails_3_1/app/mailers/.gitkeep
  35. +1 −0 rails_3_1/app/models
  36. +1 −0 rails_3_1/app/views/admin
  37. +32 −0 rails_3_1/app/views/layouts/admin.html.erb
  38. +14 −0 rails_3_1/app/views/layouts/application.html.erb
  39. +0 −1 rails_3_1/config
  40. +0 −1 rails_3_1/config.ru
  41. +4 −0 rails_3_1/config.ru
  42. +48 −0 rails_3_1/config/application.rb
  43. +6 −0 rails_3_1/config/boot.rb
  44. +25 −0 rails_3_1/config/database.yml
  45. +5 −0 rails_3_1/config/environment.rb
  46. +30 −0 rails_3_1/config/environments/development.rb
  47. +60 −0 rails_3_1/config/environments/production.rb
  48. +42 −0 rails_3_1/config/environments/test.rb
  49. +7 −0 rails_3_1/config/initializers/backtrace_silencers.rb
  50. +10 −0 rails_3_1/config/initializers/inflections.rb
  51. +5 −0 rails_3_1/config/initializers/mime_types.rb
  52. +7 −0 rails_3_1/config/initializers/secret_token.rb
  53. +8 −0 rails_3_1/config/initializers/session_store.rb
  54. +14 −0 rails_3_1/config/initializers/wrap_parameters.rb
  55. +5 −0 rails_3_1/config/locales/en.yml
  56. +1 −0 rails_3_1/config/routes.rb
  57. +0 −1 rails_3_1/db
  58. +1 −0 rails_3_1/db/migrate
  59. +7 −0 rails_3_1/db/seeds.rb
  60. +0 −1 rails_3_1/doc
  61. +2 −0 rails_3_1/doc/README_FOR_APP
  62. +0 −1 rails_3_1/lib
  63. 0 rails_3_1/lib/assets/.gitkeep
  64. 0 rails_3_1/lib/tasks/.gitkeep
  65. +0 −1 rails_3_1/log
  66. 0 rails_3_1/log/.gitkeep
  67. +0 −1 rails_3_1/public
  68. +26 −0 rails_3_1/public/404.html
  69. +26 −0 rails_3_1/public/422.html
  70. +26 −0 rails_3_1/public/500.html
  71. 0 rails_3_1/public/favicon.ico
  72. +241 −0 rails_3_1/public/index.html
  73. +5 −0 rails_3_1/public/robots.txt
  74. +0 −1 rails_3_1/script
  75. +6 −0 rails_3_1/script/rails
  76. +0 −1 rails_3_1/tmp
  77. +0 −1 rails_3_1/vendor
  78. 0 rails_3_1/vendor/plugins/.gitkeep
  79. BIN {lib → vendor/assets}/images/sort-asc.png
  80. BIN {lib → vendor/assets}/images/sort-desc.png
  81. 0 {lib → vendor/assets}/javascripts/admin_assistant.js
  82. 0 {lib → vendor/assets}/javascripts/jquery.tokeninput.js
  83. 0 lib/stylesheets/default.css → vendor/assets/stylesheets/admin_assistant.css
  84. 0 lib/stylesheets/activescaffold.css → vendor/assets/stylesheets/admin_assistant_activescaffold.css
  85. 0 {lib → vendor/assets}/stylesheets/token-input.css
View
@@ -1,7 +1,8 @@
# In development mode, we need to ensure that all controllers are loaded,
# because that's how AdminAssistant knows what routes to create
unless Rails.configuration.cache_classes
- Find.find("#{Rails.root}/app/controllers") do |path|
+ controllers_path = "#{Rails.root}/app/controllers"
+ AdminAssistant.all_files_under(controllers_path).each do |path|
if path =~ /\.rb$/
require path
end
View
@@ -19,6 +19,22 @@ class AdminAssistant
self.default_inputs = {}
self.routes = []
+ # From http://stackoverflow.com/questions/3974087/how-to-make-rubys-find-find-follow-symlinks
+ def self.all_files_under(*paths)
+ paths.flatten!
+ paths.map! { |p| Pathname.new(p) }
+ files = paths.select { |p| p.file? }
+ (paths - files).each do |dir|
+ files << all_files_under(dir.children)
+ end
+ files.flatten.map(&:to_s)
+ end
+
+ def self.app_uses_sprockets?
+ # For now, we assume you're using Sprockets if app/assets exists.
+ File.exist?("#{Rails.root}/app/assets")
+ end
+
def self.profile(msg)
if self.request_start_time
Rails.logger.info "#{msg}: #{Time.now - self.request_start_time}"
@@ -28,7 +44,7 @@ def self.profile(msg)
def self.template_file(template_name)
"#{File.dirname(__FILE__)}/views/#{template_name}.html.erb"
end
-
+
attr_reader :base_settings, :controller_class, :form_settings,
:index_settings, :model_class, :show_settings
attr_accessor :actions, :custom_destroy, :default_search_matches_on
@@ -1,10 +1,12 @@
class AdminAssistant
module Helper
def admin_assistant_includes(opts = {})
- theme = opts[:theme] || 'default'
- tags = stylesheet_link_tag("admin_assistant/#{theme}")
+ ss_name = "admin_assistant/admin_assistant"
+ ss_name << "_#{opts[:theme]}" if opts[:theme]
+ tags = stylesheet_link_tag(ss_name)
tags << stylesheet_link_tag("admin_assistant/token-input")
- js_dir = Pathname.new(Rails.root) + "public/javascripts/admin_assistant"
+ js_dir =
+ Pathname.new(Rails.root) + "public/javascripts/admin_assistant"
Dir.entries(js_dir).each do |entry|
if entry =~ /\.js$/
tags << javascript_include_tag("admin_assistant/#{entry}")
@@ -4,10 +4,16 @@
class AdminAssistant
def self.init
gem_root = File.dirname(__FILE__) + "/../.."
- %w(stylesheets javascripts images).each do |asset_type|
+ copy_into_public = %w(images)
+ unless app_uses_sprockets?
+ copy_into_public.concat(%w(stylesheets javascripts))
+ end
+ copy_into_public.each do |asset_type|
asset_dir = "#{Rails.root}/public/#{asset_type}/admin_assistant"
- FileUtils.mkdir(asset_dir) unless File.exist?(asset_dir)
- FileUtils.cp_r(Dir.glob("#{gem_root}/lib/#{asset_type}/*"), asset_dir)
+ FileUtils.mkdir_p(asset_dir) unless File.exist?(asset_dir)
+ FileUtils.cp_r(
+ Dir.glob("#{gem_root}/vendor/assets/#{asset_type}/*"), asset_dir
+ )
end
end
end
View
@@ -1,4 +0,0 @@
-.bundle
-db/*.sqlite3
-log/*.log
-tmp/
View
@@ -4,4 +4,4 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'
-Rails3Test::Application.load_tasks
+TestApp::Application.load_tasks
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Rails3Test</title>
+ <title>TestApp</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
View
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run Rails3Test::Application
+run TestApp::Application
@@ -6,7 +6,7 @@
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
-module Rails3Test
+module TestApp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)
# Initialize the rails application
-Rails3Test::Application.initialize!
+TestApp::Application.initialize!
@@ -1,4 +1,4 @@
-Rails3Test::Application.configure do
+TestApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
@@ -1,4 +1,4 @@
-Rails3Test::Application.configure do
+TestApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The production environment is meant for finished, "live" apps.
@@ -1,4 +1,4 @@
-Rails3Test::Application.configure do
+TestApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
@@ -4,4 +4,4 @@
# 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.
-Rails3Test::Application.config.secret_token = 'fbd8fcbecd88560f228d262f2fa5ee353d850c093f84e138c52a943afaca30783282aceda2b4fd28f908337b71e23683cc9a880b736cf9282af1797988c5a29b'
+TestApp::Application.config.secret_token = 'fbd8fcbecd88560f228d262f2fa5ee353d850c093f84e138c52a943afaca30783282aceda2b4fd28f908337b71e23683cc9a880b736cf9282af1797988c5a29b'
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
-Rails3Test::Application.config.session_store :cookie_store, :key => '_rails_3_test_session'
+TestApp::Application.config.session_store :cookie_store, :key => '_rails_3_test_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 "rails generate session_migration")
-# Rails3Test::Application.config.session_store :active_record_store
+# TestApp::Application.config.session_store :active_record_store
@@ -1,4 +1,4 @@
-Rails3Test::Application.routes.draw do
+TestApp::Application.routes.draw do
namespace :admin do
resources :comments
resources :users
@@ -39,10 +39,12 @@ def test_index_with_no_blog_posts
get "/admin/blog_posts3"
assert_response :success
- # should use the activescaffold-themed CSS
- assert_select(
- 'link[href^=/stylesheets/admin_assistant/activescaffold.css]'
- )
+ unless Rails.version =~ /^3.1/
+ # should use the activescaffold-themed CSS
+ assert_select(
+ 'link[href^=/stylesheets/admin_assistant/admin_assistant_activescaffold.css]'
+ )
+ end
# should say 'Posts'
assert_select('h2', :text => 'Posts')
@@ -200,10 +200,12 @@ def test_index_when_there_are_no_records
# should use the admin layout
assert_match(/admin_assistant sample Rails app/, response.body)
- # should use the default admin_assistant CSS
- assert_select(
- 'link[href^=/stylesheets/admin_assistant/default.css]'
- )
+ unless Rails.version =~ /^3.1/
+ # should use the default admin_assistant CSS
+ assert_select(
+ 'link[href^=/stylesheets/admin_assistant/admin_assistant.css]'
+ )
+ end
end
def test_index_when_there_is_one_record
View
@@ -1,12 +1,33 @@
source 'http://rubygems.org'
-gem 'rails', '3.1.0.rc8'
+gem 'rails', '3.1.0'
gem 'admin_assistant', :path => "../../admin_assistant"
gem 'paperclip', '2.3.11'
gem 'sqlite3'
+gem 'json'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', " ~> 3.1.0"
+ gem 'coffee-rails', "~> 3.1.0"
+ gem 'uglifier'
+end
+
+gem 'jquery-rails'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug'
+
group :development, :test do
- gem 'json'
gem 'webrat', '>=0.7.2.pre', :git => 'http://github.com/kalv/webrat.git'
end
+
View
@@ -17,42 +17,54 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.1.0.rc8)
- actionpack (= 3.1.0.rc8)
+ actionmailer (3.1.0)
+ actionpack (= 3.1.0)
mail (~> 2.3.0)
- actionpack (3.1.0.rc8)
- activemodel (= 3.1.0.rc8)
- activesupport (= 3.1.0.rc8)
+ actionpack (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.2)
rack-cache (~> 1.0.3)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
- sprockets (~> 2.0.0.beta.15)
- activemodel (3.1.0.rc8)
- activesupport (= 3.1.0.rc8)
+ sprockets (~> 2.0.0)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
bcrypt-ruby (~> 3.0.0)
builder (~> 3.0.0)
i18n (~> 0.6)
- activerecord (3.1.0.rc8)
- activemodel (= 3.1.0.rc8)
- activesupport (= 3.1.0.rc8)
+ activerecord (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
- activeresource (3.1.0.rc8)
- activemodel (= 3.1.0.rc8)
- activesupport (= 3.1.0.rc8)
- activesupport (3.1.0.rc8)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
multi_json (~> 1.0)
arel (2.2.1)
bcrypt-ruby (3.0.0)
builder (3.0.0)
+ coffee-rails (3.1.0)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0.rc1)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
dynamic_form (1.1.4)
erubis (2.7.0)
+ execjs (1.2.4)
+ multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
+ jquery-rails (1.0.13)
+ railties (~> 3.0)
+ thor (~> 0.14)
json (1.5.4)
mail (2.3.0)
i18n (>= 0.4.0)
@@ -74,43 +86,55 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.1.0.rc8)
- actionmailer (= 3.1.0.rc8)
- actionpack (= 3.1.0.rc8)
- activerecord (= 3.1.0.rc8)
- activeresource (= 3.1.0.rc8)
- activesupport (= 3.1.0.rc8)
+ rails (3.1.0)
+ actionmailer (= 3.1.0)
+ actionpack (= 3.1.0)
+ activerecord (= 3.1.0)
+ activeresource (= 3.1.0)
+ activesupport (= 3.1.0)
bundler (~> 1.0)
- railties (= 3.1.0.rc8)
- railties (3.1.0.rc8)
- actionpack (= 3.1.0.rc8)
- activesupport (= 3.1.0.rc8)
+ railties (= 3.1.0)
+ railties (3.1.0)
+ actionpack (= 3.1.0)
+ activesupport (= 3.1.0)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2)
rdoc (3.9.4)
+ sass (3.1.7)
+ sass-rails (3.1.0)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
sprockets (2.0.0)
hike (~> 1.2)
rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
+ tilt (!= 1.3.0, ~> 1.1)
sqlite3 (1.3.4)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.29)
+ uglifier (1.0.2)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
will_paginate (3.0.0)
PLATFORMS
ruby
DEPENDENCIES
admin_assistant!
+ coffee-rails (~> 3.1.0)
+ jquery-rails
json
paperclip (= 2.3.11)
- rails (= 3.1.0.rc8)
+ rails (= 3.1.0)
+ sass-rails (~> 3.1.0)
sqlite3
+ uglifier
webrat (>= 0.7.2.pre)!
View
Oops, something went wrong.

0 comments on commit 420f710

Please sign in to comment.