pages_core 3.8.0 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +37 -0
- data/app/assets/builds/pages_core/admin-dist.js +11 -11
- data/app/controllers/admin/images_controller.rb +1 -1
- data/app/javascript/components/Attachments/Attachment.jsx +2 -2
- data/app/javascript/components/Attachments/AttachmentEditor.jsx +2 -2
- data/app/javascript/components/EditableImage.jsx +1 -1
- data/app/javascript/components/FileUploadButton.jsx +27 -34
- data/app/javascript/components/ImageEditor/Form.jsx +2 -2
- data/app/javascript/components/ImageEditor.jsx +1 -1
- data/app/javascript/components/ImageGrid/GridImage.jsx +1 -1
- data/app/javascript/components/ImageGrid.jsx +1 -1
- data/app/javascript/components/ImageUploader.jsx +1 -1
- data/app/javascript/components/Modal.jsx +1 -1
- data/app/javascript/components/Toast.jsx +1 -1
- data/app/javascript/components.js +1 -0
- data/app/javascript/index.js +5 -0
- data/app/javascript/{components → stores}/ModalStore.jsx +0 -0
- data/app/javascript/{components → stores}/ToastStore.jsx +0 -0
- data/app/javascript/stores.js +2 -0
- data/app/models/role.rb +6 -16
- data/lib/pages_core/cache_sweeper.rb +0 -9
- data/lib/pages_core/configuration/base.rb +3 -1
- data/lib/pages_core/pub_sub.rb +1 -2
- data/lib/pages_core/version.rb +3 -1
- metadata +20 -5
@@ -2,8 +2,8 @@ import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
3
3
|
import copyToClipboard from "../../lib/copyToClipboard";
|
4
4
|
import AttachmentEditor from "./AttachmentEditor";
|
5
|
-
import ModalStore from "
|
6
|
-
import ToastStore from "
|
5
|
+
import ModalStore from "../../stores/ModalStore";
|
6
|
+
import ToastStore from "../../stores/ToastStore";
|
7
7
|
|
8
8
|
import { useDraggable } from "../drag";
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
2
|
import PropTypes from "prop-types";
|
3
3
|
import copyToClipboard, { copySupported } from "../../lib/copyToClipboard";
|
4
|
-
import ModalStore from "
|
5
|
-
import ToastStore from "
|
4
|
+
import ModalStore from "../../stores/ModalStore";
|
5
|
+
import ToastStore from "../../stores/ToastStore";
|
6
6
|
import { putJson } from "../../lib/request";
|
7
7
|
|
8
8
|
export default function AttachmentEditor(props) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
2
|
import PropTypes from "prop-types";
|
3
3
|
import ImageEditor from "./ImageEditor";
|
4
|
-
import ModalStore from "
|
4
|
+
import ModalStore from "../stores/ModalStore";
|
5
5
|
|
6
6
|
export default function EditableImage(props) {
|
7
7
|
const [image, setImage] = useState(props.image);
|
@@ -1,49 +1,42 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { useRef } from "react";
|
2
2
|
import PropTypes from "prop-types";
|
3
3
|
|
4
|
-
export default
|
5
|
-
|
6
|
-
super(props);
|
7
|
-
this.inputRef = React.createRef();
|
8
|
-
this.handleChange = this.handleChange.bind(this);
|
9
|
-
this.triggerDialog = this.triggerDialog.bind(this);
|
10
|
-
}
|
4
|
+
export default function FileUploadButton(props) {
|
5
|
+
const inputRef = useRef();
|
11
6
|
|
12
|
-
handleChange(evt) {
|
7
|
+
const handleChange = (evt) => {
|
13
8
|
let fileList = evt.target.files;
|
14
9
|
let files = [];
|
15
10
|
for (var i = 0; i < fileList.length; i++) {
|
16
11
|
files.push(fileList[i]);
|
17
12
|
}
|
18
13
|
if (files.length > 0) {
|
19
|
-
|
14
|
+
props.callback(files);
|
20
15
|
}
|
21
|
-
}
|
16
|
+
};
|
22
17
|
|
23
|
-
|
24
|
-
return (
|
25
|
-
<div className="upload-button">
|
26
|
-
<span>
|
27
|
-
Drag and drop {this.props.type || "file"}
|
28
|
-
{this.props.multiple && "s"} here, or
|
29
|
-
{this.props.multiline && <br />}
|
30
|
-
<button onClick={this.triggerDialog}>
|
31
|
-
choose a file
|
32
|
-
</button>
|
33
|
-
</span>
|
34
|
-
<input type="file"
|
35
|
-
onChange={this.handleChange}
|
36
|
-
ref={this.inputRef}
|
37
|
-
style={{ display: "none" }}
|
38
|
-
multiple={this.props.multiple || false} />
|
39
|
-
</div>
|
40
|
-
);
|
41
|
-
}
|
42
|
-
|
43
|
-
triggerDialog(evt) {
|
18
|
+
const triggerDialog = (evt) => {
|
44
19
|
evt.preventDefault();
|
45
|
-
|
46
|
-
}
|
20
|
+
inputRef.current.click();
|
21
|
+
};
|
22
|
+
|
23
|
+
return (
|
24
|
+
<div className="upload-button">
|
25
|
+
<span>
|
26
|
+
Drag and drop {props.type || "file"}
|
27
|
+
{props.multiple && "s"} here, or
|
28
|
+
{props.multiline && <br />}
|
29
|
+
<button onClick={triggerDialog}>
|
30
|
+
choose a file
|
31
|
+
</button>
|
32
|
+
</span>
|
33
|
+
<input type="file"
|
34
|
+
onChange={handleChange}
|
35
|
+
ref={inputRef}
|
36
|
+
style={{ display: "none" }}
|
37
|
+
multiple={props.multiple || false} />
|
38
|
+
</div>
|
39
|
+
);
|
47
40
|
}
|
48
41
|
|
49
42
|
FileUploadButton.propTypes = {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import PropTypes from "prop-types";
|
3
|
-
import ModalStore from "
|
4
|
-
import ToastStore from "
|
3
|
+
import ModalStore from "../../stores/ModalStore";
|
4
|
+
import ToastStore from "../../stores/ToastStore";
|
5
5
|
import copyToClipboard, { copySupported } from "../../lib/copyToClipboard";
|
6
6
|
|
7
7
|
export default function Form(props) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
2
|
import PropTypes from "prop-types";
|
3
|
-
import ModalStore from "
|
3
|
+
import ModalStore from "../stores/ModalStore";
|
4
4
|
import { putJson } from "../lib/request";
|
5
5
|
|
6
6
|
import ImageCropper, { useCrop, cropParams } from "./ImageCropper";
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
3
3
|
import copyToClipboard from "../../lib/copyToClipboard";
|
4
4
|
import EditableImage from "../EditableImage";
|
5
|
-
import ToastStore from "
|
5
|
+
import ToastStore from "../../stores/ToastStore";
|
6
6
|
import Placeholder from "./Placeholder";
|
7
7
|
|
8
8
|
import { useDraggable } from "../drag";
|
@@ -4,7 +4,7 @@ import FileUploadButton from "./FileUploadButton";
|
|
4
4
|
import DragElement from "./ImageGrid/DragElement";
|
5
5
|
import FilePlaceholder from "./ImageGrid/FilePlaceholder";
|
6
6
|
import GridImage from "./ImageGrid/GridImage";
|
7
|
-
import ToastStore from "
|
7
|
+
import ToastStore from "../stores/ToastStore";
|
8
8
|
import { post } from "../lib/request";
|
9
9
|
|
10
10
|
import { createDraggable,
|
@@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
3
3
|
import EditableImage from "./EditableImage";
|
4
4
|
import FileUploadButton from "./FileUploadButton";
|
5
|
-
import ToastStore from "
|
5
|
+
import ToastStore from "../stores/ToastStore";
|
6
6
|
import { post } from "../lib/request";
|
7
7
|
|
8
8
|
function getFiles(dt) {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export { default as Attachments } from "./components/Attachments";
|
2
2
|
export { default as DateRangeSelect } from "./components/DateRangeSelect";
|
3
3
|
export { default as EditableImage } from "./components/EditableImage";
|
4
|
+
export { default as FileUploadButton } from "./components/FileUploadButton";
|
4
5
|
export { default as ImageCropper } from "./components/ImageCropper";
|
5
6
|
export { default as ImageGrid } from "./components/ImageGrid";
|
6
7
|
export { default as ImageUploader } from "./components/ImageUploader";
|
data/app/javascript/index.js
CHANGED
File without changes
|
File without changes
|
data/app/models/role.rb
CHANGED
@@ -7,17 +7,15 @@ class Role < ApplicationRecord
|
|
7
7
|
uniqueness: { scope: :user_id },
|
8
8
|
inclusion: { in: proc { Role.roles.map(&:name) } }
|
9
9
|
|
10
|
+
RoleDefinition = Struct.new(:name, :description, :default)
|
11
|
+
|
10
12
|
class << self
|
11
13
|
def define(name, description, default: false)
|
12
14
|
if roles.map(&:name).include?(name.to_s)
|
13
15
|
raise ArgumentError, "Tried to define role :#{role}, " \
|
14
16
|
"but a role by that name already exists"
|
15
17
|
else
|
16
|
-
roles <<
|
17
|
-
name: name.to_s,
|
18
|
-
description: description,
|
19
|
-
default: default
|
20
|
-
)
|
18
|
+
roles << RoleDefinition.new(name.to_s, description, default)
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -39,21 +37,13 @@ class Role < ApplicationRecord
|
|
39
37
|
return [] unless File.exist?(config_file)
|
40
38
|
|
41
39
|
YAML.load_file(config_file).map do |key, opts|
|
42
|
-
|
43
|
-
description: opts["description"],
|
44
|
-
default: opts["default"])
|
40
|
+
RoleDefinition.new(key.to_s, opts["description"], opts["default"])
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
44
|
def default_roles
|
49
|
-
[
|
50
|
-
|
51
|
-
name: "users", description: "Can manage users", default: false
|
52
|
-
),
|
53
|
-
OpenStruct.new(
|
54
|
-
name: "pages", description: "Can manage pages", default: true
|
55
|
-
)
|
56
|
-
]
|
45
|
+
[RoleDefinition.new("users", "Can manage users", false),
|
46
|
+
RoleDefinition.new("pages", "Can manage pages", true)]
|
57
47
|
end
|
58
48
|
end
|
59
49
|
|
@@ -16,15 +16,6 @@ module PagesCore
|
|
16
16
|
disable(&block)
|
17
17
|
PagesCore::StaticCache.handler.sweep!
|
18
18
|
end
|
19
|
-
|
20
|
-
def config
|
21
|
-
ActiveSupport::Deprecation.warn(
|
22
|
-
"PagesCore::CacheSweeper.config is no longer used."
|
23
|
-
)
|
24
|
-
configuration = OpenStruct.new(patterns: [])
|
25
|
-
yield configuration if block_given?
|
26
|
-
configuration
|
27
|
-
end
|
28
19
|
end
|
29
20
|
|
30
21
|
self.enabled ||= true
|
@@ -5,12 +5,14 @@ module PagesCore
|
|
5
5
|
class Base
|
6
6
|
class InvalidConfigurationKey < StandardError; end
|
7
7
|
|
8
|
+
SettingStruct = Struct.new(:type, :default)
|
9
|
+
|
8
10
|
def self.settings
|
9
11
|
@settings ||= {}
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.setting(key, type, default = nil)
|
13
|
-
settings[key] =
|
15
|
+
settings[key] = SettingStruct.new(type, default)
|
14
16
|
|
15
17
|
define_method key do |*args|
|
16
18
|
args.any? ? set(key, *args) : get(key)
|
data/lib/pages_core/pub_sub.rb
CHANGED
@@ -4,9 +4,8 @@ module PagesCore
|
|
4
4
|
module PubSub
|
5
5
|
class << self
|
6
6
|
def publish(name, payload = {})
|
7
|
-
payload_struct = OpenStruct.new(payload)
|
8
7
|
subscribers.select { |s| s.name == name }
|
9
|
-
.each { |s| s.call(
|
8
|
+
.each { |s| s.call(payload) }
|
10
9
|
end
|
11
10
|
|
12
11
|
def subscribe(name, &block)
|
data/lib/pages_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pages_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 3.8.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: semantic
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: shoulda-matchers
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -621,7 +635,6 @@ files:
|
|
621
635
|
- app/javascript/components/ImageGrid/Placeholder.jsx
|
622
636
|
- app/javascript/components/ImageUploader.jsx
|
623
637
|
- app/javascript/components/Modal.jsx
|
624
|
-
- app/javascript/components/ModalStore.jsx
|
625
638
|
- app/javascript/components/PageDates.jsx
|
626
639
|
- app/javascript/components/PageFiles.jsx
|
627
640
|
- app/javascript/components/PageImages.jsx
|
@@ -634,7 +647,6 @@ files:
|
|
634
647
|
- app/javascript/components/TagEditor/AddTagForm.jsx
|
635
648
|
- app/javascript/components/TagEditor/Tag.jsx
|
636
649
|
- app/javascript/components/Toast.jsx
|
637
|
-
- app/javascript/components/ToastStore.jsx
|
638
650
|
- app/javascript/components/drag.js
|
639
651
|
- app/javascript/components/drag/draggedOrder.js
|
640
652
|
- app/javascript/components/drag/useDragCollection.js
|
@@ -651,6 +663,9 @@ files:
|
|
651
663
|
- app/javascript/lib/copyToClipboard.js
|
652
664
|
- app/javascript/lib/readyHandler.js
|
653
665
|
- app/javascript/lib/request.js
|
666
|
+
- app/javascript/stores.js
|
667
|
+
- app/javascript/stores/ModalStore.jsx
|
668
|
+
- app/javascript/stores/ToastStore.jsx
|
654
669
|
- app/jobs/pages_core/autopublish_job.rb
|
655
670
|
- app/jobs/pages_core/sweep_cache_job.rb
|
656
671
|
- app/mailers/admin_mailer.rb
|
@@ -833,7 +848,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
833
848
|
- !ruby/object:Gem::Version
|
834
849
|
version: '0'
|
835
850
|
requirements: []
|
836
|
-
rubygems_version: 3.2.
|
851
|
+
rubygems_version: 3.2.32
|
837
852
|
signing_key:
|
838
853
|
specification_version: 4
|
839
854
|
summary: Pages Core
|