ab_admin 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/Gemfile +3 -3
  2. data/TODO +2 -1
  3. data/ab_admin.gemspec +2 -2
  4. data/app/assets/javascripts/ab_admin/components/admin_assets.js.coffee +2 -22
  5. data/app/assets/javascripts/ab_admin/components/croppable_image.js.coffee +3 -3
  6. data/app/assets/javascripts/ab_admin/components/gmaps.js.coffee +0 -38
  7. data/app/assets/javascripts/ab_admin/components/in_place_edit.js.coffee +2 -1
  8. data/app/assets/javascripts/ab_admin/components/init_nested_filelds.js.coffee +1 -0
  9. data/app/assets/javascripts/ab_admin/core/init.js.coffee +2 -0
  10. data/app/assets/javascripts/ab_admin/core/pjax.js.coffee +6 -6
  11. data/app/assets/javascripts/ab_admin/core/ui_utils.js.coffee +7 -7
  12. data/app/assets/javascripts/ab_admin/core/utils.js.coffee +19 -1
  13. data/app/assets/javascripts/ab_admin/core/view_layout.js.coffee +44 -0
  14. data/app/assets/stylesheets/ab_admin/bootstrap_and_overrides.css.scss +22 -0
  15. data/app/assets/stylesheets/ab_admin/components/_base.css.scss +3 -3
  16. data/app/assets/stylesheets/ab_admin/components/_form.css.scss +1 -1
  17. data/app/assets/stylesheets/ab_admin/components/_navigation.css.scss +7 -1
  18. data/app/assets/stylesheets/ab_admin/components/_table_view.css.scss +4 -0
  19. data/app/assets/stylesheets/ab_admin/components/_view_layout.css.scss +65 -0
  20. data/app/assets/stylesheets/ab_admin/fileupload.css.scss +1 -0
  21. data/app/controllers/admin/base_controller.rb +30 -14
  22. data/app/controllers/admin/static_pages_controller.rb +3 -1
  23. data/app/views/admin/base/_search_layout.html.slim +2 -0
  24. data/app/views/admin/base/create.js.erb +2 -2
  25. data/app/views/admin/base/edit.js.erb +3 -1
  26. data/app/views/admin/base/index.html.slim +5 -0
  27. data/app/views/admin/base/new.js.erb +3 -1
  28. data/app/views/admin/base/update.js.erb +1 -1
  29. data/app/views/admin/fileupload/_file.html.slim +1 -1
  30. data/app/views/admin/fileupload/_video.html.slim +9 -0
  31. data/app/views/admin/fileupload/_vtmpl.html.slim +10 -0
  32. data/app/views/admin/shared/_batch_actions.html.slim +9 -3
  33. data/app/views/admin/shared/_breadcrumbs.html.slim +5 -6
  34. data/app/views/admin/shared/_flash.js.erb +3 -0
  35. data/app/views/admin/shared/inputs/_checkbox_tree.html.slim +14 -0
  36. data/app/views/admin/structures/_form.html.slim +5 -2
  37. data/app/views/layouts/admin/_footer.html.slim +1 -0
  38. data/app/views/layouts/admin/_navigation.html.slim +5 -7
  39. data/app/views/layouts/admin/application.html.slim +1 -1
  40. data/config/locales/en.yml +4 -10
  41. data/config/locales/it.yml +1 -8
  42. data/config/locales/ru.yml +4 -10
  43. data/features/dsl/export.feature +6 -6
  44. data/lib/ab_admin/concerns/utilities.rb +3 -3
  45. data/lib/ab_admin/controllers/head_options.rb +1 -0
  46. data/lib/ab_admin/core_ext/string.rb +3 -2
  47. data/lib/ab_admin/hooks/paginate_hooks.rb +1 -0
  48. data/lib/ab_admin/models/asset.rb +4 -0
  49. data/lib/ab_admin/models/attachment_file.rb +0 -4
  50. data/lib/ab_admin/models/type_model.rb +10 -0
  51. data/lib/ab_admin/models/user.rb +1 -1
  52. data/lib/ab_admin/utils.rb +2 -0
  53. data/lib/ab_admin/version.rb +1 -1
  54. data/lib/ab_admin/views/admin_helpers.rb +14 -6
  55. data/lib/ab_admin/views/admin_navigation_helpers.rb +4 -2
  56. data/lib/ab_admin/views/form_builder.rb +5 -2
  57. data/lib/ab_admin/views/helpers.rb +4 -0
  58. data/lib/ab_admin/views/inputs/ckeditor_input.rb +0 -1
  59. data/lib/generators/ab_admin/install/templates/config/nginx.conf +12 -7
  60. data/lib/generators/ab_admin/install/templates/models/structure.rb +2 -1
  61. data/lib/generators/ab_admin/resource/templates/_form.haml.erb +1 -1
  62. data/lib/generators/ab_admin/resource/templates/_form.slim.erb +1 -1
  63. metadata +12 -22
