simple_admin 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,12 @@ Bundle install:
32
32
 
33
33
  Generate out the configuration:
34
34
 
35
- rails g simple_admin
35
+ rails g simple_admin:install
36
+
37
+ Install the assets into your public folder so that they can be served
38
+ by your web server instead of being served through rails.
39
+
40
+ rails g simple_admin:assets
36
41
 
37
42
  Add any administration interfaces (for example, in app/admin/posts.rb):
38
43
 
@@ -284,13 +289,15 @@ default styling from active_admin relies on formtastic output.
284
289
 
285
290
  The +stylesheet+ and +javascript+ properties are used within the admin
286
291
  layout and are defaulted to the active_admin styles and scripts. You
287
- may want to override these styles, or simply move them to your public
288
- folder so that they are not served through rails. These properties allow
292
+ may want to override these styles, or simply use the asset pipeline
293
+ instead of installing them to your public folder. These properties allow
289
294
  you to manage where the assets are stored (either within the default
290
- pipeline or no):
295
+ pipeline or no). By default, SimpleAdmin assumes you have run the
296
+ asset generator (rails g simple_admin:assets) and that these files
297
+ live within your public folder:
291
298
 
292
- config.stylesheet = "simple_admin/active_admin.css"
293
- config.javascript = "simple_admin/active_admin.js"
299
+ config.stylesheet = "/stylesheets/simple_admin/active_admin.css"
300
+ config.javascript = "/javascripts/simple_admin/active_admin.js"
294
301
 
295
302
  == Testing
296
303
 
data/Rakefile CHANGED
@@ -19,7 +19,8 @@ task :sample do
19
19
  Dir.chdir "spec/sample"
20
20
 
21
21
  # Generate our initializer into the sample application
22
- system "rails g #{ENGINE}"
22
+ system "rails g #{ENGINE}:install"
23
+ system "rails g #{ENGINE}:assets"
23
24
 
24
25
  # Make a place and a thing
25
26
  system "rails g scaffold place name:string"
@@ -275,10 +275,10 @@ th, td, caption {
275
275
  background: #7b8389;
276
276
  color: #fff; }
277
277
  #header ul#tabs > li.has_nested > a {
278
- background: url("/assets/simple_admin/active_admin/nested_menu_arrow.gif") no-repeat 89% 50%;
278
+ background: url("/images/simple_admin/active_admin/nested_menu_arrow.gif") no-repeat 89% 50%;
279
279
  padding-right: 20px; }
280
280
  #header ul#tabs > li.has_nested.current > a {
281
- background: #7b8389 url("/assets/simple_admin/active_admin/nested_menu_arrow_dark.gif") no-repeat 89% 50%;
281
+ background: #7b8389 url("/images/simple_admin/active_admin/nested_menu_arrow_dark.gif") no-repeat 89% 50%;
282
282
  padding-right: 20px; }
283
283
  #header ul#tabs > li:hover > a {
284
284
  background: #7b8389;
@@ -295,7 +295,7 @@ th, td, caption {
295
295
  -webkit-border-top-left-radius: 10px;
296
296
  z-index: 800;
297
297
  border-bottom: 5px solid #7b8389;
298
- background: #7b8389 url("/assets/simple_admin/active_admin/nested_menu_arrow_dark.gif") no-repeat 89% 50%; }
298
+ background: #7b8389 url("/images/simple_admin/active_admin/nested_menu_arrow_dark.gif") no-repeat 89% 50%; }
299
299
  #header ul#tabs > li:hover ul {
300
300
  display: block; }
301
301
  #header ul#tabs > li ul {
@@ -952,7 +952,7 @@ table {
952
952
  text-decoration: none;
953
953
  display: block; }
954
954
  table th.sortable a {
955
- background: url("/assets/simple_admin/active_admin/orderable.png") no-repeat 0 4px;
955
+ background: url("/images/simple_admin/active_admin/orderable.png") no-repeat 0 4px;
956
956
  padding-left: 13px; }
957
957
  table th.sorted-asc a {
958
958
  background-position: 0 -27px; }
@@ -7,5 +7,6 @@ module SimpleAdmin
7
7
  include SimpleAdmin::FilterHelper
