releaf-core 3.1.0 → 4.0.0
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/app/assets/javascripts/releaf/include/field.type_richtext.js +2 -18
- data/app/assets/javascripts/releaf/include/remote_validator.js +2 -12
- data/app/assets/stylesheets/releaf/environment/mixins/blocks.scss +1 -1
- data/app/assets/stylesheets/releaf/layout/fields.scss +1 -2
- data/app/assets/stylesheets/releaf/layout.scss +0 -1
- data/app/builders/releaf/builders/form_builder/fields.rb +0 -1
- data/app/builders/releaf/builders/form_builder/richtext_fields.rb +1 -3
- data/app/builders/releaf/builders/utilities/resolve_attribute_field_method_name.rb +2 -7
- data/app/controllers/releaf/action_controller.rb +0 -1
- data/app/lib/releaf/default_searchable_fields.rb +1 -12
- data/app/lib/releaf/resource_base.rb +1 -9
- data/app/lib/releaf/resource_params.rb +0 -12
- data/app/lib/releaf/resource_table_fields.rb +1 -1
- data/app/lib/releaf/search.rb +0 -5
- data/lib/generators/dummy/templates/config/routes.rb +0 -37
- data/lib/generators/dummy/templates/initializers/releaf.rb +1 -26
- data/lib/generators/dummy/templates/migrations/create_books.rb +1 -2
- data/lib/generators/dummy/templates/models/book.rb +0 -3
- data/lib/generators/releaf/templates/initializers/releaf.rb +1 -3
- data/lib/generators/releaf/templates/seeds/seeds.rb +0 -10
- data/lib/releaf/humanize_missing_translations.rb +13 -0
- data/lib/releaf/route_mapper.rb +0 -3
- data/lib/releaf-core.rb +2 -3
- metadata +4 -63
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/icons/hidpi/mediaembed.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/icons/mediaembed.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/lang/en.js +0 -12
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/lang/es.js +0 -12
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/plugin.js +0 -63
- data/app/assets/javascripts/releaf/include/localization.js +0 -208
- data/app/assets/stylesheets/releaf/layout/localization.scss +0 -79
- data/app/builders/releaf/builders/form_builder/i18n_fields.rb +0 -75
- data/app/lib/releaf/action_controller/richtext_attachments.rb +0 -20
- data/app/models/releaf/richtext_attachment.rb +0 -6
- data/lib/generators/dummy/templates/assets/javascripts/controllers/admin/nodes.js +0 -1
- data/lib/generators/dummy/templates/assets/javascripts/controllers/admin/other_site/other_nodes.js +0 -1
- data/lib/generators/dummy/templates/assets/stylesheets/controllers/admin/nodes.scss +0 -1
- data/lib/generators/dummy/templates/assets/stylesheets/controllers/admin/other_site/other_nodes.scss +0 -1
- data/lib/generators/dummy/templates/builders/admin/nodes/form_builder.rb +0 -7
- data/lib/generators/dummy/templates/controllers/admin/nodes_controller.rb +0 -3
- data/lib/generators/dummy/templates/controllers/admin/other_site/other_nodes_controller.rb +0 -3
- data/lib/generators/dummy/templates/controllers/application_controller.rb +0 -61
- data/lib/generators/dummy/templates/controllers/concerns/node_controller.rb +0 -47
- data/lib/generators/dummy/templates/controllers/contacts_controller.rb +0 -5
- data/lib/generators/dummy/templates/controllers/home_pages_controller.rb +0 -3
- data/lib/generators/dummy/templates/controllers/text_pages_controller.rb +0 -3
- data/lib/generators/dummy/templates/migrations/create_banner_pages.rb +0 -11
- data/lib/generators/dummy/templates/migrations/create_bundles.rb +0 -7
- data/lib/generators/dummy/templates/migrations/create_home_pages.rb +0 -9
- data/lib/generators/dummy/templates/migrations/create_node_extra_fields.rb +0 -5
- data/lib/generators/dummy/templates/migrations/create_other_nodes.rb +0 -29
- data/lib/generators/dummy/templates/migrations/create_text_pages.rb +0 -9
- data/lib/generators/dummy/templates/models/banner_page.rb +0 -7
- data/lib/generators/dummy/templates/models/bundle.rb +0 -17
- data/lib/generators/dummy/templates/models/home_page.rb +0 -3
- data/lib/generators/dummy/templates/models/node.rb +0 -10
- data/lib/generators/dummy/templates/models/other_site/other_node.rb +0 -7
- data/lib/generators/dummy/templates/models/text_page.rb +0 -4
- data/lib/generators/dummy/templates/views/contacts/show.html.haml +0 -1
- data/lib/generators/dummy/templates/views/home_pages/show.haml +0 -1
- data/lib/generators/dummy/templates/views/layouts/application.html.haml +0 -30
- data/lib/generators/dummy/templates/views/text_pages/show.haml +0 -1
- data/lib/generators/releaf/templates/migrations/create_releaf_nodes.rb +0 -28
- data/lib/generators/releaf/templates/migrations/create_releaf_richtext_attachments.rb +0 -12
- data/lib/generators/releaf/templates/migrations/create_releaf_translations.rb +0 -20
- data/lib/generators/releaf/templates/models/node.rb +0 -3
- data/lib/releaf/rails_ext/globalize-accessors.rb +0 -64
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Fabian Vogelsteller [frozeman.de]
|
|
3
|
-
* @copyright Copyright (c) 2013 - Önder Ceylan. All rights reserved.
|
|
4
|
-
* @version 0.6
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// set CKeditor lang
|
|
8
|
-
CKEDITOR.plugins.setLang( 'mediaembed', 'en', {
|
|
9
|
-
toolbar: 'Embed Media',
|
|
10
|
-
dialogTitle : 'Embed Media',
|
|
11
|
-
dialogLabel : 'Paste Embed Code Here'
|
|
12
|
-
} );
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Alejandro Vasquez [neurotools.cl]
|
|
3
|
-
* @copyright Copyright (c) 2013 - Önder Ceylan. All rights reserved.
|
|
4
|
-
* @version 0.6
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// set CKeditor lang
|
|
8
|
-
CKEDITOR.plugins.setLang( 'mediaembed', 'es', {
|
|
9
|
-
toolbar: 'Incrustar Medios',
|
|
10
|
-
dialogTitle : 'Incrustar Medios',
|
|
11
|
-
dialogLabel : 'Pegue el código de incrustación aquí'
|
|
12
|
-
} );
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Embed Media Dialog based on http://www.fluidbyte.net/embed-youtube-vimeo-etc-into-ckeditor
|
|
3
|
-
*
|
|
4
|
-
* Plugin name: mediaembed
|
|
5
|
-
* Menu button name: MediaEmbed
|
|
6
|
-
*
|
|
7
|
-
* Youtube Editor Icon
|
|
8
|
-
* http://paulrobertlloyd.com/
|
|
9
|
-
*
|
|
10
|
-
* @author Fabian Vogelsteller [frozeman.de]
|
|
11
|
-
* @version 0.6
|
|
12
|
-
*/
|
|
13
|
-
CKEDITOR.plugins.add( 'mediaembed',
|
|
14
|
-
{
|
|
15
|
-
icons: 'mediaembed', // %REMOVE_LINE_CORE%
|
|
16
|
-
hidpi: true, // %REMOVE_LINE_CORE%
|
|
17
|
-
lang: 'en,es',
|
|
18
|
-
init: function( editor )
|
|
19
|
-
{
|
|
20
|
-
var me = this;
|
|
21
|
-
CKEDITOR.dialog.add( 'MediaEmbedDialog', function (instance)
|
|
22
|
-
{
|
|
23
|
-
return {
|
|
24
|
-
title : editor.lang.mediaembed.dialogTitle,
|
|
25
|
-
minWidth : 550,
|
|
26
|
-
minHeight : 200,
|
|
27
|
-
contents :
|
|
28
|
-
[
|
|
29
|
-
{
|
|
30
|
-
id : 'iframe',
|
|
31
|
-
expand : true,
|
|
32
|
-
elements :[{
|
|
33
|
-
id : 'embedArea',
|
|
34
|
-
type : 'textarea',
|
|
35
|
-
label : editor.lang.mediaembed.dialogLabel,
|
|
36
|
-
'autofocus':'autofocus',
|
|
37
|
-
setup: function(element){
|
|
38
|
-
},
|
|
39
|
-
commit: function(element){
|
|
40
|
-
}
|
|
41
|
-
}]
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
onOk: function() {
|
|
45
|
-
var div = instance.document.createElement('div');
|
|
46
|
-
div.setHtml(this.getContentElement('iframe', 'embedArea').getValue());
|
|
47
|
-
instance.insertElement(div);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
editor.addCommand( 'MediaEmbed', new CKEDITOR.dialogCommand( 'MediaEmbedDialog',
|
|
53
|
-
{ allowedContent: 'iframe[*]' }
|
|
54
|
-
) );
|
|
55
|
-
|
|
56
|
-
editor.ui.addButton( 'MediaEmbed',
|
|
57
|
-
{
|
|
58
|
-
label: editor.lang.mediaembed.toolbar,
|
|
59
|
-
command: 'MediaEmbed',
|
|
60
|
-
toolbar: 'mediaembed'
|
|
61
|
-
} );
|
|
62
|
-
}
|
|
63
|
-
} );
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
jQuery(function()
|
|
2
|
-
{
|
|
3
|
-
var body = jQuery('body');
|
|
4
|
-
|
|
5
|
-
var overlay = jQuery('<div />').addClass('localization-menu-overlay').appendTo(body);
|
|
6
|
-
overlay.bind('click', function()
|
|
7
|
-
{
|
|
8
|
-
body.trigger('localizationmenucloseall');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
body.bind('localizationinit', function(e)
|
|
12
|
-
{
|
|
13
|
-
var block = jQuery(e.target);
|
|
14
|
-
|
|
15
|
-
e.stopPropagation();
|
|
16
|
-
|
|
17
|
-
var fields;
|
|
18
|
-
if (block.is('.field.i18n'))
|
|
19
|
-
{
|
|
20
|
-
fields = block;
|
|
21
|
-
}
|
|
22
|
-
else
|
|
23
|
-
{
|
|
24
|
-
fields = block.find('.field.i18n');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (fields.length < 1)
|
|
28
|
-
{
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fields.bind('localizationmenuopen', function()
|
|
33
|
-
{
|
|
34
|
-
var field = jQuery(this);
|
|
35
|
-
|
|
36
|
-
// close all other open menus
|
|
37
|
-
body.trigger('localizationmenucloseall');
|
|
38
|
-
|
|
39
|
-
var menu = field.data('localization-menu');
|
|
40
|
-
|
|
41
|
-
field.attr('data-localization-menu-open', true);
|
|
42
|
-
|
|
43
|
-
menu.appendTo( body );
|
|
44
|
-
|
|
45
|
-
field.trigger('localizationmenuposition');
|
|
46
|
-
|
|
47
|
-
overlay.show();
|
|
48
|
-
|
|
49
|
-
menu.show();
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
fields.bind('localizationmenuclose', function()
|
|
55
|
-
{
|
|
56
|
-
var field = jQuery(this);
|
|
57
|
-
|
|
58
|
-
var menu = field.data('localization-menu');
|
|
59
|
-
|
|
60
|
-
var localization_switch = field.data('localization-switch');
|
|
61
|
-
|
|
62
|
-
menu.hide().appendTo( localization_switch );
|
|
63
|
-
|
|
64
|
-
overlay.hide();
|
|
65
|
-
|
|
66
|
-
field.removeAttr('data-localization-menu-open');
|
|
67
|
-
|
|
68
|
-
return;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
fields.bind('localizationmenutoggle', function()
|
|
72
|
-
{
|
|
73
|
-
var field = jQuery(this);
|
|
74
|
-
var event = (field.attr('data-localization-menu-open')) ? 'localizationmenuclose' : 'localizationmenuopen';
|
|
75
|
-
field.trigger( event );
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
fields.bind('localizationmenuposition', function()
|
|
79
|
-
{
|
|
80
|
-
var field = jQuery(this);
|
|
81
|
-
if (!field.attr('data-localization-menu-open'))
|
|
82
|
-
{
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
var menu = field.data('localization-menu');
|
|
87
|
-
|
|
88
|
-
var trigger = field.data('localization-switch-trigger');
|
|
89
|
-
|
|
90
|
-
var triggerOffset = trigger.offset();
|
|
91
|
-
|
|
92
|
-
menu.css({
|
|
93
|
-
left: triggerOffset.left + trigger.outerWidth() - menu.outerWidth() ,
|
|
94
|
-
top : triggerOffset.top + trigger.outerHeight()
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
fields.find('.localization-switch .trigger').click(function()
|
|
100
|
-
{
|
|
101
|
-
jQuery(this).closest('.field.i18n').trigger('localizationmenutoggle');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
fields.find('.localization-menu-items button').click(function()
|
|
106
|
-
{
|
|
107
|
-
var button = jQuery(this);
|
|
108
|
-
var locale = button.attr('data-locale');
|
|
109
|
-
var menu = button.closest('.localization-menu-items');
|
|
110
|
-
var field = menu.data('field');
|
|
111
|
-
var localization_box = field.find('.localization[data-locale="' + locale + '"]');
|
|
112
|
-
|
|
113
|
-
body.trigger('localizationmenucloseall');
|
|
114
|
-
|
|
115
|
-
localization_box.trigger('localizationlocaleactivate');
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
fields.bind('localizationlocaleset', function( e, params )
|
|
121
|
-
{
|
|
122
|
-
var field = jQuery(this);
|
|
123
|
-
|
|
124
|
-
var locale = params.locale;
|
|
125
|
-
|
|
126
|
-
var localization_boxes = field.find('.localization[data-locale]');
|
|
127
|
-
|
|
128
|
-
var target_box = localization_boxes.filter('[data-locale="' + locale + '"]');
|
|
129
|
-
var other_boxes = localization_boxes.not( target_box );
|
|
130
|
-
|
|
131
|
-
target_box.addClass('active');
|
|
132
|
-
other_boxes.removeClass('active');
|
|
133
|
-
|
|
134
|
-
var trigger_label = field.find('.localization-switch .trigger .label');
|
|
135
|
-
|
|
136
|
-
trigger_label.text( locale );
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
fields.find('.localization').bind('localizationlocaleactivate', function()
|
|
141
|
-
{
|
|
142
|
-
var localization_box = jQuery(this);
|
|
143
|
-
var locale = localization_box.attr('data-locale');
|
|
144
|
-
|
|
145
|
-
var form = localization_box.closest('form');
|
|
146
|
-
|
|
147
|
-
form.find('.field.i18n').trigger('localizationlocaleset', { locale : locale });
|
|
148
|
-
|
|
149
|
-
body.trigger( 'settingssave', [ "releaf.i18n.locale", locale ] );
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var input_selector = 'input[type!="hidden"],textarea,select';
|
|
154
|
-
fields.find(input_selector).bind('focusprepare', function(e)
|
|
155
|
-
{
|
|
156
|
-
var localization_box = (jQuery(e.target).closest('.localization'));
|
|
157
|
-
if (localization_box.length < 1)
|
|
158
|
-
{
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// focus target is inside a i18n localization box
|
|
163
|
-
if (!localization_box.is('.active'))
|
|
164
|
-
{
|
|
165
|
-
localization_box.trigger('localizationlocaleactivate');
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
fields.each(function()
|
|
171
|
-
{
|
|
172
|
-
var field = jQuery(this);
|
|
173
|
-
|
|
174
|
-
var localization_switch = field.find('.localization-switch').first();
|
|
175
|
-
|
|
176
|
-
field.data('localization-switch', localization_switch );
|
|
177
|
-
|
|
178
|
-
field.data('localization-switch-trigger', localization_switch.find('.trigger').first() );
|
|
179
|
-
|
|
180
|
-
var menu = localization_switch.find('menu').first();
|
|
181
|
-
|
|
182
|
-
field.data('localization-menu', menu);
|
|
183
|
-
|
|
184
|
-
menu.data('field', field);
|
|
185
|
-
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
body.bind('localizationmenucloseall', function()
|
|
192
|
-
{
|
|
193
|
-
body.find('.field.i18n[data-localization-menu-open]').trigger('localizationmenuclose');
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// attach localizationinit to all loaded content
|
|
199
|
-
body.on('contentloaded', function(e)
|
|
200
|
-
{
|
|
201
|
-
// reinit localization for all content that gets replaced via ajax
|
|
202
|
-
jQuery(e.target).trigger('localizationinit');
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
.localization:not(.active)
|
|
2
|
-
{
|
|
3
|
-
display: none;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.localization-switch
|
|
7
|
-
{
|
|
8
|
-
position: absolute;
|
|
9
|
-
right: 0;
|
|
10
|
-
top: steps(1);
|
|
11
|
-
|
|
12
|
-
.trigger
|
|
13
|
-
{
|
|
14
|
-
display: inline-block;
|
|
15
|
-
padding: 0 steps(1);
|
|
16
|
-
border: 1px solid $color-border-normal;
|
|
17
|
-
background: $color-background-lighter;
|
|
18
|
-
color: $color-text-normal;
|
|
19
|
-
text-transform: uppercase;
|
|
20
|
-
|
|
21
|
-
&:hover
|
|
22
|
-
{
|
|
23
|
-
border-color: $color-border-darker;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&:focus,
|
|
27
|
-
&:active
|
|
28
|
-
{
|
|
29
|
-
background-color: $color-background-darkest;
|
|
30
|
-
border-color: $color-background-darkest;
|
|
31
|
-
color: $color-text-normal;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.fa
|
|
35
|
-
{
|
|
36
|
-
@include icon-small;
|
|
37
|
-
color: $color-highlight-darkest;
|
|
38
|
-
margin-left: steps(1);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.localization-menu-items
|
|
50
|
-
{
|
|
51
|
-
@include pop-up-menu;
|
|
52
|
-
|
|
53
|
-
border: 1px solid $color-border-normal;
|
|
54
|
-
box-shadow: 0 0 2px 2px $color-shadow-lightest;
|
|
55
|
-
|
|
56
|
-
button
|
|
57
|
-
{
|
|
58
|
-
background: $color-background-lightest;
|
|
59
|
-
|
|
60
|
-
text-transform: uppercase;
|
|
61
|
-
padding: steps(0.5) steps(2);
|
|
62
|
-
|
|
63
|
-
&:hover,
|
|
64
|
-
&:focus
|
|
65
|
-
{
|
|
66
|
-
background: $color-background-normal;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.localization-menu-overlay
|
|
73
|
-
{
|
|
74
|
-
@include full-screen-overlay;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
module Releaf::Builders::FormBuilder::I18nFields
|
|
2
|
-
def releaf_text_i18n_field(name, input: {}, label: {}, field: {}, options: {})
|
|
3
|
-
options = {field: {type: "text"}}.deep_merge(options)
|
|
4
|
-
input = {class: "text"}.deep_merge(input)
|
|
5
|
-
localized_field(name, :text_field, input: input, label: label, field: field, options: options)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def releaf_link_i18n_field(name, input: {}, label: {}, field: {}, options: {})
|
|
9
|
-
options = {field: {type: "link"}}.deep_merge(options)
|
|
10
|
-
releaf_text_i18n_field(name, input: input, label: label, field: field, options: options)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def releaf_textarea_i18n_field(name, input: {}, label: {}, field: {}, options: {})
|
|
14
|
-
input = {
|
|
15
|
-
rows: 5,
|
|
16
|
-
cols: 75,
|
|
17
|
-
}.merge(input)
|
|
18
|
-
options = {field: {type: "textarea"}}.deep_merge(options)
|
|
19
|
-
localized_field(name, :text_area, input: input, label: label, field: field, options: options)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def releaf_richtext_i18n_field(name, input: {}, label: {}, field: {}, options: {})
|
|
23
|
-
input = richtext_input_attributes(name).merge(input)
|
|
24
|
-
options = richtext_options(name, options)
|
|
25
|
-
releaf_textarea_i18n_field(name, input: input, label: label, field: field, options: options)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def localized_field(name, field_type, input: {}, label: {}, field: {}, options: {})
|
|
29
|
-
options = {i18n: true, label: {translation_key: name}}.deep_merge(options)
|
|
30
|
-
|
|
31
|
-
wrapper(field_attributes(name, field, options)) do
|
|
32
|
-
content = object.class.globalize_locales.collect do |locale|
|
|
33
|
-
localized_name = "#{name}_#{locale}"
|
|
34
|
-
html_class = ["localization"]
|
|
35
|
-
html_class << "active" if locale == default_locale
|
|
36
|
-
|
|
37
|
-
tag(:div, class: html_class, data: {locale: locale}) do
|
|
38
|
-
releaf_label(localized_name, label, options) <<
|
|
39
|
-
tag(:div, class: "value") do
|
|
40
|
-
attributes = input_attributes(name, {value: object.send(localized_name)}.merge(input), options)
|
|
41
|
-
send(field_type, localized_name, attributes)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
content << localization_switch
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def localization_switch
|
|
51
|
-
tag(:div, class: "localization-switch") do
|
|
52
|
-
button_tag(type: 'button', title: t('Switch locale'), class: "trigger") do
|
|
53
|
-
tag(:span, default_locale, class: "label") + tag(:i, nil, class: ["fa", "fa-chevron-down"])
|
|
54
|
-
end <<
|
|
55
|
-
tag(:menu, class: ["localization-menu-items"], type: 'toolbar') do
|
|
56
|
-
tag(:ul) do
|
|
57
|
-
object.class.globalize_locales.collect do |locale|
|
|
58
|
-
tag(:li) do
|
|
59
|
-
tag(:button, translate_locale(locale), type: "button", data: {locale: locale})
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def locales
|
|
68
|
-
object.class.globalize_locales
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def default_locale
|
|
72
|
-
selected_locale = (layout_settings("releaf.i18n.locale") || I18n.locale).to_sym
|
|
73
|
-
locales.include?(selected_locale) ? selected_locale : locales.first
|
|
74
|
-
end
|
|
75
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Releaf::ActionController::RichtextAttachments
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
skip_before_action :verify_authenticity_token, only: [:create_releaf_richtext_attachment]
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def releaf_richtext_attachment_upload_url
|
|
9
|
-
begin
|
|
10
|
-
url_for(action: :create_releaf_richtext_attachment)
|
|
11
|
-
rescue ::ActionController::UrlGenerationError
|
|
12
|
-
nil
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def create_releaf_richtext_attachment
|
|
17
|
-
return unless params[:upload]
|
|
18
|
-
@resource = Releaf::RichtextAttachment.create!(file_type: params[:upload].content_type, file: params[:upload])
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//= require controllers/releaf/content/nodes
|
data/lib/generators/dummy/templates/assets/javascripts/controllers/admin/other_site/other_nodes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//= require controllers/releaf/content/nodes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import 'controllers/releaf/content/nodes';
|
data/lib/generators/dummy/templates/assets/stylesheets/controllers/admin/other_site/other_nodes.scss
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import 'controllers/releaf/content/nodes';
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
class ApplicationController < ActionController::Base
|
|
2
|
-
class PageNotFound < StandardError; end
|
|
3
|
-
rescue_from ActionController::RoutingError, with: :render_404
|
|
4
|
-
rescue_from ActiveRecord::RecordNotFound, with: :render_404
|
|
5
|
-
|
|
6
|
-
protect_from_forgery with: :exception
|
|
7
|
-
before_action :set_locale
|
|
8
|
-
layout "application"
|
|
9
|
-
helper_method :translation_scope, :node_class, :site
|
|
10
|
-
|
|
11
|
-
def render_404
|
|
12
|
-
render file: Rails.root.join('public', '404.html'), status: 404, layout: nil
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def set_locale
|
|
16
|
-
I18n.locale = params[:locale]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def redirect_to_locale_root
|
|
20
|
-
# if no matching root found for any of client locales
|
|
21
|
-
# use first root
|
|
22
|
-
target_root = available_roots.first
|
|
23
|
-
if target_root
|
|
24
|
-
redirect_to target_root.path
|
|
25
|
-
else
|
|
26
|
-
render plain: "Welcome to Releaf", layout: true
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def translation_scope
|
|
31
|
-
"public." + self.class.name.gsub("Controller", "").underscore
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def node_class
|
|
35
|
-
if @node_class.blank?
|
|
36
|
-
# this method detects whether the dummy application is running in a single or multiple node context
|
|
37
|
-
routing = Releaf::Content.routing
|
|
38
|
-
|
|
39
|
-
if routing.length == 1
|
|
40
|
-
# for single node class site
|
|
41
|
-
# the node class is the first and only defined class
|
|
42
|
-
node_class = routing.keys.first.constantize
|
|
43
|
-
else
|
|
44
|
-
# for multinode sites
|
|
45
|
-
# for non-node routes the node class can be detected from hostname via routing config
|
|
46
|
-
node_class = Releaf::Content.routing.find { |node_class_name, options| request.host =~ options[:constraints][:host] }.first.constantize
|
|
47
|
-
end
|
|
48
|
-
@node_class = node_class
|
|
49
|
-
end
|
|
50
|
-
@node_class
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def site
|
|
54
|
-
# for non-node routes site is detectable from node class via routing config
|
|
55
|
-
@site = Releaf::Content.routing[node_class.name][:site]
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def available_roots
|
|
59
|
-
@roots ||= node_class.roots.where(locale: I18n.available_locales, active: true)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
module NodeController
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
before_action :load_node
|
|
6
|
-
# node finding helpers
|
|
7
|
-
helper_method :root_node, :menu, :node_active?
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def show
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def root_node
|
|
14
|
-
@root ||= available_roots.find_by(locale: I18n.locale)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def menu
|
|
18
|
-
@menu ||= root_node.children.where(active: true)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def node_class
|
|
22
|
-
# for node routes the node class can be detected from params
|
|
23
|
-
@node_class ||= params[:node_class].constantize
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def site
|
|
27
|
-
# for node routes site can be detected from params
|
|
28
|
-
@site ||= params[:site]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def node_active? node
|
|
32
|
-
@active_nodes.include? node
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def load_node
|
|
38
|
-
@node = node_class.find(params[:node_id])
|
|
39
|
-
@content = @node.content unless @node.nil?
|
|
40
|
-
|
|
41
|
-
@active_nodes = []
|
|
42
|
-
if @node.present?
|
|
43
|
-
@active_nodes += @node.ancestors.reorder(node_class.arel_table[:depth])
|
|
44
|
-
@active_nodes << @node
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|