manage 1.3.20 → 1.3.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/README.rdoc +96 -96
  4. data/Rakefile +31 -31
  5. data/app/assets/javascripts/manage/application.js +0 -2
  6. data/app/assets/javascripts/manage/collection_actions.js.coffee +30 -30
  7. data/app/assets/javascripts/manage/handlers.js.coffee +46 -46
  8. data/app/assets/javascripts/manage/init.js.coffee +1 -4
  9. data/app/assets/javascripts/manage/table_checkboxes.js.coffee +11 -11
  10. data/app/assets/stylesheets/manage/application.css.scss +1 -2
  11. data/app/assets/stylesheets/manage/layout.css.scss +44 -44
  12. data/app/controllers/manage/application_controller.rb +13 -13
  13. data/app/controllers/manage/dashboards_controller.rb +4 -4
  14. data/app/controllers/manage/resource_controller.rb +125 -125
  15. data/app/controllers/manage/responder.rb +11 -11
  16. data/app/controllers/manage/sessions_controller.rb +11 -11
  17. data/app/helpers/manage/application_helper.rb +42 -42
  18. data/app/helpers/manage/form_helper.rb +21 -21
  19. data/app/helpers/manage/resource_helper.rb +77 -77
  20. data/app/models/admin_user.rb +4 -4
  21. data/app/views/layouts/manage/_main_menu.html.slim +52 -52
  22. data/app/views/layouts/manage/application.html.slim +39 -39
  23. data/app/views/layouts/manage/sign_in.html.slim +30 -30
  24. data/app/views/manage/resource/_form.html.slim +4 -4
  25. data/app/views/manage/resource/index.html.slim +18 -18
  26. data/app/views/manage/resource/index/_collection_actions.html.slim +2 -2
  27. data/app/views/manage/resource/index/_count.html.slim +6 -6
  28. data/app/views/manage/resource/index/_filters.html.slim +22 -22
  29. data/app/views/manage/resource/index/_table.html.slim +25 -25
  30. data/app/views/manage/resource/show.html.slim +10 -10
  31. data/app/views/manage/sessions/new.html.slim +10 -10
  32. data/config/initializers/devise.rb +247 -247
  33. data/config/initializers/session_store.rb +3 -3
  34. data/config/initializers/simple_form.rb +145 -145
  35. data/config/initializers/simple_form_foundation.rb +26 -26
  36. data/config/locales/devise.en.yml +59 -59
  37. data/config/locales/en.yml +20 -20
  38. data/config/routes.rb +10 -10
  39. data/db/migrate/20131204142720_create_admin_users.rb +24 -24
  40. data/lib/manage.rb +5 -5
  41. data/lib/manage/engine.rb +21 -21
  42. data/lib/manage/fields.rb +6 -6
  43. data/lib/manage/fields/reader.rb +57 -57
  44. data/lib/manage/fields/searcher.rb +51 -51
  45. data/lib/manage/version.rb +1 -1
  46. data/lib/tasks/manage_tasks.rake +15 -15
  47. data/lib/templates/erb/scaffold/_form.html.erb +13 -13
  48. data/spec/controllers/manage/resource_controller_spec.rb +29 -29
  49. data/spec/dummy/README.rdoc +28 -28
  50. data/spec/dummy/Rakefile +6 -6
  51. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  52. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  53. data/spec/dummy/app/controllers/application_controller.rb +5 -5
  54. data/spec/dummy/app/controllers/manage/posts_controller.rb +4 -4
  55. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  56. data/spec/dummy/app/models/post.rb +3 -3
  57. data/spec/dummy/app/models/user.rb +5 -5
  58. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  59. data/spec/dummy/bin/bundle +3 -3
  60. data/spec/dummy/bin/rails +4 -4
  61. data/spec/dummy/bin/rake +4 -4
  62. data/spec/dummy/config.ru +4 -4
  63. data/spec/dummy/config/application.rb +24 -24
  64. data/spec/dummy/config/boot.rb +5 -5
  65. data/spec/dummy/config/database.yml +25 -25
  66. data/spec/dummy/config/environment.rb +5 -5
  67. data/spec/dummy/config/environments/development.rb +29 -29
  68. data/spec/dummy/config/environments/production.rb +80 -80
  69. data/spec/dummy/config/environments/test.rb +36 -36
  70. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  71. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  72. data/spec/dummy/config/initializers/inflections.rb +16 -16
  73. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  74. data/spec/dummy/config/initializers/secret_token.rb +12 -12
  75. data/spec/dummy/config/initializers/session_store.rb +3 -3
  76. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  77. data/spec/dummy/config/locales/en.yml +23 -23
  78. data/spec/dummy/config/routes.rb +10 -10
  79. data/spec/dummy/db/migrate/20130716083410_init_migration.rb +21 -21
  80. data/spec/dummy/db/schema.rb +53 -53
  81. data/spec/dummy/public/404.html +58 -58
  82. data/spec/dummy/public/422.html +58 -58
  83. data/spec/dummy/public/500.html +57 -57
  84. data/spec/fields/reader_spec.rb +79 -79
  85. data/spec/spec_helper.rb +24 -24
  86. metadata +88 -110
  87. data/app/assets/javascripts/manage/tinymce/plugins/code/plugin.min.js +0 -1
  88. data/app/assets/javascripts/manage/tinymce/theme.min.js +0 -1
  89. data/app/assets/javascripts/manage/tinymce/tinymce.min.js +0 -9
  90. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/content.inline.min.css +0 -1
  91. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/content.min.css +0 -1
  92. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/readme.md +0 -1
  93. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce-small.eot +0 -0
  94. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce-small.svg +0 -175
  95. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  96. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce-small.woff +0 -0
  97. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce.eot +0 -0
  98. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce.svg +0 -153
  99. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce.ttf +0 -0
  100. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/fonts/tinymce.woff +0 -0
  101. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/img/anchor.gif +0 -0
  102. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/img/loader.gif +0 -0
  103. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/img/object.gif +0 -0
  104. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/img/trans.gif +0 -0
  105. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/img/wline.gif +0 -0
  106. data/app/assets/stylesheets/manage/tinymce/skins/lightgray/skin.min.css +0 -1
  107. data/spec/dummy/log/test.log +0 -0
