panda_cms 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/panda_cms/admin/posts_controller.rb +1 -1
- data/app/controllers/panda_cms/posts_controller.rb +1 -1
- data/app/helpers/panda_cms/application_helper.rb +6 -2
- data/app/javascript/controllers/text_field_update_controller.js +38 -10
- data/app/models/panda_cms/post.rb +8 -2
- data/app/views/panda_cms/admin/posts/index.html.erb +1 -1
- data/lib/panda_cms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23e115d751f17c8f528f17626e520797d040f582219836ba9b2fa996609cdc7b
|
4
|
+
data.tar.gz: 171b6cfcea626582610a896d7197f50abb6fa436aade77c15291d50a21ac528c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93cf0d36e41110790a6e9e08361dbfb843fb8607a5795a016247b2d4a9aa909d75bd4ef9f6af71a31ed7f9e967ac21eee6a0f80315caccad66bb790c1664d2c1
|
7
|
+
data.tar.gz: 25b6b5455c97a1a791edb38667890928d10ea5cdf29249f7d9e689911919ad9225f785eab6e94c41d8494726a9b03d83537b93f86a79f2825f8ce02f330e7d09
|
@@ -47,8 +47,8 @@ module PandaCms
|
|
47
47
|
"text-white hover:bg-mid/60 transition-all group flex gap-x-3 py-3 px-2 mb-2 rounded-md text-base leading-6 font-normal "
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
51
|
-
case
|
50
|
+
def level_indent(level)
|
51
|
+
case level
|
52
52
|
when 0
|
53
53
|
"ml-0"
|
54
54
|
when 1
|
@@ -76,6 +76,10 @@ module PandaCms
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
def table_indent(item_with_level_attribute)
|
80
|
+
level_indent(item_with_level_attribute.level)
|
81
|
+
end
|
82
|
+
|
79
83
|
def menu_indent(item_with_level_attribute)
|
80
84
|
case item_with_level_attribute.level
|
81
85
|
when 0
|
@@ -1,23 +1,51 @@
|
|
1
|
-
import { Controller as PandaCmsController } from "@hotwired/stimulus"
|
1
|
+
import { Controller as PandaCmsController } from "@hotwired/stimulus";
|
2
2
|
export default class extends PandaCmsController {
|
3
|
-
static targets = [
|
3
|
+
static targets = [
|
4
|
+
"existing_root",
|
5
|
+
"input_select",
|
6
|
+
"input_text",
|
7
|
+
"output_text",
|
8
|
+
];
|
4
9
|
|
5
|
-
connect() {
|
6
|
-
}
|
10
|
+
connect() {}
|
7
11
|
|
8
12
|
generatePath() {
|
9
|
-
this.output_textTarget.value =
|
13
|
+
this.output_textTarget.value =
|
14
|
+
"/" + this.createSlug(this.input_textTarget.value);
|
10
15
|
}
|
11
16
|
|
12
17
|
setPrePath() {
|
13
|
-
this.parent_slugs =
|
14
|
-
|
18
|
+
this.parent_slugs =
|
19
|
+
this.input_selectTarget.options[
|
20
|
+
this.input_selectTarget.selectedIndex
|
21
|
+
].text.match(/.*\((.*)\)$/)[1];
|
22
|
+
this.output_textTarget.previousSibling.innerHTML = (
|
23
|
+
this.existing_rootTarget.value + this.parent_slugs
|
24
|
+
).replace(/\/$/, "");
|
15
25
|
}
|
16
26
|
|
27
|
+
// TODO: Invoke a library or helper which can be shared with the backend
|
28
|
+
// and check for uniqueness at the same time
|
17
29
|
createSlug(input) {
|
18
|
-
|
30
|
+
var str = input
|
31
|
+
.toLowerCase()
|
32
|
+
.trim()
|
19
33
|
.replace(/[^\w\s-]/g, "-")
|
20
|
-
.replace(
|
21
|
-
.replace(/[\s_-]+/g, "-")
|
34
|
+
.replace(/&/g, "and")
|
35
|
+
.replace(/[\s_-]+/g, "-")
|
36
|
+
.trim();
|
37
|
+
|
38
|
+
return this.trimStartEnd(str, "-");
|
39
|
+
}
|
40
|
+
|
41
|
+
trimStartEnd(str, ch) {
|
42
|
+
var start = 0,
|
43
|
+
end = str.length;
|
44
|
+
|
45
|
+
while (start < end && str[start] === ch) ++start;
|
46
|
+
|
47
|
+
while (end > start && str[end - 1] === ch) --end;
|
48
|
+
|
49
|
+
return start > 0 || end < str.length ? str.substring(start, end) : str;
|
22
50
|
}
|
23
51
|
}
|
@@ -27,8 +27,14 @@ module PandaCms
|
|
27
27
|
archived: "archived"
|
28
28
|
}
|
29
29
|
|
30
|
-
def
|
31
|
-
|
30
|
+
def to_param
|
31
|
+
slug.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def excerpt(length = 100, squish: true)
|
35
|
+
excerpt = post_content.to_plain_text
|
36
|
+
excerpt = excerpt.squish if squish
|
37
|
+
excerpt.truncate(length).html_safe
|
32
38
|
end
|
33
39
|
|
34
40
|
def path
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<% table.column("Title") do |post| %>
|
8
8
|
<div class="">
|
9
9
|
<%= link_to post.title, edit_admin_post_path(post), class: "block h-full w-full" %>
|
10
|
-
<span class="block text-xs text-black/60"><%= post
|
10
|
+
<span class="block text-xs text-black/60"><%= post_path(post) %></span>
|
11
11
|
</div>
|
12
12
|
<% end %>
|
13
13
|
<% table.column("Status") { |post| render PandaCms::Admin::TagComponent.new(status: post.status) } %>
|
data/lib/panda_cms/version.rb
CHANGED