pages_core 3.15.3 → 3.15.5

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.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/assets/builds/pages_core/admin-dist.js +1 -1
  4. data/app/assets/builds/pages_core/admin-dist.js.map +4 -4
  5. data/app/assets/builds/pages_core/admin.css +378 -253
  6. data/app/assets/builds/pages_core/mailer.css +41 -6
  7. data/app/assets/builds/pages_core_fonts/121b837e.woff2 +0 -0
  8. data/app/assets/builds/pages_core_fonts/216e5c23.woff2 +0 -0
  9. data/app/assets/builds/pages_core_fonts/3017b52f.woff2 +0 -0
  10. data/app/assets/builds/pages_core_fonts/489746b9.woff2 +0 -0
  11. data/app/assets/builds/pages_core_fonts/49775483.woff2 +0 -0
  12. data/app/assets/builds/pages_core_fonts/49c9e472.woff2 +0 -0
  13. data/app/assets/builds/pages_core_fonts/4a119645.woff2 +0 -0
  14. data/app/assets/builds/pages_core_fonts/5d56d7a8.woff2 +0 -0
  15. data/app/assets/builds/pages_core_fonts/61ea75a6.woff2 +0 -0
  16. data/app/assets/builds/pages_core_fonts/62cbb778.woff2 +0 -0
  17. data/app/assets/builds/pages_core_fonts/647d26c.woff2 +0 -0
  18. data/app/assets/builds/pages_core_fonts/67764053.woff2 +0 -0
  19. data/app/assets/builds/pages_core_fonts/6bb0fd00.woff2 +0 -0
  20. data/app/assets/builds/pages_core_fonts/6c0194a2.woff2 +0 -0
  21. data/app/assets/builds/pages_core_fonts/71423409.woff2 +0 -0
  22. data/app/assets/builds/pages_core_fonts/7584e61d.woff2 +0 -0
  23. data/app/assets/builds/pages_core_fonts/77bcfa1c.woff2 +0 -0
  24. data/app/assets/builds/pages_core_fonts/7aca0cc5.woff2 +0 -0
  25. data/app/assets/builds/pages_core_fonts/9a09533f.woff2 +0 -0
  26. data/app/assets/builds/pages_core_fonts/a51f5bc8.woff2 +0 -0
  27. data/app/assets/builds/pages_core_fonts/a80b2975.woff2 +0 -0
  28. data/app/assets/builds/pages_core_fonts/a891f617.woff2 +0 -0
  29. data/app/assets/builds/pages_core_fonts/ad6083f3.woff2 +0 -0
  30. data/app/assets/builds/pages_core_fonts/b29a61ff.woff2 +0 -0
  31. data/app/assets/builds/{fonts/6569749d.ttf → pages_core_fonts/b30b0656.ttf} +0 -0
  32. data/app/assets/builds/pages_core_fonts/b3a5f48c.woff2 +0 -0
  33. data/app/assets/builds/pages_core_fonts/bc73ee06.woff2 +0 -0
  34. data/app/assets/builds/pages_core_fonts/c38c6d45.woff2 +0 -0
  35. data/app/assets/builds/pages_core_fonts/c5ce0b1f.woff2 +0 -0
  36. data/app/assets/builds/pages_core_fonts/c8d53904.woff2 +0 -0
  37. data/app/assets/builds/pages_core_fonts/ce13c169.woff2 +0 -0
  38. data/app/assets/builds/pages_core_fonts/d43bd0d5.woff2 +0 -0
  39. data/app/assets/builds/pages_core_fonts/e1c7d368.woff2 +0 -0
  40. data/app/assets/builds/pages_core_fonts/e1e8175d.woff2 +0 -0
  41. data/app/assets/builds/pages_core_fonts/e318f796.woff2 +0 -0
  42. data/app/assets/builds/{fonts/ee32bc60.ttf → pages_core_fonts/e7acb7d9.ttf} +0 -0
  43. data/app/assets/builds/pages_core_fonts/ee5514c6.woff2 +0 -0
  44. data/app/assets/builds/pages_core_fonts/f4e495e2.woff2 +0 -0
  45. data/app/assets/builds/pages_core_fonts/f736ec65.woff2 +0 -0
  46. data/app/assets/builds/pages_core_fonts/f741c7ba.woff2 +0 -0
  47. data/app/assets/builds/pages_core_fonts/f7767345.woff2 +0 -0
  48. data/app/assets/builds/pages_core_fonts/fe9eb751.woff2 +0 -0
  49. data/app/assets/stylesheets/pages_core/admin/components/forms.css +2 -2
  50. data/app/assets/stylesheets/pages_core/admin/components/header.css +1 -1
  51. data/app/assets/stylesheets/pages_core/admin/controllers/pages.css +1 -1
  52. data/app/assets/stylesheets/pages_core/admin/global/fonts.css +38 -38
  53. data/app/controllers/{pages_core → admin}/admin_controller.rb +1 -3
  54. data/app/controllers/attachments_controller.rb +40 -0
  55. data/app/controllers/concerns/pages_core/document_title_controller.rb +16 -0
  56. data/app/controllers/concerns/pages_core/page_parameters.rb +1 -1
  57. data/app/controllers/concerns/pages_core/pages/preview_controller.rb +49 -0
  58. data/app/controllers/concerns/pages_core/pages/rss_controller.rb +43 -0
  59. data/app/controllers/errors_controller.rb +2 -0
  60. data/app/controllers/images_controller.rb +13 -0
  61. data/app/controllers/pages_core/frontend/pages_controller.rb +3 -4
  62. data/app/controllers/pages_core/frontend_controller.rb +6 -1
  63. data/app/controllers/pages_core/sitemaps_controller.rb +21 -52
  64. data/app/helpers/pages_core/admin/image_uploads_helper.rb +1 -1
  65. data/app/helpers/pages_core/application_helper.rb +0 -3
  66. data/app/helpers/pages_core/attachments_helper.rb +0 -10
  67. data/app/helpers/pages_core/feed_tags_helper.rb +31 -0
  68. data/app/helpers/pages_core/frontend_helper.rb +3 -0
  69. data/app/helpers/pages_core/head_tags_helper.rb +80 -70
  70. data/app/helpers/pages_core/page_path_helper.rb +1 -12
  71. data/app/javascript/components/Attachments/Attachment.tsx +3 -3
  72. data/app/javascript/components/Attachments/AttachmentEditor.tsx +5 -5
  73. data/app/javascript/components/Attachments/Deleted.tsx +28 -0
  74. data/app/javascript/components/Attachments/List.tsx +11 -24
  75. data/app/javascript/components/Attachments/Placeholder.tsx +0 -2
  76. data/app/javascript/components/Attachments.tsx +2 -3
  77. data/app/javascript/components/DateRangeSelect.tsx +13 -10
  78. data/app/javascript/components/DateTimeSelect.tsx +11 -11
  79. data/app/javascript/components/EditableImage.tsx +3 -3
  80. data/app/javascript/components/FileUploadButton.tsx +3 -3
  81. data/app/javascript/components/ImageCropper/FocalPoint.tsx +10 -14
  82. data/app/javascript/components/ImageCropper/Image.tsx +19 -25
  83. data/app/javascript/components/ImageCropper/Toolbar.tsx +27 -26
  84. data/app/javascript/components/ImageCropper/useContainerSize.ts +25 -0
  85. data/app/javascript/components/ImageCropper/useCrop.ts +28 -13
  86. data/app/javascript/components/ImageCropper/useImageCropperContext.ts +13 -0
  87. data/app/javascript/components/ImageCropper.tsx +24 -83
  88. data/app/javascript/components/ImageEditor/Form.tsx +25 -28
  89. data/app/javascript/components/ImageEditor/useImageEditor.ts +63 -0
  90. data/app/javascript/components/ImageEditor/useImageEditorContext.ts +14 -0
  91. data/app/javascript/components/ImageEditor.tsx +28 -42
  92. data/app/javascript/components/ImageGrid/Deleted.tsx +28 -0
  93. data/app/javascript/components/ImageGrid/DragElement.tsx +5 -5
  94. data/app/javascript/components/ImageGrid/FilePlaceholder.tsx +0 -2
  95. data/app/javascript/components/ImageGrid/Grid.tsx +15 -24
  96. data/app/javascript/components/ImageGrid/GridImage.tsx +4 -4
  97. data/app/javascript/components/ImageGrid/Placeholder.tsx +2 -4
  98. data/app/javascript/components/ImageGrid.tsx +2 -4
  99. data/app/javascript/components/ImageUploader.tsx +5 -5
  100. data/app/javascript/components/LabelledField.tsx +6 -6
  101. data/app/javascript/components/Modal.tsx +16 -13
  102. data/app/javascript/components/PageForm/Block.tsx +3 -3
  103. data/app/javascript/components/PageForm/Content.tsx +11 -15
  104. data/app/javascript/components/PageForm/Dates.tsx +3 -11
  105. data/app/javascript/components/PageForm/Files.tsx +2 -4
  106. data/app/javascript/components/PageForm/Form.tsx +3 -9
  107. data/app/javascript/components/PageForm/Images.tsx +2 -4
  108. data/app/javascript/components/PageForm/LocaleLinks.tsx +4 -11
  109. data/app/javascript/components/PageForm/Metadata.tsx +8 -13
  110. data/app/javascript/components/PageForm/Options.tsx +28 -11
  111. data/app/javascript/components/PageForm/PageDescription.tsx +7 -14
  112. data/app/javascript/components/PageForm/PathSegment.tsx +5 -10
  113. data/app/javascript/components/PageForm/TabPanel.tsx +3 -6
  114. data/app/javascript/components/PageForm/Tabs.tsx +2 -4
  115. data/app/javascript/components/PageForm/UnconfiguredContent.tsx +7 -12
  116. data/app/javascript/components/PageForm/pageParams.ts +3 -2
  117. data/app/javascript/components/PageForm/usePage.ts +1 -46
  118. data/app/javascript/components/PageForm/usePageFormContext.ts +8 -0
  119. data/app/javascript/components/PageForm/useTabs.ts +1 -1
  120. data/app/javascript/components/PageForm/utils.ts +49 -0
  121. data/app/javascript/components/PageForm.tsx +52 -48
  122. data/app/javascript/components/PageImages.tsx +1 -3
  123. data/app/javascript/components/PageTree/Button.tsx +25 -0
  124. data/app/javascript/components/PageTree/CollapseArrow.tsx +34 -0
  125. data/app/javascript/components/PageTree/CollapsedLabel.tsx +21 -0
  126. data/app/javascript/components/PageTree/EditPageName.tsx +68 -0
  127. data/app/javascript/components/PageTree/Node.tsx +143 -413
  128. data/app/javascript/components/PageTree/PageName.tsx +6 -4
  129. data/app/javascript/components/PageTree/StatusLabel.tsx +10 -0
  130. data/app/javascript/components/PageTree/tree.ts +268 -0
  131. data/app/javascript/components/PageTree/usePageTree.ts +268 -0
  132. data/app/javascript/components/PageTree/usePageTreeContext.ts +13 -0
  133. data/app/javascript/components/PageTree.tsx +194 -214
  134. data/app/javascript/components/{RichTextToolbarButton.tsx → RichTextArea/ToolbarButton.tsx} +3 -5
  135. data/app/javascript/components/RichTextArea/actions.ts +106 -0
  136. data/app/javascript/components/RichTextArea/useMaybeControlledValue.ts +14 -0
  137. data/app/javascript/components/RichTextArea.tsx +91 -209
  138. data/app/javascript/components/TagEditor/AddTagForm.tsx +2 -2
  139. data/app/javascript/components/TagEditor/Editor.tsx +3 -5
  140. data/app/javascript/components/TagEditor/Tag.tsx +3 -5
  141. data/app/javascript/components/TagEditor/useTags.ts +7 -4
  142. data/app/javascript/components/TagEditor.tsx +2 -4
  143. data/app/javascript/components/Toast.tsx +5 -5
  144. data/app/javascript/components/drag/draggedOrder.ts +6 -6
  145. data/app/javascript/components/drag/useDragCollection.ts +21 -25
  146. data/app/javascript/components/drag/useDragUploader.ts +20 -18
  147. data/app/javascript/components/drag/useDraggable.ts +3 -3
  148. data/app/javascript/features/RichText.tsx +0 -1
  149. data/app/javascript/features/contentTabs.ts +2 -2
  150. data/app/javascript/stores/useModalStore.ts +1 -1
  151. data/app/javascript/stores/useToastStore.ts +2 -2
  152. data/app/javascript/types/Attachments.ts +11 -11
  153. data/app/javascript/types/Crop.ts +16 -12
  154. data/app/javascript/types/Drag.ts +21 -23
  155. data/app/javascript/types/Images.ts +8 -8
  156. data/app/javascript/types/PageEditor.ts +11 -4
  157. data/app/javascript/types/Pages.ts +22 -27
  158. data/app/javascript/types/Tags.ts +5 -6
  159. data/app/javascript/types/Template.ts +4 -4
  160. data/app/javascript/types.ts +2 -2
  161. data/app/models/attachment.rb +5 -9
  162. data/app/models/autopublisher.rb +1 -1
  163. data/app/models/concerns/pages_core/page_model/redirectable.rb +1 -2
  164. data/app/models/concerns/pages_core/page_model/searchable.rb +1 -1
  165. data/app/models/concerns/pages_core/page_model/status.rb +2 -4
  166. data/app/models/concerns/pages_core/searchable_document.rb +2 -4
  167. data/app/models/image.rb +0 -15
  168. data/app/models/page_builder.rb +4 -6
  169. data/app/resources/admin/page_resource.rb +2 -2
  170. data/app/resources/export/page_resource.rb +1 -1
  171. data/app/services/pages_core/invite_service.rb +1 -2
  172. data/app/views/layouts/admin.html.erb +1 -0
  173. data/app/views/pages_core/sitemaps/index.xml.builder +10 -0
  174. data/config/routes.rb +4 -3
  175. data/db/migrate/20240917142300_add_skip_index_to_pages.rb +7 -0
  176. data/lib/pages_core/engine.rb +15 -17
  177. data/lib/pages_core/sitemap.rb +58 -0
  178. data/lib/pages_core/templates/configuration_proxy.rb +3 -3
  179. data/lib/pages_core.rb +7 -4
  180. data/lib/rails/generators/pages_core/frontend/frontend_generator.rb +2 -2
  181. data/lib/rails/generators/pages_core/frontend/templates/application.html.erb +13 -5
  182. data/lib/rails/generators/pages_core/frontend/templates/postcss.config.js +2 -6
  183. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/components/base.css +3 -1
  184. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/config.css +2 -3
  185. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/animation.css +1 -1
  186. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/colors.css +6 -5
  187. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/fonts.css +1 -1
  188. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/grid.css +9 -6
  189. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.css +42 -26
  190. data/lib/rails/generators/pages_core/install/templates/application_controller.rb +0 -6
  191. data/lib/rails/generators/pages_core/rspec/templates/rails_helper.rb +1 -1
  192. metadata +81 -49
  193. data/app/assets/builds/fonts/7b7db107.woff2 +0 -0
  194. data/app/assets/builds/fonts/921961e9.woff2 +0 -0
  195. data/app/controller_dummies/admin/admin_controller.rb +0 -6
  196. data/app/controller_dummies/application_controller.rb +0 -6
  197. data/app/controller_dummies/attachments_controller.rb +0 -4
  198. data/app/controller_dummies/frontend_controller.rb +0 -4
  199. data/app/controller_dummies/images_controller.rb +0 -4
  200. data/app/controller_dummies/page_files_controller.rb +0 -4
  201. data/app/controller_dummies/pages_controller.rb +0 -4
  202. data/app/controller_dummies/sitemaps_controller.rb +0 -4
  203. data/app/controllers/concerns/pages_core/preview_pages_controller.rb +0 -47
  204. data/app/controllers/concerns/pages_core/rss_controller.rb +0 -41
  205. data/app/controllers/pages_core/attachments_controller.rb +0 -42
  206. data/app/controllers/pages_core/frontend/page_files_controller.rb +0 -25
  207. data/app/controllers/pages_core/images_controller.rb +0 -15
  208. data/app/helpers/pages_core/meta_tags_helper.rb +0 -96
  209. data/app/helpers/pages_core/open_graph_tags_helper.rb +0 -49
  210. data/app/javascript/components/PageTree/Draggable.tsx +0 -338
  211. data/app/javascript/lib/Tree.ts +0 -305
  212. data/app/javascript/types/Trees.ts +0 -19
  213. data/app/views/sitemaps/show.xml.builder +0 -11
