flexible_admin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -6,6 +6,19 @@ Flexible Admin is a Rails 3.1 Admin tool to generate an attractive data admin to
6
6
 
7
7
  I have found myself loving other admins for Rails, but many projects need enough admin customization that the value of a engines/magic was offset by the difficulty of customizing.
8
8
 
9
+ h4. Depends On
10
+
11
+ # Rails 3.1+
12
+
13
+ h4. Kinda needs
14
+
15
+ # SQL database
16
+
17
+ h4. Customized for
18
+
19
+ # Paperclip file attachments
20
+ # SASS stylesheets
21
+
9
22
  h4. Distinctions from other Rails admin gems
10
23
 
11
24
  Flexible admin generates controller and view files for every model that you are managing, then invites you to get your hands dirty for the customizations of the admin.
@@ -17,6 +30,11 @@ It keeps the amount of generated code down by leveraging these gems/libraries to
17
30
  # inherited_resources for rest controllers
18
31
  # Database Tables (js) for table searching and sorting
19
32
 
33
+ h4. Shortcomings from other Rails admins gems
34
+
35
+ # Does not natively handle huge amounts of records for viewing. You would need to implement handling a large number of records for searching/sorting yourself. (Because Flexible Admin renders every record of a certain model, and then Datatables js presents just 50 at a time that is paginated/filterable/sortable with javascript)
36
+ # Because this is a generator, not an engine, the resource generator might become less effective (=breaks more) as you admin gets more and more customized. This is because its replacing/inserting code that may have modified.
37
+
20
38
  h2. Getting Started
21
39
 
22
40
  In your Gemfile
@@ -52,6 +70,10 @@ h3. Gem tests
52
70
 
53
71
  Flexible Admin as a gem is tested with rspec. The specs cover that the generator generates the right files. It does not test that you can actually admin in anything after the generator runs.
54
72
 
73
+ h3. Tests needed
74
+
75
+ If possible, my dream tests would run the admin generator on a dummy_app, then step into the dummy app and run a new test suite on how that app behaves after the generator has been run. If anyone knows how to do that get in touch through github, email or the Issues section.
76
+
55
77
  h4. Working with the tests gotchas
56
78
 
57
79
  The generator specs really on a dummy Rails app in the spec/dummy folder. That dummy app has some models, a schema, and a db/test.sqlite3 that matter for the tests. You might have to dig into those if you are having problems modding the specs. One of the generators reads the models and the database columns to generate the admin forms, and so the dummy app has those files to test off it.
@@ -1,3 +1,3 @@
1
1
  module FlexibleAdmin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -25,17 +25,15 @@ module FlexibleAdmin
25
25
 
26
26
  def make_routes
27
27
  if has_admin_route_namespace?
28
- unless has_this_route_already?
29
- routing_code = "
30
- resources :#{resources_name}, :except => :show do
31
- member do
32
- get 'toggle'
33
- end
34
- end"
35
- sentinel = /namespace :admin do$/
36
- in_root do
37
- inject_into_file 'config/routes.rb', "\n #{routing_code}", { :after => sentinel, :verbose => true }
38
- end
28
+ routing_code = "
29
+ resources :#{resources_name}, :except => :show do
30
+ member do
31
+ get 'toggle'
32
+ end
33
+ end"
34
+ sentinel = /namespace :admin do$/
35
+ in_root do
36
+ inject_into_file 'config/routes.rb', "\n #{routing_code}", { :after => sentinel, :verbose => true }
39
37
  end
40
38
  else
41
39
  route_info = "
@@ -107,9 +105,13 @@ module FlexibleAdmin
107
105
  other_columns = table_columns_for(model).collect do |column|
108
106
  if column.name =~ /_file_name/
109
107
  column_name = column.name.split("_file_name").first
110
- "<td><%= #{singular_name}.#{column_name}.url, :width => 24, :height => 24) %></td>"
108
+ if is_image?(column_name)
109
+ "<td><%= image_tag(#{singular_name}.#{column_name}.url, :width => 24, :height => 24) %></td>"
110
+ else
111
+ "<td><%= link_to #{singular_name}.#{column_name}.original_filename, #{singular_name}.#{column_name}.url %></td>"
112
+ end
111
113
  elsif column.type == :datetime
112
- "<td><%= #{singular_name}.#{column.name}.strftime(\"%F\") %></td>"
114
+ "<td><%= #{singular_name}.#{column.name}.strftime(\"%F %T\") %></td>"
113
115
  elsif column.type == :boolean
