pages_core 3.12.4 → 3.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/assets/builds/pages_core/admin-dist.js +8 -43
- data/app/assets/builds/pages_core/admin-dist.js.map +4 -4
- data/app/assets/builds/pages_core/admin.css +264 -133
- data/app/assets/stylesheets/pages_core/admin/components/attachments.css +3 -4
- data/app/assets/stylesheets/pages_core/admin/components/forms.css +17 -16
- data/app/assets/stylesheets/pages_core/admin/components/image_editor.css +8 -4
- data/app/assets/stylesheets/pages_core/admin/components/image_grid.css +1 -1
- data/app/assets/stylesheets/pages_core/admin/components/list_table.css +11 -3
- data/app/assets/stylesheets/pages_core/admin/components/modal.css +9 -5
- data/app/assets/stylesheets/pages_core/admin/components/page_tree.css +5 -1
- data/app/assets/stylesheets/pages_core/admin/components/toast.css +2 -2
- data/app/assets/stylesheets/pages_core/admin/controllers/pages.css +4 -2
- data/app/assets/stylesheets/pages_core/admin/vars.css +2 -1
- data/app/controllers/admin/calendars_controller.rb +2 -2
- data/app/controllers/admin/categories_controller.rb +3 -3
- data/app/controllers/admin/news_controller.rb +6 -6
- data/app/controllers/admin/pages_controller.rb +12 -11
- data/app/controllers/admin/users_controller.rb +1 -1
- data/app/controllers/concerns/pages_core/preview_pages_controller.rb +15 -17
- data/app/controllers/pages_core/admin_controller.rb +2 -2
- data/app/controllers/pages_core/base_controller.rb +1 -8
- data/app/controllers/pages_core/frontend/pages_controller.rb +13 -5
- data/app/controllers/pages_core/frontend_controller.rb +12 -7
- data/app/helpers/admin/menu_helper.rb +2 -0
- data/app/helpers/admin/pages_helper.rb +1 -4
- data/app/helpers/pages_core/admin/admin_helper.rb +0 -1
- data/app/helpers/pages_core/admin/content_tabs_helper.rb +9 -2
- data/app/helpers/pages_core/application_helper.rb +2 -3
- data/app/helpers/pages_core/frontend_helper.rb +1 -1
- data/app/helpers/pages_core/head_tags_helper.rb +15 -46
- data/app/helpers/pages_core/images_helper.rb +76 -21
- data/app/helpers/pages_core/locales_helper.rb +9 -0
- data/app/helpers/pages_core/open_graph_tags_helper.rb +3 -5
- data/app/helpers/pages_core/page_path_helper.rb +1 -1
- data/app/javascript/components/Attachments/Attachment.tsx +55 -52
- data/app/javascript/components/Attachments/AttachmentEditor.tsx +45 -50
- data/app/javascript/components/Attachments/Placeholder.tsx +1 -2
- data/app/javascript/components/Attachments.jsx +69 -57
- data/app/javascript/components/DateRangeSelect.jsx +94 -54
- data/app/javascript/components/EditableImage.tsx +20 -16
- data/app/javascript/components/FileUploadButton.tsx +12 -12
- data/app/javascript/components/ImageCropper/FocalPoint.tsx +22 -20
- data/app/javascript/components/ImageCropper/Image.tsx +20 -16
- data/app/javascript/components/ImageCropper/Toolbar.tsx +35 -27
- data/app/javascript/components/ImageCropper/useCrop.ts +105 -91
- data/app/javascript/components/ImageCropper.tsx +34 -25
- data/app/javascript/components/ImageEditor/Form.tsx +32 -43
- data/app/javascript/components/ImageEditor.tsx +29 -21
- data/app/javascript/components/ImageGrid/DragElement.tsx +6 -4
- data/app/javascript/components/ImageGrid/GridImage.tsx +56 -52
- data/app/javascript/components/ImageGrid/Placeholder.tsx +1 -1
- data/app/javascript/components/ImageGrid.jsx +132 -101
- data/app/javascript/components/ImageUploader.tsx +59 -55
- data/app/javascript/components/Modal.tsx +2 -4
- data/app/javascript/components/PageDates.jsx +25 -20
- data/app/javascript/components/PageFiles.jsx +7 -5
- data/app/javascript/components/PageImages.tsx +9 -7
- data/app/javascript/components/PageTree/Draggable.tsx +46 -40
- data/app/javascript/components/PageTree/Node.tsx +111 -95
- data/app/javascript/components/PageTree/types.ts +9 -9
- data/app/javascript/components/PageTree.tsx +44 -29
- data/app/javascript/components/RichTextArea.jsx +51 -37
- data/app/javascript/components/RichTextToolbarButton.tsx +8 -5
- data/app/javascript/components/TagEditor/AddTagForm.tsx +11 -10
- data/app/javascript/components/TagEditor/Tag.tsx +10 -8
- data/app/javascript/components/TagEditor.tsx +15 -10
- data/app/javascript/components/Toast.tsx +3 -7
- data/app/javascript/components/drag/draggedOrder.ts +16 -15
- data/app/javascript/components/drag/types.ts +12 -12
- data/app/javascript/components/drag/useDragCollection.ts +36 -42
- data/app/javascript/components/drag/useDragUploader.ts +3 -2
- data/app/javascript/components/drag.ts +5 -4
- data/app/javascript/controllers/LoginController.ts +0 -1
- data/app/javascript/controllers/MainController.ts +6 -2
- data/app/javascript/controllers/PageOptionsController.js +7 -2
- data/app/javascript/features/RichText.tsx +9 -7
- data/app/javascript/index.ts +5 -3
- data/app/javascript/lib/Tree.ts +27 -24
- data/app/javascript/lib/copyToClipboard.ts +5 -4
- data/app/javascript/lib/readyHandler.ts +4 -4
- data/app/javascript/lib/request.ts +7 -3
- data/app/javascript/stores/useModalStore.ts +3 -3
- data/app/javascript/stores/useToastStore.ts +14 -12
- data/app/javascript/types.ts +22 -22
- data/app/models/concerns/pages_core/page_model/templateable.rb +1 -1
- data/app/views/admin/calendars/show.html.erb +1 -1
- data/app/views/admin/news/index.html.erb +1 -1
- data/app/views/admin/pages/_edit_files.html.erb +1 -1
- data/app/views/admin/pages/_edit_images.html.erb +1 -1
- data/app/views/admin/pages/_list_item.html.erb +1 -1
- data/app/views/admin/pages/_search_bar.html.erb +1 -1
- data/app/views/admin/pages/deleted.html.erb +2 -2
- data/app/views/admin/pages/edit.html.erb +3 -3
- data/app/views/admin/pages/index.html.erb +4 -4
- data/app/views/admin/pages/new.html.erb +1 -1
- data/app/views/admin/pages/search.html.erb +3 -3
- data/app/views/feeds/pages.rss.builder +2 -2
- data/app/views/layouts/admin/_page_header.html.erb +4 -4
- data/app/views/layouts/admin.html.erb +1 -2
- data/config/locales/en.yml +1 -0
- data/lib/pages_core/pages_plugin.rb +5 -3
- data/lib/rails/generators/pages_core/frontend/templates/application.html.erb +15 -13
- data/lib/tasks/pages/reports.rake +26 -0
- metadata +32 -4
- data/app/helpers/pages_core/admin/deprecated_admin_helper.rb +0 -40
- data/app/views/pages_core/_google_analytics.html.erb +0 -8
@@ -7,9 +7,9 @@ form {
|
|
7
7
|
margin: 16px 0;
|
8
8
|
padding: 0;
|
9
9
|
|
10
|
-
& input[type=text],
|
11
|
-
& input[type=password],
|
12
|
-
& input[type=email],
|
10
|
+
& input[type="text"],
|
11
|
+
& input[type="password"],
|
12
|
+
& input[type="email"],
|
13
13
|
& textarea {
|
14
14
|
transition: border-color 150ms ease-out;
|
15
15
|
}
|
@@ -41,9 +41,9 @@ form {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
& .field-with-warning {
|
44
|
-
& input[type=text],
|
45
|
-
& input[type=password],
|
46
|
-
& input[type=email],
|
44
|
+
& input[type="text"],
|
45
|
+
& input[type="password"],
|
46
|
+
& input[type="email"],
|
47
47
|
& textarea {
|
48
48
|
border-color: var(--red-light);
|
49
49
|
}
|
@@ -79,8 +79,8 @@ form {
|
|
79
79
|
}
|
80
80
|
}
|
81
81
|
|
82
|
-
& input[type=text],
|
83
|
-
& input[type=password] {
|
82
|
+
& input[type="text"],
|
83
|
+
& input[type="password"] {
|
84
84
|
width: 100%;
|
85
85
|
max-width: none;
|
86
86
|
}
|
@@ -96,7 +96,7 @@ form {
|
|
96
96
|
display: inline-block;
|
97
97
|
}
|
98
98
|
|
99
|
-
& input[type=text] {
|
99
|
+
& input[type="text"] {
|
100
100
|
display: inline;
|
101
101
|
width: auto;
|
102
102
|
min-width: auto;
|
@@ -139,11 +139,12 @@ form {
|
|
139
139
|
display: table;
|
140
140
|
padding: 1px;
|
141
141
|
padding-right: 22px;
|
142
|
-
background: transparent url("pages/admin/warning-icon.gif") right 5px
|
142
|
+
background: transparent url("pages/admin/warning-icon.gif") right 5px
|
143
|
+
no-repeat;
|
143
144
|
}
|
144
145
|
|
145
|
-
input[type=text],
|
146
|
-
input[type=password],
|
146
|
+
input[type="text"],
|
147
|
+
input[type="password"],
|
147
148
|
textarea {
|
148
149
|
width: 100%;
|
149
150
|
max-width: 450px;
|
@@ -165,10 +166,10 @@ textarea {
|
|
165
166
|
}
|
166
167
|
}
|
167
168
|
|
168
|
-
main .login-form input[type=text],
|
169
|
-
main .login-form input[type=password],
|
170
|
-
input[type=text].large,
|
171
|
-
input[type=password].large {
|
169
|
+
main .login-form input[type="text"],
|
170
|
+
main .login-form input[type="password"],
|
171
|
+
input[type="text"].large,
|
172
|
+
input[type="password"].large {
|
172
173
|
font-size: 1.4em;
|
173
174
|
}
|
174
175
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
cursor: pointer;
|
3
3
|
display: block;
|
4
4
|
transition: transform 200ms, box-shadow 200ms, border-color 200ms ease-out;
|
5
|
-
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0
|
5
|
+
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0);
|
6
6
|
border: 1px solid #fff;
|
7
7
|
position: relative;
|
8
8
|
-webkit-perspective: 1000;
|
@@ -13,7 +13,7 @@
|
|
13
13
|
right: 6px;
|
14
14
|
font-size: 14px;
|
15
15
|
color: var(--background-warning-color);
|
16
|
-
text-shadow: 0px 0px 5px rgba(0, 0, 0, 1
|
16
|
+
text-shadow: 0px 0px 5px rgba(0, 0, 0, 1);
|
17
17
|
z-index: 100;
|
18
18
|
}
|
19
19
|
|
@@ -56,7 +56,10 @@
|
|
56
56
|
width: 100%;
|
57
57
|
height: 100%;
|
58
58
|
background: #e5e5e5;
|
59
|
-
background-image: linear-gradient(45deg, #fff 25%, transparent 25%),
|
59
|
+
background-image: linear-gradient(45deg, #fff 25%, transparent 25%),
|
60
|
+
linear-gradient(135deg, #fff 25%, transparent 25%),
|
61
|
+
linear-gradient(45deg, transparent 75%, #fff 75%),
|
62
|
+
linear-gradient(135deg, transparent 75%, #fff 75%);
|
60
63
|
background-size: 12px 12px;
|
61
64
|
background-position: 0 0, 6px 0, 6px -6px, 0px 6px;
|
62
65
|
display: flex;
|
@@ -187,7 +190,8 @@
|
|
187
190
|
touch-action: none;
|
188
191
|
user-select: none;
|
189
192
|
cursor: pointer;
|
190
|
-
transition: border-radius 200ms, margin 200ms, width 200ms, height 200ms,
|
193
|
+
transition: border-radius 200ms, margin 200ms, width 200ms, height 200ms,
|
194
|
+
border-color 200ms ease-out;
|
191
195
|
|
192
196
|
&:hover {
|
193
197
|
&:after {
|
@@ -11,7 +11,11 @@ table.list {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
& th {
|
14
|
-
background: linear-gradient(
|
14
|
+
background: linear-gradient(
|
15
|
+
to bottom,
|
16
|
+
var(--background-color) 0%,
|
17
|
+
var(--background-disabled-color) 100%
|
18
|
+
);
|
15
19
|
color: var(--text-light-color);
|
16
20
|
font-weight: bold;
|
17
21
|
border-bottom: 1px solid var(--border-color);
|
@@ -44,12 +48,16 @@ table.list {
|
|
44
48
|
}
|
45
49
|
|
46
50
|
& tr.disabled td:first-child {
|
47
|
-
background: transparent
|
51
|
+
background: transparent
|
52
|
+
radial-gradient(ellipse at center, #bdbdbd 50%, transparent 50%) no-repeat
|
53
|
+
left 12px top 50%;
|
48
54
|
background-size: 10px 10px;
|
49
55
|
}
|
50
56
|
|
51
57
|
& tr.active td:first-child {
|
52
|
-
background: transparent
|
58
|
+
background: transparent
|
59
|
+
radial-gradient(ellipse at center, #92b6c4 50%, transparent 50%) no-repeat
|
60
|
+
left 12px top 50%;
|
53
61
|
background-size: 10px 10px;
|
54
62
|
}
|
55
63
|
|
@@ -15,7 +15,11 @@ body.modal {
|
|
15
15
|
justify-content: center;
|
16
16
|
|
17
17
|
& .background {
|
18
|
-
background: radial-gradient(
|
18
|
+
background: radial-gradient(
|
19
|
+
rgba(255, 255, 255, 0.9),
|
20
|
+
rgba(255, 255, 255, 0.9) 50%,
|
21
|
+
rgba(80, 80, 80, 0.9)
|
22
|
+
);
|
19
23
|
cursor: pointer;
|
20
24
|
position: absolute;
|
21
25
|
top: 0px;
|
@@ -68,17 +72,17 @@ body.modal {
|
|
68
72
|
}
|
69
73
|
|
70
74
|
100% {
|
71
|
-
opacity: 1
|
72
|
-
transform: scale(1
|
75
|
+
opacity: 1;
|
76
|
+
transform: scale(1);
|
73
77
|
}
|
74
78
|
}
|
75
79
|
|
76
80
|
@keyframes modal-background-appear {
|
77
81
|
0% {
|
78
|
-
opacity: 0
|
82
|
+
opacity: 0;
|
79
83
|
}
|
80
84
|
|
81
85
|
100% {
|
82
|
-
opacity: 1
|
86
|
+
opacity: 1;
|
83
87
|
}
|
84
88
|
}
|
@@ -49,7 +49,11 @@
|
|
49
49
|
|
50
50
|
&:hover {
|
51
51
|
border: 1px solid var(--border-color-light);
|
52
|
-
background: linear-gradient(
|
52
|
+
background: linear-gradient(
|
53
|
+
to bottom,
|
54
|
+
var(--background-color) 0%,
|
55
|
+
var(--background-disabled-color) 100%
|
56
|
+
);
|
53
57
|
}
|
54
58
|
|
55
59
|
& .date {
|
@@ -17,7 +17,7 @@
|
|
17
17
|
text-align: left;
|
18
18
|
animation-duration: 500ms;
|
19
19
|
animation-name: toast-appear;
|
20
|
-
animation-timing-function: cubic-bezier(0.215, 0.
|
20
|
+
animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
|
21
21
|
animation-fill-mode: forwards;
|
22
22
|
|
23
23
|
&.error {
|
@@ -27,7 +27,7 @@
|
|
27
27
|
&.fadeout {
|
28
28
|
animation-duration: 300ms;
|
29
29
|
animation-name: toast-disappear;
|
30
|
-
animation-timing-function: cubic-bezier(0.
|
30
|
+
animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
|
31
31
|
}
|
32
32
|
}
|
33
33
|
}
|
@@ -136,7 +136,9 @@ td.drag-handle {
|
|
136
136
|
}
|
137
137
|
|
138
138
|
& .pinned .name {
|
139
|
-
background: transparent
|
139
|
+
background: transparent
|
140
|
+
radial-gradient(ellipse at center, #92b6c4 50%, transparent 50%) no-repeat
|
141
|
+
left 12px top 50%;
|
140
142
|
background-size: 10px 10px;
|
141
143
|
}
|
142
144
|
}
|
@@ -162,7 +164,7 @@ td.drag-handle {
|
|
162
164
|
}
|
163
165
|
}
|
164
166
|
|
165
|
-
& main input[type=text],
|
167
|
+
& main input[type="text"],
|
166
168
|
& main textarea {
|
167
169
|
width: 100%;
|
168
170
|
max-width: 100%;
|
@@ -2,7 +2,8 @@
|
|
2
2
|
@custom-media --narrow screen and (max-width: 1150px);
|
3
3
|
|
4
4
|
:root {
|
5
|
-
--font-os-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
|
5
|
+
--font-os-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
|
6
|
+
Roboto, Ubuntu, "Helvetica Neue", Oxygen, Cantarell, sans-serif;
|
6
7
|
|
7
8
|
--red: #c00007;
|
8
9
|
--red-transparent: #c0000740;
|
@@ -8,7 +8,7 @@ module Admin
|
|
8
8
|
|
9
9
|
def show
|
10
10
|
unless @year
|
11
|
-
redirect_to(admin_calendar_path(
|
11
|
+
redirect_to(admin_calendar_path(content_locale, Time.zone.now.year))
|
12
12
|
return
|
13
13
|
end
|
14
14
|
@pages = if @month
|
@@ -23,7 +23,7 @@ module Admin
|
|
23
23
|
def calendar_items
|
24
24
|
Page.with_dates
|
25
25
|
.order("starts_at DESC")
|
26
|
-
.in_locale(
|
26
|
+
.in_locale(content_locale)
|
27
27
|
.visible
|
28
28
|
.paginate(per_page: 50, page: params[:page])
|
29
29
|
end
|
@@ -22,7 +22,7 @@ module Admin
|
|
22
22
|
@category = Category.create(category_params)
|
23
23
|
if @category.valid?
|
24
24
|
flash[:notice] = t("pages_core.categories_controller.created")
|
25
|
-
redirect_to admin_pages_url(
|
25
|
+
redirect_to admin_pages_url(content_locale)
|
26
26
|
else
|
27
27
|
render action: :new
|
28
28
|
end
|
@@ -31,7 +31,7 @@ module Admin
|
|
31
31
|
def update
|
32
32
|
if @category.update(category_params)
|
33
33
|
flash[:notice] = t("pages_core.categories_controller.updated")
|
34
|
-
redirect_to admin_pages_url(
|
34
|
+
redirect_to admin_pages_url(content_locale)
|
35
35
|
else
|
36
36
|
render action: :edit
|
37
37
|
end
|
@@ -40,7 +40,7 @@ module Admin
|
|
40
40
|
def destroy
|
41
41
|
@category.destroy
|
42
42
|
flash[:notice] = t("pages_core.categories_controller.deleted")
|
43
|
-
redirect_to admin_pages_url(
|
43
|
+
redirect_to admin_pages_url(content_locale)
|
44
44
|
end
|
45
45
|
|
46
46
|
protected
|
@@ -9,9 +9,9 @@ module Admin
|
|
9
9
|
require_authorization object: Page
|
10
10
|
|
11
11
|
def index
|
12
|
-
@archive_finder = archive_finder(@news_pages,
|
12
|
+
@archive_finder = archive_finder(@news_pages, content_locale)
|
13
13
|
unless @year
|
14
|
-
redirect_to(admin_news_index_path(
|
14
|
+
redirect_to(admin_news_index_path(content_locale,
|
15
15
|
(@archive_finder.latest_year ||
|
16
16
|
Time.zone.now.year)))
|
17
17
|
return
|
@@ -32,11 +32,11 @@ module Admin
|
|
32
32
|
|
33
33
|
def find_news_pages
|
34
34
|
@news_pages = Page.news_pages
|
35
|
-
.in_locale(
|
36
|
-
.
|
35
|
+
.in_locale(content_locale)
|
36
|
+
.sort { |a, b| b.children.count <=> a.children.count }
|
37
37
|
return if @news_pages.any?
|
38
38
|
|
39
|
-
redirect_to(admin_pages_url(
|
39
|
+
redirect_to(admin_pages_url(content_locale))
|
40
40
|
end
|
41
41
|
|
42
42
|
def find_year_and_month
|
@@ -48,7 +48,7 @@ module Admin
|
|
48
48
|
def require_news_pages
|
49
49
|
return if Page.news_pages.any?
|
50
50
|
|
51
|
-
redirect_to(admin_pages_url(
|
51
|
+
redirect_to(admin_pages_url(content_locale))
|
52
52
|
end
|
53
53
|
|
54
54
|
def latest_year
|
@@ -10,11 +10,11 @@ module Admin
|
|
10
10
|
require_authorization
|
11
11
|
|
12
12
|
def index
|
13
|
-
@pages = Page.admin_list(
|
13
|
+
@pages = Page.admin_list(content_locale)
|
14
14
|
end
|
15
15
|
|
16
16
|
def deleted
|
17
|
-
@pages = Page.deleted.by_updated_at.in_locale(
|
17
|
+
@pages = Page.deleted.by_updated_at.in_locale(content_locale)
|
18
18
|
end
|
19
19
|
|
20
20
|
def search
|
@@ -22,27 +22,28 @@ module Admin
|
|
22
22
|
|
23
23
|
@search_documents =
|
24
24
|
SearchDocument.where(searchable_type: "Page")
|
25
|
-
.search(search_query, locale:
|
25
|
+
.search(search_query, locale: content_locale)
|
26
26
|
.paginate(per_page: 50, page: params[:page])
|
27
27
|
end
|
28
28
|
|
29
29
|
def show
|
30
|
-
redirect_to edit_admin_page_url(
|
30
|
+
redirect_to edit_admin_page_url(content_locale, @page)
|
31
31
|
end
|
32
32
|
|
33
33
|
def new
|
34
34
|
build_params = params[:page] ? page_params : nil
|
35
|
-
@page = build_page(
|
35
|
+
@page = build_page(content_locale, build_params)
|
36
36
|
@page.parent = Page.find_by(id: params[:parent])
|
37
37
|
end
|
38
38
|
|
39
39
|
def edit; end
|
40
40
|
|
41
41
|
def create
|
42
|
-
@page = build_page(
|
42
|
+
@page = build_page(content_locale, page_params,
|
43
|
+
param_categories).tap(&:save)
|
43
44
|
if @page.valid?
|
44
45
|
respond_with_page(@page) do
|
45
|
-
redirect_to(edit_admin_page_url(
|
46
|
+
redirect_to(edit_admin_page_url(content_locale, @page))
|
46
47
|
end
|
47
48
|
else
|
48
49
|
render action: :new
|
@@ -54,7 +55,7 @@ module Admin
|
|
54
55
|
@page.categories = param_categories
|
55
56
|
respond_with_page(@page) do
|
56
57
|
flash[:notice] = t("pages_core.changes_saved")
|
57
|
-
redirect_to edit_admin_page_url(
|
58
|
+
redirect_to edit_admin_page_url(content_locale, @page)
|
58
59
|
end
|
59
60
|
else
|
60
61
|
render action: :edit
|
@@ -64,12 +65,12 @@ module Admin
|
|
64
65
|
def move
|
65
66
|
parent = params[:parent_id] ? Page.find(params[:parent_id]) : nil
|
66
67
|
@page.update(parent: parent, position: params[:position])
|
67
|
-
respond_with_page(@page) { redirect_to admin_pages_url(
|
68
|
+
respond_with_page(@page) { redirect_to admin_pages_url(content_locale) }
|
68
69
|
end
|
69
70
|
|
70
71
|
def destroy
|
71
72
|
Page.find(params[:id]).flag_as_deleted!
|
72
|
-
redirect_to admin_pages_url(
|
73
|
+
redirect_to admin_pages_url(content_locale)
|
73
74
|
end
|
74
75
|
|
75
76
|
private
|
@@ -110,7 +111,7 @@ module Admin
|
|
110
111
|
end
|
111
112
|
|
112
113
|
def find_page
|
113
|
-
@page = Page.find(params[:id]).localize(
|
114
|
+
@page = Page.find(params[:id]).localize(content_locale)
|
114
115
|
end
|
115
116
|
|
116
117
|
def find_categories
|
@@ -48,7 +48,7 @@ module Admin
|
|
48
48
|
flash[:notice] = "Your changed to #{@user.name} were saved."
|
49
49
|
redirect_to admin_users_url
|
50
50
|
else
|
51
|
-
flash.now[:error] = "
|
51
|
+
flash.now[:error] = t("pages_core.problems_saving")
|
52
52
|
render action: :edit
|
53
53
|
end
|
54
54
|
end
|
@@ -4,23 +4,6 @@ module PagesCore
|
|
4
4
|
module PreviewPagesController
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
included do
|
8
|
-
before_action :disable_xss_protection, only: [:preview]
|
9
|
-
end
|
10
|
-
|
11
|
-
def preview
|
12
|
-
redirect_to(page_url(@locale, @page)) && return unless logged_in?
|
13
|
-
|
14
|
-
@preview = true
|
15
|
-
@page.attributes = page_params.merge(
|
16
|
-
status: 2,
|
17
|
-
published_at: Time.zone.now,
|
18
|
-
locale: @locale,
|
19
|
-
redirect_to: nil
|
20
|
-
)
|
21
|
-
render_page
|
22
|
-
end
|
23
|
-
|
24
7
|
def preview?
|
25
8
|
@preview || false
|
26
9
|
end
|
@@ -45,5 +28,20 @@ module PagesCore
|
|
45
28
|
Page.localized_attributes + permitted_page_attributes
|
46
29
|
)
|
47
30
|
end
|
31
|
+
|
32
|
+
def preview_page(page)
|
33
|
+
redirect_to(page_url(content_locale, page)) && return unless logged_in?
|
34
|
+
|
35
|
+
disable_xss_protection
|
36
|
+
|
37
|
+
@preview = true
|
38
|
+
page.attributes = page_params.merge(
|
39
|
+
status: 2,
|
40
|
+
published_at: Time.zone.now,
|
41
|
+
locale: content_locale,
|
42
|
+
redirect_to: nil
|
43
|
+
)
|
44
|
+
render_page
|
45
|
+
end
|
48
46
|
end
|
49
47
|
end
|
@@ -24,9 +24,9 @@ module PagesCore
|
|
24
24
|
|
25
25
|
def redirect
|
26
26
|
if Page.news_pages.any?
|
27
|
-
redirect_to news_admin_pages_url(
|
27
|
+
redirect_to news_admin_pages_url(content_locale)
|
28
28
|
else
|
29
|
-
redirect_to admin_pages_url(
|
29
|
+
redirect_to admin_pages_url(content_locale)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -5,11 +5,11 @@ module PagesCore
|
|
5
5
|
include PagesCore::Authentication
|
6
6
|
include PagesCore::ErrorRenderer
|
7
7
|
include PagesCore::ErrorReporting
|
8
|
+
include PagesCore::LocalesHelper
|
8
9
|
include PagesCore::ProcessTitler
|
9
10
|
include PagesCore::PoliciesHelper
|
10
11
|
include PagesCore::StaticCacheController
|
11
12
|
|
12
|
-
before_action :set_locale
|
13
13
|
after_action :set_content_language_header
|
14
14
|
|
15
15
|
protected
|
@@ -20,13 +20,6 @@ module PagesCore
|
|
20
20
|
payload.merge!(current_user_context)
|
21
21
|
end
|
22
22
|
|
23
|
-
# Sets @locale from params[:locale], with I18n.default_locale as fallback
|
24
|
-
def set_locale
|
25
|
-
legacy_locales = { "nor" => "nb", "eng" => "en" }
|
26
|
-
@locale = params[:locale] || I18n.default_locale.to_s
|
27
|
-
@locale = legacy_locales[@locale] if legacy_locales[@locale]
|
28
|
-
end
|
29
|
-
|
30
23
|
def set_content_language_header
|
31
24
|
return unless locale
|
32
25
|
|
@@ -27,6 +27,10 @@ module PagesCore
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def preview
|
31
|
+
preview_page(@page)
|
32
|
+
end
|
33
|
+
|
30
34
|
def show
|
31
35
|
respond_to do |format|
|
32
36
|
format.html { render_published_page(@page) }
|
@@ -64,10 +68,6 @@ module PagesCore
|
|
64
68
|
super
|
65
69
|
end
|
66
70
|
|
67
|
-
def page_param
|
68
|
-
params[:page].is_a?(String) ? params[:page] : 1
|
69
|
-
end
|
70
|
-
|
71
71
|
def page_template(page)
|
72
72
|
if PagesCore::Templates.names.include?(page.template)
|
73
73
|
page.template
|
@@ -98,7 +98,7 @@ module PagesCore
|
|
98
98
|
|
99
99
|
def find_page
|
100
100
|
@page ||= Page.find_by(id: params[:id]) || unique_page(params[:id])
|
101
|
-
@page.locale =
|
101
|
+
@page.locale = content_locale if @page
|
102
102
|
end
|
103
103
|
|
104
104
|
def render_published_page(page)
|
@@ -110,6 +110,14 @@ module PagesCore
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
+
def redirect_to_parent_or_root(page)
|
114
|
+
if page.parent
|
115
|
+
redirect_to page_url(locale, page.parent)
|
116
|
+
else
|
117
|
+
redirect_to root_url
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
113
121
|
def redirect_page(page)
|
114
122
|
return false unless page.redirects?
|
115
123
|
|
@@ -6,6 +6,7 @@ module PagesCore
|
|
6
6
|
include ApplicationHelper
|
7
7
|
|
8
8
|
before_action :set_i18n_locale
|
9
|
+
helper_method :page_param
|
9
10
|
|
10
11
|
# Loads @root_pages and @rss_feeds. To automatically load these in your
|
11
12
|
# own controllers, add the following line to your controller definition:
|
@@ -13,21 +14,25 @@ module PagesCore
|
|
13
14
|
# before_action :load_root_pages
|
14
15
|
#
|
15
16
|
def load_root_pages
|
16
|
-
@root_pages = Page.roots.localized(
|
17
|
-
@rss_feeds = Page.where(feed_enabled: true)
|
17
|
+
@root_pages = Page.roots.localized(content_locale).published
|
18
|
+
@rss_feeds = Page.where(feed_enabled: true)
|
19
|
+
.localized(content_locale)
|
20
|
+
.published
|
18
21
|
end
|
19
22
|
|
20
23
|
private
|
21
24
|
|
22
25
|
def legacy_locales
|
23
|
-
{
|
24
|
-
"
|
25
|
-
|
26
|
-
|
26
|
+
{ "nor" => "nb",
|
27
|
+
"eng" => "en" }
|
28
|
+
end
|
29
|
+
|
30
|
+
def page_param
|
31
|
+
params[:page].is_a?(String) ? params[:page] : 1
|
27
32
|
end
|
28
33
|
|
29
34
|
def set_i18n_locale
|
30
|
-
locale_param =
|
35
|
+
locale_param = content_locale
|
31
36
|
if legacy_locales[locale_param]
|
32
37
|
locale_param = legacy_locales[locale_param]
|
33
38
|
end
|
@@ -4,7 +4,6 @@ module PagesCore
|
|
4
4
|
module Admin
|
5
5
|
module AdminHelper
|
6
6
|
include PagesCore::Admin::ContentTabsHelper
|
7
|
-
include PagesCore::Admin::DeprecatedAdminHelper
|
8
7
|
include PagesCore::Admin::DateRangeHelper
|
9
8
|
include PagesCore::Admin::ImageUploadsHelper
|
10
9
|
include PagesCore::Admin::LocalesHelper
|
@@ -3,8 +3,15 @@
|
|
3
3
|
module PagesCore
|
4
4
|
module Admin
|
5
5
|
module ContentTabsHelper
|
6
|
-
def
|
6
|
+
def content_tabs
|
7
7
|
@content_tabs ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def content_tabs?
|
11
|
+
content_tabs.any?
|
12
|
+
end
|
13
|
+
|
14
|
+
def content_tab(name, options = {}, &block)
|
8
15
|
return unless block_given?
|
9
16
|
|
10
17
|
tab = {
|
@@ -13,7 +20,7 @@ module PagesCore
|
|
13
20
|
options: options,
|
14
21
|
content: capture(&block)
|
15
22
|
}
|
16
|
-
|
23
|
+
content_tabs.push(tab)
|
17
24
|
content_tab_tag(tab[:key], tab[:content])
|
18
25
|
end
|
19
26
|
|
@@ -22,13 +22,12 @@ module PagesCore
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def unique_page(page_name, &block)
|
25
|
-
locale = @locale || I18n.default_locale.to_s
|
26
25
|
page = Page.where(unique_name: page_name).first
|
27
26
|
if page && block_given?
|
28
|
-
output = capture(page.localize(
|
27
|
+
output = capture(page.localize(content_locale), &block)
|
29
28
|
concat(output)
|
30
29
|
end
|
31
|
-
page&.localize(
|
30
|
+
page&.localize(content_locale)
|
32
31
|
end
|
33
32
|
|
34
33
|
private
|