@@ -1,42 +1,42 @@
1
- module Manage
2
- module ApplicationHelper
3
-
4
- def collection_table collection, resource_class, no_items_text
5
-
6
- if collection.empty?
7
- return content_tag(:h3, resource_class.model_name.human(count: 2)) + content_tag(:p, no_items_text)
8
- else
9
- rows = []
10
-
11
- ths = resource_class.attribute_names.collect do |attr|
12
- content_tag(:td, truncate(resource_class.human_attribute_name(attr).to_s, length: 50))
13
- end.join('').html_safe
14
- rows << content_tag(:tr, ths)
15
-
16
- collection.each do |item|
17
- tds = resource_class.attribute_names.collect do |attr|
18
- content_tag(:td, truncate(item.public_send(attr).to_s, length: 50))
19
- end.join('').html_safe
20
-
21
- rows << content_tag(:tr, tds)
22
- end
23
- content_tag(:h3, resource_class.model_name.human(count: 2)) +
24
- content_tag(:table, rows.join('').html_safe)
25
- end
26
- end
27
-
28
- def condensed_table resource_class, cols=2
29
- rows = []
30
- resource_class.attribute_names.each_slice(cols).each do |slice|
31
- row = slice.collect do |attr|
32
- content_tag(:td, resource_class.human_attribute_name(attr)) +
33
- content_tag(:td, resource.public_send(attr))
34
- end
35
- rows << content_tag(:tr, row.join('').html_safe)
36
- end
37
-
38
- content_tag :table, rows.join('').html_safe
39
- end
40
-
41
- end
42
- end
1
+ module Manage
2
+ module ApplicationHelper
3
+
4
+ def collection_table collection, resource_class, no_items_text
5
+
6
+ if collection.empty?
7
+ return content_tag(:h3, resource_class.model_name.human(count: 2)) + content_tag(:p, no_items_text)
8
+ else
9
+ rows = []
10
+
11
+ ths = resource_class.attribute_names.collect do |attr|
12
+ content_tag(:td, truncate(resource_class.human_attribute_name(attr).to_s, length: 50))
13
+ end.join('').html_safe
14
+ rows << content_tag(:tr, ths)
15
+
16
+ collection.each do |item|
17
+ tds = resource_class.attribute_names.collect do |attr|
18
+ content_tag(:td, truncate(item.public_send(attr).to_s, length: 50))
19
+ end.join('').html_safe
20
+
21
+ rows << content_tag(:tr, tds)
22
+ end
23
+ content_tag(:h3, resource_class.model_name.human(count: 2)) +
24
+ content_tag(:table, rows.join('').html_safe)
25
+ end
26
+ end
27
+
28
+ def condensed_table resource_class, cols=2
29
+ rows = []
30
+ resource_class.attribute_names.each_slice(cols).each do |slice|
31
+ row = slice.collect do |attr|
32
+ content_tag(:td, resource_class.human_attribute_name(attr)) +
33
+ content_tag(:td, resource.public_send(attr))
34
+ end
35
+ rows << content_tag(:tr, row.join('').html_safe)
36
+ end
37
+
38
+ content_tag :table, rows.join('').html_safe
39
+ end
40
+
41
+ end
42
+ end
@@ -1,21 +1,21 @@
1
- module Manage
2
-
3
- module FormHelper
4
- include SimpleForm::ActionViewExtensions::FormHelper
5
-
6
- OPTIONS = {
7
- wrapper: :foundation,
8
- class: 'custom'
9
- }
10
-
11
- def manage_form_for(record, options={}, &block)
12
- simple_form_for(record, options.merge(Manage::FormHelper::OPTIONS), &block)
13
- end
14
-
15
- def manage_fields_for(record_name, record_object = nil, options = {}, &block)
16
- simple_fields_for(record_name, record_object = nil, options.merge(Manage::FormHelper::OPTIONS), &block)
17
- end
18
-
19
- end
20
-
21
- end
1
+ module Manage
2
+
3
+ module FormHelper
4
+ include SimpleForm::ActionViewExtensions::FormHelper
5
+
6
+ OPTIONS = {
7
+ wrapper: :foundation,
8
+ class: 'custom'
9
+ }
10
+
11
+ def manage_form_for(record, options={}, &block)
12
+ simple_form_for(record, options.merge(Manage::FormHelper::OPTIONS), &block)
13
+ end
14
+
15
+ def manage_fields_for(record_name, record_object = nil, options = {}, &block)
16
+ simple_fields_for(record_name, record_object = nil, options.merge(Manage::FormHelper::OPTIONS), &block)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -1,77 +1,77 @@
1
- module Manage
2
- module ResourceHelper
3
- def index_fields
4
- list_index_fields
5
- end
6
-
7
- def edit_fields
8
- list_edit_fields
9
- end
10
-
11
- def attributes
12
- resource_class.attribute_names - %w(id created_at updated_at)
13
- end
14
-
15
- def field_value(scope, field_data)
16
- Fields::Reader.field_value(scope, field_data).to_s
17
- end
18
-
19
- def field_title(resource_class, field_data)
20
- Fields::Reader.field_title(resource_class, field_data)
21
- end
22
-
23
-
24
- #
25
- # to customise the actions for a resource define a list of actions
26
- #
27
- # example:
28
- # action_links :posts, :tickets, ->(resource) {link_to "#{resource.name}"}
29
- #
30
- # @param scope [type] [description]
31
- # @param link_data [type] [description]
32
- #
33
- # @return [type] [description]
34
- def action_link(scope, link_data)
35
- value = nil
36
- case link_data
37
-
38
- when Proc
39
- value = link_data.call(scope)
40
-
41
- when Hash
42
- relation = link_data.keys.first
43
- entity = Fields::Reader.field_value(scope, relation)
44
- unless entity.present?
45
- return ''
46
- end
47
- if link_data[relation][:label_field].present?
48
- value = field_value(scope, link_data[relation][:label_field])
49
- elsif link_data[relation][:label].present?
50
- value = link_data[relation][:label]
51
- end
52
-
53
- path = entity.class.name.dasherize.pluralize.downcase
54
- return link_to value, [scope.public_send(relation)]
55
-
56
- when *[Symbol, String]
57
- relation = link_data.to_s
58
- assocation = scope.class.reflect_on_association(link_data.to_sym)
59
- raise "assocation #{link_data} not found on #{scope.class}" unless assocation
60
- if assocation.options[:class_name].present?
61
- rel_name = scope.class.reflect_on_association(link_data.to_sym).options[:class_name]
62
- relation = rel_name.downcase.dasherize.pluralize
63
- end
64
- if scope.class.reflect_on_association(link_data.to_sym).options[:as].present?
65
- key = scope.class.reflect_on_association(link_data.to_sym).options[:as].to_s + '_id'
66
- else
67
- key = scope.class.name.downcase.dasherize + '_id'
68
- end
69
- return "<a href=\"#{relation}?f%5B#{key}%5D=#{scope.id}\">#{resource_class.human_attribute_name(link_data.to_s)}</a>".html_safe
70
- else
71
- raise 'Unsupported link data'
72
- end
73
-
74
- end
75
-
76
- end
77
- end
1
+ module Manage
2
+ module ResourceHelper
3
+ def index_fields
4
+ list_index_fields
5
+ end
6
+
7
+ def edit_fields
8
+ list_edit_fields
9
+ end
10
+
11
+ def attributes
12
+ resource_class.attribute_names - %w(id created_at updated_at)
13
+ end
14
+
15
+ def field_value(scope, field_data)
16
+ Fields::Reader.field_value(scope, field_data).to_s
17
+ end
18
+
19
+ def field_title(resource_class, field_data)
20
+ Fields::Reader.field_title(resource_class, field_data)
21
+ end
22
+
23
+
24
+ #
25
+ # to customise the actions for a resource define a list of actions
26
+ #
27
+ # example:
28
+ # action_links :posts, :tickets, ->(resource) {link_to "#{resource.name}"}
29
+ #
30
+ # @param scope [type] [description]
31
+ # @param link_data [type] [description]
32
+ #
33
+ # @return [type] [description]
34
+ def action_link(scope, link_data)
35
+ value = nil
36
+ case link_data
37
+
38
+ when Proc
39
+ value = link_data.call(scope)
40
+
41
+ when Hash
42
+ relation = link_data.keys.first
43
+ entity = Fields::Reader.field_value(scope, relation)
44
+ unless entity.present?
45
+ return ''
46
+ end
47
+ if link_data[relation][:label_field].present?
48
+ value = field_value(scope, link_data[relation][:label_field])
49
+ elsif link_data[relation][:label].present?
50
+ value = link_data[relation][:label]
51
+ end
52
+
53
+ path = entity.class.name.dasherize.pluralize.downcase
54
+ return link_to value, [scope.public_send(relation)]
55
+
56
+ when *[Symbol, String]
57
+ relation = link_data.to_s
58
+ assocation = scope.class.reflect_on_association(link_data.to_sym)
59
+ raise "assocation #{link_data} not found on #{scope.class}" unless assocation
60
+ if assocation.options[:class_name].present?
61
+ rel_name = scope.class.reflect_on_association(link_data.to_sym).options[:class_name]
62
+ relation = rel_name.downcase.dasherize.pluralize
63
+ end
64
+ if scope.class.reflect_on_association(link_data.to_sym).options[:as].present?
65
+ key = scope.class.reflect_on_association(link_data.to_sym).options[:as].to_s + '_id'
66
+ else
67
+ key = scope.class.name.downcase.dasherize + '_id'
68
+ end
69
+ return "<a href=\"#{relation}?f%5B#{key}%5D=#{scope.id}\">#{resource_class.human_attribute_name(link_data.to_s)}</a>".html_safe
70
+ else
71
+ raise 'Unsupported link data'
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end
@@ -1,4 +1,4 @@
1
- class AdminUser < ActiveRecord::Base
2
- devise :database_authenticatable, :registerable, :lockable, :timeoutable,
3
- :recoverable, :rememberable, :trackable, :validatable
4
- end
1
+ class AdminUser < ActiveRecord::Base
2
+ devise :database_authenticatable, :registerable, :lockable, :timeoutable,
3
+ :recoverable, :rememberable, :trackable, :validatable
4
+ end
@@ -1,52 +1,52 @@
1
- // Override me in /views/layouts/manage/main_menu
2
-
3
- ul.right
4
- li.divider.hide-for-small
5
- li = link_to current_user.email, current_user
6
- li.divider.hide-for-small
7
- li = link_to 'users', users_path
8
- li.divider.hide-for-small
9
- li = link_to AdminUser.model_name.human(count:2), admin_users_path
10
- li.divider.hide-for-small
11
- li.has-dropdown
12
- a href="#" Main Item 1
13
- ul.dropdown
14
- li
15
- label Dropdown Level 1 Label
16
- li.has-dropdown
17
- a href="#" Dropdown Level 1a
18
- ul.dropdown
19
- li
20
- a href="#" Dropdown Level 2a
21
- li
22
- a href="#" Dropdown Level 2b
23
- li.has-dropdown
24
- a href="#">Dropdown Level 2c
25
- ul.dropdown
26
- li
27
- a href="#" Dropdown Level 3a
28
- li
29
- a href="#" Dropdown Level 3b
30
- li
31
- a href="#" Dropdown Level 3c
32
- li
33
- a href="#" Dropdown Level 2d
34
- li
35
- a href="#" Dropdown Level 2e
36
- li
37
- a href="#" Dropdown Level 2f
38
- li
39
- a href="#" Dropdown Level 1b
40
- li
41
- a href="#" Dropdown Level 1c
42
- li.divider
43
- li
44
- label Dropdown Level 1 Label
45
- li
46
- a href="#" Dropdown Level 1d
47
- li
48
- a href="#" Dropdown Level 1e
49
- li
50
- a href="#" Dropdown Level 1f
51
- li.has-form
52
- a.button href="http://foundation.zurb.com/docs" Sample button
1
+ // Override me in /views/layouts/manage/main_menu
2
+
3
+ ul.right
4
+ li.divider.hide-for-small
5
+ li = link_to current_user.email, current_user
6
+ li.divider.hide-for-small
7
+ li = link_to 'users', users_path
8
+ li.divider.hide-for-small
9
+ li = link_to AdminUser.model_name.human(count:2), admin_users_path
10
+ li.divider.hide-for-small
11
+ li.has-dropdown
12
+ a href="#" Main Item 1
13
+ ul.dropdown
14
+ li
15
+ label Dropdown Level 1 Label
16
+ li.has-dropdown
17
+ a href="#" Dropdown Level 1a
18
+ ul.dropdown
19
+ li
20
+ a href="#" Dropdown Level 2a
21
+ li
22
+ a href="#" Dropdown Level 2b
23
+ li.has-dropdown
24
+ a href="#">Dropdown Level 2c
25
+ ul.dropdown
26
+ li
27
+ a href="#" Dropdown Level 3a
28
+ li
29
+ a href="#" Dropdown Level 3b
30
+ li
31
+ a href="#" Dropdown Level 3c
32
+ li
33
+ a href="#" Dropdown Level 2d
34
+ li
35
+ a href="#" Dropdown Level 2e
36
+ li
37
+ a href="#" Dropdown Level 2f
38
+ li
39
+ a href="#" Dropdown Level 1b
40
+ li
41
+ a href="#" Dropdown Level 1c
42
+ li.divider
43
+ li
44
+ label Dropdown Level 1 Label
45
+ li
46
+ a href="#" Dropdown Level 1d
47
+ li
48
+ a href="#" Dropdown Level 1e
49
+ li
50
+ a href="#" Dropdown Level 1f
51
+ li.has-form
52
+ a.button href="http://foundation.zurb.com/docs" Sample button
@@ -1,40 +1,40 @@
1
- html
2
- head
3
- meta charset="utf-8"
4
- meta name="viewport" content="width=device-width, initial-scale=1.0"
5
- title Manage
6
- = stylesheet_link_tag "manage/application", media: "all"
7
-
8
- = stylesheet_link_tag "manage/custom", media: "all"
9
-
10
- = javascript_include_tag "modernizr.min.js"
11
- = csrf_meta_tags
12
-
13
- body class="#{controller.action_name} #{controller_path.gsub(/[-\/]/, '-')} simple" data-locale=I18n.locale
14
- nav.top-bar data-options="is_hover:false"
15
- ul.title-area
16
- li.name
17
- h1
18
- a href="/manage" Manage
19
- li.toggle-topbar.menu-icon
20
- a href="#"
21
- span Menu
22
- section.top-bar-section
23
- = render '/layouts/manage/main_menu'
24
-
25
- section.main
26
- #flash
27
- - flash.each do |key, value|
28
- - key = 'info' if key == :notice
29
- - key = 'alert' if key == :error
30
- div data-alert="" class="alert-box #{key}"
31
- - if value.is_a?(Array)
32
- - value.each do |element|
33
- p #{element.html_safe}
34
- - else
35
- p #{value.html_safe}
36
- a.close href="#" &times;
37
-
38
- = yield
39
-
1
+ html
2
+ head
3
+ meta charset="utf-8"
4
+ meta name="viewport" content="width=device-width, initial-scale=1.0"
5
+ title Manage
6
+ = stylesheet_link_tag "manage/application", media: "all"
7
+
8
+ = stylesheet_link_tag "manage/custom", media: "all"
9
+
10
+ = javascript_include_tag "modernizr.min.js"
11
+ = csrf_meta_tags
12
+
13
+ body class="#{controller.action_name} #{controller_path.gsub(/[-\/]/, '-')} simple" data-locale=I18n.locale
14
+ nav.top-bar data-options="is_hover:false"
15
+ ul.title-area
16
+ li.name
17
+ h1
18
+ a href="/manage" Manage
19
+ li.toggle-topbar.menu-icon
20
+ a href="#"
21
+ span Menu
22
+ section.top-bar-section
23
+ = render '/layouts/manage/main_menu'
24
+
25
+ section.main
26
+ #flash
27
+ - flash.each do |key, value|
28
+ - key = 'info' if key == :notice
29
+ - key = 'alert' if key == :error
30
+ div data-alert="" class="alert-box #{key}"
31
+ - if value.is_a?(Array)
32
+ - value.each do |element|
33
+ p #{element.html_safe}
34
+ - else
35
+ p #{value.html_safe}
36
+ a.close href="#" &times;
37
+
38
+ = yield
39
+
40
40
  = javascript_include_tag "manage/application"