114
116
  "<td><%= toggle(#{singular_name}, :#{column.name}) %></td>"
115
117
  else
@@ -169,9 +171,9 @@ module FlexibleAdmin
169
171
  File.open(File.join(destination_root, 'config', 'routes.rb')).read.index("namespace :admin do")
170
172
  end
171
173
 
172
- def has_this_route_already?
173
- File.open(File.join(destination_root, 'config', 'routes.rb')).read.index("resources :#{resources_name}")
174
+ def is_image?(text)
175
+ text =~ /(img|image|avatar|pic|logo)/
174
176
  end
175
-
177
+
176
178
  end
177
179
  end
@@ -40,6 +40,8 @@ module FlexibleAdmin
40
40
  template "stylesheets/bootstrap.sass", "app/assets/stylesheets/admin/bootstrap.sass"
41
41
  template "stylesheets/application.css", "app/assets/stylesheets/admin/application.css"
42
42
  template "stylesheets/demo_table.css", "app/assets/stylesheets/admin/datatables/demo_table.css"
43
+ template "stylesheets/admin.sass", "app/assets/stylesheets/admin/admin.sass"
44
+ template "images/admin-background.png", "app/assets/images/admin/admin-background.png"
43
45
  end
44
46
 
45
47
  def creates_datatables_images
@@ -70,6 +72,7 @@ module FlexibleAdmin
70
72
  end
71
73
 
72
74
  def inherited_resources
75
+ append_file "Gemfile", "\n", :force => true
73
76
  gem 'inherited_resources'
74
77
  end
75
78
 
@@ -80,6 +83,10 @@ module FlexibleAdmin
80
83
  gem 'devise'
81
84
  end
82
85
 
86
+ inside Rails.root do
87
+ run "bundle install"
88
+ end
89
+
83
90
  unless File.exists?(Rails.root.join("config/initializers/devise.rb"))
84
91
  say "Installing devise"
85
92
  generate "devise:install"
@@ -89,7 +96,7 @@ module FlexibleAdmin
89
96
  generate "devise AdminUser"
90
97
  template "user_sign_in.html.erb", "app/views/admin/admin_users/sessions/new.html.erb"
91
98
  gsub_file 'config/routes.rb', "devise_for :admin_users", "devise_for :admin_users, :path_prefix => 'admin', :controllers => {:sessions => 'admin/admin_users/sessions' }"
92
- template "admin_user_sessions_controller.rb", "app/controller/admin/admin_users/sessions_controller.rb"
99
+ template "admin_user_sessions_controller.rb", "app/controllers/admin/admin_users/sessions_controller.rb"
93
100
  end
94
101
 
95
102
  say "you now need to run 'rake db:migrate' to create the admin_users table", :blue
@@ -0,0 +1,14 @@
1
+ <h2>Welcome to the admin</h2>
2
+
3
+ <p>
4
+ You can manage your different resources in the top menu bar. If its empty, you can generate the admin scaffolding by running</p>
5
+
6
+ <pre>
7
+ rails g flexible_admin Post
8
+ </pre>
9
+
10
+ <p>Where "Post" is your model name.</p>
11
+
12
+ <p>You can edit/delete this page in app/views/admin/index.html.erb</p>
13
+
14
+ <p>A great use for this space is to present mini-reports about latest activity, or summary reports, or previews. You'll have to write that stuff on your own.</p>
@@ -17,7 +17,7 @@
17
17
 
18
18
  <div class="container-fluid">
19
19
  <div class="sidebar">
20
-
20
+ <%%= yield :sidebar %>
21
21
  </div><!-- .sidebar -->
22
22
  <div class="content">
23
23
  <%%= render 'layouts/admin/flash', :flash => flash %>
@@ -1,3 +1,7 @@
1
+ <%%= content_for(:sidebar) do %>
2
+ <%%= link_to "All <%= upper_case_resources_name %>", admin_<%= resources_name %>_path %>
3
+ <%% end %>
4
+
1
5
  <h1>Edit <%= upper_case_resource_name %></h1>
2
6
 
3
7
  <%%= render 'form' %>
@@ -5,7 +5,7 @@
5
5
  </ul>
6
6
  <%% end %>
7
7
 
8
- <h2><%= model_name.pluralize.humanize %></h2>
8
+ <h2><%= resources_name.humanize.titlecase %></h2>
9
9
 
10
10
  <table class="sortable">
11
11
  <thead>
