card-mod-content 0.13.2 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca747c0b4f5e5daf200645b98669e4548f9bda3ba18690bb10172c21b338d1a9
4
- data.tar.gz: 1d0d4662153d1161ce5b8c054f6e1533a2db6c8605fece3111c38e71a57cffda
3
+ metadata.gz: 6e83c52ae5a7b63e5428fc38eb57574761a3814613bd2212f39babc7aa38f08b
4
+ data.tar.gz: da7f30ddfd337f834f3fe41d3e00f33791b5da453470ad342f4cb7aa306127fe
5
5
  SHA512:
6
- metadata.gz: 15dfbb475308d689a33b725813d3f0269bead4dcb89679f66a6c81b62f19da89bb84f5aad4321af38d20fc9998862be36b65e58290b9e1c5771fba19c7b09459
7
- data.tar.gz: b1e3735b17553af224025ea1215c864c6dd38159bdecd57548c9d9016ff9b9caae93afa33f55d9a5a2c5fe16dd694f2c336290dd3b6a1371a07de5827f3a6bb9
6
+ metadata.gz: dca59e29bd5f962a070b6f03ece3abcf6c4646b3005ddef65e32625f4373f631ad43540c6a3e6b77ccada3b5958abc1752f6d191ec790a33f6dafd902f0048e4
7
+ data.tar.gz: 74ba35afd802b77b039021d230def87f043b656ef057cc34bba7697b3c3e1a6fe9125229e7f0a7c72e041f6030a6b4b0914e4fbe000dcc0dd50edf0f2ff9e107
@@ -32,7 +32,7 @@ class Card
32
32
  link_text ? { title: link_text } : {}
33
33
  end
34
34
 
35
- def replace_reference old_name, new_name
35
+ def swap_name old_name, new_name
36
36
  replace_name_reference old_name, new_name
37
37
  replace_link_text old_name, new_name
38
38
  link_text_syntax = "|#{@link_text}" if @link_text.present?
@@ -122,11 +122,7 @@ class Card
122
122
  end
123
123
 
124
124
  def replace_link_text old_name, new_name
125
- if @link_text.is_a?(Content)
126
- @link_text.find_chunks(:Reference).each do |chunk|
127
- chunk.replace_reference old_name, new_name
128
- end
129
- elsif @link_text.present?
125
+ replacing_content_object @link_text, old_name, new_name do
130
126
  @link_text = old_name.to_name.sub_in(@link_text, with: new_name)
131
127
  end
132
128
  end
@@ -76,7 +76,7 @@ class Card
76
76
  # this is not necessarily text, sometimes objects for json
77
77
  end
78
78
 
79
- def replace_reference old_name, new_name
79
+ def swap_name old_name, new_name
80
80
  replace_name_reference old_name, new_name
81
81
  nest_body = [@name.to_s, @opt_lists].compact * "|"
82
82
  @text = "{{#{nest_body}}}"
@@ -81,7 +81,7 @@ class Card
81
81
  "<##{self.class}:n[#{@name}] p[#{@process_chunk}] txt:#{@text}>"
82
82
  end
83
83
 
84
- def replace_reference old_name, new_name
84
+ def swap_name old_name, new_name
85
85
  replace_name_reference old_name, new_name
86
86
  @text = "\"#{@name}\""
87
87
  end
@@ -27,17 +27,22 @@ class Card
27
27
  private
28
28
 
29
29
  def replace_name_reference old_name, new_name
30
- @referee_card = nil
31
- @referee_name = nil
32
- if name.is_a? Content
33
- name.find_chunks(:Reference).each do |chunk|
34
- chunk.replace_reference old_name, new_name
35
- end
36
- else
30
+ @referee_card = @referee_name = nil
31
+ replacing_content_object name, old_name, new_name do
37
32
  @name = name.to_name.swap old_name, new_name
38
33
  end
39
34
  end
40
35
 
36
+ def replacing_content_object obj, old_name, new_name
37
+ if obj.is_a? Content
38
+ obj.find_chunks(:Reference).each do |chunk|
39
+ chunk.swap_name old_name, new_name
40
+ end
41
+ elsif obj.present?
42
+ yield
43
+ end
44
+ end
45
+
41
46
  def render_obj raw
42
47
  return raw unless format && raw.is_a?(Content)
43
48
 
@@ -58,6 +58,7 @@ end
58
58
 
59
59
  format :html do
60
60
  view :input do
61
+ # Localize
61
62
  "Content is stored in file and can't be edited."
62
63
  end
63
64
 
data/set/abstract/lock.rb CHANGED
@@ -2,7 +2,7 @@ def lock
2
2
  was_already_locked = locked?
3
3
  return if was_already_locked
4
4
 
5
- Auth.as_bot do
5
+ Card::Auth.as_bot do
6
6
  lock!
7
7
  yield
8
8
  end
@@ -1,13 +1,13 @@
1
1
  def is_template?
2
2
  return @is_template unless @is_template.nil?
3
3
 
