admin_interface 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.rdoc +12 -3
- data/admin_interface.gemspec +16 -11
- data/lib/admin_interface.rb +7 -0
- data/lib/generators/admin_interface/admin_interface_generator.rb +23 -18
- data/lib/generators/admin_interface/templates/INSTALL +1 -10
- data/lib/generators/admin_interface/templates/controllers/resource_controller.rb +13 -78
- data/lib/generators/admin_interface/templates/helpers/admin/base_helper.rb +77 -0
- data/lib/generators/admin_interface/templates/views/layout.html.erb +4 -5
- data/lib/generators/admin_scaffold/admin_scaffold_generator.rb +9 -0
- data/lib/generators/admin_scaffold/templates/INSTALL +1 -8
- data/lib/generators/admin_scaffold/templates/view_index.html.erb +15 -13
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/1downarrow.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/1uparrow.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/all-wcprops +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/entries +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/format +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/authent.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/comment.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/file.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/info.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/notifications.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/options.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/package.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/plugin.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/projects.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/role.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/settings.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/tracker.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/users.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/prop-base/workflow.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/authent.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/comment.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/file.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/info.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/notifications.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/options.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/package.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/plugin.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/projects.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/role.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/settings.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/tracker.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/users.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/.svn/text-base/workflow.png.svn-base +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/authent.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/comment.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/file.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/info.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/notifications.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/options.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/package.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/plugin.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/projects.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/role.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/settings.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/tracker.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/users.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/22x22/workflow.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/2downarrow.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/2uparrow.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/add.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/arrow_collapsed.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/arrow_down.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/arrow_expanded.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/attachment.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_add.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_arrow_left.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_arrow_right.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_black.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_blue.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_delete.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_diamond.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_end.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_go.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_orange.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_purple.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_toggle_minus.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/bullet_toggle_plus.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/calendar.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/cancel.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/changeset.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/close.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/close_hl.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/comment.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/comments.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/copy.png +0 -0
- data/vendor/assets/images/admin/crop.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/database_key.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/delete.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/destroy.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/document.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/download.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/draft.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/duplicate.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/edit.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/email.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/exclamation.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/external.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/false.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/fav.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/fav_off.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/feed.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/c.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/csharp.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/default.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/image.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/pdf.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/php.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/ruby.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/text.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/xml.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/files/zip.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/folder.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/folder_open.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/folder_open_add.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/folder_open_orange.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/group.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/help.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/history.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_bq.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_bq_remove.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_code.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_del.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_em.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_h1.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_h2.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_h3.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_img.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_ins.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_link.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_ol.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_pre.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_strong.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/jstoolbar/bt_ul.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/lightning.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/link.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/loading.gif +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/locked.png +0 -0
- data/vendor/assets/images/admin/mail.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/message.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/milestone.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/move.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/news.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/openid-bg.gif +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/package.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/page_go.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/plugin.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/projects.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/reload.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/report.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/save.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/search.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/server_key.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/sort_asc.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/sort_desc.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/stats.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/table_multiple.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/task_done.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/task_late.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/task_parent_end.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/task_todo.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/text_list_bullets.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/textfield.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/ticket.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/ticket_checked.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/ticket_edit.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/ticket_go.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/ticket_note.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/time.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/time_add.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/toggle_check.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/true.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/unlock.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/user.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/user_go.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/warning.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/wiki_edit.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/zoom_in.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/zoom_in_g.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/zoom_out.png +0 -0
- data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/zoom_out_g.png +0 -0
- data/{lib/generators/admin_interface/templates → vendor/assets}/javascripts/jquery.admin.js +0 -0
- data/{lib/generators/admin_interface/templates/views → vendor/assets/stylesheets}/admin.css +375 -230
- metadata +213 -179
- data/lib/generators/admin_interface/templates/helpers/admin_helper.rb +0 -24
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.rdoc
CHANGED
@@ -16,6 +16,12 @@ Add following to your Gemfile
|
|
16
16
|
gem 'admin_interface'
|
17
17
|
end
|
18
18
|
|
19
|
+
AdminInterface uses several gems. So put these in your Gemfile
|
20
|
+
|
21
|
+
gem 'inherited_resources'
|
22
|
+
gem 'meta_search'
|
23
|
+
gem 'kaminari'
|
24
|
+
|
19
25
|
Or install as plugin from Github.
|
20
26
|
|
21
27
|
rails plugin install git://github.com/joost/admin_interface.git
|
@@ -38,7 +44,7 @@ Next, add following routes to config/routes.rb.
|
|
38
44
|
root :to => 'base#index'
|
39
45
|
# Add the following after you've used the admin_scaffold generator
|
40
46
|
resources :model do
|
41
|
-
delete '
|
47
|
+
delete 'destroy_all', :on => :collection
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
@@ -71,14 +77,17 @@ Go to /admin and you can see everything in action.
|
|
71
77
|
|
72
78
|
== Error messages
|
73
79
|
|
74
|
-
Add this to your environment.rb (see: http://railscasts.com/episodes/39-customize-field-error)
|
80
|
+
Add this to a initializer or in your environment.rb (see: http://railscasts.com/episodes/39-customize-field-error)
|
75
81
|
This will make sure the admin errors will show in correct styling.
|
76
82
|
|
77
83
|
# Change the error from div to span
|
78
84
|
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
|
79
|
-
"<span class='
|
85
|
+
"<span class='field_with_errors'>#{html_tag}</span>".html_safe
|
80
86
|
end
|
81
87
|
|
88
|
+
Note that this might affect the rest of your application. A different solution is
|
89
|
+
welcome!
|
90
|
+
|
82
91
|
== Kudos
|
83
92
|
|
84
93
|
Kudos, credits or whatever you like more go to:
|
data/admin_interface.gemspec
CHANGED
@@ -2,16 +2,21 @@
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require "devise/version"
|
4
4
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "admin_interface"
|
7
|
+
spec.version = '1.2.0'
|
8
|
+
spec.platform = Gem::Platform::RUBY
|
9
|
+
spec.summary = "A Rails admin interface generator. Theme stolen from Redmine."
|
10
|
+
spec.email = "joost@joopp.com"
|
11
|
+
spec.homepage = "http://github.com/joost/admin_interface"
|
12
|
+
spec.description = "A Rails admin interface generator. Theme stolen from Redmine. Similar to web-app-theme but better ;)."
|
13
|
+
spec.authors = ['Joost Hietbrink']
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# kaminari (pagination), meta_search (search), inherited_resources (coolness)
|
16
|
+
spec.add_dependency('kaminari', '>= 0.12.4')
|
17
|
+
spec.add_dependency('meta_search', '>= 1.1.0.pre2')
|
18
|
+
spec.add_dependency('inherited_resources', '>= 1.2.2')
|
19
|
+
|
20
|
+
spec.files = `git ls-files`.split("\n")
|
21
|
+
spec.require_paths = ["lib"]
|
17
22
|
end
|
@@ -2,12 +2,12 @@ class AdminInterfaceGenerator < Rails::Generators::Base
|
|
2
2
|
|
3
3
|
source_root File.expand_path("../templates", __FILE__)
|
4
4
|
|
5
|
-
def copy_image_files
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
# def copy_image_files
|
6
|
+
# # Images
|
7
|
+
# # Copy all images to public/images/admin
|
8
|
+
# admin_image_dir = File.join('public', 'images', 'admin')
|
9
|
+
# directory('images', admin_image_dir)
|
10
|
+
# end
|
11
11
|
|
12
12
|
def copy_controller_files
|
13
13
|
copy_file("controllers/base_controller.rb", "app/controllers/admin/base_controller.rb")
|
@@ -16,24 +16,29 @@ class AdminInterfaceGenerator < Rails::Generators::Base
|
|
16
16
|
|
17
17
|
def copy_view_files
|
18
18
|
copy_file("views/layout.html.erb", "app/views/layouts/admin.html.erb")
|
19
|
-
copy_file("views/index.html.erb", "app/views/admin/index.html.erb")
|
19
|
+
copy_file("views/index.html.erb", "app/views/admin/base/index.html.erb")
|
20
20
|
end
|
21
21
|
|
22
|
-
def copy_javascript_files
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def copy_stylesheet_files
|
27
|
-
|
28
|
-
end
|
22
|
+
# def copy_javascript_files
|
23
|
+
# copy_file("javascripts/jquery.admin.js", "public/javascripts/jquery.admin.js")
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# def copy_stylesheet_files
|
27
|
+
# copy_file("views/admin.css", "public/stylesheets/admin.css")
|
28
|
+
# end
|
29
29
|
|
30
30
|
def copy_helper_files
|
31
|
-
copy_file("helpers/
|
31
|
+
copy_file("helpers/admin/base_helper.rb", "app/helpers/admin/base_helper.rb")
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
#
|
34
|
+
def add_admin_route
|
35
|
+
route "namespace :admin do"
|
36
|
+
route " root :to => 'base#index"
|
37
|
+
route " # resources :some_model do"
|
38
|
+
route " # delete 'delete_all', :on => :collection"
|
39
|
+
route " # end"
|
40
|
+
route "end"
|
41
|
+
end
|
37
42
|
|
38
43
|
def show_readme
|
39
44
|
readme("INSTALL")
|
@@ -1,10 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
map.admin 'admin', :controller => 'admin'
|
4
|
-
map.namespace :admin do |admin|
|
5
|
-
# Add the following after you've used the admin_scaffold generator
|
6
|
-
# admin.resources :model, :collection => {:destroy_all => :delete}
|
7
|
-
end
|
8
|
-
|
9
|
-
Change the app/controllers/admin_controller.rb to have a before filter
|
10
|
-
only allowing admins to access it.
|
1
|
+
See the README file on what to add to your routes.rb file!
|
@@ -1,92 +1,27 @@
|
|
1
1
|
class Admin::ResourceController < Admin::BaseController
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
inherit_resources # gem
|
4
|
+
defaults :route_prefix => 'admin'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def show
|
11
|
-
end
|
12
|
-
|
13
|
-
def new
|
14
|
-
@resource = resource_class.new
|
15
|
-
instance_variable_set("@#{resource_instance_variable_name}", @resource)
|
16
|
-
end
|
17
|
-
|
18
|
-
def edit
|
19
|
-
end
|
20
|
-
|
21
|
-
def create
|
22
|
-
@resource = resource_class.new(params_hash_for_resource)
|
23
|
-
instance_variable_set("@#{resource_instance_variable_name}", @resource)
|
24
|
-
|
25
|
-
if @resource.save
|
26
|
-
redirect_to([:admin, @resource], :notice => 'Object was successfully created.')
|
27
|
-
else
|
28
|
-
render :action => "new"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def update
|
33
|
-
if @resource.update_attributes(params_hash_for_resource)
|
34
|
-
redirect_to([:admin, @resource], :notice => 'Object was successfully updated.')
|
35
|
-
else
|
36
|
-
render :action => "edit"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def destroy
|
41
|
-
@resource.destroy
|
42
|
-
|
43
|
-
redirect_to :action => :index
|
44
|
-
end
|
6
|
+
# inherited_resources options
|
7
|
+
# nested_belongs_to :user, :optional => true
|
45
8
|
|
46
9
|
def destroy_all
|
47
10
|
destroyed_resources = resource_class.destroy_all(:id => params[:ids])
|
48
11
|
flash[:notice] = "#{destroyed_resources.size} objects destroyed."
|
49
|
-
redirect_to :
|
12
|
+
redirect_to :back
|
50
13
|
end
|
51
14
|
|
52
15
|
protected
|
53
16
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
def resource_class
|
63
|
-
controller_name.singularize.camelize.constantize
|
64
|
-
end
|
65
|
-
|
66
|
-
def filter_load_resources
|
67
|
-
instance_variable_set("@#{resources_instance_variable_name}", current_resources)
|
68
|
-
end
|
69
|
-
|
70
|
-
def filter_load_resource
|
71
|
-
instance_variable_set("@#{resource_instance_variable_name}", current_resource)
|
72
|
-
end
|
73
|
-
|
74
|
-
def resources_instance_variable_name
|
75
|
-
instance_variable_name
|
76
|
-
end
|
77
|
-
|
78
|
-
def resource_instance_variable_name
|
79
|
-
instance_variable_name.singularize
|
80
|
-
end
|
81
|
-
|
82
|
-
# The name of the instance variable that load_object should assign to.
|
83
|
-
# By default this is the controller_name.
|
84
|
-
def instance_variable_name
|
85
|
-
controller_name
|
86
|
-
end
|
87
|
-
|
88
|
-
def params_hash_for_resource
|
89
|
-
params[resource_instance_variable_name]
|
17
|
+
# Overwrites inherited_resources gem version.
|
18
|
+
# Use meta_search and kaminari gem to load collection
|
19
|
+
def collection
|
20
|
+
@search ||= end_of_association_chain.search(params[:search])
|
21
|
+
get_collection_ivar || begin
|
22
|
+
c = @search.page(params[:page]).per(params[:per])
|
23
|
+
set_collection_ivar(c.respond_to?(:scoped) ? c.scoped : c)
|
24
|
+
end
|
90
25
|
end
|
91
26
|
|
92
27
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Admin::BaseHelper
|
2
|
+
|
3
|
+
# Following methods are ripped from RedMine but very nice!
|
4
|
+
|
5
|
+
# Overwrites content_for helper to set has_content?.
|
6
|
+
def content_for(name, content = nil, &block)
|
7
|
+
@has_content ||= {}
|
8
|
+
@has_content[name] = true
|
9
|
+
super(name, content, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns if we have content for a specific yield.
|
13
|
+
def has_content?(name)
|
14
|
+
(@has_content && @has_content[name]) || false
|
15
|
+
end
|
16
|
+
|
17
|
+
# Renders flash messages.
|
18
|
+
def render_flash_messages
|
19
|
+
flash_string = ''
|
20
|
+
flash.each do |k,v|
|
21
|
+
flash_string << content_tag('div', v, :class => "flash #{k}")
|
22
|
+
end
|
23
|
+
flash_string.html_safe
|
24
|
+
end
|
25
|
+
|
26
|
+
# Following are other helper methods.
|
27
|
+
|
28
|
+
def true_false_image(boolean)
|
29
|
+
raise ArgumentError, "Expected a Boolean as argument!" unless boolean.is_a?(FalseClass) || boolean.is_a?(TrueClass)
|
30
|
+
image_tag("admin/#{boolean}.png")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Overwrites l helper.
|
34
|
+
# Make the I18n localize method work with nil dates!
|
35
|
+
# Attribute must be Date, DateTime or Time object or nil :)
|
36
|
+
# Returns '' if attribute is nil.
|
37
|
+
def l(time)
|
38
|
+
time.nil? ? '' : I18n.l(time)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Following are extra helper for kaminari gem (pagination).
|
42
|
+
# It shows similar to Redmine.
|
43
|
+
|
44
|
+
# Shows paginate, paginate_info and perinate.
|
45
|
+
# Like: '1 2 3 4 5 ... Next › Last » (1-25/4028) | Per page: 25, 50, 100'
|
46
|
+
def navigate(collection)
|
47
|
+
return if collection.blank?
|
48
|
+
html = paginate(collection) + paginate_info(collection) + ' | ' + perinate(collection)
|
49
|
+
content_tag(:div, html.html_safe, :class => 'navigation').html_safe
|
50
|
+
end
|
51
|
+
|
52
|
+
# Shows pagination info like '(51-75/815)'.
|
53
|
+
# Uses I18n 'en.views.pagination_info' translation key.
|
54
|
+
def paginate_info(collection)
|
55
|
+
return if collection.blank?
|
56
|
+
first = collection.offset_value + 1
|
57
|
+
last = [collection.offset_value + collection.limit_value, collection.total_count].min
|
58
|
+
total = collection.total_count
|
59
|
+
html = I18n.t('views.pagination_info', :default => "(%{first}-%{last}/%{total})", :first => first, :last => last, :total => total)
|
60
|
+
content_tag(:nav, html.html_safe, :class => 'pagination info').html_safe
|
61
|
+
end
|
62
|
+
|
63
|
+
# Shows a 'Per page: 25 50 100'.
|
64
|
+
# Uses I18n 'en.views.perinate' translation key.
|
65
|
+
def perinate(collection, options = {})
|
66
|
+
return if collection.blank?
|
67
|
+
options.reverse_merge!(:values => [25, 50, 100])
|
68
|
+
page = (collection.offset_value / collection.limit_value).to_i + 1
|
69
|
+
html = I18n.t('views.perinate', :default => "Per page: ")
|
70
|
+
html += options[:values].collect do |value|
|
71
|
+
page = (collection.offset_value / value).to_i + 1 # This makes sure we always show the same first entry
|
72
|
+
link_to_if(value != collection.limit_value, value, params.merge(:per => value, :page => page))
|
73
|
+
end.join(', ')
|
74
|
+
content_tag(:nav, html.html_safe, :class => 'perination').html_safe
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -4,9 +4,8 @@
|
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
6
6
|
<title>Admin</title>
|
7
|
-
<%= stylesheet_link_tag
|
8
|
-
<%= javascript_include_tag :
|
9
|
-
<%= javascript_include_tag 'jquery.admin.js' %>
|
7
|
+
<%= stylesheet_link_tag 'admin' %>
|
8
|
+
<%= javascript_include_tag :application, 'jquery.admin.js' %>
|
10
9
|
<%= csrf_meta_tag %>
|
11
10
|
</head>
|
12
11
|
<body>
|
@@ -24,9 +23,9 @@
|
|
24
23
|
<div id="main-menu">
|
25
24
|
<div class="tabs" id="admin_tabnav">
|
26
25
|
<ul>
|
27
|
-
<%= content_tag(:li, link_to('Overview', '/admin', :class => ((controller_name == '
|
26
|
+
<%= content_tag(:li, link_to('Overview', '/admin', :class => ((controller_name == 'base') ? 'selected' : ''))) %>
|
28
27
|
<% Admin::BaseController.tabs.each do |tab| %>
|
29
|
-
<%= content_tag(:li, link_to(tab.humanize,
|
28
|
+
<%= content_tag(:li, link_to(tab.humanize, [:admin, tab], :class => ((controller_name == tab) ? 'selected' : ''))) %>
|
30
29
|
<% end %>
|
31
30
|
</ul>
|
32
31
|
</div>
|
@@ -20,6 +20,15 @@ class AdminScaffoldGenerator < Rails::Generators::NamedBase
|
|
20
20
|
alias_method :controller_file_name, :controller_file_name
|
21
21
|
alias_method :controller_table_name, :controller_plural_name
|
22
22
|
|
23
|
+
def check_class_collisions # TODO
|
24
|
+
# Check for class naming collisions.
|
25
|
+
# class_collisions class_path, "Admin::#{class_name}Controller"
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_controller_files
|
29
|
+
template 'controller.rb', File.join(CONTROLLER_PATH, class_path, "#{controller_file_name}_controller.rb")
|
30
|
+
end
|
31
|
+
|
23
32
|
def create_admin_scaffold
|
24
33
|
@name = file_name
|
25
34
|
|
@@ -1,8 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
map.admin 'admin', :controller => 'admin'
|
4
|
-
map.namespace :admin do |admin|
|
5
|
-
# Add the following after you've used the admin_scaffold generator
|
6
|
-
# admin.resources :model, :collection => {:destroy_all => :delete}
|
7
|
-
end
|
8
|
-
|
1
|
+
See the README file on what to add to your routes.rb file!
|
@@ -1,8 +1,20 @@
|
|
1
1
|
<div class="contextual">
|
2
2
|
<%%= link_to 'New <%= singular_name %>', new_admin_<%= singular_name %>_path, :class => 'icon icon-add' %>
|
3
|
+
| <%%= form_for @search, :url => collection_url do |f| %>
|
4
|
+
<%%
|
5
|
+
# Check https://github.com/ernie/meta_search for options.
|
6
|
+
# Simply change :id_equals into :name_contains, etc.
|
7
|
+
%>
|
8
|
+
<%%= f.text_field :id_equals, :placeholder => 'Search by ID' %>
|
9
|
+
<%% end %>
|
3
10
|
</div>
|
4
11
|
|
5
|
-
<h2
|
12
|
+
<h2>
|
13
|
+
<%= # FIXME: parent? doesn't always work :S
|
14
|
+
link_to(parent.to_s, [:admin, parent]) + " >".html_safe if defined?(parent) && parent?
|
15
|
+
%>
|
16
|
+
<%= plural_name.humanize %>
|
17
|
+
</h2>
|
6
18
|
|
7
19
|
<%% if @<%= plural_name %>.blank? %>
|
8
20
|
<p class="nodata">No data to display</p>
|
@@ -12,11 +24,7 @@
|
|
12
24
|
<tr>
|
13
25
|
<th class="checkbox"><%%= image_tag "admin/true.png" %></th>
|
14
26
|
<% for attribute in attributes -%>
|
15
|
-
|
16
|
-
<th><%%= order(@search, {:by => :<%= attribute.name %>}) %></th>
|
17
|
-
<% else -%>
|
18
|
-
<th><%= attribute.human_name %></th>
|
19
|
-
<% end -%>
|
27
|
+
<th><%%= sort_link(@search, :<%= attribute.name %>) %></th>
|
20
28
|
<% end -%>
|
21
29
|
<th></th>
|
22
30
|
</tr>
|
@@ -50,10 +58,4 @@
|
|
50
58
|
<%% end %>
|
51
59
|
</table>
|
52
60
|
<%% end %>
|
53
|
-
|
54
|
-
# Remove unneeded stuff here
|
55
|
-
if defined?(Searchlogic) || defined?(WillPaginate)
|
56
|
-
# If you have WillPaginate installed (you should!)
|
57
|
-
%>
|
58
|
-
<%%= will_paginate(@<%= plural_name %>) %>
|
59
|
-
<% end %>
|
61
|
+
<%%= navigate(@<%= plural_name %>) %>
|
data/{lib/generators/admin_interface/templates/images → vendor/assets/images/admin}/1downarrow.png
RENAMED
File without changes
|