bhf 0.10.10 → 0.10.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e72206abf7fb55fa9fb492f9c5a003e8164c54a9
4
- data.tar.gz: 658abe68ef47bf273f1e70e170f7806c1250140b
3
+ metadata.gz: 4071d3ba1e9675e801868438caa4051e4c5ef429
4
+ data.tar.gz: 0f7ecb7934ffbd40970a2f1d2f5afafdd53be10b
5
5
  SHA512:
6
- metadata.gz: b7b7647df5a2d86dcda1b05544362ed377f3426e364e82e1a76fd1d81f019034a242176d76df84d72652ebf0271a00a0fe334ad68f1005b6998327b1995d12d6
7
- data.tar.gz: 0f22a0f775f1a61b6e64da56cb1cb520e5a2ff1379fa7e138d4f02618b68b410e0a14f0ca8da7759f0bf69922cd75a44a92cba3987d681f43cb5e12cc5396322
6
+ metadata.gz: c813183af40bc6b0a37f7f2fd3b555558518148679470ec6dec1e95335d5977d435b6050de6c8a0af1f3576b2d8fefb9baec8abaf09e887ea2cab0dee0ef9dcd
7
+ data.tar.gz: 19a590d3458fa1ea84ce4de5434c048a7aa77d82b69fac2ca34a12df74d2729163593ab705f94c4aadb71b850b107eac89811dfe16646d60a6edde2756f9bdb4
@@ -0,0 +1,16 @@
1
+ ### Setup user authentication
2
+
3
+ Along with the standard approach in authentication, instead of defining the `#login` action in the
4
+ `Admin` controller, you are able to redefine `Bhf::ApplicationController`, and its `#check_admin_account`
5
+ method, to give to `Bhf` the knowledge about weither current user is admin or not. Do it like follows:
6
+
7
+ class Bhf::ApplicationController < ActionController::Base
8
+ protect_from_forgery
9
+ before_filter :authenticate_user! # if devise authentication is used
10
+ include Bhf::Extension::ApplicationController
11
+
12
+ def check_admin_account
13
+ current_user.is_admin? # Here expression must be evaluated to `true` if user is admin.
14
+ end
15
+ end
16
+
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## [Guide and Documentation](http://antpaw.github.io/bhf/)
4
4
 
5
+ Also see [Getting Started](Getting_Started.md) document for additional info.
6
+
5
7
  ## Contributing to bhf
6
8
 
7
9
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.10
1
+ 0.10.11
@@ -36,6 +36,7 @@ Turbolinks.pagesCached(0);
36
36
  setTimeout(function(){
37
37
  rowElem.removeClass('animate');
38
38
  }, 600);
39
+ linkElem = rowElem;
39
40
  }