@@ -1,8 +1,8 @@
1
- import React, { DragEvent, useEffect, useRef } from "react";
1
+ import { DragEvent, useEffect, useRef } from "react";
2
2
 
3
3
  import * as Drag from "../../types/Drag";
4
4
 
5
- export default function useDraggable<T = Drag.DraggableRecord>(
5
+ export default function useDraggable<T>(
6
6
  draggable: Drag.Draggable<T>,
7
7
  startDrag: (evt: React.MouseEvent, draggable: Drag.Draggable<T>) => void
8
8
  ) {
@@ -16,7 +16,7 @@ export default function useDraggable<T = Drag.DraggableRecord>(
16
16
 
17
17
  useEffect(() => {
18
18
  draggable.ref.current = ref.current;
19
- }, []);
19
+ }, [draggable.ref]);
20
20
 
21
21
  return { ref: ref, onDragStart: handleDrag, draggable: true };
22
22
  }
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { createRoot } from "react-dom/client";
3
2
  import RichTextArea from "../components/RichTextArea";
4
3
  import readyHandler from "../lib/readyHandler";
@@ -1,8 +1,8 @@
1
1
  import readyHandler from "../lib/readyHandler";
2
2
 
3
- interface WindowState {
3
+ type WindowState = {
4
4
  tabId: string;
5
- }
5
+ };
6
6
 
