card-mod-content 0.14.2 → 0.15.1

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: c8528619b98ef26320d7f86bebc8dc8572ed79b19c0aa573f6f4224b316a321b
4
- data.tar.gz: f9fd038d25f1c16d9326745a6acee570135a93795943d36664b0a8c21a9f59ce
3
+ metadata.gz: af70b2c7dd6325fddf41719756af50e5c495b579e5f07d8b6099aa97df929135
4
+ data.tar.gz: 478c8eb7b8df2e7a1482cbc31422c2c9f55b34c1e19e37343c0380405797cb25
5
5
  SHA512:
6
- metadata.gz: 6daffffe944bf9b2b505f430086a42cc755415c949a54167b837dc2a7f2c4fc7acd492a634f82d2aa9510db0478ab0edf03c84f8119c0e6c3a50d216b5a7e1e3
7
- data.tar.gz: 4725a7beab0aa2b8bc7d2f6f59d46e6b31575ee8ab346b1a5d1fedf6ca898c61ea7b868a049ed14460775db7d56e4a5fa509ff5219fc8bbbc2e6b75d464f885d
6
+ metadata.gz: 23920a9f1ce7783de6e6fc29a69235b2e04b5c3fafba390279e9e646c31095a7472513d55ca701aa8dd5b67d5efb3aa1a202a5474fb389e89da28327dcfe3f62
7
+ data.tar.gz: 9eb909a81cd2e2dd4eb38f14e6fd3d6d135882e3765b27ad9814f3a48e3f09c911d60fb7a7f060bb4a386f4560d50c3df61b8f4a9e0003b9278f0b26d68c07b0
data/data/real.yml ADDED
@@ -0,0 +1,27 @@
1
+ - :name: "*default"
2
+ :type: :setting
3
+ :codename: default
4
+ - :name: "*structure"
5
+ :type: :setting
6
+ :codename: structure
7
+ - :name:
8
+ - :all
9
+ - :default
10
+
11
+ - :name:
12
+ - :cardtype
13
+ - :type
14
+ - :structure
15
+ :content: |
16
+ {{+:description|content}}
17
+ {{_|add_button}}{{_|configure_button}}
18
+ {{+:type+:by_name|content}}
19
+
20
+ - :name:
21
+ - :cardtype
22
+ - :self
23
+ - :structure
24
+ :content: |-
25
+ {{+description|content}}
26
+ {{_|add_button}}{{_|configure_button}}\n
27
+ {{_|grouped_list}}\n"
data/data/test.yml ADDED
@@ -0,0 +1,32 @@
1
+ ---
2
+ - :name: UserForm
3
+ :type: :cardtype
4
+ - :name: Book
5
+ :type: :cardtype
6
+ - :name: Author
7
+ :type: :cardtype
8
+
9
+ - :name:
10
+ - UserForm
11
+ - :type
12
+ - :structure
13
+ :type: :nest_list
14
+ :content: "{{+name}} {{+age}} {{+description}}"
15
+ - :name:
16
+ - Book
17
+ - :type
18
+ - :structure
19
+ :type: :nest_list
20
+ :content: by {{+author}}, design by {{+illustrator}}
21
+
22
+ - :name: Stam Broker
23
+ :type: Author
24
+ - :name: Darles Chickens
25
+ :type: Author
26
+
27
+ - :name: Iliad
28
+ :type: Book
29
+ - :name: Parry Hotter
30
+ :type: Book
31
+ - :name: 50 grades of shy
32
+ :type: Book
@@ -1,6 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- # require File.expand_path("../reference", __FILE__)
4
3
  load File.expand_path("reference.rb", __dir__)
5
4
 
6
5
  class Card
@@ -1,7 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- # require File.expand_path("../reference", __FILE__)
4
-
5
3
  class Card
6
4
  class Content
7
5
  module Chunk
@@ -2,26 +2,26 @@
2
2
 
3
3
  require "uri"
4
4
 
5
- # This wiki chunk matches arbitrary URIs, using patterns from the Ruby URI
6
- # modules.
7
- # It parses out a variety of fields that could be used by formats to format
8
- # the links in various ways (shortening domain names, hiding email addresses)
9
- # It matches email addresses and host.com.au domains without schemes (http://)
10
- # but adds these on as required.
11
- #
12
- # The heuristic used to match a URI is designed to err on the side of caution.
13
- # That is, it is more likely to not autolink a URI than it is to accidently
14
- # autolink something that is not a URI. The reason behind this is it is easier
15
- # to force a URI link by prefixing 'http://' to it than it is to escape and
16
- # incorrectly marked up non-URI.
17
- #
18
- # I'm using a part of the [ISO 3166-1 Standard][iso3166] for country name
19
- # suffixes.
20
- # The generic names are from www.bnoack.com/data/countrycode2.html)
21
- # [iso3166]: http://geotags.com/iso3166/
22
5
  class Card