@@ -26,6 +26,7 @@ module AbAdmin
26
26
 
27
27
  page_title.flatten.compact.uniq.join(options[:splitter])
28
28
  end
29
+ @page_title = [I18n.t('page.page_title', page: options[:page]), @page_title].join(options[:splitter]) if options[:page]
29
30
  @page_description = [I18n.t('page.prefix'), @page_description].compact.join(' - ')
30
31
  end
31
32
 
@@ -1,7 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class String
3
- #LUCENE_ESCAPE_REGEX = /(\+|-|&&|\|\||!|\(|\)|{|}|\[|\]|`|"|~|\?|:|\\)/
4
- LUCENE_ESCAPE_REGEX = /(\+|-|&&|\|\||!|\(|\)|{|}|\[|\]|`|"|~|\?|:|\\|\s)/
3
+ # http://lucene.apache.org/core/old_versioned_docs/versions/2_9_1/queryparsersyntax.html
4
+ LUCENE_ESCAPE_REGEX = /(\+|-|&&|\|\||!|\(|\)|{|}|\[|\]|`|"|~|\?|:|\\)/
5
+ #LUCENE_ESCAPE_REGEX = /(\+|-|&&|\|\||!|\(|\)|{|}|\[|\]|`|"|~|\?|:|\\|\s)/
5
6
  KEYBOARDS = {
6
7
  en: 'qwertyuiop[]asdfghjkl;\'zxcvbnm,./',
7
8
  ru: 'йцукенгшщзхъфывапролджэячсмитьбю/'
@@ -52,6 +52,7 @@ module WillPaginate
52
52
  end
53
53
  end
54
54
 
55
+ WillPaginate::ViewHelpers.pagination_options[:no_uri] = false
55
56
  WillPaginate::ActionView::LinkRenderer.class_exec do
56
57
  def url(page)
57
58
  @base_url_params ||= begin
@@ -46,6 +46,10 @@ module AbAdmin
46
46
  I18n.l(created_at, format: '%d.%m.%Y %H:%M')
47
47
  end
48
48
 
49
+ def human_name
50
+ original_name.presence || data_file_name
51
+ end
52
+
49
53
  def as_json(options = nil)
50
54
  options = {
51
55
  only: [:id, :guid, :assetable_id, :assetable_type, :user_id,
@@ -12,10 +12,6 @@ module AbAdmin
12
12
  MIME::Type.new(data_content_type).try(:sub_type).gsub('.', '_')
13
13
  end
14
14
 
15
- def human_name
16
- original_name.presence || data_file_name
17
- end
18
-
19
15
  def human_filesize
20
16
  number_to_human_size(data_file_size)
21
17
  end
@@ -26,9 +26,19 @@ module AbAdmin
26
26
  end
27
27
 
28
28
  def self.legal?(value)
29
+ ActiveSupport::Deprecation.warn('legal? id deprecated, use valid? instead')
29
30
  all.map(&:id).include?(value)
30
31
  end
31
32
 
33
+ def self.valid?(c_id)
34
+ all.map(&:id).include?(c_id.to_i)
35
+ end
36
+
37
+ def self.valid_code?(code)
38
+ return unless code
39
+ codes.include?(code.to_sym)
40
+ end
41
+
32
42
  end
33
43
  end
34
44
  end
@@ -110,7 +110,7 @@ module AbAdmin
110
110
  end
111
111
 
112
112
  def check_role
113
- errors.add(:user_role_id, :invalid) unless ::UserRoleType.legal?(user_role_id)
113
+ errors.add(:user_role_id, :invalid) unless ::UserRoleType.valid?(user_role_id)
114
114
  end
115
115
 
116
116
  end
@@ -49,6 +49,8 @@ module AbAdmin
49
49
  locale == I18n.default_locale ? '' : "/#{locale}"
50
50
  end
51
51
 
52
+ alias :locale_path :l_path
53
+
52
54
  def rss_text(raw_html)
53
55
  Rack::Utils.escape_html(raw_html.no_html.squish)
54
56
  end
@@ -1,3 +1,3 @@
1
1
  module AbAdmin
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
@@ -23,6 +23,7 @@ module AbAdmin
23
23
 
24
24
  def admin_editable(item, attr, options=nil)
25
25
  options = {} unless options.is_a?(Hash)
26
+ options[:type] ||= 'select' if options[:source]
26
27
  options[:type] ||= case attr.to_s
27
28
  when /_at$/
28
29
  'date'
@@ -35,11 +36,15 @@ module AbAdmin
35
36
  end
36
37
  options[:source] ||= {'true' => 'yes', 'false' => 'no'} if options[:type] == 'select'
37
38
  data = {
38
- type: options[:type], source: options[:source].try(:to_json),
39
- model: resource_class.model_name.singular, url: resource_path(item),
40
- name: attr, value: options[:value] || item[attr]
39
+ type: options[:type],
40
+ source: options[:source].try(:to_json),
41
+ model: resource_class.model_name.singular,
42
+ url: resource_path(item),
43
+ name: attr,
44
+ value: options[:value] || item[attr],
45
+ title: options[:title] || item[attr]
41
46
  }
42
- link_to admin_pretty_data(item[attr].to_s).html_safe, '#', class: 'editable', data: data
47
+ link_to admin_pretty_data(data[:title].to_s).html_safe, '#', class: 'editable', data: data
43
48
  end
44
49
 
45
50
  def options_for_ckeditor(options = {})
@@ -102,8 +107,11 @@ module AbAdmin
102
107
  image = item.send(options[:assoc])
103
108
  return nil unless image
104
109
  version = options[:version] || image.class.thumb_size
105
- popover_data = {content: "<img class='image_link_popover popover_#{options[:assoc]}' src='#{image.url}'></img>", title: item.name}
106
- link_to image_tag(image.url(version)), options[:url], data: popover_data, rel: 'popover', remote: options[:remote]
110
+ popover_data = {content: "<img class='image_link_popover popover_#{options[:assoc]}' src='#{image.url}'></img>", title: AbAdmin.display_name(item)}
111
+
112
+ html_options = options.delete(:html_options) || {}
113
+ html_options.reverse_merge!(rel: 'popover', remote: options[:remote], data: popover_data)
114
+ link_to image_tag(image.url(version)), options[:url], html_options
107
115
  end
108
116
 
109
117
  def item_image(item, assoc=:photo, size=:thumb)
@@ -176,12 +176,14 @@ module AbAdmin
176
176
  end
177
177
 
178
178
  def auto_edit_link(rec, opts = {})
179
- return if !rec || cannot?(:edit, rec)
179
+ return opts[:missing] unless rec
180
+ return if cannot?(:edit, rec)
180
181
  admin_edit_link(rec, opts)
181
182
  end
182
183
 
183
184
  def auto_show_link(rec, opts = {})
184
- return if !rec || cannot?(:read, rec)
185
+ return opts[:missing] unless rec
186
+ return if cannot?(:read, rec)
185
187
  admin_show_link(rec, opts)
186
188
  end
187
189
 
@@ -42,6 +42,9 @@ module AbAdmin
42
42
  end
43
43
  return association(attribute_name, options.merge(as: :select))
44
44
  end
45
+ when :checkbox_tree
46
+ reflection = object.class.reflect_on_association(attribute_name)
47
+ return template.render 'admin/shared/inputs/checkbox_tree', attribute_name: attribute_name, reflection: reflection, f: self
45
48
  end
46
49
 
47
50
  attribute_name = "#{attribute_name}_#{options[:locale]}" if options[:locale]
@@ -85,8 +88,8 @@ module AbAdmin
85
88
  </div>
86
89
  #{template.capture(&block) if block_given?}
87
90
  <div class="controls"><div id="#{prefix}_map" class="admin_map thumbnail"></div></div>
88
- #{template.init_js(js)}
89
91
  </div>
92
+ #{template.init_js(js)}
90
93
  HTML
91
94
  end
92
95
 
@@ -121,7 +124,7 @@ module AbAdmin
121
124
  elsif options[:video]
122
125
  script_options['allowedExtensions'] ||= %w(mp4 flv)
123
126
  script_options['template_id'] = '#fileupload_vtmpl'
124
- options[:asset_template] = 'video_file'
127
+ options[:asset_template] = 'video'
125
128
  end
126
129
  script_options['allowedExtensions'] ||= %w(jpg jpeg png gif)
127
130
  script_options['multiple'] ||= object.fileupload_multiple?(attribute_name)
@@ -2,6 +2,10 @@ module AbAdmin
2
2
  module Views
3
3
  module Helpers
4
4
 
5
+ def pjax?
6
+ request.headers['X-PJAX']
7
+ end
8
+
5
9
  def admin?
6
10
  user_signed_in? && current_user.admin?
7
11
  end
@@ -4,7 +4,6 @@ module AbAdmin
4
4
  class CkeditorInput < ::SimpleForm::Inputs::Base
5
5
  def input
6
6
  unless @builder.template.instance_variable_get(:@ckeditor_init)
7
- #concat template.javascript_include_tag("/assets/ckeditor/init")
8
7
  @builder.template.concat @builder.template.javascript_include_tag('/javascripts/ckeditor/init')
9
8
  @builder.template.instance_variable_set(:@ckeditor_init, true)
10
9
  end
@@ -44,14 +44,14 @@ server {
44
44
 
45
45
  root <%= app_path %>/public;
46
46
 
47
- # if (-f $document_root/maintenance.html) {
48
- # rewrite ^(.*)$ /maintenance.html last;
49
- # break;
50
- # }
47
+ # if (-f $document_root/maintenance.html) {
48
+ # rewrite ^(.*)$ /maintenance.html last;
49
+ # break;
50
+ # }
51
51
 
52
- # if ($host != 'www.<%= app_name %>.com' ) {
53
- # rewrite ^/(.*)$ http://www.<%= app_name %>.com/$1 permanent;
54
- # }
52
+ # if ($host != 'www.<%= app_name %>.com' ) {
53
+ # rewrite ^/(.*)$ http://www.<%= app_name %>.com/$1 permanent;
54
+ # }
55
55
 
56
56
  location ~ ^/uploads|ckeditor_assets|images|javascripts|stylesheets|static/ {
57
57
  expires max;
@@ -64,6 +64,11 @@ server {
64
64
  }
65
65
 
66
66
  location ~ ^/assets/ {
67
+ # Uncomment for non GET requests on /assets path
68
+ # if ($request_method != GET) {
69
+ # proxy_pass http://<%= app_name %>_upstream;
70
+ # break;
71
+ # }
67
72
  gzip_static on; # to serve pre-gzipped version
68
73
  expires max;
69
74
  add_header Cache-Control public;
@@ -4,7 +4,8 @@ class Structure < ActiveRecord::Base
4
4
  attr_accessible :kind, :position, :parent_id, :title, :redirect_url, :is_visible,
5
5
  :structure_type, :position_type, :slug, :parent
6
6
 
7
- has_one :picture, as: :assetable, dependent: :destroy
7
+ has_one :picture, as: :assetable, dependent: :destroy, conditions: {is_main: true}
8
+ has_many :pictures, as: :assetable, dependent: :destroy, conditions: {is_main: false}
8
9
 
9
10
  fileuploads :picture
10
11
  translates :title, :redirect_url
@@ -43,7 +43,7 @@
43
43
  end
44
44
  -%>
45
45
  = admin_form_for @<%= singular_name %> do |f|
46
- <% if model.translates? -%>
46
+ <% if model.respond_to?(:translates?) && model.translates? -%>
47
47
  = f.locale_tabs do |l|
48
48
  <% model.translated_columns_hash.each do |key, col| -%>
49
49
  <%= input_by_col_loc(key, col) %>
@@ -43,7 +43,7 @@
43
43
  end
44
44
  -%>
45
45
  = admin_form_for @<%= singular_name %> do |f|
46
- <% if model.translates? -%>
46
+ <% if model.respond_to?(:translates?) && model.translates? -%>
47
47
  = f.locale_tabs do |l|
48
48
  <% model.translated_columns_hash.each do |key, col| -%>
49
49
  <%= input_by_col_loc(key, col) %>
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ab_admin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.5
5
+ version: 0.3.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alex Leschenko
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-23 00:00:00.000000000 Z
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -96,7 +96,7 @@ dependencies:
96
96
  requirements:
97
97
  - - ~>
98
98
  - !ruby/object:Gem::Version
99
- version: 1.3.0
99
+ version: 1.4.0
100
100
  none: false
101
101
  prerelease: false
102
102
  name: inherited_resources
@@ -104,7 +104,7 @@ dependencies:
104
104
  requirements:
105
105
  - - ~>
106
106
  - !ruby/object:Gem::Version
107
- version: 1.3.0
107
+ version: 1.4.0
108
108
  none: false
109
109
  type: :runtime
110
110
  - !ruby/object:Gem::Dependency
@@ -571,22 +571,6 @@ dependencies:
571
571
  version: '0'
572
572
  none: false
573
573
  type: :development
574
- - !ruby/object:Gem::Dependency
575
- version_requirements: !ruby/object:Gem::Requirement
576
- requirements:
577
- - - ! '>='
578
- - !ruby/object:Gem::Version
579
- version: '0'
580
- none: false
581
- prerelease: false
582
- name: cucumber-rails
583
- requirement: !ruby/object:Gem::Requirement
584
- requirements:
585
- - - ! '>='
586
- - !ruby/object:Gem::Version
587
- version: '0'
588
- none: false
589
- type: :development
590
574
  description: Simple and real-life tested Rails::Engine admin interface
591
575
  email:
592
576
  - leschenko.al@gmail.com
@@ -639,6 +623,7 @@ files:
639
623
  - app/assets/javascripts/ab_admin/core/search_form.js.coffee
640
624
  - app/assets/javascripts/ab_admin/core/ui_utils.js.coffee
641
625
  - app/assets/javascripts/ab_admin/core/utils.js.coffee
626
+ - app/assets/javascripts/ab_admin/core/view_layout.js.coffee
642
627
  - app/assets/javascripts/ab_admin/inputs/datetime_input.js.coffee
643
628
  - app/assets/javascripts/ab_admin/main.js
644
629
  - app/assets/javascripts/i18n/translations.js
@@ -657,6 +642,7 @@ files:
657
642
  - app/assets/stylesheets/ab_admin/components/_table_view.css.scss
658
643
  - app/assets/stylesheets/ab_admin/components/_text_styles.css.scss
659
644
  - app/assets/stylesheets/ab_admin/components/_translations.css.scss
645
+ - app/assets/stylesheets/ab_admin/components/_view_layout.css.scss
660
646
  - app/assets/stylesheets/ab_admin/devise.css.scss
661
647
  - app/assets/stylesheets/ab_admin/fileupload.css.scss
662
648
  - app/assets/stylesheets/ab_admin/main.css.scss
@@ -699,6 +685,8 @@ files:
699
685
  - app/views/admin/fileupload/_file.html.slim
700
686
  - app/views/admin/fileupload/_ftmpl.html.slim
701
687
  - app/views/admin/fileupload/_tmpl.html.slim
688
+ - app/views/admin/fileupload/_video.html.slim
689
+ - app/views/admin/fileupload/_vtmpl.html.slim
702
690
  - app/views/admin/headers/_form.html.slim
703
691
  - app/views/admin/locators/edit.html.slim
704
692
  - app/views/admin/locators/show.html.slim
@@ -711,8 +699,10 @@ files:
711
699
  - app/views/admin/shared/_breadcrumbs.html.slim
712
700
  - app/views/admin/shared/_columns_hider.html.slim
713
701
  - app/views/admin/shared/_flash.html.slim
702
+ - app/views/admin/shared/_flash.js.erb
714
703
  - app/views/admin/shared/_locale_tabs.html.slim
715
704
  - app/views/admin/shared/_save_buttons.html.slim
705
+ - app/views/admin/shared/inputs/_checkbox_tree.html.slim
716
706
  - app/views/admin/static_pages/_form.html.slim
717
707
  - app/views/admin/structures/_form.html.slim
718
708
  - app/views/admin/users/_form.html.slim
@@ -1081,7 +1071,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1081
1071
  version: '0'
1082
1072
  segments:
1083
1073
  - 0
1084
- hash: 4208234598639910796
1074
+ hash: 218612203791956818
1085
1075
  none: false
1086
1076
  required_rubygems_version: !ruby/object:Gem::Requirement
1087
1077
  requirements:
@@ -1090,7 +1080,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1090
1080
  version: '0'
1091
1081
  segments:
1092
1082
  - 0
1093
- hash: 4208234598639910796
1083
+ hash: 218612203791956818
1094
1084
  none: false
1095
1085
  requirements: []
1096
1086
  rubyforge_project: