bhf 0.6.20 → 0.6.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/bhf/application_controller.rb +1 -1
- data/app/controllers/bhf/embed_entries_controller.rb +7 -7
- data/app/controllers/bhf/entries_controller.rb +10 -10
- data/app/helpers/bhf/frontend_helper.rb +17 -0
- data/app/views/bhf/_user.haml +2 -2
- data/app/views/bhf/application/index.haml +1 -1
- data/app/views/bhf/entries/_form.haml +1 -1
- data/app/views/bhf/entries/form/embeds_many/_static.haml +3 -3
- data/app/views/bhf/entries/form/embeds_one/_static.haml +3 -3
- data/app/views/bhf/entries/form/has_many/_static.haml +2 -2
- data/app/views/bhf/entries/form/has_one/_static.haml +2 -2
- data/app/views/bhf/helper/_frontend_edit.haml +1 -1
- data/app/views/bhf/pages/_platform.haml +6 -6
- data/app/views/layouts/bhf/application.haml +2 -2
- data/config/routes.rb +16 -4
- data/lib/bhf/pagination.rb +1 -1
- data/lib/bhf.rb +9 -24
- data/lib/rails/generators/bhf/templates/initializer.rb +0 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea3828bf228388314f66419153703d30d693255f
|
4
|
+
data.tar.gz: c8391df2548607b8a27363b550b73edaa0610b3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95313defc1225ba4e8b4965a4a799136a0060edb80facee19a279a9e370411bb1631d7ec2739d2e5cc3d4b4b6c778e0c0ecda133e6eb467af862b7423ffa8754
|
7
|
+
data.tar.gz: 1fd7e80f81ca5f5fe5ee4b9a6b55e4edd7ac5090f118496e291a9d112bac2af369940b7a8da6023a89c988446ca921fd9d26536cd4ada92c3b35b78d27e0caec
|
@@ -16,7 +16,7 @@ class Bhf::ApplicationController < ActionController::Base
|
|
16
16
|
return true
|
17
17
|
end
|
18
18
|
|
19
|
-
redirect_to(send(Bhf::Engine.config.on_login_fail.to_sym), error: t('bhf.helpers.user.login.error')) and return false
|
19
|
+
redirect_to(main_app.send(Bhf::Engine.config.on_login_fail.to_sym), error: t('bhf.helpers.user.login.error')) and return false
|
20
20
|
end
|
21
21
|
|
22
22
|
def setup_current_account
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class Bhf::EmbedEntriesController < Bhf::EntriesController
|
2
2
|
|
3
3
|
def new
|
4
|
-
@form_url =
|
4
|
+
@form_url = entry_embed_index_path(@platform.name, @model.get_embedded_parent(params[:entry_id]))
|
5
5
|
|
6
6
|
render 'bhf/entries/new', ({layout: 'bhf/quick_edit'} if @quick_edit) || {}
|
7
7
|
end
|
8
8
|
|
9
9
|
def edit
|
10
|
-
@form_url =
|
10
|
+
@form_url = entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
|
11
11
|
|
12
12
|
render 'bhf/entries/edit', ({layout: 'bhf/quick_edit'} if @quick_edit) || {}
|
13
13
|
end
|
@@ -18,14 +18,14 @@ class Bhf::EmbedEntriesController < Bhf::EntriesController
|
|
18
18
|
manage_many_to_many
|
19
19
|
after_save
|
20
20
|
|
21
|
-
edit_path =
|
21
|
+
edit_path = edit_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
|
22
22
|
if @quick_edit
|
23
|
-
render json:
|
23
|
+
render json: object_to_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
|
-
@form_url =
|
28
|
+
@form_url = entry_embed_index_path(@platform.name, @model.get_embedded_parent(params[:entry_id]))
|
29
29
|
|
30
30
|
r_settings = {status: :unprocessable_entity}
|
31
31
|
r_settings[:layout] = 'bhf/quick_edit' if @quick_edit
|
@@ -42,10 +42,10 @@ 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
|
-
redirect_back_or_default(
|
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
|
-
@form_url =
|
48
|
+
@form_url = entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
|
49
49
|
|
50
50
|
r_settings = {status: :unprocessable_entity}
|
51
51
|
r_settings[:layout] = 'bhf/quick_edit' if @quick_edit
|
@@ -4,7 +4,7 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
4
4
|
before_filter :load_new_object, only: [:create, :new]
|
5
5
|
|
6
6
|
def new
|
7
|
-
@form_url =
|
7
|
+
@form_url = entries_path(@platform.name)
|
8
8
|
|
9
9
|
render layout: 'bhf/quick_edit' if @quick_edit
|
10
10
|
end
|
@@ -12,7 +12,7 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
12
12
|
def edit
|
13
13
|
render file: 'public/404.html', layout: false and return unless @object
|
14
14
|
|
15
|
-
@form_url =
|
15
|
+
@form_url = entry_path(@platform.name, @object)
|
16
16
|
|
17
17
|
render layout: 'bhf/quick_edit' if @quick_edit
|
18
18
|
end
|
@@ -30,10 +30,10 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
30
30
|
if @quick_edit
|
31
31
|
render json: object_to_bhf_display_hash, status: :ok
|
32
32
|
else
|
33
|
-
redirect_back_or_default(
|
33
|
+
redirect_back_or_default(page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('create.success', @model))
|
34
34
|
end
|
35
35
|
else
|
36
|
-
@form_url =
|
36
|
+
@form_url = entries_path(@platform.name)
|
37
37
|
|
38
38
|
r_settings = {status: :unprocessable_entity}
|
39
39
|
r_settings[:layout] = 'bhf/quick_edit' if @quick_edit
|
@@ -52,10 +52,10 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
52
52
|
if @quick_edit
|
53
53
|
render json: object_to_bhf_display_hash, status: :ok
|
54
54
|
else
|
55
|
-
redirect_back_or_default(
|
55
|
+
redirect_back_or_default(page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('update.success', @model))
|
56
56
|
end
|
57
57
|
else
|
58
|
-
@form_url =
|
58
|
+
@form_url = entry_path(@platform.name, @object)
|
59
59
|
|
60
60
|
r_settings = {status: :unprocessable_entity}
|
61
61
|
r_settings[:layout] = 'bhf/quick_edit' if @quick_edit
|
@@ -68,9 +68,9 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
68
68
|
new_record.before_bhf_duplicate(@object) if new_record.respond_to?(:before_bhf_duplicate)
|
69
69
|
if new_record.save
|
70
70
|
new_record.after_bhf_duplicate(@object) if new_record.respond_to?(:after_bhf_duplicate)
|
71
|
-
redirect_to(
|
71
|
+
redirect_to(page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('duplicate.success', @model))
|
72
72
|
else
|
73
|
-
redirect_to(
|
73
|
+
redirect_to(page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('duplicate.error', @model))
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -91,14 +91,14 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
91
91
|
if @quick_edit
|
92
92
|
head :ok
|
93
93
|
else
|
94
|
-
redirect_back_or_default(
|
94
|
+
redirect_back_or_default(page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('destory.success', @model))
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
private
|
99
99
|
|
100
100
|
def object_to_bhf_display_hash
|
101
|
-
@platform.columns.each_with_object({to_bhf_s: @object.to_bhf_s, edit_path:
|
101
|
+
@platform.columns.each_with_object({to_bhf_s: @object.to_bhf_s, edit_path: edit_entry_path(@platform.name, @object), object_id: @object.id}) do |column, hash|
|
102
102
|
unless column.field.macro == :column && @object.send(column.name).blank?
|
103
103
|
p = "bhf/pages/macro/#{column.field.macro}/#{column.field.display_type}"
|
104
104
|
hash[column.name] = render_to_string partial: p, locals: {column: column, object: @object}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Bhf
|
2
|
+
module FrontendHelper
|
3
|
+
|
4
|
+
def bhf_edit(object, options = {}) # TODO: add a block of html for custom editing buttons and links
|
5
|
+
return unless session[Bhf::Engine.config.session_auth_name.to_s] == true
|
6
|
+
|
7
|
+
options[:platform_name] ||= object.class.to_s.pluralize.downcase
|
8
|
+
|
9
|
+
if object.respond_to?(:'bhf_can_edit?', true)
|
10
|
+
return unless object.bhf_can_edit?(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
render partial: 'bhf/helper/frontend_edit', locals: { platform_name: options[:platform_name], object: object }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
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
|
5
|
-
= link_to t('bhf.helpers.user.logout.link'),
|
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
|
@@ -13,4 +13,4 @@
|
|
13
13
|
.label
|
14
14
|
.input
|
15
15
|
= f.submit f.object.new_record? ? new_t(@platform) : edit_t(@platform)
|
16
|
-
= link_to t('bhf.helpers.entry.cancel'),
|
16
|
+
= link_to t('bhf.helpers.entry.cancel'), page_path(@platform.page_name), class: 'cancel'
|
@@ -4,9 +4,9 @@
|
|
4
4
|
%ul.relation{class: field.macro}
|
5
5
|
- ref_objects.each do |ref_object|
|
6
6
|
%li
|
7
|
-
= link_to_if field.link, ref_object.to_bhf_s,
|
7
|
+
= link_to_if field.link, ref_object.to_bhf_s, edit_entry_embed_path(field.link || 0, f.object, ref_object), class: :quick_edit
|
8
8
|
- if field.link
|
9
|
-
= link_to '×'.html_safe,
|
9
|
+
= link_to '×'.html_safe, entry_embed_path(field.link, f.object, ref_object), method: :delete, class: :delete, remote: true, data: {confirm: t('bhf.helpers.promts.confirm')}
|
10
10
|
|
11
11
|
- if field.link
|
12
|
-
= link_to '+',
|
12
|
+
= link_to '+', new_entry_embed_path(field.link, f.object), class: 'add_field quick_edit'
|
@@ -4,9 +4,9 @@
|
|
4
4
|
%ul.relation{class: field.macro}
|
5
5
|
%li
|
6
6
|
- if ref_object
|
7
|
-
= link_to_if field.link, ref_object.to_bhf_s,
|
7
|
+
= link_to_if field.link, ref_object.to_bhf_s, edit_entry_embed_path(field.link || 0, f.object, ref_object), class: :quick_edit
|
8
8
|
- if field.link
|
9
|
-
= link_to '×'.html_safe,
|
9
|
+
= link_to '×'.html_safe, entry_embed_path(field.link, f.object, ref_object), method: :delete, class: :delete, remote: true, data: {confirm: t('bhf.helpers.promts.confirm')}
|
10
10
|
|
11
11
|
- if field.link
|
12
|
-
= link_to '+',
|
12
|
+
= link_to '+', new_entry_embed_path(field.link, f.object), class: "add_field quick_edit #{('hide' if ref_object)}"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
%p.empty{class: ('hide' unless ref_objects.blank?)}= t 'bhf.helpers.entry.empty', count: 2
|
4
4
|
%ul.relation{class: field.macro}
|
5
5
|
- ref_objects.each do |ref_object|
|
6
|
-
%li= link_to_if field.link, ref_object.to_bhf_s,
|
6
|
+
%li= link_to_if field.link, ref_object.to_bhf_s, edit_entry_path(field.link || 0, ref_object), class: :quick_edit
|
7
7
|
|
8
8
|
- if field.link
|
9
|
-
= link_to '+',
|
9
|
+
= link_to '+', new_entry_path(field.link), class: 'add_field quick_edit'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
%p.empty{class: ('hide' if ref_object)}= t 'bhf.helpers.entry.empty', count: 1
|
4
4
|
%ul.relation{class: field.macro}
|
5
5
|
- if ref_object
|
6
|
-
%li= link_to_if field.link, ref_object.to_bhf_s,
|
6
|
+
%li= link_to_if field.link, ref_object.to_bhf_s, edit_entry_path(field.link || 0, ref_object), class: :quick_edit
|
7
7
|
|
8
8
|
- if field.link
|
9
|
-
= link_to '+',
|
9
|
+
= link_to '+', new_entry_path(field.link), class: 'add_field quick_edit'
|
@@ -1 +1 @@
|
|
1
|
-
= link_to t('bhf.helpers.entry.edit', platform_name: object.to_bhf_s),
|
1
|
+
= link_to t('bhf.helpers.entry.edit', platform_name: object.to_bhf_s), bhf.edit_entry_path(platform_name, object), class: 'bhf_edit', data: {:'no-turbolink' => true}
|
@@ -7,7 +7,7 @@
|
|
7
7
|
%h4= platform.title
|
8
8
|
%p.info= platform.pagination.info platform
|
9
9
|
- unless platform.hide_create
|
10
|
-
%p.create= link_to new_t(platform),
|
10
|
+
%p.create= link_to new_t(platform), new_entry_path(platform.name), class: :alt_button
|
11
11
|
- unless platform.custom_partial
|
12
12
|
= render partial: 'search', locals: {platform: platform} if platform.search?
|
13
13
|
|
@@ -28,10 +28,10 @@
|
|
28
28
|
%td{colspan: platform.columns_count}
|
29
29
|
= platform.pagination.create(platform) unless platform.sortable
|
30
30
|
|
31
|
-
%tbody{class: (:sortable if platform.sortable), :'data-sort-url' =>
|
31
|
+
%tbody{class: (:sortable if platform.sortable), :'data-sort-url' => sort_entries_path(platform.name)}
|
32
32
|
- if platform.objects.any?
|
33
33
|
- platform.objects.each do |object|
|
34
|
-
- edit_link =
|
34
|
+
- edit_link = edit_entry_path(platform.name, object)
|
35
35
|
- custom_link = send(platform.custom_link, platform.name, object) if platform.custom_link
|
36
36
|
%tr{id: "#{object.id}_#{platform.name}"}
|
37
37
|
- if platform.sortable
|
@@ -49,14 +49,14 @@
|
|
49
49
|
%td.action{class: (:wider if platform.show_duplicate && !platform.hide_edit && !platform.hide_delete)}
|
50
50
|
- if platform.show_duplicate
|
51
51
|
- dt = duplicate_t(platform)
|
52
|
-
= link_to dt,
|
52
|
+
= link_to dt, duplicate_entry_path(platform.name, object), class: 'icon duplicate', method: :post, title: dt
|
53
53
|
- unless platform.hide_edit
|
54
54
|
= link_to edit_t(platform), edit_link, class: 'icon edit'
|
55
55
|
- unless platform.hide_delete
|
56
|
-
= link_to delete_t(platform),
|
56
|
+
= link_to delete_t(platform), entry_path(platform.name, object), method: :delete, remote: true, class: 'icon delete', data: {confirm: t('bhf.helpers.promts.confirm')}
|
57
57
|
- else
|
58
58
|
%td.no_entries{colspan: platform.columns_count}
|
59
59
|
= t 'bhf.pagination.info', name_zero: platform.title, count: 0
|
60
60
|
- unless platform.hide_create
|
61
|
-
= link_to new_t(platform),
|
61
|
+
= link_to new_t(platform), new_entry_path(platform.name)
|
62
62
|
|
@@ -10,13 +10,13 @@
|
|
10
10
|
%header
|
11
11
|
%h1
|
12
12
|
- logo = Rails.application.assets.find_asset('logo_bhf.png') ? 'logo_bhf.png' : 'logo_bhf.svg'
|
13
|
-
= link_to image_tag(asset_path(logo)), root_url, :'data-no-turbolink' => true
|
13
|
+
= link_to image_tag(asset_path(logo)), main_app.root_url, :'data-no-turbolink' => true
|
14
14
|
- if @config && @config.pages.any?
|
15
15
|
%nav
|
16
16
|
%ul
|
17
17
|
- @config.pages.each do |page|
|
18
18
|
%li{class: ('active' if @page == page)}
|
19
|
-
= link_to t("bhf.pages.navigation.#{page}", default: page.capitalize),
|
19
|
+
= link_to t("bhf.pages.navigation.#{page}", default: page.capitalize), page_path(page)
|
20
20
|
|
21
21
|
#content
|
22
22
|
#main
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
Bhf::Engine.routes.draw do
|
2
|
+
root to: 'application#index'
|
3
|
+
|
4
|
+
get 'page/:page', to: 'pages#show', as: :page
|
5
|
+
|
6
|
+
scope ':platform' do
|
7
|
+
resources :entries, except: [:index] do
|
8
|
+
put :sort, on: :collection
|
9
|
+
|
10
|
+
resources :embed_entries, except: [:index, :show], as: :embed
|
11
|
+
post :duplicate, on: :member
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
#()((.+)_?(path|url))
|
16
|
+
end
|
data/lib/bhf/pagination.rb
CHANGED
@@ -93,7 +93,7 @@ module Bhf
|
|
93
93
|
direction = plus ? 'more' : 'less'
|
94
94
|
template.link_to(
|
95
95
|
I18n.t("bhf.pagination.load_#{direction}"),
|
96
|
-
template.
|
96
|
+
template.page_path(
|
97
97
|
platform.page_name,
|
98
98
|
template.params.merge(platform.name => platform_params)
|
99
99
|
), attributes.merge(class: "load_#{direction}")
|
data/lib/bhf.rb
CHANGED
@@ -6,9 +6,11 @@ require 'kaminari'
|
|
6
6
|
|
7
7
|
module Bhf
|
8
8
|
class Engine < Rails::Engine
|
9
|
+
|
10
|
+
isolate_namespace Bhf
|
11
|
+
|
9
12
|
# Config defaults
|
10
13
|
config.page_title = nil
|
11
|
-
config.mount_at = 'bhf'
|
12
14
|
config.on_login_fail = :root_url
|
13
15
|
config.logout_path = :logout_path
|
14
16
|
config.session_auth_name = :is_admin
|
@@ -18,29 +20,14 @@ module Bhf
|
|
18
20
|
config.css = []
|
19
21
|
config.js = []
|
20
22
|
|
21
|
-
config.
|
22
|
-
namespace :bhf, path: Bhf::Engine.config.mount_at do
|
23
|
-
root to: 'application#index'
|
24
|
-
|
25
|
-
get 'page/:page', to: 'pages#show', as: :page
|
26
|
-
|
27
|
-
scope ':platform' do
|
28
|
-
resources :entries, except: [:index] do
|
29
|
-
put :sort, on: :collection
|
30
|
-
|
31
|
-
resources :embed_entries, except: [:index, :show], as: :embed
|
32
|
-
post :duplicate, on: :member
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
}
|
38
|
-
|
23
|
+
# config.bhf_logic = YAML::load(IO.read('config/bhf.yml'))
|
39
24
|
|
40
|
-
|
25
|
+
initializer 'bhf.action_controller' do |app|
|
26
|
+
ActiveSupport.on_load :action_controller do
|
27
|
+
helper Bhf::FrontendHelper
|
28
|
+
end
|
29
|
+
end
|
41
30
|
|
42
|
-
# config.bhf_logic = YAML::load(IO.read('config/bhf.yml'))
|
43
|
-
|
44
31
|
end
|
45
32
|
end
|
46
33
|
|
@@ -48,7 +35,6 @@ require 'bhf/i18n'
|
|
48
35
|
require 'bhf/active_record/active_record'
|
49
36
|
require 'bhf/active_record/upload'
|
50
37
|
require 'bhf/mongoid/document'
|
51
|
-
require 'bhf/view_helpers'
|
52
38
|
require 'bhf/data'
|
53
39
|
require 'bhf/platform'
|
54
40
|
require 'bhf/settings'
|
@@ -64,4 +50,3 @@ if defined?(Mongoid)
|
|
64
50
|
::Mongoid::Document.send :include, Bhf::Mongoid::Document
|
65
51
|
end
|
66
52
|
|
67
|
-
::ActionView::Base.send :include, Bhf::ViewHelpers::ActionView
|
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.6.
|
4
|
+
version: 0.6.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Pawlik
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- app/controllers/bhf/pages_controller.rb
|
128
128
|
- app/helpers/bhf/application_helper.rb
|
129
129
|
- app/helpers/bhf/entries_helper.rb
|
130
|
+
- app/helpers/bhf/frontend_helper.rb
|
130
131
|
- app/helpers/bhf/pages_helper.rb
|
131
132
|
- app/views/bhf/_footer.haml
|
132
133
|
- app/views/bhf/_user.haml
|