mokio 0.0.14 → 0.0.15
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 +4 -4
- data/README.rdoc +15 -1
- data/app/assets/javascripts/backend/datatable.js.coffee.erb +2 -3
- data/app/assets/javascripts/backend/head.js +2 -2
- data/app/assets/javascripts/backend/main.js +2 -2
- data/app/assets/stylesheets/{backend.css.scss → backend.scss} +0 -0
- data/app/assets/stylesheets/backend/bootstrap/{bootstrap2-switch.css.scss → bootstrap2-switch.scss} +0 -0
- data/app/assets/stylesheets/backend/{comments.css.scss → comments.scss} +0 -0
- data/app/assets/stylesheets/backend/{custom.css.scss → custom.scss} +0 -0
- data/app/assets/stylesheets/backend/{dashboard.css.scss → dashboard.scss} +0 -0
- data/app/assets/stylesheets/backend/{errors.css.scss → errors.scss} +0 -0
- data/app/assets/stylesheets/backend/{icons.css.scss → icons.scss} +6278 -6278
- data/app/assets/stylesheets/backend/{main.css.scss → main.scss} +3189 -3189
- data/app/assets/stylesheets/backend/{menu.css.scss → menu.scss} +0 -0
- data/app/assets/stylesheets/backend/{mov_gallery.css.scss → mov_gallery.scss} +0 -0
- data/app/assets/stylesheets/backend/{new.css.scss → new.scss} +15 -15
- data/app/assets/stylesheets/backend/plugins/forms/select2/{select2.css.scss → select2.scss} +0 -0
- data/app/assets/stylesheets/backend/plugins/tables/dataTables/{jquery.dataTables.css.scss → jquery.dataTables.scss} +0 -0
- data/app/assets/stylesheets/backend/supr-theme/{jquery-ui-timepicker-addon.css.scss → jquery-ui-timepicker-addon.scss} +0 -0
- data/app/assets/stylesheets/backend/supr-theme/{jquery.ui.datepicker.css.scss → jquery.ui.datepicker.scss} +0 -0
- data/app/assets/stylesheets/backend/supr-theme/{jquery.ui.supr.css.scss → jquery.ui.supr.scss} +10 -10
- data/app/assets/stylesheets/backend/supr-theme/{jquery.ui.theme.css.scss → jquery.ui.theme.scss} +263 -263
- data/app/assets/stylesheets/{dashboard.css.scss → dashboard.scss} +0 -0
- data/app/assets/stylesheets/{scaffolds.css.scss → scaffolds.scss} +0 -0
- data/app/controllers/mokio/support_controller.rb +3 -1
- data/app/helpers/mokio/backend/backend_helper.rb +25 -3
- data/app/helpers/mokio/backend/menu_helper.rb +4 -4
- data/app/models/devise_custom_failure.rb +5 -0
- data/app/models/{ability.rb → mokio/ability.rb} +25 -28
- data/app/views/devise/sessions/new.html.haml +1 -1
- data/app/views/layouts/mokio/backend.html.haml +3 -1
- data/app/views/mokio/common/index.html.slim +1 -0
- data/app/views/mokio/layout/_user_widget.html.slim +1 -1
- data/app/views/mokio/layout/sidebar.html.slim +1 -1
- data/app/views/mokio/menus/_form.html.haml +2 -2
- data/config/initializers/devise.rb +3 -2
- data/config/routes.rb +1 -4
- data/lib/mokio/concerns/common/controller_functions.rb +9 -2
- data/lib/mokio/concerns/common/controller_object.rb +14 -5
- data/lib/mokio/concerns/controllers/application.rb +2 -2
- data/lib/mokio/concerns/controllers/base.rb +7 -0
- data/lib/mokio/concerns/controllers/common.rb +9 -5
- data/lib/mokio/concerns/controllers/dashboard.rb +4 -4
- data/lib/mokio/concerns/models/common.rb +6 -6
- data/lib/mokio/concerns/models/user.rb +4 -4
- data/lib/mokio/version.rb +1 -1
- data/spec/dummy/config/routes.rb +1 -1
- metadata +104 -177
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Mokio
|
2
2
|
module Backend
|
3
|
-
module BackendHelper
|
3
|
+
module BackendHelper
|
4
4
|
include Haml::Helpers
|
5
5
|
#
|
6
6
|
# Translate methods
|
@@ -55,7 +55,8 @@ module Mokio
|
|
55
55
|
# i.e.(can? : manage, Mokio::Menu)
|
56
56
|
# * +plus_icon_class+ Icon css class for "+" button
|
57
57
|
def sidebar_btn(type, icon_class, label="", add_btn = true, check_permissions = true, plus_icon_class = "icomoon-icon-plus")
|
58
|
-
|
58
|
+
|
59
|
+
table = generate_tableize_name(type.to_s) #Mokio::Menu => menus or Mokio::MyModule::Menu => mymodule_menus
|
59
60
|
model = table.singularize#Mokio::Menu => menu
|
60
61
|
|
61
62
|
if label.empty?
|
@@ -98,6 +99,27 @@ module Mokio
|
|
98
99
|
html.html_safe
|
99
100
|
end
|
100
101
|
|
102
|
+
#
|
103
|
+
# Can user manage any site elements
|
104
|
+
#
|
105
|
+
def can_manage_site_elements?
|
106
|
+
(
|
107
|
+
(can? :manage, Mokio::StaticModule) ||
|
108
|
+
(can? :create, Mokio::StaticModule) ||
|
109
|
+
(can? :manage, Mokio::ModulePosition) ||
|
110
|
+
(can? :create, Mokio::ModulePosition) ||
|
111
|
+
(can? :manage, Mokio::ExternalScript) ||
|
112
|
+
(can? :create, Mokio::ExternalScript)
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
#return table name for type
|
117
|
+
def generate_tableize_name(type)
|
118
|
+
type.gsub!("Mokio::","")
|
119
|
+
type.gsub!("::","_") if(type.include? "::")
|
120
|
+
type.tableize
|
121
|
+
end
|
122
|
+
|
101
123
|
end
|
102
124
|
end
|
103
|
-
end
|
125
|
+
end
|
@@ -3,10 +3,10 @@ module Mokio
|
|
3
3
|
module MenuHelper
|
4
4
|
include Haml::Helpers
|
5
5
|
|
6
|
-
#displays
|
7
|
-
def
|
6
|
+
#displays breadcrumb to current menu element
|
7
|
+
def tree_menu_breadcrumbs(menu)
|
8
8
|
unless menu.nil?
|
9
|
-
@tree_nodes = menu.ancestors << menu
|
9
|
+
@tree_nodes = menu.ancestors.to_a << menu
|
10
10
|
@tree_nodes.map do |m|
|
11
11
|
if m.present? and m != menu
|
12
12
|
link_to(m.name, edit_menu_path(m)) + " -> "
|
@@ -214,4 +214,4 @@ module Mokio
|
|
214
214
|
|
215
215
|
end
|
216
216
|
end
|
217
|
-
end
|
217
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Mokio
|
2
|
+
class Ability
|
3
|
+
include CanCan::Ability
|
3
4
|
|
4
|
-
def initialize(user)
|
5
5
|
# Define abilities for the passed in user here. For example:
|
6
6
|
#
|
7
7
|
# user ||= User.new # guest user (not logged in)
|
@@ -28,31 +28,28 @@ class Ability
|
|
28
28
|
#
|
29
29
|
# See the wiki for details:
|
30
30
|
# https://github.com/bryanrite/cancancan/wiki/Defining-Abilities
|
31
|
+
def initialize(user)
|
32
|
+
if user.has_role? :admin
|
33
|
+
can :manage, :all
|
34
|
+
end
|
35
|
+
if user.has_role? :content_editor
|
36
|
+
can :manage, [Mokio::Content]
|
37
|
+
end
|
38
|
+
if user.has_role? :menu_editor
|
39
|
+
can :manage, [Mokio::Menu]
|
40
|
+
end
|
41
|
+
if user.has_role? :static_module_editor
|
42
|
+
can :manage, [Mokio::StaticModule]
|
43
|
+
end
|
44
|
+
if user.has_role? :user_editor
|
45
|
+
can :manage, [Mokio::User]
|
46
|
+
end
|
47
|
+
if user.has_role? :reader
|
48
|
+
can :read, :all
|
49
|
+
end
|
31
50
|
|
32
|
-
|
33
|
-
can :
|
51
|
+
can :edit_password, Mokio::User
|
52
|
+
can :update_password, Mokio::User
|
34
53
|
end
|
35
|
-
if user.has_role? :content_editor
|
36
|
-
can :manage, [Mokio::Content]
|
37
|
-
end
|
38
|
-
if user.has_role? :menu_editor
|
39
|
-
can :manage, [Mokio::Menu]
|
40
|
-
end
|
41
|
-
if user.has_role? :static_module_editor
|
42
|
-
can :manage, [Mokio::StaticModule]
|
43
|
-
end
|
44
|
-
if user.has_role? :user_editor
|
45
|
-
can :manage, [Mokio::User]
|
46
|
-
end
|
47
|
-
if user.has_role? :reader
|
48
|
-
can :read, :all
|
49
|
-
end
|
50
|
-
|
51
|
-
can :edit_password, Mokio::User
|
52
|
-
can :update_password, Mokio::User
|
53
|
-
|
54
|
-
|
55
|
-
|
56
54
|
end
|
57
|
-
end
|
58
|
-
|
55
|
+
end
|
@@ -23,14 +23,14 @@
|
|
23
23
|
#url_box{:style => "display: #{!@menu.external_link.blank? ? 'block' : 'none'};"}
|
24
24
|
= f.input :external_link, label: btc("external_link",'Menu'), disabled: !@menu.display_editable_field?('external_link')
|
25
25
|
= f.input :follow, :as => :select, :collection => [[bt("follow",'Menu'), "true"], [bt("nofollow",'Menu'), "false"]], :include_blank => false
|
26
|
-
= f.input :parent_id, :collection => @menu.parent_tree.collect{|m| ["#{'-' * m.
|
26
|
+
= f.input :parent_id, :collection => @menu.parent_tree.where.not(ancestry: nil).collect{|m| ["#{'-' * (m.depth - 1)} #{m.name}", m.id]}, include_blank: false, disabled: !@menu.display_editable_field?('parent_id')
|
27
27
|
|
28
28
|
.row-fluid
|
29
29
|
%label.form-label.span2
|
30
30
|
= btc('path', Mokio::Menu)
|
31
31
|
.span10
|
32
32
|
#menu_breadcrumps
|
33
|
-
=
|
33
|
+
= tree_menu_breadcrumbs(@menu.parent)
|
34
34
|
|
35
35
|
= f.input :target, :collection => [[bt("current_window_inside",Mokio::Menu), nil], [bt("new_window",Mokio::Menu), "_blank"]], include_blank: false, disabled: !@menu.display_editable_field?('target')
|
36
36
|
|
@@ -235,10 +235,11 @@ Devise.setup do |config|
|
|
235
235
|
# If you want to use other strategies, that are not supported by Devise, or
|
236
236
|
# change the failure app, you can configure them inside the config.warden block.
|
237
237
|
#
|
238
|
-
|
238
|
+
config.warden do |manager|
|
239
|
+
manager.failure_app = DeviseCustomFailure
|
239
240
|
# manager.intercept_401 = false
|
240
241
|
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
241
|
-
|
242
|
+
end
|
242
243
|
|
243
244
|
# ==> Mountable engine configurations
|
244
245
|
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
data/config/routes.rb
CHANGED
@@ -66,11 +66,18 @@ module Mokio
|
|
66
66
|
parameters
|
67
67
|
end
|
68
68
|
|
69
|
+
def generate_path
|
70
|
+
path = @obj_class.name
|
71
|
+
path = path.gsub("Mokio::","") if path.include? "Mokio::"
|
72
|
+
path = path.tableize.gsub("/","_")
|
73
|
+
path
|
74
|
+
end
|
75
|
+
|
69
76
|
#
|
70
77
|
# Returns obj index url
|
71
78
|
#
|
72
79
|
def obj_index_url #:doc:
|
73
|
-
send("#{
|
80
|
+
send("#{generate_path}_url") # call your_controller index path
|
74
81
|
end
|
75
82
|
|
76
83
|
#
|
@@ -89,7 +96,7 @@ module Mokio
|
|
89
96
|
# Returns obj new url
|
90
97
|
#
|
91
98
|
def obj_new_url(obj) #:doc:
|
92
|
-
send("new_#{
|
99
|
+
send("new_#{generate_path.singularize}_path", obj) # call your_controller edit path for obj
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Mokio
|
2
|
-
module Concerns
|
3
|
-
module Common
|
2
|
+
module Concerns
|
3
|
+
module Common
|
4
4
|
#
|
5
5
|
# Most important logic for CommonController
|
6
6
|
#
|
@@ -16,7 +16,7 @@ module Mokio
|
|
16
16
|
|
17
17
|
private
|
18
18
|
#
|
19
|
-
# Returns inherited conroller singularized name
|
19
|
+
# Returns inherited conroller singularized name
|
20
20
|
#
|
21
21
|
def obj_name #:doc:
|
22
22
|
self.controller_name.singularize
|
@@ -68,13 +68,22 @@ module Mokio
|
|
68
68
|
create_obj( @obj_class.respond_to?(:friendly) ? @obj_class.friendly.find(params[:id]) : @obj_class.find(params[:id]) )
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
|
72
72
|
#
|
73
73
|
# Setting constant parsed from controller name to @obj_class variable.
|
74
74
|
# Our controllers are named to match model name. <b>before_filter</b> in CommonController
|
75
75
|
#
|
76
76
|
def set_obj_class #:doc:
|
77
|
-
|
77
|
+
|
78
|
+
class_name = (self.class.name.include? "Mokio::") ? self.class.name.gsub("Mokio::", "") : self.class.name
|
79
|
+
#check is class in Mokio module
|
80
|
+
@obj_class = "Mokio::#{class_name.gsub("Controller", "").classify}".constantize rescue nil
|
81
|
+
#if there is no class in Mokio module check outside
|
82
|
+
if @obj_class.nil?
|
83
|
+
@obj_class = "#{class_name.gsub("Controller", "").classify}".constantize rescue nil
|
84
|
+
end
|
85
|
+
#used for path to update_active action in datatable.js.coffee.erb
|
86
|
+
@obj_path = ((@obj_class.to_s.include? "Mokio::") ? @obj_class.to_s.gsub("Mokio::","") : @obj_class.to_s).tableize
|
78
87
|
end
|
79
88
|
|
80
89
|
#
|
@@ -24,7 +24,7 @@ module Mokio
|
|
24
24
|
# <b>before_filter</b> in ApplicationController using <b>gem devise</b>
|
25
25
|
#
|
26
26
|
def configure_permitted_parameters
|
27
|
-
devise_parameter_sanitizer.
|
27
|
+
devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation])
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
@@ -73,4 +73,4 @@ module Mokio
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
end
|
76
|
+
end
|
@@ -54,6 +54,13 @@ module Mokio
|
|
54
54
|
@breadcrumbs_prefix = ""
|
55
55
|
@breadcrumbs_prefix_link = ""
|
56
56
|
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# override current_ability to use Mokio's one
|
60
|
+
#
|
61
|
+
def current_ability
|
62
|
+
@current_ability ||= Mokio::Ability.new(current_user)
|
63
|
+
end
|
57
64
|
end
|
58
65
|
end
|
59
66
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mokio
|
2
2
|
module Concerns
|
3
3
|
module Controllers
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Concern for CommonController. Many important controller logic is placed here.
|
6
6
|
#
|
7
7
|
# Most of Mokio's controllers are inherited by this controller. The main logic is to not repeat same part of code with changing only variables.
|
@@ -12,10 +12,10 @@ module Mokio
|
|
12
12
|
# == CommonController provides:
|
13
13
|
#
|
14
14
|
# * +index+ method with json sending data.
|
15
|
-
# Its using common/index view and place date into jquery.datatable plugin (you can see in backend/datatable.js.coffee.erb file).
|
15
|
+
# Its using common/index view and place date into jquery.datatable plugin (you can see in backend/datatable.js.coffee.erb file).
|
16
16
|
# We send json as CommonsDatatable object (app/datatables/commons_datatable.rb)
|
17
17
|
# Columns displayed in table are specified in used model inside method called columns_for_table.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# * +new+ method with building meta/gmap if they are enabled in used model
|
20
20
|
# Its using common/new view and need partial '_form' with specifed form elements. Main form uses simple_form.
|
21
21
|
#
|
@@ -23,7 +23,7 @@ module Mokio
|
|
23
23
|
# Its using common/edit and need same partial as in 'new' action.
|
24
24
|
#
|
25
25
|
# * +create+ method
|
26
|
-
# Simple creating and saving object to database if passed validation.
|
26
|
+
# Simple creating and saving object to database if passed validation.
|
27
27
|
#
|
28
28
|
# * +update+ method
|
29
29
|
# Simple updating object in database
|
@@ -49,7 +49,11 @@ module Mokio
|
|
49
49
|
include Mokio::Concerns::Common::ControllerObject
|
50
50
|
include Mokio::Concerns::Common::ControllerFunctions
|
51
51
|
|
52
|
-
|
52
|
+
before_action :authorize_actions
|
53
|
+
def authorize_actions
|
54
|
+
authorize!(params[:action].to_sym, @obj_class)
|
55
|
+
end
|
56
|
+
|
53
57
|
end
|
54
58
|
|
55
59
|
#
|
@@ -25,9 +25,9 @@ module Mokio
|
|
25
25
|
#
|
26
26
|
# menu without displayed content
|
27
27
|
#
|
28
|
-
@menu_with_invisible_content = (Mokio::Menu.includes(:contents).where('mokio_contents.id is not NULL').references(:contents)).select{|menu| menu.invisible_content}
|
29
|
-
@empty_menu = Mokio::Menu.includes(:contents).where(:mokio_content_links => {:menu_id => nil}, :external_link => nil, :fake => false)
|
30
|
-
@empty_menu = @empty_menu
|
28
|
+
@menu_with_invisible_content = (Mokio::Menu.includes(:contents).where('mokio_contents.id is not NULL').references(:contents)).select{|menu| menu.invisible_content}.pluck :id
|
29
|
+
@empty_menu = Mokio::Menu.includes(:contents).where(:mokio_content_links => {:menu_id => nil}, :external_link => nil, :fake => false).pluck :id
|
30
|
+
@empty_menu = Mokio::Menu.where id: @empty_menu + @menu_with_invisible_content
|
31
31
|
@empty_menu = @empty_menu.first(Mokio.dashboard_size.to_i)
|
32
32
|
@more_empty_menu = @empty_menu.size
|
33
33
|
|
@@ -38,4 +38,4 @@ module Mokio
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
@@ -29,7 +29,7 @@ module Mokio
|
|
29
29
|
#
|
30
30
|
if Mokio.solr_enabled
|
31
31
|
exceptions = Mokio::SolrConfig.all_exceptions # Classes which are excluded from indexing or have own searchable method
|
32
|
-
|
32
|
+
|
33
33
|
unless exceptions.include? self.name.demodulize.downcase.to_sym
|
34
34
|
searchable do # Columns where Sunspot knows which data use to index
|
35
35
|
text :title, :boost => 5
|
@@ -37,7 +37,7 @@ module Mokio
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
end
|
40
|
+
end
|
41
41
|
|
42
42
|
module ClassMethods
|
43
43
|
#
|
@@ -60,12 +60,12 @@ module Mokio
|
|
60
60
|
#
|
61
61
|
def active_view
|
62
62
|
"<div class=\"activebutton\">
|
63
|
-
<input type=\"checkbox\"
|
64
|
-
#{"checked=\"checked\"" if self.active}
|
63
|
+
<input type=\"checkbox\"
|
64
|
+
#{"checked=\"checked\"" if self.active}
|
65
65
|
class=\"activebtn switch-small\"
|
66
66
|
data-on=\"success\"
|
67
67
|
data-off=\"danger\"
|
68
|
-
data-on-label=\"<i class='icomoon-icon-checkmark white'></i>\"
|
68
|
+
data-on-label=\"<i class='icomoon-icon-checkmark white'></i>\"
|
69
69
|
data-off-label=\"<i class='icomoon-icon-cancel-3 white'></i>\"
|
70
70
|
>
|
71
71
|
</div>"
|
@@ -103,7 +103,7 @@ module Mokio
|
|
103
103
|
def some_editable
|
104
104
|
if !self.editable && !self.changed.nil?
|
105
105
|
(self.changed.to_set - self.always_editable_fields.to_set).each do |field|
|
106
|
-
errors.add(field.to_sym, "#{I18n.t('activerecord.errors.editable.not_permitted')}")
|
106
|
+
errors.add(field.to_sym, "#{I18n.t('activerecord.errors.editable.not_permitted')}")
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|