4
- @is_template = name.trait_name? :structure, :default
4
+ @is_template = name.right_name&.codename&.in? %i[structure default]
5
5
  end
6
6
 
7
7
  def is_structure?
8
8
  return @is_structure unless @is_structure.nil?
9
9
 
10
- @is_structure = name.trait_name? :structure
10
+ @is_structure = name.right_name&.codename == :structure
11
11
  end
12
12
 
13
13
  def template
@@ -24,31 +24,6 @@ def template
24
24
  end
25
25
  end
26
26
 
27
- def default_type_id
28
- Card.default_type_id
29
- end
30
-
31
- def new_card_template
32
- default = rule_card :default, skip_modules: true
33
- return default unless (structure = dup_structure default&.type_id)
34
-
35
- @virtual = true if compound?
36
- self.type_id = structure.type_id if assign_type_to?(structure)
37
- structure
38
- end
39
-
40
- def dup_structure type_id
41
- dup_card = dup
42
- dup_card.type_id = type_id || default_type_id
43
- dup_card.structure_rule_card
44
- end
45
-
46
- def assign_type_to? structure
47
- return if type_id == structure.type_id
48
-
49
- structure.assigns_type?
50
- end
51
-
52
27
  def assigns_type?
53
28
  # needed because not all *structure templates govern the type of set members
54
29
  # for example, X+*type+*structure governs all cards of type X,
@@ -68,3 +43,24 @@ def structure_rule_card
68
43
 
69
44
  card.db_content&.strip == "_self" ? nil : card
70
45
  end
46
+
47
+ private
48
+
49
+ def new_card_template
50
+ default = rule_card :default, skip_modules: true
51
+ return default unless (structure = dup_structure default&.type_id)
52
+
53
+ @virtual = true if compound?
54
+ self.type_id = structure.type_id if assign_type_to?(structure)
55
+ structure
56
+ end
57
+
58
+ def dup_structure type_id
59
+ dup_card = dup
60
+ dup_card.type_id = type_id || Card.default_type_id
61
+ dup_card.structure_rule_card
62
+ end
63
+
64
+ def assign_type_to? structure
65
+ type_id == structure.type_id && structure.assigns_type?
66
+ end
data/set/right/default.rb CHANGED
@@ -23,7 +23,7 @@ format :html do
23
23
  end
24
24
 
25
25
  def visible_cardtype_groups
26
- hash = ::Card::Set::Self::Cardtype::GROUP.slice("Text", "Data", "Upload")
26
+ hash = All::CardtypeGroups::GROUP.slice("Text", "Data", "Upload")
27
27
  hash["Organize"] = ["List", "Pointer", "Link list", "Nest list"]
28
28
  hash
29
29
  end
@@ -16,7 +16,7 @@ format :html do
16
16
  end
17
17
 
18
18
  def visible_cardtype_groups
19
- hash = ::Card::Set::Self::Cardtype::GROUP.slice("Text")
19
+ hash = All::CardtypeGroups::GROUP.slice("Text")
20
20
  hash["Organize"] = ["Search", "Nest list"]
21
21
  hash
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-08-06 00:00:00.000000000 Z
13
+ date: 2022-01-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.103.2
21
+ version: 1.104.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.103.2
28
+ version: 1.104.1
29
29
  description: ''
30
30
  email:
31
31
  - info@decko.org
@@ -35,7 +35,6 @@ extra_rdoc_files: []
35
35
  files:
36
36
  - db/migrate_core_cards/20201115133753_add_asset_file_card.rb
37
37
  - lib/card/content/chunk/escaped_literal.rb
38
- - lib/card/content/chunk/keep_escaped_literal.rb
39
38
  - lib/card/content/chunk/link.rb
40
39
  - lib/card/content/chunk/nest.rb
41
40
  - lib/card/content/chunk/query_reference.rb
@@ -81,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  requirements: []
84
- rubygems_version: 3.1.6
83
+ rubygems_version: 3.2.15
85
84
  signing_key:
86
85
  specification_version: 4
87
86
  summary: card content handling
@@ -1,26 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- class Card
4
- class Content
5
- module Chunk
6
- # These are basic chunks that have a pattern and can be protected.
7
- # This chunk is used for markdown processing to ensure that
8
- # the escaping survives the markdown rendering.
9
- class KeepEscapedLiteral < Abstract
10
- FULL_RE = { "[" => /\A\\\[\[[^\]]*\]\]/,
11
- "{" => /\A\\\{\{[^}]*\}\}/ }.freeze
12
- Card::Content::Chunk.register_class self,
13
- prefix_re: '\\\\(?:\\[\\[|\\{\\{)',
14
- idx_char: "\\"
15
-
16
- def self.full_re prefix
17
- FULL_RE[prefix[1, 1]]
18
- end
19
-
20
- def interpret match, _content
21
- @process_chunk = match[0].sub(/^\\(.)/, '\\\\\\\\\1')
22
- end
23
- end
24
- end
25
- end
26
- end