8
8
  include SimpleAdmin::SidebarHelper
9
9
  include SimpleAdmin::PathHelper
10
+ include SimpleAdmin::AssetsHelper
10
11
  end
11
12
  end
@@ -0,0 +1,12 @@
1
+ module SimpleAdmin
2
+ module AssetsHelper
3
+ def simple_admin_stylesheet_link_tag(*args)
4
+ stylesheet_link_tag(*args)
5
+ end
6
+
7
+ def simple_admin_javascript_include_tag(*args)
8
+ javascript_include_tag(*args)
9
+ end
10
+ end
11
+ end
12
+
@@ -5,8 +5,8 @@
5
5
  <%- if protect_against_forgery? -%>
6
6
  <meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" />
7
7
  <%- end -%>
8
- <%= stylesheet_link_tag SimpleAdmin.stylesheet %>
9
- <%= javascript_include_tag SimpleAdmin.javascript %>
8
+ <%= simple_admin_stylesheet_link_tag SimpleAdmin.stylesheet %>
9
+ <%= simple_admin_javascript_include_tag SimpleAdmin.javascript %>
10
10
  </head>
11
11
  <body class="index admin_occasions">
12
12
  <div id="wrapper">
@@ -0,0 +1,24 @@
1
+ require 'rails/generators'
2
+
3
+ module SimpleAdmin
4
+ class AssetsGenerator < Rails::Generators::Base
5
+ desc <<-CONTENT
6
+ This will install the admin assets into your public \
7
+ folder. If you want to move these files you can adjust \
8
+ your config/initializer/simple_admin.rb and modify the \
9
+ config.javascripts and config.stylesheets. \
10
+ \
11
+ The default theme comes from ActiveAdmin.
12
+
13
+ CONTENT
14
+
15
+ def self.source_root
16
+ File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..')
17
+ end
18
+
19
+ def copy_assets_folder
20
+ directory 'app/assets', 'public'
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module SimpleAdmin
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc <<-CONTENT
7
+ This will mount SimpleAdmin in your routes.rb using the admin \
8
+ path. It will also install a simple_admin initializer file in \
9
+ your config where you can setup the options.\
10
+ \
11
+ Once complete, register admin interfaces like app/admin/posts.rb:\
12
+ \
13
+ SimpleAdmin.register :posts do\
14
+ end\
15
+
16
+ CONTENT
17
+
18
+ def self.source_root
19
+ File.join(File.dirname(__FILE__), '..', 'templates')
20
+ end
21
+
22
+ def copy_initializer_file
23
+ copy_file 'initializer.rb', 'config/initializers/simple_admin.rb'
24
+ end
25
+
26
+ def app_admin
27
+ empty_directory('app/admin')
28
+ end
29
+
30
+ def add_simple_admin_routes
31
+ simple_admin_routes = %(mount SimpleAdmin::Engine => '/admin'\n)
32
+ route simple_admin_routes
33
+ end
34
+ end
35
+ end
@@ -65,12 +65,14 @@ SimpleAdmin.setup do |config|
65
65
 
66
66
  # The +stylesheet+ and +javascript+ properties are used within the admin
67
67
  # layout and are defaulted to the active_admin styles and scripts. You
68
- # may want to override these styles, or simply move them to your public
69
- # folder so that they are not served through rails. These properties allow
68
+ # may want to override these styles, or simply use the asset pipeline
69
+ # instead of installing them to your public folder. These properties allow
70
70
  # you to manage where the assets are stored (either within the default
71
- # pipeline or no):
71
+ # pipeline or no). By default, SimpleAdmin assumes you have run the
72
+ # asset generator (rails g simple_admin:assets) and that these files
73
+ # live within your public folder:
72
74
  #
73
- # config.stylesheet = "simple_admin/active_admin.css"
74
- # config.javascript = "simple_admin/active_admin.js"
75
+ # config.stylesheet = "/stylesheets/simple_admin/active_admin.css"
76
+ # config.javascript = "/javascripts/simple_admin/active_admin.js"
75
77
 
76
78
  end
@@ -31,11 +31,11 @@ module SimpleAdmin
31
31
  end
32
32
 
33
33
  def stylesheet
