trek 0.1.11 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3358d8b92a863e10db5e015d6747fc1973249b9cf266f245bcee6fea5e11ada2
4
- data.tar.gz: 84b609db2a23b60cd98868334cbf59142a1581b72e1d20c3088f342b80daa539
3
+ metadata.gz: bcca487a933ebe86ba5e95e8d6ef7bd786ffa4a96e8d8155f0898cd387109cee
4
+ data.tar.gz: 188f713348ecee4568fff807d15b8d6bf92ec01c875e6a59dfbaefbbf7e2f6ec
5
5
  SHA512:
6
- metadata.gz: d38576c0fe0adb84d673cc6ec7d66e2524619d09e1586f70072a3892ca9fe124b7b42d4534100f594588ab5655d218f48b476669b828fcc81bc209510e6b6f84
7
- data.tar.gz: 2247bc4a71af0581c7b9779fda55ff39065566945153852238fc870a13668e7eb77deaa1fcd58eb086818d0ea6933718c26749e90c29d0e35a0ddf8f80a6e0ac
6
+ metadata.gz: e6e77bc0ec3be5cc2127c4c1602bf4134c13808bddae692d9c5412fae283347d5c51a711e9bd205edea305ed9809a7f0d02bfcad14336698ef539be5840ea678
7
+ data.tar.gz: 36a7ac56b65cbe436adb19e3696d1b3724a0ae15daba6eb7c5f1b46ebda6d5d616c8e012eadb551423cfbcb736aee33163e2b3baa2c0c3df95799ecb81eabe61
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trek (0.1.11)
4
+ trek (0.1.12)
5
5
  action_policy (~> 0.6)
6
6
  actioncable
7
7
  acts_as_list (~> 1.1)
@@ -204,7 +204,7 @@ GEM
204
204
  zeitwerk (~> 2.6)
205
205
  erb (6.0.1)
206
206
  erubi (1.13.1)
207
- faraday (2.14.0)
207
+ faraday (2.14.1)
208
208
  faraday-net_http (>= 2.0, < 3.5)
209
209
  json
210
210
  logger
@@ -245,7 +245,7 @@ GEM
245
245
  rdoc (>= 4.0.0)
246
246
  reline (>= 0.4.2)
247
247
  jmespath (1.6.2)
248
- json (2.18.0)
248
+ json (2.18.1)
249
249
  jwt (3.1.2)
250
250
  base64
251
251
  kaminari (1.2.2)
@@ -1,29 +1,29 @@
1
- @import url("@radix-ui/colors/amber.css");
2
- @import url("@radix-ui/colors/amber-dark.css");
3
- @import url("@radix-ui/colors/blue.css");
4
- @import url("@radix-ui/colors/blue-dark.css");
5
- @import url("@radix-ui/colors/cyan.css");
6
- @import url("@radix-ui/colors/cyan-dark.css");
7
- @import url("@radix-ui/colors/grass.css");
8
- @import url("@radix-ui/colors/grass-dark.css");
9
- @import url("@radix-ui/colors/lime.css");
10
- @import url("@radix-ui/colors/lime-dark.css");
11
- @import url("@radix-ui/colors/mint.css");
12
- @import url("@radix-ui/colors/mint-dark.css");
13
- @import url("@radix-ui/colors/purple.css");
14
- @import url("@radix-ui/colors/purple-dark.css");
15
- @import url("@radix-ui/colors/sky.css");
16
- @import url("@radix-ui/colors/sky-dark.css");
17
- @import url("@radix-ui/colors/slate.css");
18
- @import url("@radix-ui/colors/slate-alpha.css");
19
- @import url("@radix-ui/colors/slate-dark.css");
20
- @import url("@radix-ui/colors/slate-dark-alpha.css");
21
- @import url("@radix-ui/colors/teal.css");
22
- @import url("@radix-ui/colors/teal-dark.css");
23
- @import url("@radix-ui/colors/tomato.css");
24
- @import url("@radix-ui/colors/tomato-dark.css");
25
- @import url("@radix-ui/colors/violet.css");
26
- @import url("@radix-ui/colors/violet-dark.css");
1
+ @import "@radix-ui/colors/amber.css";
2
+ @import "@radix-ui/colors/amber-dark.css";
3
+ @import "@radix-ui/colors/blue.css";
4
+ @import "@radix-ui/colors/blue-dark.css";
5
+ @import "@radix-ui/colors/cyan.css";
6
+ @import "@radix-ui/colors/cyan-dark.css";
7
+ @import "@radix-ui/colors/grass.css";
8
+ @import "@radix-ui/colors/grass-dark.css";
9
+ @import "@radix-ui/colors/lime.css";
10
+ @import "@radix-ui/colors/lime-dark.css";
11
+ @import "@radix-ui/colors/mint.css";
12
+ @import "@radix-ui/colors/mint-dark.css";
13
+ @import "@radix-ui/colors/purple.css";
14
+ @import "@radix-ui/colors/purple-dark.css";
15
+ @import "@radix-ui/colors/sky.css";
16
+ @import "@radix-ui/colors/sky-dark.css";
17
+ @import "@radix-ui/colors/slate.css";
18
+ @import "@radix-ui/colors/slate-alpha.css";
19
+ @import "@radix-ui/colors/slate-dark.css";
20
+ @import "@radix-ui/colors/slate-dark-alpha.css";
21
+ @import "@radix-ui/colors/teal.css";
22
+ @import "@radix-ui/colors/teal-dark.css";
23
+ @import "@radix-ui/colors/tomato.css";
24
+ @import "@radix-ui/colors/tomato-dark.css";
25
+ @import "@radix-ui/colors/violet.css";
26
+ @import "@radix-ui/colors/violet-dark.css";
27
27
 