23
6
  class Content
24
7
  module Chunk
8
+ # This wiki chunk matches arbitrary URIs, using patterns from the Ruby URI
9
+ # modules.
10
+ # It parses out a variety of fields that could be used by formats to format
11
+ # the links in various ways (shortening domain names, hiding email addresses)
12
+ # It matches email addresses and host.com.au domains without schemes (http://)
13
+ # but adds these on as required.
14
+ #
15
+ # The heuristic used to match a URI is designed to err on the side of caution.
16
+ # That is, it is more likely to not autolink a URI than it is to accidently
17
+ # autolink something that is not a URI. The reason behind this is it is easier
18
+ # to force a URI link by prefixing 'http://' to it than it is to escape and
19
+ # incorrectly marked up non-URI.
20
+ #
21
+ # I'm using a part of the [ISO 3166-1 Standard][iso3166] for country name
22
+ # suffixes.
23
+ # The generic names are from www.bnoack.com/data/countrycode2.html)
24
+ # [iso3166]: http://geotags.com/iso3166/
25
25
  class Uri < Abstract
26
26
  SCHEMES = %w[irc http https ftp ssh git sftp file ldap ldaps mailto].freeze
27
27
 
@@ -0,0 +1,19 @@
1
+ format :html do
2
+ view :input do
3
+ # Localize
4
+ "Content is stored in file and can't be edited."
5
+ end
6
+
7
+ view :bar_middle do
8
+ short_content
9
+ end
10
+
11
+ def short_content
12
+ icon_tag(:warning, class: "text-muted pe-2") +
13
+ wrap_with(:span, "file", class: "text-muted")
14
+ end
15
+
16
+ def standard_submit_button
17
+ multi_card_editor? ? super : ""
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ include_set Abstract::Sources
2
+ include_set Abstract::CodeContent
3
+
4
+ class << self
5
+ def included host_class
6
+ track_mod_name host_class, caller
7
+ end
8
+
9
+ def track_mod_name host_class, caller
10
+ host_class.mattr_accessor :file_content_mod_name
11
+ host_class.file_content_mod_name = Card::Set.mod_name(caller)
12
+ end
13
+ end
14
+
15
+ def source_paths
16
+ # OVERRIDE to use paths for content
17
+ end
18
+
19
+ def content
20
+ Array.wrap(source_paths).map do |path|
21
+ if (source_path = find_file path)
22
+ Rails.logger.debug "reading file: #{source_path}"
23
+ ::File.read source_path
24
+ end
25
+ end.compact.join "\n"
26
+ end
27
+
28
+ format :html do
29
+ view :file_size do
30
+ "#{card.name}: #{number_to_human_size card.content.bytesize}"
31
+ end
32
+ end
@@ -4,7 +4,7 @@ format :html do
4
4
  end
5
5
 
6
6
  def short_content
7
- fa_icon("exclamation-circle", class: "text-muted pr-2") +
7
+ icon_tag(:warning, class: "text-muted pe-2") +
8
8
  wrap_with(:span, "read-only", class: "text-muted")
9
9
  end
10
10
 
data/set/all/chunk.rb CHANGED
@@ -124,21 +124,24 @@ format do
124
124
 
125
125
  def explicit_edit_fields_config
126
126
  edit_fields.map do |cardish, options|
127
- field_mark = normalized_edit_field_mark cardish, options
128
- options = normalized_edit_field_options options, Card::Name[field_mark]
129
- [field_mark, options]
127
+ normalized_edit_field_config cardish, options
130
128
  end
131
129
  end
132
130
 
133
- def normalized_edit_field_options options, cardname
134
- options ||= cardname
135
- options.is_a?(String) ? { title: options } : options
131
+ def normalized_edit_field_config cardish, options={}
132
+ options ||= {}
133
+ field_mark = normalized_edit_field_mark cardish, options
134
+ options[:title] ||= Card::Name[field_mark]
135
+ [field_mark, options]
136
136
  end
137
137
 
138
- def normalized_edit_field_mark cardish, options
139
- return cardish if cardish.is_a?(Card) ||
140
- (options.is_a?(Hash) && options.delete(:absolute))
138
+ def normalized_edit_field_mark cardish, options={}
139
+ return cardish if options.delete(:absolute) || normalized_edit_field_mark?(cardish)
141
140
 
142
141
  card.name.field cardish
143
142
  end
143
+
144
+ def normalized_edit_field_mark? cardish
145
+ cardish.is_a?(Card) || (cardish.is_a?(String) && cardish.to_name.compound?)
146
+ end
144
147
  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.14.2
4
+ version: 0.15.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: 2022-01-08 00:00:00.000000000 Z
13
+ date: 2023-03-29 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.104.2
21
+ version: 1.105.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.104.2
28
+ version: 1.105.1
29
29
  description: ''
