bhf 0.6.20 → 0.6.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df4b4e02c7a3ff276bf5fa43b43f1945ef314175
4
- data.tar.gz: 3768bbb9588dd1e84e2b24b3515fde68af523702
3
+ metadata.gz: ea3828bf228388314f66419153703d30d693255f
4
+ data.tar.gz: c8391df2548607b8a27363b550b73edaa0610b3e
5
5
  SHA512:
6
- metadata.gz: 500ae8b85c83571f366179a8870a2adf50a1ddbed89cb8be8cdc29cf19d9042983627c1ac7018890dc502c0e46eb297a5a46674dc503cb2249c948ac247c4299
7
- data.tar.gz: 7ba90cdc49913a0e395ab94090bc93918d1b4d607949b03f962a8fd32b478cf52365b7fe54b8ee937a5ae69d14ef382749354c9afd40ab70cb8c9a2196d232a4
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 = bhf_entry_embed_index_path(@platform.name, @model.get_embedded_parent(params[:entry_id]))
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 = bhf_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
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 = edit_bhf_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
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: object_to_bhf_display_hash.merge(edit_path: edit_path), status: :ok
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 = bhf_entry_embed_index_path(@platform.name, @model.get_embedded_parent(params[:entry_id]))
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(edit_bhf_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object), notice: set_message('update.success', @model))
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 = bhf_entry_embed_path(@platform.name, @model.get_embedded_parent(params[:entry_id]), @object)
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 = bhf_entries_path(@platform.name)
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 = bhf_entry_path(@platform.name, @object)
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(bhf_page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('create.success', @model))
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 = bhf_entries_path(@platform.name)
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(bhf_page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('update.success', @model))
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 = bhf_entry_path(@platform.name, @object)
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(bhf_page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('duplicate.success', @model))
71
+ redirect_to(page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('duplicate.success', @model))
72
72
  else
73
- redirect_to(bhf_page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('duplicate.error', @model))
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(bhf_page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('destory.success', @model))
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: edit_bhf_entry_path(@platform.name, @object), object_id: @object.id}) do |column, hash|
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
@@ -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 self.respond_to?(Bhf::Engine.config.logout_path)
5
- = link_to t('bhf.helpers.user.logout.link'), self.send(Bhf::Engine.config.logout_path), method: :delete, class: :alt_button
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
@@ -1,4 +1,4 @@
1
1
  .content_box
2
2
  %ul.basic_info_list
3
3
  - @config.pages.each do |page|
4
- %li= link_to t("bhf.pages.navigation.#{page}", default: page.capitalize), bhf_page_path(page)
4
+ %li= link_to t("bhf.pages.navigation.#{page}", default: page.capitalize), page_path(page)
@@ -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'), bhf_page_path(@platform.page_name), class: '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, edit_bhf_entry_embed_path(field.link || 0, f.object, ref_object), class: :quick_edit
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 '&times;'.html_safe, bhf_entry_embed_path(field.link, f.object, ref_object), method: :delete, class: :delete, remote: true, data: {confirm: t('bhf.helpers.promts.confirm')}
9
+ = link_to '&times;'.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 '+', new_bhf_entry_embed_path(field.link, f.object), class: 'add_field quick_edit'
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, edit_bhf_entry_embed_path(field.link || 0, f.object, ref_object), class: :quick_edit
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 '&times;'.html_safe, bhf_entry_embed_path(field.link, f.object, ref_object), method: :delete, class: :delete, remote: true, data: {confirm: t('bhf.helpers.promts.confirm')}
9
+ = link_to '&times;'.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 '+', new_bhf_entry_embed_path(field.link, f.object), class: "add_field quick_edit #{('hide' if ref_object)}"
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, edit_bhf_entry_path(field.link || 0, ref_object), class: :quick_edit
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 '+', new_bhf_entry_path(field.link), class: 'add_field quick_edit'
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, edit_bhf_entry_path(field.link || 0, ref_object), class: :quick_edit
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 '+', new_bhf_entry_path(field.link), class: 'add_field quick_edit'
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), edit_bhf_entry_path(platform_name, object), class: 'bhf_edit', data: {:'no-turbolink' => true}
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), new_bhf_entry_path(platform.name), class: :alt_button
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' => sort_bhf_entries_path(platform.name)}
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 = edit_bhf_entry_path(platform.name, object)
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, duplicate_bhf_entry_path(platform.name, object), class: 'icon duplicate', method: :post, title: 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), bhf_entry_path(platform.name, object), method: :delete, remote: true, class: 'icon delete', data: {confirm: t('bhf.helpers.promts.confirm')}
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), new_bhf_entry_path(platform.name)
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), bhf_page_path(page)
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
- unless Bhf::Engine.config.remove_default_routes
2
- Rails.application.routes.draw(&Bhf::Engine.config.bhf_routes)
3
- #(bhf_)((.+)_?(path|url))
4
- end
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
@@ -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.bhf_page_path(
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.bhf_routes = lambda {
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
- config.remove_default_routes = false
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
@@ -2,7 +2,6 @@ module Bhf
2
2
  class Engine < Rails::Engine
3
3
 
4
4
  config.page_title = 'Bahnhof Admin'
5
- config.mount_at = '/bhf'
6
5
  # config.current_admin_account = :current_user
7
6
  # config.session_auth_name = :admin
8
7
  # config.css = ['bhf_extend']
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.20
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