28
28
  :root {
29
29
  --white: #fff;
@@ -142,7 +142,7 @@
142
142
  width: 2rem;
143
143
  }
144
144
 
145
- @svg-load arrow-bar-left url("admin/arrow-bar-left.svg") {
145
+ @svg-load arrow-bar-left url("trek/arrow-bar-left.svg") {
146
146
  }
147
147
 
148
148
  .content-image[data-size="larger"]::before {
@@ -150,7 +150,7 @@
150
150
  margin-right: 1rem;
151
151
  }
152
152
 
153
- @svg-load arrow-bar-right url("admin/arrow-bar-right.svg") {
153
+ @svg-load arrow-bar-right url("trek/arrow-bar-right.svg") {
154
154
  }
155
155
 
156
156
  .content-image[data-size="larger"]::after {
@@ -202,9 +202,9 @@ div(
202
202
  )
203
203
 
204
204
  = form.text_area method_name,
205
- value: content_json,
206
- data: stimulus_target_hash("editorJson"),
207
- style: "display: none"
205
+ value: content_json,
206
+ data: stimulus_target_hash("editorJson"),
207
+ style: "display: none"
208
208
 
209
209
  - if floating
210
210
  div(
@@ -40,7 +40,8 @@ module Trek
40
40
  end
41
41
 
42
42
  def content_json
43
- form.object.public_send(method_name)
43
+ value = form.object.public_send(method_name)
44
+ value.is_a?(Hash) ? value.to_json : value
44
45
  end
45
46
 
46
47
  def turbo_frame_id
@@ -26,6 +26,7 @@
26
26
  border-radius: 0.2rem;
27
27
  color: var(--slate-8);
28
28
  display: flex;
29
+ flex-shrink: 0;
29
30
  height: 5rem;
30
31
  justify-content: center;
31
32
  margin-right: 2rem;
@@ -58,6 +59,7 @@
58
59
  font-size: 0.8em;
59
60
  letter-spacing: 0.01rem;
60
61
  text-transform: uppercase;
62
+ white-space: nowrap;
61
63
  }
62
64
 
63
65
  .dot {
@@ -5,7 +5,7 @@ module Trek
5
5
  def parsed_content
6
6
  return if content.blank?
7
7
 
8
- JSON.parse(content)
8
+ content.is_a?(Hash) ? content : JSON.parse(content)
9
9
  end
10
10
 
11
11
  def formatted_content
@@ -14,8 +14,27 @@ module Trek
14
14
  Prosemirror.new.format_content(parsed_content)
15
15
  end
16
16
 
17
+ def content_text
18
+ return if content.blank?
19
+
20
+ extract_text(parsed_content)
21
+ end
22
+
17
23
  def prosemirror_content?
18
- content&.starts_with?("{\"type\":\"doc\"")
24
+ case content
25
+ when Hash then content["type"] == "doc"
26
+ when String then content.start_with?('{"type":"doc"')
27
+ else false
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def extract_text(node)
34
+ return node["text"].to_s if node["type"] == "text"
35
+ return "" unless node["content"]
36
+
37
+ node["content"].map { |child| extract_text(child) }.join
19
38
  end
20
39
  end
21
40
  end
@@ -9,6 +9,7 @@ module Trek
9
9
  optional: true,
10
10
  inverse_of: :current_page
11
11
  has_many :paths,
12
+ ->(page) { order(Arel.sql("page_paths.id = #{page.current_path_id&.to_i} DESC"), path: :asc) },
12
13
  class_name: "PagePath",
13
14
  dependent: :destroy
14
15
 
@@ -39,16 +39,18 @@ fr:
39
39
  logout: Se déconnecter
40
40
  manage: Gérer
41
41
  new_resource:
42
- "n": Nouveau %{resource}
42
+ "n": Nouveau ou nouvelle %{resource}
43
43
  f: Nouvelle %{resource}
44
44
  m: Nouveau %{resource}
45
45
  m_alt: Nouvel %{resource}
46
46
  reorder_resource:
47
+ "n": Réorganiser les %{resources}
47
48
  f: Réorganiser les %{resources}
48
49
  m: Réorganiser les %{resources}
49
50
  m_alt: Réorganiser les %{resources}
50
51
  replace: Remplacer
51
52
  search_resource:
53
+ "n": Rechercher un·e %{resources}
52
54
  f: Rechercher une %{resource}
53
55
  m: Rechercher un %{resource}
54
56
  m_alt: Rechercher un %{resource}
@@ -17,7 +17,7 @@ module Admin
17
17
  end
18
18
 
19
19
  def reorder?
20
- user.admin? || user.editor?
20
+ false
21
21
  end
22
22
 
23
23
  def permitted_attributes
@@ -1,11 +1,39 @@
1
1
  module Admin
2
2
  class TagCategoryPolicy < Trek::ResourcePolicy
3
3
  def index?
4
- user.admin? || user.editor?
4
+ user.privileged?
5
+ end
6
+
7
+ def create?
8
+ user.privileged?
9
+ end
10
+
11
+ def manage?
12
+ user.privileged?
5
13
  end
6
14
 
7
15
  def destroy?
8
- user.admin? && record.tags.empty?
16
+ user.privileged? && record.tags.empty?
17
+ end
18
+
19
+ def reorder?
20
+ false
21
+ end
22
+
23
+ def permitted_attributes
24
+ if user.privileged?
25
+ %i[name key position]
26
+ else
27
+ []
28
+ end
29
+ end
30
+
31
+ # Scoping
32
+ # See https://actionpolicy.evilmartians.io/#/scoping
33
+ relation_scope do |relation|
34
+ next relation if user.privileged?
35
+
36
+ relation.none
9
37
  end
10
38
  end
11
39
  end
@@ -1,9 +1,39 @@
1
- class Admin::TagPolicy < ApplicationPolicy
2
- def index?
3
- user.admin? || user.editor?
4
- end
1
+ module Admin
2
+ class TagPolicy < Trek::ResourcePolicy
3
+ def index?
4
+ user.privileged?
5
+ end
6
+
7
+ def create?
8
+ user.privileged?
9
+ end
10
+
11
+ def manage?
12
+ user.privileged?
13
+ end
14
+
15
+ def destroy?
16
+ user.privileged? && record.taggables.empty?
17
+ end
18
+
19
+ def reorder?
20
+ false
21
+ end
22
+
23
+ def permitted_attributes
24
+ if user.privileged?
25
+ %i[name key category_id]
26
+ else
27
+ []
28
+ end
29
+ end
30
+
31
+ # Scoping
32
+ # See https://actionpolicy.evilmartians.io/#/scoping
33
+ relation_scope do |relation|
34
+ next relation if user.privileged?
5
35
 
6
- def destroy?
7
- user.admin? && record.taggables.empty?
36
+ relation.none
37
+ end
8
38
  end
9
39
  end
data/lib/trek/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trek
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.12"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etaminstudio/trek",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "A modern CMS for Ruby on Rails",
5
5
  "main": "app/javascript/trek.js",
6
6
  "repository": {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Bengrich
@@ -909,7 +909,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
909
909
  - !ruby/object:Gem::Version
910
910
  version: '0'
911
911
  requirements: []
912
- rubygems_version: 4.0.4
912
+ rubygems_version: 4.0.3
913
913
  specification_version: 4
914
914
  summary: A modern CMS for Ruby on Rails
915
915
  test_files: []