bhf 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/bhf/application.js +2 -2
- data/app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js +6508 -0
- data/app/assets/javascripts/bhf/mootools-more-1.5.0.js +2561 -0
- data/app/controllers/bhf/application_controller.rb +24 -29
- data/app/controllers/bhf/embed_entries_controller.rb +2 -2
- data/app/helpers/bhf/frontend_helper.rb +1 -1
- data/app/views/bhf/_user.haml +2 -2
- data/app/views/layouts/bhf/application.haml +2 -2
- data/lib/bhf.rb +13 -12
- data/lib/bhf/config_parser.rb +2 -2
- data/lib/bhf/data.rb +1 -0
- data/lib/rails/generators/bhf/templates/initializer.rb +9 -9
- metadata +3 -1
@@ -12,18 +12,17 @@ class Bhf::ApplicationController < ActionController::Base
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def check_admin_account
|
15
|
-
if session[Bhf::Engine.config.session_auth_name.to_s] == true
|
15
|
+
if session[Bhf::Engine.config.bhf.session_auth_name.to_s] == true
|
16
16
|
return true
|
17
17
|
end
|
18
|
-
|
19
|
-
redirect_to(main_app.send(Bhf::Engine.config.on_login_fail.to_sym), error: t('bhf.helpers.user.login.error')) and return false
|
18
|
+
redirect_to(main_app.send(Bhf::Engine.config.bhf.on_login_fail.to_sym), error: t('bhf.helpers.user.login.error')) and return false
|
20
19
|
end
|
21
20
|
|
22
21
|
def setup_current_account
|
23
|
-
if session[Bhf::Engine.config.session_account_id]
|
24
|
-
@current_account = Bhf::Engine.config.account_model.constantize.send(
|
25
|
-
Bhf::Engine.config.account_model_find_method.to_sym,
|
26
|
-
session[Bhf::Engine.config.session_account_id.to_s]
|
22
|
+
if session[Bhf::Engine.config.bhf.session_account_id]
|
23
|
+
@current_account = Bhf::Engine.config.bhf.account_model.constantize.send(
|
24
|
+
Bhf::Engine.config.bhf.account_model_find_method.to_sym,
|
25
|
+
session[Bhf::Engine.config.bhf.session_account_id.to_s]
|
27
26
|
)
|
28
27
|
# => User.find(current_account.id)
|
29
28
|
end
|
@@ -37,17 +36,17 @@ class Bhf::ApplicationController < ActionController::Base
|
|
37
36
|
return unless current_account
|
38
37
|
|
39
38
|
if area
|
40
|
-
if current_account.respond_to?(:
|
41
|
-
return current_account.
|
42
|
-
elsif current_account.respond_to?(:
|
43
|
-
return current_account.
|
39
|
+
if current_account.respond_to?(:bhf_area_role)
|
40
|
+
return current_account.bhf_area_role(area)
|
41
|
+
elsif current_account.respond_to?(:bhf_area_roles)
|
42
|
+
return current_account.bhf_area_roles(area).collect(&:identifier)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
if current_account.respond_to?(:
|
48
|
-
current_account.
|
49
|
-
elsif current_account.respond_to?(:
|
50
|
-
current_account.
|
46
|
+
if current_account.respond_to?(:bhf_role)
|
47
|
+
current_account.bhf_role.is_a?(String) ? current_account.bhf_role : current_account.bhf_role.identifier
|
48
|
+
elsif current_account.respond_to?(:bhf_roles)
|
49
|
+
current_account.bhf_roles.collect(&:identifier)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -58,24 +57,20 @@ class Bhf::ApplicationController < ActionController::Base
|
|
58
57
|
def set_title
|
59
58
|
@app_title = Rails.application.class.to_s.split('::').first
|
60
59
|
|
61
|
-
@title = if
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
t(
|
66
|
-
area: params[:bhf_area],
|
60
|
+
@title = if params[:bhf_area]
|
61
|
+
t("bhf.areas.page_title.#{params[:bhf_area]}",
|
62
|
+
area: params[:bhf_area],
|
63
|
+
title: @app_title,
|
64
|
+
default: t('bhf.areas.page_title',
|
67
65
|
title: @app_title,
|
68
|
-
|
69
|
-
title: @app_title,
|
70
|
-
area: t("bhf.areas.links.#{params[:bhf_area]}", default: params[:bhf_area])
|
71
|
-
)
|
66
|
+
area: t("bhf.areas.links.#{params[:bhf_area]}", default: params[:bhf_area])
|
72
67
|
)
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
)
|
69
|
+
else
|
70
|
+
t('bhf.page_title', title: @app_title)
|
76
71
|
end.html_safe
|
77
72
|
end
|
78
|
-
|
73
|
+
|
79
74
|
def set_areas
|
80
75
|
@areas = []
|
81
76
|
if current_account and current_account.respond_to?(:bhf_areas)
|
@@ -22,7 +22,7 @@ class Bhf::EmbedEntriesController < Bhf::EntriesController
|
|
22
22
|
if @quick_edit
|
23
23
|
render json: object_to_bhf_display_hash.merge(edit_path: edit_path), status: :ok
|
24
24
|
else
|
25
|
-
|
25
|
+
redirect_back_or_default(edit_path, notice: set_message('create.success', @model))
|
26
26
|
end
|
27
27
|
else
|
28
28
|
@form_url = entry_embed_index_path(@platform.name, @model.get_embedded_parent(params[:entry_id]))
|
@@ -42,7 +42,7 @@ class Bhf::EmbedEntriesController < Bhf::EntriesController
|
|
42
42
|
if @quick_edit
|
43
43
|
render json: object_to_bhf_display_hash, status: :ok
|
44
44
|
else
|
45
|
-
|
45
|
+
redirect_back_or_default(edit_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object), notice: set_message('update.success', @model))
|
46
46
|
end
|
47
47
|
else
|
48
48
|
@form_url = entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
|
@@ -2,7 +2,7 @@ module Bhf
|
|
2
2
|
module FrontendHelper
|
3
3
|
|
4
4
|
def bhf_edit(object, options = {}, &block)
|
5
|
-
return unless session[Bhf::Engine.config.session_auth_name.to_s] == true
|
5
|
+
return unless session[Bhf::Engine.config.bhf.session_auth_name.to_s] == true
|
6
6
|
|
7
7
|
options[:platform_name] ||= object.class.to_s.pluralize.downcase
|
8
8
|
|
data/app/views/bhf/_user.haml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
- if defined?(current_account) && current_account
|
2
2
|
%p.user
|
3
3
|
= t('bhf.helpers.user.login.as', user: current_account.to_bhf_s).html_safe
|
4
|
-
- if main_app.respond_to?(Bhf::Engine.config.logout_path)
|
5
|
-
= link_to t('bhf.helpers.user.logout.link'), main_app.send(Bhf::Engine.config.logout_path), method: :delete, class: :alt_button
|
4
|
+
- if main_app.respond_to?(Bhf::Engine.config.bhf.logout_path)
|
5
|
+
= link_to t('bhf.helpers.user.logout.link'), main_app.send(Bhf::Engine.config.bhf.logout_path), method: :delete, class: :alt_button
|
@@ -4,7 +4,7 @@
|
|
4
4
|
%meta{charset: 'utf-8'}
|
5
5
|
%title= @title
|
6
6
|
%link{href: "/favicon.ico?#{@app_title.to_s.downcase}", rel: 'icon', type: 'image/x-icon'}
|
7
|
-
- (['bhf/application'] + Bhf::Engine.config.css.to_a).each do |css|
|
7
|
+
- (['bhf/application'] + Bhf::Engine.config.bhf.css.to_a).each do |css|
|
8
8
|
= stylesheet_link_tag css
|
9
9
|
%body
|
10
10
|
%header
|
@@ -36,5 +36,5 @@
|
|
36
36
|
= render 'bhf/user'
|
37
37
|
= render 'bhf/footer'
|
38
38
|
|
39
|
-
- (['bhf/application'] + Bhf::Engine.config.js.to_a).each do |js|
|
39
|
+
- (['bhf/application'] + Bhf::Engine.config.bhf.js.to_a).each do |js|
|
40
40
|
= javascript_include_tag js, {:'data-turbolinks-eval' => false}
|
data/lib/bhf.rb
CHANGED
@@ -9,19 +9,20 @@ module Bhf
|
|
9
9
|
|
10
10
|
isolate_namespace Bhf
|
11
11
|
|
12
|
-
#
|
13
|
-
config.
|
14
|
-
config.
|
15
|
-
config.
|
16
|
-
config.
|
17
|
-
config.
|
18
|
-
config.
|
19
|
-
config.
|
20
|
-
config.
|
21
|
-
config.
|
22
|
-
config.
|
12
|
+
# config.bhf defaults
|
13
|
+
config.bhf = OpenStruct.new
|
14
|
+
config.bhf.page_title = nil
|
15
|
+
config.bhf.on_login_fail = :root_url
|
16
|
+
config.bhf.logout_path = :logout_path
|
17
|
+
config.bhf.session_auth_name = :is_admin
|
18
|
+
config.bhf.session_account_id = :admin_account_id
|
19
|
+
config.bhf.account_model = 'User'
|
20
|
+
config.bhf.account_model_find_method = 'find'
|
21
|
+
config.bhf.css = []
|
22
|
+
config.bhf.js = []
|
23
|
+
config.bhf.abstract_config = []
|
23
24
|
|
24
|
-
# config.bhf_logic = YAML::load(IO.read('config/bhf.yml'))
|
25
|
+
# config.bhf.bhf_logic = YAML::load(IO.read('config/bhf.yml'))
|
25
26
|
|
26
27
|
initializer 'bhf.action_controller' do |app|
|
27
28
|
ActiveSupport.on_load :action_controller do
|
data/lib/bhf/config_parser.rb
CHANGED
@@ -6,9 +6,9 @@ module Bhf
|
|
6
6
|
def parse(roles_array, area = nil)
|
7
7
|
roles_config = roles_yml(roles_array, area)
|
8
8
|
|
9
|
-
if Bhf::Engine.config.abstract_config.any?
|
9
|
+
if Bhf::Engine.config.bhf.abstract_config.any?
|
10
10
|
|
11
|
-
tmp_pages = get_config_array(Bhf::Engine.config.abstract_config, '/abstract')['pages']
|
11
|
+
tmp_pages = get_config_array(Bhf::Engine.config.bhf.abstract_config, '/abstract')['pages']
|
12
12
|
abstract_platform_config = tmp_pages.each_with_object({}) do |abstract_pages, hash|
|
13
13
|
abstract_pages.each do |abstract_page|
|
14
14
|
abstract_page[1].each do |abstract_platform|
|
data/lib/bhf/data.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Bhf
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
|
4
|
-
# config.css << 'bhf'
|
5
|
-
# config.js << 'bhf'
|
6
|
-
# config.abstract_config << 'abstract'
|
4
|
+
# config.bhf.css << 'bhf'
|
5
|
+
# config.bhf.js << 'bhf'
|
6
|
+
# config.bhf.abstract_config << 'abstract'
|
7
7
|
|
8
|
-
# config.on_login_fail = :root_url
|
9
|
-
# config.logout_path = :logout_path
|
8
|
+
# config.bhf.on_login_fail = :root_url
|
9
|
+
# config.bhf.logout_path = :logout_path
|
10
10
|
|
11
|
-
# config.session_account_id = :admin_account_id
|
12
|
-
# config.session_auth_name = :is_admin
|
13
|
-
# config.account_model = 'User'
|
14
|
-
# config.account_model_find_method = 'find'
|
11
|
+
# config.bhf.session_account_id = :admin_account_id
|
12
|
+
# config.bhf.session_auth_name = :is_admin
|
13
|
+
# config.bhf.account_model = 'User'
|
14
|
+
# config.bhf.account_model_find_method = 'find'
|
15
15
|
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bhf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Pawlik
|
@@ -114,6 +114,8 @@ files:
|
|
114
114
|
- app/assets/javascripts/bhf/classes/Setlatlng.js
|
115
115
|
- app/assets/javascripts/bhf/classes/showdown.js
|
116
116
|
- app/assets/javascripts/bhf/classes/wmd.js
|
117
|
+
- app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js
|
118
|
+
- app/assets/javascripts/bhf/mootools-more-1.5.0.js
|
117
119
|
- app/assets/javascripts/bhf/mootools_ujs.js
|
118
120
|
- app/assets/stylesheets/bhf/MooEditable.css.scss
|
119
121
|
- app/assets/stylesheets/bhf/application.css.sass
|