40
41
  setTimeout(function(){
41
42
  linkElem.removeClass('live_edit');
@@ -1,103 +1,4 @@
1
1
  class Bhf::ApplicationController < ActionController::Base
2
-
3
- before_filter :init_time, :check_admin_account, :setup_current_account, :load_settings, :set_title, :set_areas
4
-
5
- helper_method :current_account
6
- layout 'bhf/application'
7
-
8
- def index
9
-
10
- end
11
-
12
- private
13
-
14
- def check_admin_account
15
- if session[Bhf.configuration.session_auth_name.to_s] == true
16
- return true
17
- end
18
- redirect_to(main_app.send(Bhf.configuration.on_login_fail.to_sym), error: t('bhf.helpers.user.login.error')) and return false
19
- end
20
-
21
- def setup_current_account
22
- if session[Bhf.configuration.session_account_id]
23
- @current_account = Bhf.configuration.account_model.classify.constantize.send(
24
- Bhf.configuration.account_model_find_method.to_sym,
25
- session[Bhf.configuration.session_account_id.to_s]
26
- )
27
- # => User.find(current_account.id)
28
- end
29
- end
30
-
31
- def current_account
32
- @current_account
33
- end
34
-
35
- def get_account_roles(area = nil)
36
- return unless current_account
37
-
38
- if area
39
- if current_account.respond_to?(:bhf_area_roles)
40
- return current_account.bhf_area_roles(area).collect(&:identifier)
41
- end
42
- end
43
-
44
- if current_account.respond_to?(:bhf_roles)
45
- current_account.bhf_roles.collect(&:identifier)
46
- end
47
- end
48
-
49
- def load_settings
50
- yaml_parser = Bhf::Settings::YAMLParser.new(get_account_roles(params[:bhf_area]), params[:bhf_area])
51
- @settings = Bhf::Settings::Base.new(yaml_parser.settings_hash, current_account)
52
- end
53
-
54
- def set_title
55
- @app_title = Rails.application.class.to_s.split('::').first
56
-
57
- @title = if params[:bhf_area]
58
- t("bhf.areas.page_title.#{params[:bhf_area]}",
59
- area: params[:bhf_area],
60
- title: @app_title,
61
- default: t('bhf.areas.page_title',
62
- title: @app_title,
63
- area: t("bhf.areas.links.#{params[:bhf_area]}", default: params[:bhf_area])
64
- )
65
- )
66
- else
67
- t('bhf.page_title', title: @app_title)
68
- end.html_safe
69
- end
70
-
71
- def set_areas
72
- @areas = []
73
- if current_account and current_account.respond_to?(:bhf_areas)
74
- current_account.bhf_areas.each do |area|
75
- selected = params[:bhf_area] == area.identifier
76
- @areas << OpenStruct.new(
77
- name: area.to_bhf_s,
78
- selected: selected,
79
- path: main_app.bhf_path(area.identifier)
80
- )
81
- @root_link = area.link if selected
82
- end
83
- end
84
- end
85
-
86
- def set_message(type, model = nil)
87
- key = model && ActiveModel::Naming.singular(model)
88
- I18n.t("bhf.activerecord.notices.models.#{key}.#{type}", model: model.model_name.human, default: I18n.t("activerecord.notices.messages.#{type}"))
89
- end
90
-
91
- def init_time
92
- @start_time = Time.now
93
- end
94
-
95
- def find_platform(platform_name)
96
- Bhf::Platform::Base.new(@settings.find_platform_settings(platform_name))
97
- end
98
-
99
- def redirect_back_or_default(default, msg)
100
- redirect_to(params[:return_to] || default, flash: msg)
101
- end
102
-
2
+ include Bhf::Extension::ApplicationController
3
+ protect_from_forgery
103
4
  end
@@ -2,23 +2,23 @@ module Bhf
2
2
  module ApplicationHelper
3
3
 
4
4
  def show_t(platform)
5
- t("bhf.helpers.entry.models.#{platform.model_name}.show", platform_title: platform.title_singular, default: t('bhf.helpers.entry.show')).html_safe
5
+ t("bhf.helpers.entry.models.#{platform.model_name}.show", platform_title: platform.title_singular.titleize, default: t('bhf.helpers.entry.show')).html_safe
6
6
  end
7
7
 
8
8
  def new_t(platform)
9
- t("bhf.helpers.entry.models.#{platform.model_name}.new", platform_title: platform.title_singular, default: t('bhf.helpers.entry.new')).html_safe
9
+ t("bhf.helpers.entry.models.#{platform.model_name}.new", platform_title: platform.title_singular.titleize, default: t('bhf.helpers.entry.new')).html_safe
10
10
  end
11
11
 
12
12
  def duplicate_t(platform)
13
- t("bhf.helpers.entry.models.#{platform.model_name}.duplicate", platform_title: platform.title_singular, default: t('bhf.helpers.entry.duplicate')).html_safe
13
+ t("bhf.helpers.entry.models.#{platform.model_name}.duplicate", platform_title: platform.title_singular.titleize, default: t('bhf.helpers.entry.duplicate')).html_safe
14
14
  end
15
15
 
16
16
  def edit_t(platform)
17
- t("bhf.helpers.entry.models.#{platform.model_name}.edit", platform_title: platform.title_singular, default: t('bhf.helpers.entry.edit')).html_safe
17
+ t("bhf.helpers.entry.models.#{platform.model_name}.edit", platform_title: platform.title_singular.titleize, default: t('bhf.helpers.entry.edit')).html_safe
18
18
  end
19
19
 
20
20
  def delete_t(platform)
21
- t("bhf.helpers.entry.models.#{platform.model_name}.delete", platform_title: platform.title_singular, default: t('bhf.helpers.entry.delete')).html_safe
21
+ t("bhf.helpers.entry.models.#{platform.model_name}.delete", platform_title: platform.title_singular.titleize, default: t('bhf.helpers.entry.delete')).html_safe
22
22
  end
23
23
 
24
24
  def find_smallest_size_url_for_file(file)
@@ -36,4 +36,4 @@ module Bhf
36
36
  end
37
37
 
38
38
  end
39
- end
39
+ end
@@ -1,4 +1,4 @@
1
1
  .content_box
2
2
  %ul.basic_info_list
3
3
  - @settings.pages.each do |page|
4
- %li= link_to t("bhf.pages.navigation.#{page}", default: page.capitalize), page_path(page)
4
+ %li= link_to t("bhf.pages.navigation.#{page}", default: page.titleize), page_path(page)
@@ -10,7 +10,7 @@
10
10
  - local_names = [:column_value, :object, :link, :add_quick_link]
11
11
  %table.data_table{id: "#{platform.name}_platform", class: (platform.custom_columns? ? :custom_columns : :default_columns)}
12
12
  %caption
13
- %h4= platform.title
13
+ %h4= platform.title.titleize
14
14
  - unless platform.hide_create
15
15
  %p.create= link_to new_t(platform), new_entry_path(platform.name), class: :alt_button
16
16
  - unless platform.custom_partial
@@ -22,7 +22,7 @@
22
22
  %th.drag
23
23
  - platform.columns.each do |column|
24
24
  %th{class: "#{column.macro} #{column.display_type} #{order_class(column.db_name, platform.name)}"}
25
- = link_to_if column.reorderble, column.title, current_order_path(column.db_name, platform.name)
25
+ = link_to_if column.reorderble, column.title.titleize, current_order_path(column.db_name, platform.name)
26
26
  %th.action
27
27
 
28
28
  %tfoot
@@ -69,15 +69,15 @@
69
69
  - unless platform.hide_edit
70
70
  = link_to edit_t(platform), edit_link, class: 'icon edit'
71
71
  - unless platform.hide_delete
72
- = link_to delete_t(platform), entry_path(platform.name, object), method: :delete, remote: true, class: 'icon delete js_delete', data: {confirm: t('bhf.helpers.promts.confirm', platform_title: platform.title_singular)}
72
+ = link_to delete_t(platform), entry_path(platform.name, object), method: :delete, remote: true, class: 'icon delete js_delete', data: {confirm: t('bhf.helpers.promts.confirm', platform_title: platform.title_singular.titleize)}
73
73
  - else
74
74
  %td.no_entries{colspan: platform.columns_count}
75
- = t 'bhf.pagination.info', name_zero: platform.title, count: 0
75
+ = t 'bhf.pagination.info', name_zero: platform.title.titleize, count: 0
76
76
  - unless platform.hide_create
77
77
  = link_to new_t(platform), new_entry_path(platform.name)
78
78
 
79
79
  - if platform.table_quick_edit
80
- .quick_edit_template{type: 'text/template'}
80
+ %template.quick_edit_template{type: 'text/template'}
81
81
  %tr.quick_edit_entry{id: "{object_id}_#{platform.name}"}
82
82
  - edit_link = edit_entry_path(platform.name, '{object_id}')
83
83
  - if platform.sortable
@@ -96,4 +96,4 @@
96
96
  - unless platform.hide_edit
97
97
  = link_to edit_t(platform), edit_link, class: 'icon edit'
98
98
  - unless platform.hide_delete
99
- = link_to delete_t(platform), entry_path(platform.name, '{object_id}'), method: :delete, remote: true, class: 'icon delete js_delete', data: {confirm: t('bhf.helpers.promts.confirm', platform_title: platform.title_singular)}
99
+ = link_to delete_t(platform), entry_path(platform.name, '{object_id}'), method: :delete, remote: true, class: 'icon delete js_delete', data: {confirm: t('bhf.helpers.promts.confirm', platform_title: platform.title_singular.titleize)}
@@ -26,7 +26,7 @@
26
26
  %ul{class: ('shrink_space' if @settings.pages.count > 7)}
27
27
  - @settings.pages.each do |page|
28
28
  %li{class: ('active' if @page == page)}
29
- = link_to t("bhf.pages.navigation.#{page}", default: page.capitalize), page_path(page)
29
+ = link_to t("bhf.pages.navigation.#{page}", default: page.titleize), page_path(page)
30
30
 
31
31
  #content
32
32
  #main
data/bhf.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bhf 0.10.10 ruby lib
5
+ # stub: bhf 0.10.11 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "bhf"
9
- s.version = "0.10.10"
9
+ s.version = "0.10.11"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Anton Pawlik"]
14
- s.date = "2015-04-18"
14
+ s.date = "2015-10-02"
15
15
  s.description = "A simple to use Rails-Engine-Gem that offers an admin interface for trusted user. Easy integratable and highly configurable and agnostic. Works with ActiveRecord and Mongoid."
16
16
  s.email = "anton.pawlik@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.files = [
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
+ "Getting_Started.md",
24
25
  "LICENSE.txt",
25
26
  "README.md",
26
27
  "Rakefile",
@@ -146,6 +147,7 @@ Gem::Specification.new do |s|
146
147
  "lib/bhf/action_view/form_builder.rb",
147
148
  "lib/bhf/action_view/form_options.rb",
148
149
  "lib/bhf/active_record/base.rb",
150
+ "lib/bhf/controller/extension.rb",
149
151
  "lib/bhf/mongoid/document.rb",
150
152
  "lib/bhf/platform/attribute/abstract.rb",
151
153
  "lib/bhf/platform/attribute/column.rb",
data/lib/bhf.rb CHANGED
@@ -44,7 +44,8 @@ module Bhf
44
44
  config_accessor(:js) { ['bhf/application'] }
45
45
  config_accessor(:abstract_settings) { [] }
46
46
  config_accessor(:paperclip_image_types) {
47
- ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/tif', 'image/gif']
47
+ ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png',
48
+ 'image/tif', 'image/gif']
48
49
  }
49
50
  end
50
51
  end
@@ -61,3 +62,4 @@ require 'bhf/active_record/base'
61
62
  require 'bhf/mongoid/document'
62
63
  require 'bhf/action_view/form_options'
63
64
  require 'bhf/action_view/form_builder'
65
+ require 'bhf/controller/extension'
@@ -0,0 +1,122 @@
1
+ module Bhf
2
+ module Extension
3
+ module ApplicationController
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ include Instance
8
+
9
+ before_filter :init_time
10
+ before_filter :check_admin_account, :setup_current_account,
11
+ :load_settings, :set_title, :set_areas
12
+
13
+ helper_method :current_account
14
+ layout 'bhf/application'
15
+ end
16
+
17
+ module Instance
18
+ def index
19
+
20
+ end
21
+
22
+ protected
23
+
24
+ def check_admin_account
25
+ if session[Bhf.configuration.session_auth_name.to_s] == true
26
+ return true
27
+ end
28
+ redirect_to(main_app.send(Bhf.configuration.on_login_fail.to_sym),
29
+ error: t('bhf.helpers.user.login.error')) and return false
30
+ end
31
+
32
+ def setup_current_account
33
+ if session[Bhf.configuration.session_account_id]
34
+ @current_account =
35
+ Bhf.configuration.account_model.classify.constantize.send(
36
+ Bhf.configuration.account_model_find_method.to_sym,
37
+ session[Bhf.configuration.session_account_id.to_s]
38
+ )
39
+ # => User.find(current_account.id)
40
+ end
41
+ end
42
+
43
+ def current_account
44
+ @current_account
45
+ end
46
+
47
+ def get_account_roles(area = nil)
48
+ return unless current_account
49
+
50
+ if area
51
+ if current_account.respond_to?(:bhf_area_roles)
52
+ return current_account.bhf_area_roles(area).collect(&:identifier)
53
+ end
54
+ end
55
+
56
+ if current_account.respond_to?(:bhf_roles)
57
+ current_account.bhf_roles.collect(&:identifier)
58
+ end
59
+ end
60
+
61
+ def load_settings
62
+ yaml_parser = Bhf::Settings::YAMLParser.new(get_account_roles(
63
+ params[:bhf_area]), params[:bhf_area])
64
+ @settings =
65
+ Bhf::Settings::Base.new(yaml_parser.settings_hash, current_account)
66
+ end
67
+
68
+ def set_title
69
+ @app_title = Rails.application.class.to_s.split('::').first
70
+
71
+ @title = if params[:bhf_area]
72
+ t("bhf.areas.page_title.#{params[:bhf_area]}",
73
+ area: params[:bhf_area],
74
+ title: @app_title,
75
+ default: t('bhf.areas.page_title',
76
+ title: @app_title,
77
+ area: t("bhf.areas.links.#{params[:bhf_area]}",
78
+ default: params[:bhf_area])
79
+ )
80
+ )
81
+ else
82
+ t('bhf.page_title', title: @app_title)
83
+ end.html_safe
84
+ end
85
+
86
+ def set_areas
87
+ @areas = []
88
+ if current_account and current_account.respond_to?(:bhf_areas)
89
+ current_account.bhf_areas.each do |area|
90
+ selected = params[:bhf_area] == area.identifier
91
+ @areas << OpenStruct.new(
92
+ name: area.to_bhf_s,
93
+ selected: selected,
94
+ path: main_app.bhf_path(area.identifier)
95
+ )
96
+ @root_link = area.link if selected
97
+ end
98
+ end
99
+ end
100
+
101
+ def set_message(type, model = nil)
102
+ key = model && ActiveModel::Naming.singular(model)
103
+ I18n.t("bhf.activerecord.notices.models.#{key}.#{type}",
104
+ model: model.model_name.human,
105
+ default: I18n.t("activerecord.notices.messages.#{type}"))
106
+ end
107
+
108
+ def init_time
109
+ @start_time = Time.zone.now
110
+ end
111
+
112
+ def find_platform(platform_name)
113
+ Bhf::Platform::Base.new(@settings.find_platform_settings(platform_name))
114
+ end
115
+
116
+ def redirect_back_or_default(default, msg)
117
+ redirect_to(params[:return_to] || default, flash: msg)
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bhf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.10
4
+ version: 0.10.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Pawlik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-18 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -162,6 +162,7 @@ extra_rdoc_files:
162
162
  files:
163
163
  - Gemfile
164
164
  - Gemfile.lock
165
+ - Getting_Started.md
165
166
  - LICENSE.txt
166
167
  - README.md
167
168
  - Rakefile
@@ -287,6 +288,7 @@ files:
287
288
  - lib/bhf/action_view/form_builder.rb
288
289
  - lib/bhf/action_view/form_options.rb
289
290
  - lib/bhf/active_record/base.rb
291
+ - lib/bhf/controller/extension.rb
290
292
  - lib/bhf/mongoid/document.rb
291
293
  - lib/bhf/platform/attribute/abstract.rb
292
294
  - lib/bhf/platform/attribute/column.rb