@@ -0,0 +1,48 @@
1
+ body
2
+ padding-top: 60px
3
+ background: #fff url(/assets/admin/admin-background.png) repeat-y
4
+
5
+ label.checkbox
6
+ float: none
7
+
8
+ div.signin
9
+ margin-top: 10px
10
+ margin-left: 10px
11
+ float: right
12
+
13
+ form .clearfix
14
+ .field_with_errors
15
+ label, .help-block, .help-inline
16
+ color: #b94a48
17
+ input, textarea
18
+ color: #b94a48
19
+ border-color: #ee5f5b
20
+ input:focus, textarea:focus
21
+ border-color: #e9322d
22
+ -webkit-box-shadow: 0 0 6px #f8b9b7
23
+ -moz-box-shadow: 0 0 6px #f8b9b7
24
+ box-shadow: 0 0 6px #f8b9b7
25
+ .input-prepend .add-on, .input-append .add-on
26
+ color: #b94a48
27
+ background-color: #fce6e6
28
+ border-color: #b94a48
29
+
30
+
31
+ #navigation
32
+ color: #ababab
33
+
34
+ .nav
35
+ min-width: 300px
36
+
37
+ .dataTables_wrapper
38
+ a
39
+ color: #5D478B
40
+
41
+ .dataTables_length
42
+ display: none
43
+
44
+ .dataTables_filter
45
+ margin-bottom: 10px
46
+ label
47
+ float: none
48
+
@@ -5,8 +5,5 @@
5
5
  *= require_self
6
6
  *= require admin/datatables/demo_table
7
7
  *= require admin/bootstrap
8
+ *= require admin/admin
8
9
  */
9
-
10
- div.container-fluid {
11
- padding-top: 40px
12
- }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexible_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-09 00:00:00.000000000Z
12
+ date: 2012-01-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70279930697780 !ruby/object:Gem::Requirement
16
+ requirement: &70250395871320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70279930697780
24
+ version_requirements: *70250395871320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &70279930697360 !ruby/object:Gem::Requirement
27
+ requirement: &70250395870860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70279930697360
35
+ version_requirements: *70250395870860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70279930696900 !ruby/object:Gem::Requirement
38
+ requirement: &70250395870400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70279930696900
46
+ version_requirements: *70250395870400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: generator_spec
49
- requirement: &70279930696480 !ruby/object:Gem::Requirement
49
+ requirement: &70250395869980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70279930696480
57
+ version_requirements: *70250395869980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pry
60
- requirement: &70279930696060 !ruby/object:Gem::Requirement
60
+ requirement: &70250395869540 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70279930696060
68
+ version_requirements: *70250395869540
69
69
  description: Rails 3.1 admin generator
70
70
  email:
71
71
  - josh@joshcrews.com
@@ -93,6 +93,7 @@ files:
93
93
  - lib/generators/flexible_admin/templates/forms/select_field.html.erb
94
94
  - lib/generators/flexible_admin/templates/forms/text_area_field.html.erb
95
95
  - lib/generators/flexible_admin/templates/forms/text_field.html.erb
96
+ - lib/generators/flexible_admin/templates/images/admin-background.png
96
97
  - lib/generators/flexible_admin/templates/images/back_disabled.jpg
97
98
  - lib/generators/flexible_admin/templates/images/back_enabled.jpg
98
99
  - lib/generators/flexible_admin/templates/images/forward_disabled.jpg
@@ -111,6 +112,7 @@ files:
111
112
  - lib/generators/flexible_admin/templates/resources/index.html.erb
112
113
  - lib/generators/flexible_admin/templates/resources/new.html.erb
113
114
  - lib/generators/flexible_admin/templates/resources_controller.rb
115
+ - lib/generators/flexible_admin/templates/stylesheets/admin.sass
114
116
  - lib/generators/flexible_admin/templates/stylesheets/application.css
115
117
  - lib/generators/flexible_admin/templates/stylesheets/bootstrap.sass
116
118
  - lib/generators/flexible_admin/templates/stylesheets/demo_table.css
@@ -133,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
135
  version: '0'
134
136
  segments:
135
137
  - 0
136
- hash: -2557047139848653288
138
+ hash: 4582513282580412729
137
139
  required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  none: false
139
141
  requirements:
@@ -142,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
144
  version: '0'
143
145
  segments:
144
146
  - 0
145
- hash: -2557047139848653288
147
+ hash: 4582513282580412729
146
148
  requirements: []
147
149
  rubyforge_project:
148
150
  rubygems_version: 1.8.11