34
- @@stylesheet || "simple_admin/active_admin.css"
34
+ @@stylesheet || "/stylesheets/simple_admin/active_admin.css"
35
35
  end
36
36
 
37
37
  def javascript
38
- @@javascript || "simple_admin/active_admin.js"
38
+ @@javascript || "/javascripts/simple_admin/active_admin.js"
39
39
  end
40
40
 
41
41
  def registered
@@ -4,7 +4,7 @@ require 'rails'
4
4
  module SimpleAdmin
5
5
  class Engine < Rails::Engine
6
6
  isolate_namespace SimpleAdmin
7
- initializer 'simple_admin' do
7
+ initializer 'simple_admin' do |app|
8
8
  if Rails.env == "development"
9
9
  simple_admin_reloader = ActiveSupport::FileUpdateChecker.new(Dir["app/admin/**/*"], true) do
10
10
  SimpleAdmin.unregister
@@ -1,3 +1,3 @@
1
1
  module SimpleAdmin
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -42,13 +42,13 @@ describe SimpleAdmin do
42
42
  end
43
43
 
44
44
  it "has a default stylesheet" do
45
- SimpleAdmin.stylesheet.should == "simple_admin/active_admin.css"
45
+ SimpleAdmin.stylesheet.should == "/stylesheets/simple_admin/active_admin.css"
46
46
  SimpleAdmin.setup {|config| config.stylesheet = "nyan-cat.css"}
47
47
  SimpleAdmin.stylesheet.should == "nyan-cat.css"
48
48
  end
49
49
 
50
50
  it "has a default script" do
51
- SimpleAdmin.javascript.should == "simple_admin/active_admin.js"
51
+ SimpleAdmin.javascript.should == "/javascripts/simple_admin/active_admin.js"
52
52
  SimpleAdmin.setup {|config| config.javascript = "nyan-cat.js"}
53
53
  SimpleAdmin.javascript.should == "nyan-cat.js"
54
54
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_admin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Rafter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-22 00:00:00 -07:00
18
+ date: 2011-06-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -197,6 +197,7 @@ files:
197
197
  - app/assets/stylesheets/simple_admin/active_admin.css
198
198
  - app/controllers/simple_admin/admin_controller.rb
199
199
  - app/helpers/simple_admin/admin_helper.rb
200
+ - app/helpers/simple_admin/assets_helper.rb
200
201
  - app/helpers/simple_admin/display_helper.rb
201
202
  - app/helpers/simple_admin/filter_helper.rb
202
203
  - app/helpers/simple_admin/header_helper.rb
@@ -212,7 +213,8 @@ files:
212
213
  - app/views/simple_admin/admin/new.html.erb
213
214
  - app/views/simple_admin/admin/show.html.erb
214
215
  - config/routes.rb
215
- - lib/rails/generators/simple_admin/simple_admin_generator.rb
216
+ - lib/rails/generators/simple_admin/assets/assets_generator.rb
217
+ - lib/rails/generators/simple_admin/install/install_generator.rb
216
218
  - lib/rails/generators/simple_admin/templates/initializer.rb
217
219
  - lib/simple_admin.rb
218
220
  - lib/simple_admin/attributes.rb
@@ -1,33 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- class SimpleAdminGenerator < Rails::Generators::Base
5
- desc <<-CONTENT
6
- This will mount SimpleAdmin in your routes.rb using the admin \
7
- path. It will also install a simple_admin initializer file in \
8
- your config where you can setup the options.\
9
- \
10
- Once complete, register admin interfaces like app/admin/posts.rb:\
11
- \
12
- SimpleAdmin.register :posts do\
13
- end\
14
-
15
- CONTENT
16
-
17
- def self.source_root
18
- File.join(File.dirname(__FILE__), 'templates')
19
- end
20
-
21
- def copy_initializer_file
22
- copy_file 'initializer.rb', 'config/initializers/simple_admin.rb'
23
- end
24
-
25
- def app_admin
26
- empty_directory('app/admin')
27
- end
28
-
29
- def add_simple_admin_routes
30
- simple_admin_routes = %(mount SimpleAdmin::Engine => '/admin'\n)
31
- route simple_admin_routes
32
- end
33
- end