flexible_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.textile +61 -0
  3. data/Rakefile +37 -0
  4. data/lib/flexible_admin/version.rb +3 -0
  5. data/lib/flexible_admin.rb +2 -0
  6. data/lib/generators/flexible_admin/flexible_admin_generator.rb +177 -0
  7. data/lib/generators/flexible_admin/install_generator.rb +99 -0
  8. data/lib/generators/flexible_admin/templates/admin_controller.rb +21 -0
  9. data/lib/generators/flexible_admin/templates/admin_helper.rb +49 -0
  10. data/lib/generators/flexible_admin/templates/admin_index.html.erb +0 -0
  11. data/lib/generators/flexible_admin/templates/admin_layout.html.erb +30 -0
  12. data/lib/generators/flexible_admin/templates/admin_resources_controller.rb +7 -0
  13. data/lib/generators/flexible_admin/templates/admin_user_sessions_controller.rb +3 -0
  14. data/lib/generators/flexible_admin/templates/flash.html.erb +9 -0
  15. data/lib/generators/flexible_admin/templates/forms/checkbox_field.html.erb +10 -0
  16. data/lib/generators/flexible_admin/templates/forms/cktext_area_field.html.erb +9 -0
  17. data/lib/generators/flexible_admin/templates/forms/email_field.html.erb +8 -0
  18. data/lib/generators/flexible_admin/templates/forms/error_messages.html.erb +10 -0
  19. data/lib/generators/flexible_admin/templates/forms/file_field.html.erb +8 -0
  20. data/lib/generators/flexible_admin/templates/forms/password_field.html.erb +6 -0
  21. data/lib/generators/flexible_admin/templates/forms/select_field.html.erb +8 -0
  22. data/lib/generators/flexible_admin/templates/forms/text_area_field.html.erb +9 -0
  23. data/lib/generators/flexible_admin/templates/forms/text_field.html.erb +9 -0
  24. data/lib/generators/flexible_admin/templates/images/back_disabled.jpg +0 -0
  25. data/lib/generators/flexible_admin/templates/images/back_enabled.jpg +0 -0
  26. data/lib/generators/flexible_admin/templates/images/forward_disabled.jpg +0 -0
  27. data/lib/generators/flexible_admin/templates/images/forward_enabled.jpg +0 -0
  28. data/lib/generators/flexible_admin/templates/images/sort_asc.png +0 -0
  29. data/lib/generators/flexible_admin/templates/images/sort_asc_disabled.png +0 -0
  30. data/lib/generators/flexible_admin/templates/images/sort_both.png +0 -0
  31. data/lib/generators/flexible_admin/templates/images/sort_desc.png +0 -0
  32. data/lib/generators/flexible_admin/templates/images/sort_desc_disabled.png +0 -0
  33. data/lib/generators/flexible_admin/templates/javascripts/app.js +5 -0
  34. data/lib/generators/flexible_admin/templates/javascripts/application.js +10 -0
  35. data/lib/generators/flexible_admin/templates/javascripts/jquery.dataTables.js +7440 -0
  36. data/lib/generators/flexible_admin/templates/navigation.html.erb +22 -0
  37. data/lib/generators/flexible_admin/templates/resources/edit.html.erb +3 -0
  38. data/lib/generators/flexible_admin/templates/resources/form.html.erb +11 -0
  39. data/lib/generators/flexible_admin/templates/resources/index.html.erb +26 -0
  40. data/lib/generators/flexible_admin/templates/resources/new.html.erb +7 -0
  41. data/lib/generators/flexible_admin/templates/resources_controller.rb +3 -0
  42. data/lib/generators/flexible_admin/templates/stylesheets/application.css +12 -0
  43. data/lib/generators/flexible_admin/templates/stylesheets/bootstrap.sass +2186 -0
  44. data/lib/generators/flexible_admin/templates/stylesheets/demo_table.css +538 -0
  45. data/lib/generators/flexible_admin/templates/user_sign_in.html.erb +22 -0
  46. data/lib/generators/flexible_admin/utils.rb +0 -0
  47. metadata +163 -0
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Josh Crews
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,61 @@
1
+ h1. Flexible Admin
2
+
3
+ h3. Reason for being
4
+
5
+ Flexible Admin is a Rails 3.1 Admin tool to generate an attractive data admin to handle login, data CRUD, search and sort while leaving an easy way to customize the particular needs of an app's custom admin functions.
6
+
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
+
9
+ h4. Distinctions from other Rails admin gems
10
+
11
+ 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.
12
+
13
+ It keeps the amount of generated code down by leveraging these gems/libraries to do the heavy lifting
14
+
15
+ # Devise for login
16
+ # Bootstrap for style
17
+ # inherited_resources for rest controllers
18
+ # Database Tables (js) for table searching and sorting
19
+
20
+ h2. Getting Started
21
+
22
+ In your Gemfile
23
+
24
+ <code>gem 'flexible_admin'</code>
25
+
26
+ run <code>bundle install</code>
27
+
28
+ run <code>rails generate flexible_admin:install</code>
29
+
30
+ run <code>rake db:migrate</code> to create admin_users tables
31
+
32
+ h2. Adding models
33
+
34
+ run <code>rails generate flexible_admin Post</code> to generate a admin/posts controller, /admin/posts route, and add Posts to the admin navigation
35
+
36
+ h2. Editing views and controllers
37
+
38
+ Edit views directly in the app/views/admin, app/views/layouts/admin and app/views/controllers/admin
39
+
40
+ h3. Dashboard
41
+
42
+ You can (and should) edit the /admin view at app/views/admin/index.html. It starts out blank.
43
+
44
+ h3. Sidebar
45
+
46
+ Every view file does or can have a <code>content_for :sidebar</code> block where you can content for the sidebar
47
+
48
+
49
+ h2. Testing
50
+
51
+ h3. Gem tests
52
+
53
+ 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
+
55
+ h4. Working with the tests gotchas
56
+
57
+ 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.
58
+
59
+ h2. License
60
+
61
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'FlexibleAdminmin'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ module FlexibleAdmin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ module FlexibleAdmin
2
+ end
@@ -0,0 +1,177 @@
1
+ require 'rails/generators'
2
+
3
+ # http://guides.rubyonrails.org/generators.html
4
+ # http://rdoc.info/github/wycats/thor/master/Thor/Actions.html
5
+ # keep generator idempotent, thanks
6
+
7
+ module FlexibleAdmin
8
+ class FlexibleAdminGenerator < Rails::Generators::Base
9
+ namespace "flexible_admin"
10
+ source_root File.expand_path("../templates", __FILE__)
11
+ argument :model_name, :type => :string, :required => true, :desc => "Model name for admin section generation"
12
+
13
+ desc "flexible_admin resource generator, rails g flexible_admin Post"
14
+
15
+ def creates_resource_views
16
+ template "resources/index.html.erb", "app/views/admin/#{resources_name}/index.html.erb"
17
+ template "resources/new.html.erb", "app/views/admin/#{resources_name}/new.html.erb"
18
+ template "resources/edit.html.erb", "app/views/admin/#{resources_name}/edit.html.erb"
19
+ template "resources/form.html.erb", "app/views/admin/#{resources_name}/_form.html.erb"
20
+ end
21
+
22
+ def remove_any_namespace_admin_comments_in_routes
23
+ gsub_file 'config/routes.rb', /#\s*(namespace :admin do)/, ''
24
+ end
25
+
26
+ def make_routes
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
39
+ end
40
+ else
41
+ route_info = "
42
+ namespace :admin do
43
+ resources :#{resources_name}, :except => :show do
44
+ member do
45
+ get 'toggle'
46
+ end
47
+ end
48
+ end"
49
+ route(route_info)
50
+ end
51
+ end
52
+
53
+ def create_resources_controller
54
+ template "admin_resources_controller.rb", "app/controllers/admin/resources_controller.rb"
55
+ template "resources_controller.rb", "app/controllers/admin/#{resources_name}_controller.rb"
56
+ end
57
+
58
+ def add_to_navigation_menu
59
+ gsub_file 'app/views/layouts/admin/_navigation.html.erb', "models = %w(", "models = %w(#{resources_name} "
60
+ end
61
+
62
+ private
63
+
64
+ def model
65
+ singular_name.classify.constantize
66
+ end
67
+
68
+ def resources_name
69
+ model_name.tableize
70
+ end
71
+
72
+ def singular_name
73
+ resources_name.singularize
74
+ end
75
+
76
+ def instance_variable_resource
77
+ "@#{resources_name.singularize}"
78
+ end
79
+
80
+ def upper_case_resources_name
81
+ upper_case_resource_name.pluralize
82
+ end
83
+
84
+ def upper_case_resource_name
85
+ resources_name.classify.pluralize
86
+ end
87
+
88
+ def table_column_headers
89
+ model_title = ["<th>#{model_title(model)}</th>"]
90
+ other_columns = table_column_names_for(model).collect{|column_name| "<th>#{column_name.titleize}</th>" }
91
+ (model_title + other_columns).join("\n ")
92
+ end
93
+
94
+ def model_title(model)
95
+ attributes = model.column_names
96
+ if attributes.include?("title")
97
+ "Title"
98
+ elsif attributes.include?("name")
99
+ "Name"
100
+ else
101
+ "#{model.name} ID"
102
+ end
103
+ end
104
+
105
+ def table_rows
106
+ model_title_value = "<td><%= link_to #{model_title_value(model)}, edit_admin_#{singular_name}_path(#{singular_name}) %></td>"
107
+ other_columns = table_columns_for(model).collect do |column|
108
+ if column.name =~ /_file_name/
109
+ column_name = column.name.split("_file_name").first
110
+ "<td><%= #{singular_name}.#{column_name}.url, :width => 24, :height => 24) %></td>"
111
+ elsif column.type == :datetime
112
+ "<td><%= #{singular_name}.#{column.name}.strftime(\"%F\") %></td>"
113
+ elsif column.type == :boolean
114
+ "<td><%= toggle(#{singular_name}, :#{column.name}) %></td>"
115
+ else
116
+ "<td><%= #{singular_name}.#{column.name} %></td>"
117
+ end
118
+ end
119
+ ([model_title_value] + other_columns).join("\n ")
120
+ end
121
+
122
+ def model_title_value(model)
123
+ attributes = model.column_names
124
+ if attributes.include?("title")
125
+ "#{singular_name}.title"
126
+ elsif attributes.include?("name")
127
+ "#{singular_name}.name"
128
+ else
129
+ "#{singular_name}.id"
130
+ end
131
+ end
132
+
133
+ def columns_for(model)
134
+ rejections = %w( ^id$ _type$ type created_at created_on updated_at updated_on deleted_at reset_password_token reset_password_sent_at sign_in _content_type file_size).join("|")
135
+ model.columns.reject { |f| f.name.match(rejections) }
136
+ end
137
+
138
+ def table_columns_for(model)
139
+ rejections = %w( ^id$ _type$ type password remember ^name$ ^title$ created_on updated_at updated_on deleted_at reset_password_token reset_password_sent_at sign_in _content_type file_size).join("|")
140
+ desired_columns = model.columns.reject { |f| f.name.match(rejections) }
141
+ end
142
+
143
+ def table_column_names_for(model)
144
+ table_columns_for(model).collect { |c| c.name =~ /_file_name/ ? c.name.split("_file_name").first : c.name }
145
+ end
146
+
147
+ def render_form_fields(model)
148
+ columns_for(model).collect do |column|
149
+ if column.type == :string && column.name =~ /_file_name/
150
+ column_name = column.name.split("_file_name").first
151
+ "<%= render 'admin/shared/file_field', :f => f, :what => :#{column_name} %>"
152
+ elsif column.type == :string && column.name =~ /encrypted_password/
153
+ "<%= render 'admin/shared/text_field', :f => f, :what => :password %>"
154
+ elsif column.type == :string && column.name =~ /email/
155
+ "<%= render 'admin/shared/email_field', :f => f, :what => :#{column.name} %>"
156
+ elsif column.type == :boolean
157
+ "<%= render 'admin/shared/checkbox_field', :f => f, :what => :#{column.name} %>"
158
+ elsif column.type == :text
159
+ "<%= render 'admin/shared/text_area_field', :f => f, :what => :#{column.name} %>"
160
+ else
161
+ "<%= render 'admin/shared/text_field', :f => f, :what => :#{column.name} %>"
162
+ end
163
+ end.join("\n")
164
+
165
+ end
166
+
167
+
168
+ def has_admin_route_namespace?
169
+ File.open(File.join(destination_root, 'config', 'routes.rb')).read.index("namespace :admin do")
170
+ end
171
+
172
+ def has_this_route_already?
173
+ File.open(File.join(destination_root, 'config', 'routes.rb')).read.index("resources :#{resources_name}")
174
+ end
175
+
176
+ end
177
+ end
@@ -0,0 +1,99 @@
1
+ require 'rails/generators'
2
+
3
+ # http://guides.rubyonrails.org/generators.html
4
+ # http://rdoc.info/github/wycats/thor/master/Thor/Actions.html
5
+ # keep generator idempotent, thanks
6
+
7
+ module FlexibleAdmin
8
+ class InstallGenerator < Rails::Generators::Base
9
+ source_root File.expand_path("../templates", __FILE__)
10
+
11
+ desc "flexible_admin installation generator"
12
+
13
+ def create_admin_view
14
+ template "admin_index.html.erb", "app/views/admin/index.html.erb"
15
+ end
16
+
17
+ def create_admin_layout_view
18
+ template "admin_layout.html.erb", "app/views/layouts/admin/base.html.erb"
19
+ template "navigation.html.erb", "app/views/layouts/admin/_navigation.html.erb"
20
+ template "flash.html.erb", "app/views/layouts/admin/_flash.html.erb"
21
+ end
22
+
23
+ def create_shared_form_files
24
+ template "forms/text_field.html.erb", "app/views/admin/shared/_text_field.html.erb"
25
+ template "forms/text_area_field.html.erb", "app/views/admin/shared/_text_area_field.html.erb"
26
+ template "forms/select_field.html.erb", "app/views/admin/shared/_select_field.html.erb"
27
+ template "forms/file_field.html.erb", "app/views/admin/shared/_file_field.html.erb"
28
+ template "forms/email_field.html.erb", "app/views/admin/shared/_email_field.html.erb"
29
+ template "forms/cktext_area_field.html.erb", "app/views/admin/shared/_cktext_area_field.html.erb"
30
+ template "forms/checkbox_field.html.erb", "app/views/admin/shared/_checkbox_field.html.erb"
31
+ template "forms/error_messages.html.erb", "app/views/admin/shared/_error_messages.html.erb"
32
+ template "forms/password_field.html.erb", "app/views/admin/shared/_password_field.html.erb"
33
+ end
34
+
35
+ def create_admin_helper
36
+ template "admin_helper.rb", "app/helpers/admin_helper.rb"
37
+ end
38
+
39
+ def create_stylesheets
40
+ template "stylesheets/bootstrap.sass", "app/assets/stylesheets/admin/bootstrap.sass"
41
+ template "stylesheets/application.css", "app/assets/stylesheets/admin/application.css"
42
+ template "stylesheets/demo_table.css", "app/assets/stylesheets/admin/datatables/demo_table.css"
43
+ end
44
+
45
+ def creates_datatables_images
46
+ template "images/back_disabled.jpg", "app/assets/images/admin/datatables/back_disabled.jpg"
47
+ template "images/back_enabled.jpg", "app/assets/images/admin/datatables/back_enabled.jpg"
48
+ template "images/forward_disabled.jpg", "app/assets/images/admin/datatables/forward_disabled.jpg"
49
+ template "images/forward_enabled.jpg", "app/assets/images/admin/datatables/forward_enabled.jpg"
50
+
51
+ template "images/sort_asc.png", "app/assets/images/admin/datatables/sort_asc.png"
52
+ template "images/sort_desc.png", "app/assets/images/admin/datatables/sort_desc.png"
53
+ template "images/sort_both.png", "app/assets/images/admin/datatables/sort_both.png"
54
+ template "images/sort_asc_disabled.png", "app/assets/images/admin/datatables/sort_asc_disabled.png"
55
+ template "images/sort_desc_disabled.png", "app/assets/images/admin/datatables/sort_desc_disabled.png"
56
+ end
57
+
58
+ def creates_javascripts
59
+ template "javascripts/application.js", "app/assets/javascripts/admin/application.js"
60
+ template "javascripts/app.js", "app/assets/javascripts/admin/app.js"
61
+ template "javascripts/jquery.dataTables.js", "app/assets/javascripts/admin/jquery.dataTables.js"
62
+ end
63
+
64
+ def make_admin_route
65
+ route("get '/admin' => 'admin#index'")
66
+ end
67
+
68
+ def create_admin_controller
69
+ template "admin_controller.rb", "app/controllers/admin_controller.rb"
70
+ end
71
+
72
+ def inherited_resources
73
+ gem 'inherited_resources'
74
+ end
75
+
76
+ def devise
77
+ unless defined?(Devise)
78
+ say "Adding devise gem to your Gemfile:"
79
+ append_file "Gemfile", "\n", :force => true
80
+ gem 'devise'
81
+ end
82
+
83
+ unless File.exists?(Rails.root.join("config/initializers/devise.rb"))
84
+ say "Installing devise"
85
+ generate "devise:install"
86
+ end
87
+
88
+ unless File.exists?(Rails.root.join("app/models/admin_user.rb"))
89
+ generate "devise AdminUser"
90
+ template "user_sign_in.html.erb", "app/views/admin/admin_users/sessions/new.html.erb"
91
+ 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"
93
+ end
94
+
95
+ say "you now need to run 'rake db:migrate' to create the admin_users table", :blue
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,21 @@
1
+ class AdminController < ApplicationController
2
+ before_filter :authenticate_admin_user!
3
+ layout 'admin/base'
4
+
5
+ def index
6
+ end
7
+
8
+ def toggle
9
+ @resource = resource
10
+ @resource.toggle(params[:field])
11
+ @resource.save
12
+ redirect_to :back, :notice => "#{resource.class.to_s} successfully updated"
13
+ end
14
+
15
+ private
16
+ def resource
17
+ params[:controller].extract_class
18
+ end
19
+ # helper_method :resource
20
+
21
+ end
@@ -0,0 +1,49 @@
1
+ module AdminHelper
2
+
3
+ def optional_label(form, field, label, cssclass = nil)
4
+ if label.present?
5
+ if cssclass.present?
6
+ form.label field, label, :class => cssclass
7
+ else
8
+ form.label field, label
9
+ end
10
+ else
11
+ if cssclass.present?
12
+ form.label field, label, :class => cssclass
13
+ else
14
+ form.label field
15
+ end
16
+ end
17
+ end
18
+
19
+ def admin_nav_item(item)
20
+ content_tag(:li, link_to(item.humanize.titlecase, Rails.application.routes.url_helpers.send("admin_#{item}_path")), :class => active_if(controller_name == item))
21
+ end
22
+
23
+ def active_if(selected)
24
+ if selected
25
+ "active"
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ def help_text_present?(all_variables)
32
+ all_variables.include?(:help)
33
+ end
34
+
35
+ def toggle(resource, attribute)
36
+ if resource.send(attribute)
37
+ link_to "True", toggle_admin_path(resource, attribute)
38
+ else
39
+ link_to "False", toggle_admin_path(resource, attribute)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def toggle_admin_path(resource, field)
46
+ url_for(:controller => "admin/#{resource.class.name.pluralize.downcase}", :action => "toggle", :id => resource.id, :field => field)
47
+ end
48
+
49
+ end
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+
5
+ <head>
6
+ <meta charset="utf-8" />
7
+
8
+ <title>Flexible Admin</title>
9
+ <%%= stylesheet_link_tag 'admin/application' %>
10
+ <%%= javascript_include_tag 'admin/application' %>
11
+ <%%= csrf_meta_tag %>
12
+ </head>
13
+
14
+ <body>
15
+
16
+ <%%= render 'layouts/admin/navigation' %>
17
+
18
+ <div class="container-fluid">
19
+ <div class="sidebar">
20
+
21
+ </div><!-- .sidebar -->
22
+ <div class="content">
23
+ <%%= render 'layouts/admin/flash', :flash => flash %>
24
+ <%%= yield :layout %>
25
+ </div>
26
+ </div>
27
+
28
+ </body>
29
+
30
+ </html>
@@ -0,0 +1,7 @@
1
+ class Admin::ResourcesController < AdminController
2
+ inherit_resources
3
+ defaults :route_prefix => 'admin'
4
+ respond_to :html
5
+ actions :all, :except => :show
6
+
7
+ end
@@ -0,0 +1,3 @@
1
+ class Admin::AdminUsers::SessionsController < Devise::SessionsController
2
+ layout 'admin/base'
3
+ end
@@ -0,0 +1,9 @@
1
+ <%% if flash.present? %>
2
+ <div id="flash" class="clearfix">
3
+ <%% flash.each do |key, value| -%>
4
+ <div class="alert-message <%%= key %>" data-alert="alert">
5
+ <p><%%= value %></p>
6
+ </div>
7
+ <%% end -%>
8
+ </div>
9
+ <%% end %>
@@ -0,0 +1,10 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <div class="input-prepend">
7
+ <label class="add-on"><%%= f.check_box what %></label>
8
+ </div>
9
+ </div>
10
+ </div><!-- /clearfix -->
@@ -0,0 +1,9 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <%%= f.cktext_area what, :toolbar => 'Easy', :width => 800, :height => 400 %>
7
+ <%%= content_tag(:span, help, :class => 'help-block') if help_text_present?(local_variables) %>
8
+ </div>
9
+ </div><!-- /clearfix -->
@@ -0,0 +1,8 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <%%= f.email_field what %>
7
+ </div>
8
+ </div><!-- /clearfix -->
@@ -0,0 +1,10 @@
1
+ <%% if item.errors.any? %>
2
+ <div class="alert-message block-message error">
3
+ <p><strong>You got an error!</strong></p>
4
+ <ul>
5
+ <%% item.errors.full_messages.each do |msg| %>
6
+ <li><%%= msg %></li>
7
+ <%% end %>
8
+ </ul>
9
+ </div>
10
+ <%% end %>
@@ -0,0 +1,8 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <%%= f.file_field what %>
7
+ </div>
8
+ </div><!-- /clearfix -->
@@ -0,0 +1,6 @@
1
+ <div class="clearfix">
2
+ <%%= f.label what %>
3
+ <div class="input">
4
+ <%%= f.password_field what %>
5
+ </div>
6
+ </div><!-- /clearfix -->
@@ -0,0 +1,8 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <%%= f.select what, collection %>
7
+ </div>
8
+ </div><!-- /clearfix -->
@@ -0,0 +1,9 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <%%= f.text_area what, :class => 'span6', :rows => 10 %>
7
+ <%%= content_tag(:span, help, :class => 'help-block') if help_text_present?(local_variables) %>
8
+ </div>
9
+ </div><!-- /clearfix -->
@@ -0,0 +1,9 @@
1
+ <%% label ||= nil %>
2
+
3
+ <div class="clearfix">
4
+ <%%= optional_label(f, what, label) %>
5
+ <div class="input">
6
+ <%%= f.text_field what, :class => 'span6' %>
7
+ <%%= content_tag(:span, help, :class => 'help-block') if help_text_present?(local_variables) %>
8
+ </div>
9
+ </div><!-- /clearfix -->
@@ -0,0 +1,5 @@
1
+ $(document).ready(function() {
2
+ $("#flash").delay(6000).fadeOut(3000);
3
+ $('.sortable').dataTable();
4
+ });
5
+