releaf 0.1.1 → 0.1.2
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 +7 -0
- data/README.md +15 -12
- data/Rakefile +8 -0
- data/app/assets/javascripts/releaf/controllers/base.js +0 -40
- data/app/assets/javascripts/releaf/include/field.type_date_or_datetime_or_time.js +43 -0
- data/app/assets/javascripts/releaf/include/nested_fields.js +58 -65
- data/app/assets/javascripts/releaf/include/sortable.js +19 -17
- data/app/assets/stylesheets/releaf/controllers/releaf/content.css.erb +6 -0
- data/app/assets/stylesheets/releaf/include/field.css.erb +37 -13
- data/app/controllers/releaf/admins_controller.rb +13 -6
- data/app/controllers/releaf/base_application_controller.rb +4 -1
- data/app/controllers/releaf/base_controller.rb +415 -154
- data/app/controllers/releaf/content_controller.rb +62 -45
- data/app/controllers/releaf/roles_controller.rb +11 -9
- data/app/controllers/releaf/sessions_controller.rb +23 -1
- data/app/controllers/releaf/translations_controller.rb +21 -25
- data/app/helpers/releaf/admin_helper.rb +0 -20
- data/app/models/releaf/admin.rb +9 -0
- data/app/models/releaf/blank_node_base.rb +29 -0
- data/app/models/releaf/node.rb +6 -5
- data/app/models/releaf/node_base.rb +9 -3
- data/app/models/releaf/role.rb +9 -2
- data/app/views/layouts/releaf/admin.html.haml +12 -6
- data/app/views/layouts/releaf/devise.html.haml +32 -0
- data/app/views/releaf/aliases/{_edit.body.haml → _edit.body.html.haml} +0 -0
- data/app/views/releaf/aliases/{_edit.header.haml → _edit.header.html.haml} +1 -1
- data/app/views/releaf/aliases/_index.row.html.haml +5 -0
- data/app/views/releaf/aliases/{_secondary_panel.haml → _secondary_panel.html.haml} +0 -0
- data/app/views/releaf/base/_edit.body.html.haml +11 -0
- data/app/views/releaf/base/_edit.field.html.haml +23 -0
- data/app/views/releaf/base/{_edit.field.type_autocomplete.haml → _edit.field_type_autocomplete.html.haml} +1 -1
- data/app/views/releaf/base/{_edit.field.type_checkbox.haml → _edit.field_type_boolean.html.haml} +1 -1
- data/app/views/releaf/base/{_edit.field.type_date.haml → _edit.field_type_date.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_datetime.haml → _edit.field_type_datetime.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_delete_nested.haml → _edit.field_type_delete_nested.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_file.haml → _edit.field_type_file.html.haml} +0 -0
- data/app/views/releaf/base/_edit.field_type_image.html.haml +12 -0
- data/app/views/releaf/base/_edit.field_type_item.html.haml +31 -0
- data/app/views/releaf/base/{_edit.field.type_link.haml → _edit.field_type_link.html.haml} +0 -0
- data/app/views/releaf/base/_edit.field_type_link_i18n.html.haml +26 -0
- data/app/views/releaf/base/{_edit.field.type_password.haml → _edit.field_type_password.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_richtext.haml → _edit.field_type_richtext.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_richtext_i18n.haml → _edit.field_type_richtext_i18n.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_text.haml → _edit.field_type_text.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_text_i18n.haml → _edit.field_type_text_i18n.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_textarea.haml → _edit.field_type_textarea.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_textarea_i18n.haml → _edit.field_type_textarea_i18n.html.haml} +0 -0
- data/app/views/releaf/base/{_edit.field.type_time.haml → _edit.field_type_time.html.haml} +0 -0
- data/app/views/releaf/base/_edit.fields.association.html.haml +48 -0
- data/app/views/releaf/base/_edit.fields.has_many_template.html.haml +15 -0
- data/app/views/releaf/base/_edit.fields.html.haml +20 -0
- data/app/views/releaf/base/{_edit.footer.haml → _edit.footer.html.haml} +2 -2
- data/app/views/releaf/base/_edit.form.html.haml +4 -0
- data/app/views/releaf/base/_edit.header.html.haml +3 -0
- data/app/views/releaf/base/{_index.body.haml → _index.body.html.haml} +2 -2
- data/app/views/releaf/base/_index.cell.html.haml +20 -0
- data/app/views/releaf/base/_index.footer.html.haml +28 -0
- data/app/views/releaf/base/_index.header.html.haml +4 -0
- data/app/views/releaf/base/_index.row.html.haml +6 -0
- data/app/views/releaf/base/_index.search.html.haml +5 -0
- data/app/views/releaf/base/_index.table.html.haml +24 -0
- data/app/views/releaf/base/_secondary_panel.html.haml +10 -0
- data/app/views/releaf/base/_show.body.html.haml +3 -0
- data/app/views/releaf/base/_show.field.html.haml +20 -0
- data/app/views/releaf/base/_show.field_type_date.html.haml +9 -0
- data/app/views/releaf/base/_show.field_type_date_time.html.haml +9 -0
- data/app/views/releaf/base/_show.field_type_email.html.haml +6 -0
- data/app/views/releaf/base/_show.field_type_file.html.haml +7 -0
- data/app/views/releaf/base/_show.field_type_image.html.haml +10 -0
- data/app/views/releaf/base/_show.field_type_item.html.haml +11 -0
- data/app/views/releaf/base/_show.field_type_link.html.haml +14 -0
- data/app/views/releaf/base/_show.field_type_password.html.haml +6 -0
- data/app/views/releaf/base/_show.field_type_richtext.html.haml +6 -0
- data/app/views/releaf/base/_show.field_type_text.html.haml +6 -0
- data/app/views/releaf/base/_show.field_type_textarea.html.haml +6 -0
- data/app/views/releaf/base/_show.field_type_time.html.haml +9 -0
- data/app/views/releaf/base/_show.field_type_url.html.haml +7 -0
- data/app/views/releaf/base/_show.fields.association.html.haml +36 -0
- data/app/views/releaf/base/_show.fields.has_many_template.html.haml +12 -0
- data/app/views/releaf/base/_show.fields.html.haml +17 -0
- data/app/views/releaf/base/{_show.footer.haml → _show.footer.html.haml} +6 -4
- data/app/views/releaf/base/_show.header.html.haml +3 -0
- data/app/views/releaf/base/confirm_destroy.html.haml +17 -0
- data/app/views/releaf/base/edit.html.haml +1 -0
- data/app/views/releaf/base/index.html.haml +3 -0
- data/app/views/releaf/base/new.html.haml +1 -0
- data/app/views/releaf/base/show.html.haml +3 -0
- data/app/views/releaf/content/{_edit.body.haml → _edit.body.html.haml} +7 -6
- data/app/views/releaf/content/_edit.content_fields.html.haml +11 -0
- data/app/views/releaf/content/_edit.fields.html.haml +17 -0
- data/app/views/releaf/content/{_edit.slug.haml → _edit.slug.html.haml} +0 -0
- data/app/views/releaf/content/{_get_content_form.haml → _get_content_form.html.haml} +2 -2
- data/app/views/releaf/content/{_secondary_panel.haml → _secondary_panel.html.haml} +0 -0
- data/app/views/releaf/content/{_tree_level.haml → _tree_level.html.haml} +0 -0
- data/app/views/releaf/content/{ajax.new.haml → ajax.new.html.haml} +0 -0
- data/app/views/releaf/content/{index.haml → index.html.haml} +0 -0
- data/app/views/releaf/roles/_edit.field.permissions.html.haml +5 -0
- data/app/views/releaf/roles/{_show.field.default.haml → _show.field.default.html.haml} +1 -1
- data/app/views/releaf/roles/{_show.field.permissions.haml → _show.field.permissions.html.haml} +2 -2
- data/app/views/releaf/translations/{_edit.body.haml → _edit.body.html.haml} +0 -0
- data/app/views/releaf/translations/{_edit.header.haml → _edit.header.html.haml} +1 -1
- data/app/views/releaf/translations/_index.row.html.haml +5 -0
- data/app/views/releaf/translations/{_secondary_panel.haml → _secondary_panel.html.haml} +0 -0
- data/lib/generators/releaf/templates/initializers/releaf.rb +0 -39
- data/lib/generators/releaf/templates/initializers/releaf_i18n.rb +17 -0
- data/lib/generators/releaf/templates/javascripts/3rd_party/jquery.jcarousel.js +1058 -0
- data/lib/generators/releaf/templates/javascripts/lib/init_jcarousel.js +40 -0
- data/lib/generators/releaf/templates/migrations/create_releaf_roles.rb +1 -0
- data/lib/generators/releaf/templates/migrations/create_releaf_tinymce_assets.rb +1 -0
- data/lib/generators/releaf/templates/models/admin_ability.rb +1 -1
- data/lib/i18n/backend/releaf.rb +5 -4
- data/lib/i18n/backend/releaf/translation.rb +5 -0
- data/lib/i18n/backend/releaf/translation_data.rb +7 -0
- data/lib/i18n/backend/releaf/translation_group.rb +4 -0
- data/lib/releaf.rb +4 -0
- data/lib/releaf/boolean_at.rb +77 -0
- data/lib/releaf/globalize3/fallbacks.rb +19 -0
- data/lib/releaf/resources.rb +101 -0
- data/lib/releaf/slug.rb +99 -60
- data/lib/releaf/version.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/templates/releaf/installer.rb +15 -4
- metadata +275 -329
- data/app/views/releaf/aliases/_index.row.haml +0 -5
- data/app/views/releaf/base/_edit.body.haml +0 -19
- data/app/views/releaf/base/_edit.field.haml +0 -96
- data/app/views/releaf/base/_edit.field.type_image.haml +0 -14
- data/app/views/releaf/base/_edit.field.type_select.haml +0 -11
- data/app/views/releaf/base/_edit.form.haml +0 -4
- data/app/views/releaf/base/_edit.has_many_associations.haml +0 -45
- data/app/views/releaf/base/_edit.header.haml +0 -3
- data/app/views/releaf/base/_index.cell.haml +0 -19
- data/app/views/releaf/base/_index.footer.haml +0 -22
- data/app/views/releaf/base/_index.header.haml +0 -4
- data/app/views/releaf/base/_index.row.haml +0 -6
- data/app/views/releaf/base/_index.search.haml +0 -5
- data/app/views/releaf/base/_index.table.haml +0 -8
- data/app/views/releaf/base/_secondary_panel.haml +0 -9
- data/app/views/releaf/base/_show.body.haml +0 -7
- data/app/views/releaf/base/_show.field.haml +0 -78
- data/app/views/releaf/base/_show.field.type_html.haml +0 -1
- data/app/views/releaf/base/_show.header.haml +0 -3
- data/app/views/releaf/base/confirm_destroy.haml +0 -10
- data/app/views/releaf/base/edit.haml +0 -1
- data/app/views/releaf/base/index.haml +0 -3
- data/app/views/releaf/base/new.haml +0 -1
- data/app/views/releaf/base/show.haml +0 -3
- data/app/views/releaf/content/_edit.content_fields.haml +0 -19
- data/app/views/releaf/content/_show.field.content.haml +0 -11
- data/app/views/releaf/roles/_edit.field.admins.haml +0 -0
- data/app/views/releaf/roles/_edit.field.permissions.haml +0 -5
- data/app/views/releaf/translations/_index.row.haml +0 -5
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/admin_ability.rb +0 -51
- data/spec/dummy/app/models/settings.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.haml +0 -10
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -68
- data/spec/dummy/config/boot.rb +0 -6
- data/spec/dummy/config/common_fields.yml.example +0 -17
- data/spec/dummy/config/database.yml +0 -42
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/devise.rb +0 -232
- data/spec/dummy/config/initializers/dragonfly.rb +0 -1
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/releaf.rb +0 -59
- data/spec/dummy/config/initializers/releaf_i18n.rb +0 -8
- data/spec/dummy/config/initializers/releaf_store_current_template.rb +0 -25
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/devise.en.yml +0 -58
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -11
- data/spec/dummy/db/migrate/20130204164516_create_settings.rb +0 -17
- data/spec/dummy/db/migrate/20130204164523_create_releaf_nodes.rb +0 -25
- data/spec/dummy/db/migrate/20130204164524_create_releaf_roles.rb +0 -11
- data/spec/dummy/db/migrate/20130204164525_create_releaf_translations.rb +0 -31
- data/spec/dummy/db/migrate/20130204164526_create_releaf_admins.rb +0 -53
- data/spec/dummy/db/schema.rb +0 -112
- data/spec/dummy/db/seeds.rb +0 -64
- data/spec/dummy/doc/README_FOR_APP +0 -2
- data/spec/dummy/log/development.log +0 -74
- data/spec/dummy/log/test.log +0 -129
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/tmp/cache/9C5/660/settings%3Ai18n_updated_at +0 -1
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
module Releaf
|
|
2
2
|
class ContentController < BaseController
|
|
3
|
+
helper_method :content_fields_to_display
|
|
3
4
|
|
|
4
|
-
def
|
|
5
|
-
if
|
|
6
|
-
|
|
5
|
+
def content_fields_to_display obj_class
|
|
6
|
+
if obj_class.respond_to? :releaf_fields_to_display
|
|
7
|
+
obj_class.releaf_fields_to_display params[:action]
|
|
7
8
|
else
|
|
8
|
-
|
|
9
|
+
obj_class.column_names - %w[id created_at updated_at position]
|
|
9
10
|
end
|
|
10
11
|
end
|
|
11
12
|
|
|
13
|
+
def fields_to_display
|
|
14
|
+
return super unless params[:action] == 'show'
|
|
15
|
+
return %w[name parent_id visible protected content]
|
|
16
|
+
end
|
|
17
|
+
|
|
12
18
|
def build_secondary_panel_variables
|
|
13
19
|
@nodes = Node.roots
|
|
14
20
|
super
|
|
@@ -24,12 +30,11 @@ module Releaf
|
|
|
24
30
|
def create
|
|
25
31
|
content_type = _node_params[:content_type].constantize
|
|
26
32
|
authorize! :create, content_type
|
|
27
|
-
@
|
|
28
|
-
@item.assign_attributes(_node_common_fields_params)
|
|
33
|
+
@resource = resource_class.new(_node_params)
|
|
29
34
|
|
|
30
35
|
respond_to do |format|
|
|
31
|
-
if @
|
|
32
|
-
format.html { redirect_to url_for(:action => "
|
|
36
|
+
if @resource.save
|
|
37
|
+
format.html { redirect_to url_for(:action => "edit", :controller => 'content', :id => @resource.id)}
|
|
33
38
|
else
|
|
34
39
|
form_extras
|
|
35
40
|
@order_nodes = Node.where(:parent_id => (params[:parent_id] ? params[:parent_id] : nil))
|
|
@@ -39,40 +44,39 @@ module Releaf
|
|
|
39
44
|
end
|
|
40
45
|
|
|
41
46
|
def generate_url
|
|
42
|
-
|
|
47
|
+
tmp_resource = nil
|
|
43
48
|
|
|
44
49
|
if params[:id]
|
|
45
|
-
|
|
50
|
+
tmp_resource = Node.find(params[:id])
|
|
46
51
|
elsif params[:parent_id].blank? == false
|
|
47
52
|
parent = Node.find(params[:parent_id])
|
|
48
|
-
|
|
53
|
+
tmp_resource = parent.children.new
|
|
49
54
|
else
|
|
50
|
-
|
|
55
|
+
tmp_resource = Node.new
|
|
51
56
|
end
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
tmp_resource.name = params[:name]
|
|
59
|
+
tmp_resource.slug = nil
|
|
55
60
|
# FIXME calling private method
|
|
56
|
-
|
|
61
|
+
tmp_resource.send(:ensure_unique_url)
|
|
57
62
|
|
|
58
63
|
respond_to do |format|
|
|
59
|
-
format.js { render :text =>
|
|
64
|
+
format.js { render :text => tmp_resource.slug }
|
|
60
65
|
end
|
|
61
66
|
end
|
|
62
67
|
|
|
63
68
|
def update
|
|
64
|
-
@
|
|
65
|
-
authorize! :edit, @
|
|
69
|
+
@resource = resource_class.find(params[:id])
|
|
70
|
+
authorize! :edit, @resource
|
|
66
71
|
|
|
67
72
|
form_extras
|
|
68
|
-
@order_nodes = Node.where(:parent_id => (@
|
|
73
|
+
@order_nodes = Node.where(:parent_id => (@resource.parent_id ? @resource.parent_id : nil)).where('id != :id', :id => params[:id])
|
|
69
74
|
|
|
70
|
-
@
|
|
71
|
-
@item.assign_attributes(_node_common_fields_params)
|
|
75
|
+
@resource.assign_attributes(_node_params)
|
|
72
76
|
|
|
73
77
|
|
|
74
78
|
respond_to do |format|
|
|
75
|
-
if @
|
|
79
|
+
if @resource.save
|
|
76
80
|
format.html { redirect_to url_for(:action => "edit") }
|
|
77
81
|
else
|
|
78
82
|
format.html { render action: "edit" }
|
|
@@ -81,12 +85,12 @@ module Releaf
|
|
|
81
85
|
end
|
|
82
86
|
|
|
83
87
|
def new
|
|
84
|
-
authorize! :create,
|
|
88
|
+
authorize! :create, resource_class
|
|
85
89
|
unless params[:ajax] == '1'
|
|
86
90
|
super
|
|
87
91
|
@order_nodes = Node.where(:parent_id => (params[:parent_id] ? params[:parent_id] : nil))
|
|
88
92
|
@position = 1
|
|
89
|
-
@
|
|
93
|
+
@resource.parent_id = params[:parent_id]
|
|
90
94
|
form_extras
|
|
91
95
|
else
|
|
92
96
|
Rails.application.eager_load!
|
|
@@ -97,10 +101,10 @@ module Releaf
|
|
|
97
101
|
|
|
98
102
|
def edit
|
|
99
103
|
super
|
|
100
|
-
@order_nodes = Node.where(:parent_id => (@
|
|
104
|
+
@order_nodes = Node.where(:parent_id => (@resource.parent_id ? @resource.parent_id : nil)).where('id != :id', :id => params[:id])
|
|
101
105
|
|
|
102
|
-
if @
|
|
103
|
-
@position = @
|
|
106
|
+
if @resource.higher_item
|
|
107
|
+
@position = @resource.position
|
|
104
108
|
else
|
|
105
109
|
@position = 1
|
|
106
110
|
end
|
|
@@ -108,13 +112,18 @@ module Releaf
|
|
|
108
112
|
form_extras
|
|
109
113
|
end
|
|
110
114
|
|
|
115
|
+
def setup
|
|
116
|
+
super
|
|
117
|
+
@features[:show] = false
|
|
118
|
+
end
|
|
119
|
+
|
|
111
120
|
def get_content_form
|
|
112
121
|
Rails.application.eager_load!
|
|
113
|
-
raise ArgumentError unless
|
|
114
|
-
@node =
|
|
115
|
-
authorize! :edit, @
|
|
122
|
+
raise ArgumentError unless content_type_class_names.include? params[:content_type]
|
|
123
|
+
@node = resource_class.find(params[:id])
|
|
124
|
+
authorize! :edit, @resource
|
|
116
125
|
|
|
117
|
-
@
|
|
126
|
+
@resource = params[:content_type].constantize.new
|
|
118
127
|
|
|
119
128
|
respond_to do |format|
|
|
120
129
|
format.html { render :partial => 'get_content_form', :layout => false }
|
|
@@ -122,25 +131,26 @@ module Releaf
|
|
|
122
131
|
|
|
123
132
|
end
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
def current_object_class
|
|
134
|
+
def resource_class
|
|
127
135
|
Node
|
|
128
136
|
end
|
|
129
137
|
|
|
130
138
|
protected
|
|
131
139
|
|
|
132
|
-
def _node_common_fields_params
|
|
133
|
-
allowed_params = (@item.common_field_names).map { |f| f.sub(/_uid$/, '') }
|
|
134
|
-
params.require(current_object_class_name).permit(*allowed_params)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
140
|
def _node_params
|
|
138
|
-
|
|
139
|
-
params.require(current_object_class_name).permit(*allowed_params)
|
|
141
|
+
params.require(:resource).permit!
|
|
140
142
|
end
|
|
141
143
|
|
|
142
144
|
private
|
|
143
145
|
|
|
146
|
+
def content_type_class_names
|
|
147
|
+
content_type_classes.map { |nc| nc.name }.sort
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def content_type_classes
|
|
151
|
+
NodeBase.node_classes + BlankNodeBase.node_classes
|
|
152
|
+
end
|
|
153
|
+
|
|
144
154
|
def form_extras
|
|
145
155
|
Rails.application.eager_load!
|
|
146
156
|
get_base_models
|
|
@@ -148,18 +158,25 @@ module Releaf
|
|
|
148
158
|
new_content_if_needed
|
|
149
159
|
end
|
|
150
160
|
|
|
151
|
-
def
|
|
152
|
-
# make sure none of actions, that are defined by BaseController can update item
|
|
161
|
+
def resource_params
|
|
153
162
|
[]
|
|
154
163
|
end
|
|
155
164
|
|
|
156
165
|
def new_content_if_needed
|
|
157
|
-
return if @
|
|
158
|
-
|
|
166
|
+
return if @resource.content
|
|
167
|
+
if params[:content_type]
|
|
168
|
+
if get_base_models.map { |bm| bm.name }.include? params[:content_type]
|
|
169
|
+
@resource.content_type = params[:content_type]
|
|
170
|
+
content_class = @resource.content_type.constantize
|
|
171
|
+
if content_class.node_type == 'Releaf::NodeBase'
|
|
172
|
+
@resource.content = @resource.content_type.constantize.new
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
159
176
|
end
|
|
160
177
|
|
|
161
178
|
def get_base_models
|
|
162
|
-
@base_models ||=
|
|
179
|
+
@base_models ||= content_type_classes
|
|
163
180
|
end
|
|
164
181
|
|
|
165
182
|
end
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
module Releaf
|
|
2
2
|
class RolesController < BaseController
|
|
3
3
|
|
|
4
|
-
def
|
|
4
|
+
def resource_class
|
|
5
5
|
Releaf::Role
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
def fields_to_display
|
|
9
|
+
case params[:action].to_sym
|
|
10
|
+
when :index
|
|
11
|
+
%w[name default_controller default]
|
|
12
|
+
when :create, :edit, :new, :update, :show
|
|
13
|
+
%w[name default default_controller permissions]
|
|
12
14
|
else
|
|
13
|
-
|
|
15
|
+
[]
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
protected
|
|
18
20
|
|
|
19
|
-
def
|
|
20
|
-
return [] unless [
|
|
21
|
+
def resource_params
|
|
22
|
+
return [] unless %w[update create].include? params[:action]
|
|
21
23
|
|
|
22
|
-
fields = ['name', 'default']
|
|
24
|
+
fields = ['name', 'default', 'default_controller']
|
|
23
25
|
AdminAbility::PERMISSIONS.each do |permission|
|
|
24
26
|
if permission.is_a? String
|
|
25
27
|
fields.push "#{permission}_permission"
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
module Releaf
|
|
2
2
|
class SessionsController < Devise::SessionsController
|
|
3
|
-
layout "releaf/
|
|
3
|
+
layout "releaf/devise"
|
|
4
|
+
|
|
5
|
+
def after_sign_in_path_for(resource)
|
|
6
|
+
controller_name = resource.role.default_controller
|
|
7
|
+
|
|
8
|
+
if controller_name
|
|
9
|
+
if controller_name == 'content'
|
|
10
|
+
default_path = releaf_nodes_path
|
|
11
|
+
elsif controller_name == 'translations'
|
|
12
|
+
default_path = releaf_translation_groups_path
|
|
13
|
+
else
|
|
14
|
+
default_path = send("admin_#{controller_name}_path")
|
|
15
|
+
end
|
|
16
|
+
else
|
|
17
|
+
default_path = releaf_nodes_path
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
return default_path
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def full_controller_name
|
|
24
|
+
self.class.name.sub(/Controller$/, '').underscore
|
|
25
|
+
end
|
|
4
26
|
end
|
|
5
27
|
end
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
module Releaf
|
|
2
2
|
class TranslationsController < BaseController
|
|
3
3
|
|
|
4
|
-
def
|
|
5
|
-
super
|
|
6
|
-
@object_class = I18n::Backend::Releaf::TranslationGroup
|
|
7
|
-
@features[:show] = false
|
|
8
|
-
@continuous_scroll = true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def current_object_class
|
|
4
|
+
def resource_class
|
|
12
5
|
@object_class
|
|
13
6
|
end
|
|
14
7
|
|
|
@@ -23,7 +16,7 @@ module Releaf
|
|
|
23
16
|
|
|
24
17
|
def index
|
|
25
18
|
authorize! :manage, I18n::Backend::Releaf::Translation
|
|
26
|
-
@
|
|
19
|
+
@resources = @object_class = I18n::Backend::Releaf::Translation.includes(:translation_data).filter(:search => params[:search])
|
|
27
20
|
if !params[:ajax].blank?
|
|
28
21
|
render :layout => false
|
|
29
22
|
end
|
|
@@ -31,23 +24,18 @@ module Releaf
|
|
|
31
24
|
|
|
32
25
|
def edit
|
|
33
26
|
authorize! :manage, I18n::Backend::Releaf::Translation
|
|
34
|
-
@
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def show
|
|
38
|
-
authorize! :manage, I18n::Backend::Releaf::Translation
|
|
39
|
-
redirect_to url_for( :action => "edit", :id => params[:id] )
|
|
27
|
+
@resource = resource_class.find(params[:id])
|
|
40
28
|
end
|
|
41
29
|
|
|
42
30
|
def create
|
|
43
31
|
authorize! :manage, I18n::Backend::Releaf::Translation
|
|
44
|
-
@
|
|
32
|
+
@resource = resource_class.new(resource_params)
|
|
45
33
|
|
|
46
34
|
respond_to do |format|
|
|
47
|
-
if @
|
|
35
|
+
if @resource.save
|
|
48
36
|
update_translations
|
|
49
37
|
Settings.i18n_updated_at = Time.now
|
|
50
|
-
format.html { redirect_to url_for(:action => "edit", :id => @
|
|
38
|
+
format.html { redirect_to url_for(:action => "edit", :id => @resource.id) }
|
|
51
39
|
else
|
|
52
40
|
format.html { render :action => "new" }
|
|
53
41
|
end
|
|
@@ -56,22 +44,30 @@ module Releaf
|
|
|
56
44
|
|
|
57
45
|
def update
|
|
58
46
|
authorize! :manage, I18n::Backend::Releaf::Translation
|
|
59
|
-
@
|
|
47
|
+
@resource = resource_class.find(params[:id])
|
|
60
48
|
|
|
61
49
|
unless params[:translations].blank?
|
|
62
50
|
ids_to_keep = update_translations
|
|
63
|
-
@
|
|
51
|
+
@resource.translations.where('id NOT IN (?)', ids_to_keep).destroy_all
|
|
64
52
|
else
|
|
65
|
-
@
|
|
53
|
+
@resource.translations.destroy_all
|
|
66
54
|
end
|
|
67
55
|
Settings.i18n_updated_at = Time.now
|
|
68
56
|
|
|
69
57
|
|
|
70
58
|
respond_to do |format|
|
|
71
|
-
format.html { redirect_to url_for(:action => "edit", :id => @
|
|
59
|
+
format.html { redirect_to url_for(:action => "edit", :id => @resource.id) }
|
|
72
60
|
end
|
|
73
61
|
end
|
|
74
62
|
|
|
63
|
+
protected
|
|
64
|
+
|
|
65
|
+
def setup
|
|
66
|
+
super
|
|
67
|
+
@object_class = I18n::Backend::Releaf::TranslationGroup
|
|
68
|
+
@features[:show] = false
|
|
69
|
+
@continuous_scroll = true
|
|
70
|
+
end
|
|
75
71
|
|
|
76
72
|
private
|
|
77
73
|
|
|
@@ -86,7 +82,7 @@ module Releaf
|
|
|
86
82
|
if id =~ /\A\d+\z/
|
|
87
83
|
translation = I18n::Backend::Releaf::Translation.find(id)
|
|
88
84
|
else
|
|
89
|
-
translation = @
|
|
85
|
+
translation = @resource.translations.new
|
|
90
86
|
end
|
|
91
87
|
|
|
92
88
|
translation.key = params[:translation_group][:scope] + '.' + t['key']
|
|
@@ -113,8 +109,8 @@ module Releaf
|
|
|
113
109
|
return ids_to_keep
|
|
114
110
|
end
|
|
115
111
|
|
|
116
|
-
def
|
|
117
|
-
params.require(
|
|
112
|
+
def resource_params
|
|
113
|
+
params.require(:resource).permit(:scope)
|
|
118
114
|
end
|
|
119
115
|
|
|
120
116
|
end
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
module Releaf
|
|
2
2
|
module AdminHelper
|
|
3
3
|
|
|
4
|
-
def polymorphic_association_names obj
|
|
5
|
-
poly_asoc = obj.class.reflect_on_all_associations.map { |r| r.options[:polymorphic] ? r.name : nil }
|
|
6
|
-
poly_asoc.delete(nil)
|
|
7
|
-
poly_asoc.map { |pa| pa.to_s }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def has_many_association_names obj
|
|
11
|
-
reflect_all_asoc = obj.reflect_on_all_associations(:has_many)
|
|
12
|
-
has_many_asoc_names = reflect_all_asoc.map { |asoc| asoc.name }
|
|
13
|
-
|
|
14
|
-
reflect_all_asoc.each do |asoc|
|
|
15
|
-
next unless asoc.options.has_key?(:through)
|
|
16
|
-
has_many_asoc_names.delete(asoc.name)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# don't show translations associaton which is created by globalize3
|
|
20
|
-
has_many_asoc_names - [:translations]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
4
|
def is_this_main_menu_item_active? releaf_main_menu_item
|
|
25
5
|
_check_if_this_is_valid_releaf_main_menu_item releaf_main_menu_item
|
|
26
6
|
|
data/app/models/releaf/admin.rb
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Releaf
|
|
2
|
+
class BlankNodeBase
|
|
3
|
+
# returns only bottom level, not /^Releaf::/ subclasses
|
|
4
|
+
def self.node_classes
|
|
5
|
+
return _node_classes(self).reject { |n| n.name =~ /^Releaf::/ }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.releaf_fields_to_display action
|
|
9
|
+
[]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.node_type
|
|
13
|
+
"Releaf::BlankNodeBase"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def self._node_classes(klass)
|
|
19
|
+
classes = [klass]
|
|
20
|
+
|
|
21
|
+
klass.subclasses.each do |sublcass|
|
|
22
|
+
classes += _node_classes(sublcass)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
return classes
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|