7
7
  function applyTabs() {
8
8
  const tabLinks: HTMLAnchorElement[] = Array.from(
@@ -1,6 +1,6 @@
1
1
  import { create } from "zustand";
2
2
 
3
- interface ModalState {
3
+ type ModalState = {
4
4
  component: JSX.Element | null;
5
5
  open: (elem: JSX.Element) => void;
6
6
  close: () => void;
@@ -1,11 +1,11 @@
1
1
  import { create } from "zustand";
2
2
 
3
- interface Toast {
3
+ type Toast = {
4
4
  type: string;
5
5
  message: string;
6
6
  }
7
7
 
8
- interface ToastState {
8
+ type ToastState = {
9
9
  toasts: Toast[];
10
10
  error: (msg: string) => void;
11
11
  notice: (msg: string) => void;
@@ -1,30 +1,30 @@
1
1
  import * as Drag from "./Drag";
2
2
  import { Locale, LocalizedValue } from "../types";
3
3
 
4
- export interface Resource {
5
- id: number | null;
4
+ export type Resource = {
5
+ id?: number;
6
6
  name: LocalizedValue;
7
- description: LocalizedValue;
8
- url: string;
9
7
  filename: string;
10
- }
8
+ description?: LocalizedValue;
9
+ url?: string;
10
+ };
11
11
 
12
- export interface Record extends Drag.DraggableRecord {
12
+ export type Record = {
13
13
  id?: number;
14
14
  attachment: Resource;
15
15
  uploading?: boolean;
16
- }
16
+ };
17
17
 
18
- export interface Options {
18
+ export type Options = {
19
19
  attribute: string;
20
20
  locale: string;
21
21
  locales: { [index: string]: Locale };
22
22
  showEmbed: boolean;
23
- }
23
+ };
24
24
 
25
- export interface State {
25
+ export type State = {
26
26
  collection: Drag.Collection<Record>;
27
27
  deleted: Record[];
28
28
  setDeleted: (records: Record[]) => void;
29
29
  update: (records: Record[]) => void;
30
- }
30
+ };
@@ -1,36 +1,40 @@
1
1
  import * as Images from "./Images";
2
2
 
3
- export interface Position {
3
+ export type Position = {
4
4
  x: number;
5
5
  y: number;
6
- }
6
+ };
7
7
 
8
- export interface Size {
8
+ export type Ratio = number | null;
9
+
10
+ export type Size = {
9
11
  width: number;
10
12
  height: number;
11
- }
13
+ };
12
14
 
13
- export interface Params {
15
+ export type Params = {
14
16
  crop_start_x: number;
15
17
  crop_start_y: number;
16
18
  crop_width: number;
17
19
  crop_height: number;
18
20
  crop_gravity_x: number;
19
21
  crop_gravity_y: number;
20
- }
22
+ };
21
23
 
22
- export interface State extends Params {
24
+ export type State = Params & {
23
25
  aspect: number | null;
24
26
  cropping: boolean;
25
27
  image: Images.Resource;
26
- }
28
+ focalPoint?: Position;
29
+ };
27
30
 
28
- export interface CropSize extends Position, Size {
29
- aspect?: number;
30
- }
31
+ export type CropSize = Position &
32
+ Size & {
33
+ aspect?: number;
34
+ };
31
35
 
32
36
  export type Action =
33
37
  | { type: "completeCrop" | "startCrop" | "toggleFocal" }
34
38
  | { type: "setCrop"; payload: CropSize }
35
- | { type: "setAspect"; payload: number }
39
+ | { type: "setAspect"; payload: Ratio }
36
40
  | { type: "setFocal"; payload: Position };
@@ -1,35 +1,33 @@
1
- export type DraggableRecord = Record<string, unknown>;
2
-
3
- export interface Draggable<T = DraggableRecord> {
1
+ export type Draggable<T> = {
4
2
  record: T;
5
3
  ref: React.MutableRefObject<HTMLDivElement>;
6
4
  rect: DOMRect | null;
7
5
  handle: string;
8
- }
6
+ };
9
7
 
10
- export type Item<T = DraggableRecord> = Draggable<T> | "Files";
8
+ export type DraggableOrFiles<T> = Draggable<T> | "Files";
11
9
 
12
- export type CollectionAction<T = DraggableRecord> =
13
- | {
14
- type: "append" | "prepend" | "insertFiles" | "replace" | "reorder";
15
- payload: Item<T>[];
16
- }
17
- | { type: "update"; payload: Item<T> }
10
+ export type CollectionAction<T> =
11
+ | { type: "append" | "insertFiles" | "replace"; payload: Draggable<T>[] }
12
+ | { type: "prepend" | "reorder"; payload: DraggableOrFiles<T>[] }
13
+ | { type: "update"; payload: Draggable<T> }
18
14
  | { type: "reinitialize"; payload: Array<T> }
19
15
  | { type: "remove"; payload: Draggable<T> }
20
- | { type: "updatePositions"; payload?: Draggable<T> };
16
+ | { type: "updatePositions"; payload?: DraggableOrFiles<T> };
21
17
 
22
- export interface Collection<T = DraggableRecord> {
18
+ export type Collection<T> = {
23
19
  ref: React.MutableRefObject<HTMLDivElement>;
24
- draggables: Item<T>[];
25
- dispatch: (CollectionAction) => void;
26
- }
20
+ draggables: DraggableOrFiles<T>[];
21
+ dispatch: React.Dispatch<CollectionAction<T>>;
22
+ };
27
23
 
28
- export interface Position {
29
- x: number | null;
30
- y: number | null;
31
- }
24
+ export type Position = {
25
+ x: number;
26
+ y: number;
27
+ };
32
28
 
33
- export interface State<T = DraggableRecord> extends Position {
34
- dragging: Item<T> | false;
35
- }
29
+ export type State<T> = {
30
+ dragging: DraggableOrFiles<T> | false;
31
+ x?: number;
32
+ y?: number;
33
+ };
@@ -1,7 +1,7 @@
1
1
  import * as Drag from "./Drag";
2
2
  import { Locale, LocalizedValue } from "../types";
3
3
 
4
- export interface Resource {
4
+ export type Resource = {
5
5
  id: number | null;
6
6
  alternative: LocalizedValue;
7
7
  caption: LocalizedValue;
@@ -18,31 +18,31 @@ export interface Resource {
18
18
  original_url: string;
19
19
  thumbnail_url: string;
20
20
  uncropped_url: string;
21
- }
21
+ };
22
22
 
23
- export interface Record extends Drag.DraggableRecord {
23
+ export type Record = {
24
24
  id?: number;
25
25
  image: Resource;
26
26
  primary?: boolean;
27
27
  src?: string;
28
28
  file?: File;
29
- }
29
+ };
30
30
 
31
31
  export type Response = Resource | { status: "error"; error: string };
32
32
 
33
- export interface GridOptions {
33
+ export type GridOptions = {
34
34
  attribute: string;
35
35
  enablePrimary: boolean;
36
36
  locale: string;
37
37
  locales: { [index: string]: Locale };
38
38
  primaryAttribute: string;
39
39
  showEmbed: boolean;
40
- }
40
+ };
41
41
 
42
- export interface GridState {
42
+ export type GridState = {
43
43
  primary: Drag.Collection<Record>;
44
44
  images: Drag.Collection<Record>;
45
45
  deleted: Record[];
46
46
  setDeleted: (records: Record[]) => void;
47
47
  update: (records: Record[]) => void;
48
- }
48
+ };
@@ -9,7 +9,7 @@ export type Action =
9
9
  | { type: "update"; payload: Partial<Pages.Resource> }
10
10
  | { type: "updateBlocks"; payload: Partial<Pages.Blocks> };
11
11
 
12
- export interface State<T = Pages.Resource> {
12
+ export type State<T = Pages.Resource> = {
13
13
  locale: string;
14
14
  locales: { [index: string]: Locale };
15
15
  page: T;
@@ -17,10 +17,17 @@ export interface State<T = Pages.Resource> {
17
17
  datesEnabled?: boolean;
18
18
  inputDir?: "ltr" | "rtl";
19
19
  templateConfig?: Template.Config;
20
- }
20
+ };
21
21
 
22
- export interface Tab {
22
+ export type Tab = {
23
23
  id: string;
24
24
  name: string;
25
25
  enabled: boolean;
26
- }
26
+ };
27
+
28
+ export type Return = [State, React.Dispatch<Action>];
29
+
30
+ export type Context = {
31
+ state: State;
32
+ dispatch: React.Dispatch<Action>;
33
+ };
@@ -1,21 +1,20 @@
1
1
  import * as Attachments from "./Attachments";
2
2
  import * as Images from "./Images";
3
- import * as Trees from "./Trees";
4
3
  import { LocalizedValue, MaybeLocalizedValue } from "../types";
5
4
 
6
5
  export type Author = [name: string, id: number];
7
6
 
8
- export interface Ancestor {
7
+ export type Ancestor = {
9
8
  id: number;
10
9
  name: LocalizedValue;
11
10
  path_segment: LocalizedValue;
12
- }
11
+ };
13
12
 
14
- export interface StatusLabels {
13
+ export type StatusLabels = {
15
14
  [index: number]: string;
16
- }
15
+ };
17
16
 
18
- export interface TreeResource {
17
+ type BaseResource = {
19
18
  id?: number;
20
19
  blocks: Blocks;
21
20
  news_page: boolean;
@@ -24,22 +23,25 @@ export interface TreeResource {
24
23
  pinned: boolean;
25
24
  published_at: Date;
26
25
  status: number;
27
- }
26
+ };
28
27
 
29
- export interface Blocks {
28
+ export type TreeResource = BaseResource & {
29
+ editing?: boolean;
30
+ };
31
+
32
+ export type Blocks = {
30
33
  [index: string]: MaybeLocalizedValue;
31
34
  name: LocalizedValue;
32
- }
35
+ };
33
36
 
34
- export interface MetaImage {
37
+ export type MetaImage = {
35
38
  src?: string;
36
39
  image?: Images.Resource;
37
- }
40
+ };
38
41
 
39
- export interface Resource extends TreeResource {
42
+ export type Resource = BaseResource & {
40
43
  all_day: boolean;
41
44
  ancestors: Ancestor[];
42
- blocks: Blocks;
43
45
  enabled_tags: string[];
44
46
  ends_at: Date;
45
47
  errors: { attribute: string; message: string }[];
@@ -49,27 +51,20 @@ export interface Resource extends TreeResource {
49
51
  page_images: Images.Record[];
50
52
  path_segment: MaybeLocalizedValue;
51
53
  redirect_to: string;
54
+ skip_index: boolean;
52
55
  starts_at: Date;
53
56
  tags_and_suggestions: string[];
54
57
  template: string;
55
58
  unique_name: string;
56
59
  urls: LocalizedValue;
57
60
  user_id: number;
58
- }
61
+ };
59
62
 
60
- export interface SerializedResource
61
- extends Omit<Resource, "published_at" | "starts_at" | "ends_at"> {
63
+ export type SerializedResource = Omit<
64
+ Resource,
65
+ "published_at" | "starts_at" | "ends_at"
66
+ > & {
62
67
  published_at: string;
63
68
  starts_at: string;
64
69
  ends_at: string;
65
- }
66
-
67
- export interface TreeItem extends Partial<TreeResource> {
68
- blocks: Blocks;
69
- editing?: boolean;
70
- permissions?: string[];
71
- }
72
-
73
- export interface TreeNode extends TreeItem, Trees.Node {
74
- children: TreeNode[];
75
- }
70
+ };
@@ -1,9 +1,8 @@
1
- export interface Action {
2
- type: "addTag" | "toggleTag";
3
- payload: string;
4
- }
1
+ export type Action =
2
+ | { type: "addTag" | "toggleTag"; payload: string }
3
+ | { type: "update"; payload: State };
5
4
 
6
- export interface State {
5
+ export type State = {
7
6
  enabled: string[];
8
7
  tags: string[];
9
- }
8
+ };
@@ -1,4 +1,4 @@
1
- export interface Block {
1
+ export type Block = {
2
2
  name: string;
3
3
  title: string;
4
4
  description?: string;
@@ -10,9 +10,9 @@ export interface Block {
10
10
  placeholder?: string;
11
11
  options?: [string, string][];
12
12
  type?: string;
13
- }
13
+ };
14
14
 
15
- export interface Config {
15
+ export type Config = {
16
16
  name: string;
17
17
  template_name: string;
18
18
  blocks: Block[];
@@ -21,4 +21,4 @@ export interface Config {
21
21
  dates: boolean;
22
22
  tags: boolean;
23
23
  files: boolean;
24
- }
24
+ };
@@ -1,7 +1,7 @@
1
- export interface Locale {
1
+ export type Locale = {
2
2
  name: string;
3
3
  dir: "ltr" | "rtl";
4
- }
4
+ };
5
5
 
6
6
  export type LocalizedValue = Record<string, string>;
7
7
  export type MaybeLocalizedValue = LocalizedValue | string;
@@ -26,15 +26,13 @@ class Attachment < ApplicationRecord
26
26
  end
27
27
 
28
28
  def formats
29
- {
30
- "audio/mpeg" => :mp3,
29
+ { "audio/mpeg" => :mp3,
31
30
  "image/gif" => :gif,
32
31
  "image/jpeg" => :jpg,
33
32
  "image/jpg" => :jpg,
34
33
  "image/pjpeg" => :jpg,
35
34
  "image/png" => :png,
36
- "application/pdf" => :pdf
37
- }
35
+ "application/pdf" => :pdf }
38
36
  end
39
37
  end
40
38
 
@@ -53,11 +51,9 @@ class Attachment < ApplicationRecord
53
51
  end
54
52
 
55
53
  def filename_extension
56
- if filename_extension?
57
- filename.match(/\.([^.]+)$/)[1]
58
- else
59
- ""
60
- end
54
+ return "" unless filename_extension?
55
+
56
+ filename.match(/\.([^.]+)$/)[1]
61
57
  end
62
58
 
63
59
  def filename_extension?
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Autopublisher
4
4
  class << self
5
- def run!(_options = {})
5
+ def run!
6
6
  if due_pages.any?
7
7
  PagesCore::CacheSweeper.once do
8
8
  due_pages.each do |p|
@@ -9,8 +9,7 @@ module PagesCore
9
9
 
10
10
  included do
11
11
  validates(:redirect_to,
12
- format: { with: %r{\A(/|https?://).+\z},
13
- allow_blank: true })
12
+ format: { with: %r{\A(/|https?://).+\z}, allow_blank: true })
14
13
  end
15
14
 
16
15
  # Returns boolean true if page has a valid redirect
@@ -7,7 +7,7 @@ module PagesCore
7
7
 
8
8
  def search_document_attributes
9
9
  super.merge(
10
- published: published?,
10
+ published: published? && !skip_index?,
11
11
  name:,
12
12
  description: try(&:meta_description?) ? meta_description : excerpt,
13
13
  # content: "",
@@ -7,13 +7,11 @@ module PagesCore
7
7
 
8
8
  module ClassMethods
9
9
  def status_labels
10
- {
11
- 0 => "Draft",
10
+ { 0 => "Draft",
12
11
  1 => "Reviewed",
13
12
  2 => "Published",
14
13
  3 => "Hidden",
15
- 4 => "Deleted"
16
- }
14
+ 4 => "Deleted" }
17
15
  end
18
16
  end
19
17
 
@@ -26,10 +26,8 @@ module PagesCore
26
26
  SearchDocument.transaction do
27
27
  record.search_documents.where.not(locale: locales).destroy_all
28
28
  locales.each do |locale|
29
- update_index(
30
- locale,
31
- localized_record(locale).search_document_attributes
32
- )
29
+ update_index(locale,
30
+ localized_record(locale).search_document_attributes)
33
31
  end
34
32
  end
35
33
  end
data/app/models/image.rb CHANGED
@@ -11,21 +11,6 @@ class Image < ApplicationRecord
11
11
  attribute :caption
12
12
  end
13
13
 
14
- def byline
15
- ActiveSupport::Deprecation.warn "Image#byline is deprecated, use #caption"
16
- caption
17
- end
18
-
19
- def byline?
20
- ActiveSupport::Deprecation.warn "Image#byline? is deprecated, use #caption?"
21
- caption?
22
- end
23
-
24
- def byline=(new_caption)
25
- ActiveSupport::Deprecation.warn "Image#byline= is deprecated, use #caption="
26
- self.caption = new_caption
27
- end
28
-
29
14
  private
30
15
 
31
16
  def ensure_max_size
@@ -18,9 +18,9 @@ class PageBuilder
18
18
  attr_reader :user, :locale, :parent
19
19
 
20
20
  class << self
21
- def build(user, locale: nil, parent: nil, &block)
21
+ def build(user, locale: nil, parent: nil, &)
22
22
  new(user, locale:, parent:)
23
- .run(&block)
23
+ .run(&)
24
24
  end
25
25
  end
26
26
 
@@ -49,11 +49,9 @@ class PageBuilder
49
49
  private
50
50
 
51
51
  def default_options
52
- {
53
- author: user,
52
+ { author: user,
54
53
  parent:,
55
54
  status: 2,
56
- locale:
57
- }
55
+ locale: }
58
56
  end
59
57
  end
@@ -9,7 +9,7 @@ module Admin
9
9
 
10
10
  attributes :id, :starts_at, :ends_at, :all_day, :status, :published_at,
11
11
  :pinned, :template, :unique_name, :feed_enabled, :news_page,
12
- :parent_page_id, :user_id, :redirect_to
12
+ :parent_page_id, :user_id, :redirect_to, :skip_index
13
13
 
14
14
  has_many :page_images, resource: Admin::PageImageResource
15
15
  has_many :page_files, resource: Admin::PageFileResource
@@ -79,7 +79,7 @@ module Admin
79
79
  return { src: nil, image: nil } unless image
80
80
 
81
81
  { src: dynamic_image_path(image, size: "500x"),
82
- image: ::Admin::ImageResource.new(image).to_hash }
82
+ image: ::Admin::ImageResource.new(image).to_h }
83
83
  end
84
84
 
85
85
  def localized_objects
@@ -7,7 +7,7 @@ module Export
7
7
  attributes :id, :locale
8
8
  attributes(*PagesCore::Templates::TemplateConfiguration.all_blocks)
9
9
  attributes :created_at, :published_at, :pinned, :template, :redirect_to,
10
- :starts_at, :ends_at, :all_day
10
+ :starts_at, :ends_at, :all_day, :skip_index
11
11
 
12
12
  has_many :attachments, resource: Export::AttachmentResource
13
13
 
@@ -35,8 +35,7 @@ module PagesCore
35
35
  def deliver_invite(invite)
36
36
  AdminMailer.invite(
37
37
  invite,
38
- admin_invite_with_token_url(invite, invite.token,
39
- host:, protocol:)
38
+ admin_invite_with_token_url(invite, invite.token, host:, protocol:)
40
39
  ).deliver_later
41
40
  end
42
41
  end
@@ -29,6 +29,7 @@
29
29
  <% end %>
30
30
 
31
31
  <%= csrf_meta_tag %>
32
+ <%= csp_meta_tag %>
32
33
  <meta name="viewport"
33
34
  content="width=device-width, initial-scale=1, user-scalable=no">
34
35
  </head>
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.instruct!
4
+ xml.sitemapindex xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" do |index|
5
+ @sitemaps.each do |url|
6
+ index.sitemap do |sitemap|
7
+ sitemap.loc(url)
8
+ end
9
+ end
10
+ end
data/config/routes.rb CHANGED
@@ -19,7 +19,6 @@ Rails.application.routes.draw do
19
19
  post "search"
20
20
  post "preview"
21
21
  end
22
- resources :files, controller: "page_files"
23
22
  end
24
23
 
25
24
  get "/:locale/pages/:id/:page" => "pages#show",
@@ -31,8 +30,10 @@ Rails.application.routes.draw do
31
30
  get "pages/:locale/*glob" => redirect("/%{locale}/pages/%{glob}"),
32
31
  locale: /\w\w\w/
33
32
 
34
- # Sitemap
35
- resource :sitemap, only: [:show]
33
+ # Sitemaps
34
+ get("sitemap" => "pages_core/sitemaps#index", as: :sitemap_index)
35
+ get("/sitemap-pages-:locale" => "pages_core/sitemaps#pages",
36
+ as: :pages_sitemap)
36
37
 
37
38
  namespace :admin do
38
39
  get "users/login" => redirect("/admin/login")