30
30
  email:
31
31
  - info@decko.org
@@ -33,7 +33,8 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
- - db/migrate_core_cards/20201115133753_add_asset_file_card.rb
36
+ - data/real.yml
37
+ - data/test.yml
37
38
  - lib/card/content/chunk/escaped_literal.rb
38
39
  - lib/card/content/chunk/link.rb
39
40
  - lib/card/content/chunk/nest.rb
@@ -42,12 +43,12 @@ files:
42
43
  - lib/card/content/chunk/uri.rb
43
44
  - lib/card/content/chunk/view_stub.rb
44
45
  - set/abstract/00_sources.rb
45
- - set/abstract/01_code_file.rb
46
+ - set/abstract/01_code_content.rb
47
+ - set/abstract/02_code_file.rb
46
48
  - set/abstract/haml_file.rb
47
49
  - set/abstract/lock.rb
48
50
  - set/abstract/read_only.rb
49
51
  - set/abstract/templated_nests.rb
50
- - set/abstract/vendor_code_file.rb
51
52
  - set/all/chunk.rb
52
53
  - set/all/contextual_content.rb
53
54
  - set/all/templating.rb
@@ -65,6 +66,7 @@ metadata:
65
66
  wiki_uri: https://decko.org
66
67
  documentation_url: http://docs.decko.org/
67
68
  card-mod: content
69
+ card-mod-group: gem-defaults
68
70
  post_install_message:
69
71
  rdoc_options: []
70
72
  require_paths:
@@ -80,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  - !ruby/object:Gem::Version
81
83
  version: '0'
82
84
  requirements: []
83
- rubygems_version: 3.2.15
85
+ rubygems_version: 3.3.11
84
86
  signing_key:
85
87
  specification_version: 4
86
88
  summary: card content handling
@@ -1,7 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- class AddAssetFileCard < Cardio::Migration::Core
4
- def up
5
- ensure_code_card "Asset file", type_id: Card::CardtypeID
6
- end
7
- end
@@ -1,85 +0,0 @@
1
- include_set Abstract::Sources
2
-
3
- class << self
4
- def included host_class
5
- track_mod_name host_class, caller
6
- end
7
-
8
- def track_mod_name host_class, caller
9
- host_class.mattr_accessor :file_content_mod_name
10
- host_class.file_content_mod_name = Card::Set.mod_name(caller)
11
- end
12
- end
13
-
14
- # FIXME: these should abstracted and configured on the types
15
- # (same codes for `rake card:create:codefile`)
16
-
17
- # @return [Array<String>, String] the name of file(s) to be loaded
18
- def source_files
19
- case type_id
20
- when CoffeeScriptID then "#{codename}.js.coffee"
21
- when JavaScriptID then "#{codename}.js"
22
- when CssID then "#{codename}.css"
23
- when ScssID then "#{codename}.scss"
24
- end
25
- end
26
-
27
- def source_dir
28
- case type_id
29
- when CoffeeScriptID, JavaScriptID then "lib/javascript"
30
- when CssID, ScssID then "lib/stylesheets"
31
- else
32
- "lib"
33
- end
34
- end
35
-
36
- def mod_path
37
- modname = file_content_mod_name
38
- if (match = modname.match(/^card-mod-(\w*)/))
39
- modname = match[1]
40
- end
41
- Cardio::Mod.dirs.path modname
42
- end
43
-
44
- def source_paths
45
- Array.wrap(source_files).map do |filename|
46
- ::File.join mod_path, source_dir, filename
47
- end
48
- end
49
-
50
- def content
51
- Array.wrap(source_paths).map do |path|
52
- if (source_path = find_file path)
53
- Rails.logger.debug "reading file: #{source_path}"
54
- ::File.read source_path
55
- end
56
- end.compact.join "\n"
57
- end
58
-
59
- format :html do
60
- view :input do
61
- # Localize
62
- "Content is stored in file and can't be edited."
63
- end
64
-
65
- view :file_size do
66
- "#{card.name}: #{number_to_human_size card.content.bytesize}"
67
- end
68
-
69
- def short_content
70
- fa_icon("exclamation-circle", class: "text-muted pr-2") +
71
- wrap_with(:span, "file", class: "text-muted")
72
- end
73
-
74
- def standard_submit_button
75
- multi_card_editor? ? super : ""
76
- end
77
- end
78
-
79
- def coffee_files files
80
- files.map { |f| "script_#{f}.js.coffee" }
81
- end
82
-
83
- def scss_files files
84
- files.map { |f| "style_#{f}.scss" }
85
- end
@@ -1,9 +0,0 @@
1
- include_set Abstract::CodeFile
2
-
3
- def self.included host_class
4
- Abstract::CodeFile.track_mod_name host_class, caller
5
- end
6
-
7
- def source_dir
8
- "vendor"
9
- end