card-mod-format 0.13.1 → 0.14.0

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: a95c6cfc3ba84f96868903f03ca20748bc5bbb61e2f80c7ee6b506275adb1a01
4
- data.tar.gz: 436730b795bac80c8f3964b57ae1bbe1d9a74b00265dab1c70ad0d708fa33c9c
3
+ metadata.gz: 6dd1742c8a71de4e306dc775686c546a4e2f4063a70ef8f84697f1b78f055578
4
+ data.tar.gz: 619d41643aa1096b45d554d1c3d6b04b7ee9b49dbcd1acf14b8cb85c5685e150
5
5
  SHA512:
6
- metadata.gz: faba2efb3dd0cccad23ef75eae8668545c5e1e57d495899ba9b1053daa68bc70be86ae7072707ae181e47d1929a87c70fd21379d1c914aeef705a9017fb01861
7
- data.tar.gz: abcf786842ceb4f6829cf86f56f1d5e37dfdb7a1f26e02d39625d96359e6490b885b0a17be4528c592c0e6d22ccb080a08802d2466b9b7e92c698934982c57c3
6
+ metadata.gz: 5b8bfc3064d3b517298a744ac8020d02702c6ad808b9d2bcdec95d087122c21bd3070918e99e51513250a082cb2bc2a333df65b40c3ff106365e247e08183f77
7
+ data.tar.gz: 639a5b55df3c1e846b95eb3cee7e202e9b803060b81abaf1d4b6c6f795de88531199b35178d321098466f530dabf9ec2da1750d317723f5fa133fc9e6df89ff7
@@ -19,15 +19,6 @@ class Card
19
19
  @focal ||= show_layout? ? main? : depth.zero?
20
20
  end
21
21
 
22
- def default_nest_view
23
- # FIXME: not sure this makes sense as a rule...
24
- card.rule(:default_html_view) || :titled
25
- end
26
-
27
- def default_item_view
28
- :bar
29
- end
30
-
31
22
  def escape_literal literal
32
23
  "<span>#{literal}</span>"
33
24
  end
@@ -0,0 +1,18 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class Card
4
+ class Format
5
+ # Scss format
6
+ class ScssFormat < CssFormat
7
+ register :scss
8
+
9
+ def mime_type
10
+ "text/x-scss"
11
+ end
12
+
13
+ def self.view_caching?
14
+ false
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class Card
4
+ class Format
5
+ # base class for rendering in YAML (Yet Another Markup Language)
6
+ class YamlFormat < DataFormat
7
+ register :yaml
8
+ register :yml
9
+ aliases["yml"] = "yaml"
10
+
11
+ def mime_type
12
+ "text/x-yaml"
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/card/path.rb CHANGED
@@ -35,7 +35,8 @@ class Card
35
35
  end
36
36
 
37
37
  def standard
38
- base + extension + query
38
+ anch = anchor
39
+ base + extension + query + anch
39
40
  end
40
41
 
41
42
  def base
@@ -75,6 +76,11 @@ class Card
75
76
  extension ? ".#{extension}" : ""
76
77
  end
77
78
 
79
+ def anchor
80
+ anchor = opts.delete :anchor
81
+ anchor ? "##{anchor}" : ""
82
+ end
83
+
78
84
  def query
79
85
  query_opts = cast_path_hash opts
80
86
  query_opts.empty? ? "" : "?#{query_opts.to_param}"
data/locales/de.yml ADDED
@@ -0,0 +1,23 @@
1
+ de:
2
+ format_add_card: "%{cardname} hinzufügen"
3
+ format_bad_address: "404: Ungültige Adresse"
4
+ format_close: Schließen
5
+ format_configure_card: "%{cardname} konfigurieren"
6
+ format_denial: Erlaubnis abgelehnt
7
+ format_denied_task: to %{denied_task} this
8
+ format_invalid_json: ungültiges json
9
+ format_need_permission_task: "Sie brauchen Erlaubnis %{task}."
10
+ format_not_found_named: Konnte %{cardname} nicht finden.
11
+ format_not_found_no_name: die angeforderte Karte
12
+ format_not_numeric: "'%{content}' ist nicht numerisch"
13
+ format_or: "oder"
14
+ format_please: Bitte
15
+ format_problems_name: Probleme mit %{cardname}
16
+ format_read_only: Wir sind derzeit im Nur-Lese-Modus. Bitte versuchen Sie es später noch einmal.
17
+ format_server_error: "\nServer Fehler. Ups, entschuldige bitte.\nUm uns den Fehler mitzuteilen und über eine Lösung informiert zu werden,\nerstelle ein Support-Ticket %{ticket_link}\n"
18
+ format_sorry: Sorry!
19
+ format_to_do_that: um das zu tun
20
+ format_toggle_no: "nein"
21
+ format_toggle_yes: "ja"
22
+ format_too_deep: Du bist zu tief. (Zu viele verschachtelte Nester aufeinmal)
23
+ format_unsupported_view: Ansicht (%{view}) wird nicht unterstützt für %{cardname}
data/locales/en.yml ADDED
@@ -0,0 +1,23 @@
1
+ en:
2
+ format_add_card: Add %{cardname}
3
+ format_bad_address: "404: Bad Address"
4
+ format_close: Close
5
+ format_configure_card: Configure %{cardname}
6
+ format_denial: Permission Denied
7
+ format_denied_task: to %{denied_task} this
8
+ format_invalid_json: invalid json
9
+ format_need_permission_task: "You need permission %{task}."
10
+ format_not_found_named: Could not find %{cardname}.
11
+ format_not_found_no_name: the card requested
12
+ format_not_numeric: "'%{content}' is not numeric"
13
+ format_or: "or"
14
+ format_please: Please
15
+ format_problems_name: Problems with %{cardname}
16
+ format_read_only: We are currently in read-only mode. Please try again later.
17
+ format_server_error: "\nServer Error. Yuck, sorry about that.\nTo tell us more and follow the fix,\nadd a support ticket at %{ticket_link}\n"
18
+ format_sorry: Sorry!
19
+ format_to_do_that: to do that
20
+ format_toggle_no: "no"
21
+ format_toggle_yes: "yes"
22
+ format_too_deep: Man, you're too deep. (Too many levels of nests at a time)
23
+ format_unsupported_view: view (%{view}) not supported for %{cardname}
data/set/all/base.rb CHANGED
@@ -1,3 +1,8 @@
1
+ def format opts={}
2
+ opts = { format: opts.to_sym } if [Symbol, String].member? opts.class
3
+ Card::Format.new self, opts
4
+ end
5
+
1
6
  format do
2
7
  def show view, args
3
8
  view ||= :core
@@ -130,10 +135,4 @@ format do
130
135
  subformat(item_card)._render_core
131
136
  end.inspect
132
137
  end
133
-
134
- # DEPRECATED
135
- view :naked do
136
- Rails.logger.info "DEPRECATED: naked view (used with #{card.name} card)"
137
- render_core
138
- end
139
138
  end
data/set/all/data.rb ADDED
@@ -0,0 +1,110 @@
1
+ def cast
2
+ real? ? { id: id } : { name: name, type_id: type_id, content: db_content }
3
+ end
4
+
5
+ def export_hash field_tags: []
6
+ { name: export_name,
7
+ type: export_type,
8
+ codename: codename,
9
+ content: export_content,
10
+ subfields: export_subfields(field_tags) }.compact_blank
11
+ end
12
+
13
+ def export_subfields marks
14
+ marks.each_with_object({}) do |mark, hash|
15
+ hash[mark] = [name, mark].card&.export_content
16
+ end.compact_blank
17
+ end
18
+
19
+ def export_type
20
+ type_name.codename_or_string
21
+ end
22
+
23
+ def export_name
24
+ simple? ? name.s : name.part_names.map(&:codename_or_string)
25
+ end
26
+
27
+ def export_content
28
+ structure ? nil : db_content
29
+ end
30
+
31
+ format :data do
32
+ view :export do
33
+ card.export_hash
34
+ end
35
+
36
+ view :core, unknown: true do
37
+ card.known? ? render_content : nil
38
+ end
39
+
40
+ view :content do
41
+ card.content
42
+ end
43
+
44
+ view :nucleus do
45
+ nucleus
46
+ end
47
+
48
+ # TODO: add simple values for fields
49
+ view :atom, unknown: true do
50
+ atom
51
+ end
52
+
53
+ view :molecule do
54
+ molecule
55
+ end
56
+
57
+ view :ancestors do
58
+ card.name.ancestors.map do |name|
59
+ nest name, view: :nucleus
60
+ end
61
+ end
62
+
63
+ # minimum needed to re-fetch card
64
+ view :cast do
65
+ card.cast
66
+ end
67
+
68
+ # NOCACHE because sometimes item_cards is dynamic.
69
+ # could be safely cached for non-dynamic lists
70
+ view :items, cache: :never do
71
+ listing item_cards, view: (voo_items_view || :atom)
72
+ end
73
+
74
+ view :links do
75
+ card.link_chunks.map do |chunk|
76
+ if chunk.referee_name
77
+ path mark: chunk.referee_name, format: :json
78
+ else
79
+ link_to_resource chunk.link_target
80
+ end
81
+ end
82
+ end
83
+
84
+ # NOTE: moving these to methods prevents potential caching problems, because other
85
+ # views manipulate their hashes.
86
+ def nucleus
87
+ { id: card.id,
88
+ name: card.name,
89
+ type: card.type_name,
90
+ url: path(format: :json) }.tap do |h|
91
+ h[:codename] = card.codename if card.codename
92
+ end
93
+ end
94
+
95
+ def atom
96
+ nucleus.tap do |h|
97
+ h[:content] = render_content if card.known? && !card.structure
98
+ end
99
+ end
100
+
101
+ def molecule
102
+ atom.merge items: _render_items,
103
+ links: _render_links,
104
+ ancestors: _render_ancestors,
105
+ html_url: path,
106
+ type: nest(card.type_card, view: :nucleus),
107
+ created_at: card.created_at,
108
+ updated_at: card.updated_at
109
+ end
110
+ end
data/set/all/error.rb CHANGED
@@ -50,7 +50,7 @@ format do
50
50
  end
51
51
 
52
52
  def unsupported_view_error_message view
53
- t(:format_unsupported_view, view: view, cardname: card.name)
53
+ t :format_unsupported_view, view: view, cardname: card.name
54
54
  end
55
55
  end
56
56
 
@@ -21,8 +21,9 @@ format :html do
21
21
  end
22
22
 
23
23
  def unknown_link text
24
- path_opts = voo.type ? { card: { type: voo.type } } : {}
25
- link_to_view :new_in_modal, text, path: path_opts, class: classy("unknown-link")
24
+ link_to_view :new_in_modal, text,
25
+ path: (voo.type ? { card: { type: voo.type } } : {}),
26
+ class: classy("unknown-link")
26
27
  end
27
28
 
28
29
  def unknown_icon
@@ -63,7 +64,7 @@ format :html do
63
64
  standard_errors voo.title
64
65
  end
65
66
 
66
- view :not_found do
67
+ view :not_found, cache: :never do
67
68
  voo.hide! :menu
68
69
  voo.title = "Not Found"
69
70
  frame do
File without changes
@@ -7,11 +7,6 @@ format do
7
7
  end
8
8
 
9
9
  format :html do
10
- # add tuples containing a
11
- # - the codename of a card with javascript config (usually in json format)
12
- # - the name of a javascript method that handles the config
13
- basket :mod_js_config
14
-
15
10
  view :head, unknown: true, perms: :none do
16
11
  views_in_head.map { |viewname| render viewname }.flatten.compact.join "\n"
17
12
  end
@@ -61,7 +56,7 @@ format :html do
61
56
  def debug_or_machine_path setting, debug_lambda, machine_path_lambda
62
57
  return unless (asset_card = param_or_rule_card setting)
63
58
  debug_path(setting, asset_card, &debug_lambda) ||
64
- machine_path_lambda.call(asset_card.machine_output_url)
59
+ machine_path_lambda.call(asset_card.asset_output_url)
65
60
  end
66
61
 
67
62
  def debug_path setting, asset_card
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,31 @@
1
+ format :html do
2
+ def show view, args
3
+ content = send show_method, view, args
4
+ Env.ajax? ? content : wrap_with_html_page(content)
5
+ end
6
+
7
+ wrapper :html_page do
8
+ <<-HTML.strip_heredoc
9
+ <!DOCTYPE HTML>
10
+ <html class="h-100">
11
+ <head>
12
+ #{nest card.rule_card(:head), view: :head_content}
13
+ </head>
14
+ #{interior}
15
+ </html>
16
+ HTML
17
+ end
18
+
19
+ private
20
+
21
+ def show_without_page_layout view, args
22
+ @main = true if params[:is_main] || args[:main]
23
+ args.delete(:layout)
24
+ view ||= args[:home_view] || default_page_view
25
+ render! view, args
26
+ end
27
+
28
+ def show_method
29
+ "show_#{show_layout? ? :with : :without}_page_layout"
30
+ end
31
+ end
@@ -13,7 +13,7 @@ format :html do
13
13
  end
14
14
  end
15
15
 
16
- before(:content_with_edit_button) do
16
+ before :content_with_edit_button do
17
17
  prepare_content_slot
18
18
  end
19
19
 
@@ -64,8 +64,7 @@ format :html do
64
64
  [
65
65
  naming { render_header },
66
66
  render_flash,
67
- wrap_body { render_titled_content },
68
- render_comment_box(optional: :hide)
67
+ wrap_body { render_titled_content }
69
68
  ]
70
69
  end
71
70
  end
@@ -91,9 +90,7 @@ format :html do
91
90
  toggle_logic
92
91
  @toggle_mode = :open
93
92
  @content_body = true
94
- frame do
95
- [_render_open_content, render_comment_box(optional: :hide)]
96
- end
93
+ frame { _render_open_content }
97
94
  end
98
95
 
99
96
  view :closed do
File without changes
@@ -13,4 +13,13 @@ format :html do
13
13
  link_to_card card.type_name, nil, class: "navbar-link"
14
14
  end
15
15
  end
16
+
17
+ def default_nest_view
18
+ :titled
19
+ # card.rule(:default_html_view) || :titled
20
+ end
21
+
22
+ def default_item_view
23
+ :bar
24
+ end
16
25
  end
data/set/all/json.rb CHANGED
@@ -26,24 +26,6 @@ format :json do
26
26
  end
27
27
  end
28
28
 
29
- def string_with_page_details
30
- raw = yield
31
- return raw if raw.is_a? String
32
-
33
- stringify page_details(raw)
34
- end
35
-
36
- def stringify raw
37
- method = params[:compress] ? :generate : :pretty_generate
38
- JSON.send method, raw
39
- end
40
-
41
- def page_details obj
42
- return obj unless obj.is_a? Hash
43
-
44
- obj.merge url: request_url, requested_at: Time.now.to_s
45
- end
46
-
47
29
  view :status, unknown: true, perms: :none do
48
30
  { key: card.key,
49
31
  url_key: card.name.url_key,
@@ -52,116 +34,31 @@ format :json do
52
34
  end
53
35
  end
54
36
 
55
- def request_url
56
- controller.request&.original_url || path
57
- end
58
-
59
- view :core, unknown: true do
60
- card.known? ? render_content : nil
61
- end
62
-
63
- view :content do
64
- card.content
65
- end
66
-
67
- view :nucleus do
68
- nucleus
69
- end
70
-
71
- # TODO: add simple values for fields
72
- view :atom, unknown: true do
73
- atom
74
- end
75
-
76
- view :molecule do
77
- molecule
78
- end
79
-
80
37
  view :page, cache: :never do
81
38
  page_details card: render_atom
82
39
  end
83
40
 
84
- # NOCACHE because sometimes item_cards is dynamic.
85
- # could be safely cached for non-dynamic lists
86
- view :items, cache: :never do
87
- listing item_cards, view: (voo_items_view || :atom)
88
- end
89
-
90
- view :links do
91
- card.link_chunks.map do |chunk|
92
- if chunk.referee_name
93
- path mark: chunk.referee_name, format: :json
94
- else
95
- link_to_resource chunk.link_target
96
- end
97
- end
98
- end
99
-
100
- view :ancestors do
101
- card.name.ancestors.map do |name|
102
- nest name, view: :nucleus
103
- end
104
- end
41
+ private
105
42
 
106
- # minimum needed to re-fetch card
107
- view :cast do
108
- card.cast
109
- end
110
-
111
- ## DEPRECATED
112
- view :marks do
113
- {
114
- id: card.id,
115
- name: card.name,
116
- key: card.key,
117
- url: path
118
- }
119
- end
120
-
121
- view :essentials do
122
- if voo.show? :marks
123
- render_marks.merge(essentials)
124
- else
125
- essentials
126
- end
43
+ def request_url
44
+ controller.request&.original_url || path
127
45
  end
128
46
 
129
- def essentials
130
- return {} if card.structure
47
+ def string_with_page_details
48
+ raw = yield
49
+ return raw if raw.is_a? String
131
50
 
132
- { content: card.db_content }
51
+ stringify page_details(raw)
133
52
  end
134
53
 
135
- # NOTE: moving these to methods prevents potential caching problems, because other
136
- # views manipulate their hashes.
137
- #
138
- def nucleus
139
- { id: card.id,
140
- name: card.name,
141
- type: card.type_name,
142
- url: path(format: :json) }.tap do |h|
143
- h[:codename] = card.codename if card.codename
144
- end
145
- end
54
+ def page_details obj
55
+ return obj unless obj.is_a? Hash
146
56
 
147
- def atom
148
- nucleus.tap do |h|
149
- h[:content] = render_content if card.known? && !card.structure
150
- end
57
+ obj.merge url: request_url, requested_at: Time.now.to_s
151
58
  end
152
59
 
153
- def molecule
154
- atom.merge items: _render_items,
155
- links: _render_links,
156
- ancestors: _render_ancestors,
157
- html_url: path,
158
- type: nest(card.type_card, view: :nucleus),
159
- created_at: card.created_at,
160
- updated_at: card.updated_at
60
+ def stringify raw
61
+ method = params[:compress] ? :generate : :pretty_generate
62
+ JSON.send method, raw
161
63
  end
162
64
  end
163
-
164
- # TODO: perhaps this should be in a general "data" module.
165
- def cast
166
- real? ? { id: id } : { name: name, type_id: type_id, content: db_content }
167
- end
data/set/all/links.rb CHANGED
@@ -95,7 +95,7 @@ format :html do
95
95
  opts[:href] ||= path opts.delete(:path)
96
96
  text = raw(text || opts[:href])
97
97
  interpret_data_opts_to_link_to opts
98
- wrap_with :a, text, opts
98
+ content_tag :a, text, opts
99
99
  end
100
100
 
101
101
  # in HTML, #link_to_card adds special css classes indicated whether a
data/set/all/text.rb CHANGED
@@ -1,8 +1,25 @@
1
1
  require "htmlentities"
2
2
 
3
+ format do
4
+ def to_text html
5
+ HTMLEntities.new.decode strip_tags(html).to_s
6
+ end
7
+
8
+ def nestless_content
9
+ content_obj = content_object card.content
10
+ content_obj.strip_nests
11
+ content_obj.process_chunks
12
+ content_obj.to_s
13
+ end
14
+
15
+ view :text_without_nests do
16
+ to_text nestless_content
17
+ end
18
+ end
19
+
3
20
  format :text do
21
+ # TODO: override this in cards without html content
4
22
  view :core do
5
- HTMLEntities.new.decode strip_tags(super()).to_s
6
- # need this string method to get out of html_safe mode
23
+ to_text super()
7
24
  end
8
25
  end
File without changes
data/set/all/yaml.rb ADDED
@@ -0,0 +1,6 @@
1
+ format :yaml do
2
+ def show view, args={}
3
+ view ||= :export
4
+ render!(view, args).to_yaml
5
+ end
6
+ end
data/set/type/basic.rb ADDED
@@ -0,0 +1,3 @@
1
+ def export_type
2
+ nil
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
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: 2021-12-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.103.1
21
+ version: 1.104.0
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.1
28
+ version: 1.104.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: card-mod-content
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.13.1
35
+ version: 0.14.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.13.1
42
+ version: 0.14.0
43
43
  description: ''
44
44
  email:
45
45
  - info@decko.org
@@ -55,43 +55,48 @@ files:
55
55
  - lib/card/format/js_format.rb
56
56
  - lib/card/format/json_format.rb
57
57
  - lib/card/format/rss_format.rb
58
+ - lib/card/format/scss_format.rb
58
59
  - lib/card/format/text_format.rb
59
60
  - lib/card/format/xml_format.rb
61
+ - lib/card/format/yaml_format.rb
60
62
  - lib/card/path.rb
61
63
  - lib/card/path/cast_params.rb
62
- - set/all/active_card.rb
64
+ - locales/de.yml
65
+ - locales/en.yml
63
66
  - set/all/base.rb
64
67
  - set/all/content.rb
65
68
  - set/all/css.rb
66
69
  - set/all/csv.rb
70
+ - set/all/data.rb
67
71
  - set/all/demo.rb
68
72
  - set/all/error.rb
69
- - set/all/export.rb
70
73
  - set/all/file.rb
71
- - set/all/frame.rb
72
74
  - set/all/haml.rb
73
- - set/all/head.rb
74
- - set/all/header.rb
75
- - set/all/header/header_wrap.haml
76
- - set/all/html_content.rb
77
- - set/all/html_content/labeled.haml
78
- - set/all/html_error.rb
79
- - set/all/html_error/debug_server_error.haml
80
- - set/all/html_error/not_found.haml
81
- - set/all/html_error/server_error.haml
82
- - set/all/html_show.rb
83
- - set/all/html_title.rb
84
- - set/all/html_wrapper.rb
75
+ - set/all/html.rb
76
+ - set/all/html/debug_server_error.haml
77
+ - set/all/html/error.rb
78
+ - set/all/html/frame.rb
79
+ - set/all/html/head.rb
80
+ - set/all/html/header.rb
81
+ - set/all/html/header_wrap.haml
82
+ - set/all/html/labeled.haml
83
+ - set/all/html/menu.rb
84
+ - set/all/html/meta_tags.haml
85
+ - set/all/html/not_found.haml
86
+ - set/all/html/server_error.haml
87
+ - set/all/html/show.rb
88
+ - set/all/html/views.rb
89
+ - set/all/html/wrap.rb
85
90
  - set/all/js.rb
86
91
  - set/all/json.rb
87
92
  - set/all/links.rb
88
- - set/all/menu.rb
89
- - set/all/meta_tags.haml
90
93
  - set/all/path.rb
91
- - set/all/rich_html.rb
92
94
  - set/all/rss.rb
93
95
  - set/all/text.rb
96
+ - set/all/title.rb
97
+ - set/all/yaml.rb
94
98
  - set/self/home.rb
99
+ - set/type/basic.rb
95
100
  - set/type/cardtype.rb
96
101
  - set/type/html.rb
97
102
  - set/type/json.rb
@@ -125,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
130
  - !ruby/object:Gem::Version
126
131
  version: '0'
127
132
  requirements: []
128
- rubygems_version: 3.1.6
133
+ rubygems_version: 3.2.15
129
134
  signing_key:
130
135
  specification_version: 4
131
136
  summary: format
@@ -1,5 +0,0 @@
1
- # FIXME: -this needs a better home!
2
- def format opts={}
3
- opts = { format: opts.to_sym } if [Symbol, String].member? opts.class
4
- Card::Format.new self, opts
5
- end
data/set/all/export.rb DELETED
@@ -1,70 +0,0 @@
1
- format :json do
2
- # returns an array of Hashes (each in export_item view)
3
- view :export, cache: :never do
4
- exporting_uniques do
5
- Array.wrap(render_export_item).concat(export_items_in_view(:export)).flatten
6
- end
7
- end
8
-
9
- def max_export_depth
10
- Env.params[:max_export_depth].present? ? Env.params[:max_export_depth].to_i : 2
11
- end
12
-
13
- # returns an array of Hashes (each in export_item view)
14
- view :export_items, cache: :never do
15
- exporting_uniques do
16
- export_items_in_view(:export).flatten
17
- end
18
- end
19
-
20
- # returns Hash with the essentials needed to import a card into a new database
21
- view :export_item do
22
- item = { name: card.name, type: card.type_name, content: card.content }
23
- item[:codename] = card.codename if card.codename
24
- track_exporting card
25
- item
26
- end
27
-
28
- def export_items_in_view view
29
- within_max_depth do
30
- valid_items_for_export.map do |item|
31
- nest item, view: view
32
- end
33
- end
34
- end
35
-
36
- def track_exporting card
37
- return unless @exported_keys
38
-
39
- @exported_keys << card.key
40
- end
41
-
42
- def exporting_uniques
43
- @exported_keys ||= inherit(:exported_keys) || ::Set.new
44
- yield
45
- end
46
-
47
- # prevent recursion
48
- def within_max_depth
49
- @export_depth ||= inherit(:export_depth).to_i + 1
50
- @export_depth > max_export_depth ? [] : yield
51
- end
52
-
53
- def items_for_export
54
- nest_chunks.map do |chunk|
55
- next if chunk.try :main?
56
-
57
- chunk.referee_card
58
- end.compact
59
- end
60
-
61
- def valid_items_for_export
62
- items_for_export.flatten.reject(&:blank?).uniq.find_all do |card|
63
- valid_export_card? card
64
- end
65
- end
66
-
67
- def valid_export_card? ecard
68
- ecard.real? && !@exported_keys.include?(ecard.key)
69
- end
70
- end
data/set/all/html_show.rb DELETED
@@ -1,53 +0,0 @@
1
- format :html do
2
- def show view, args
3
- capture_the_freak do
4
- content = send show_method, view, args
5
- show_full_page? ? wrap_with_html_page(content) : content
6
- end
7
- end
8
-
9
- def show_method
10
- "show_#{show_layout? ? :with : :without}_page_layout"
11
- end
12
-
13
- def show_without_page_layout view, args
14
- @main = true if params[:is_main] || args[:main]
15
- args.delete(:layout)
16
- view ||= args[:home_view] || :open # default_nest_view
17
- render! view, args
18
- end
19
-
20
- def show_full_page?
21
- !Env.ajax?
22
- end
23
-
24
- wrapper :html_page do
25
- <<-HTML.strip_heredoc
26
- <!DOCTYPE HTML>
27
- <html class="h-100">
28
- <head>
29
- #{head_content}
30
- </head>
31
- #{interior}
32
- </html>
33
- HTML
34
- end
35
-
36
- def head_content
37
- nest card.rule_card(:head), view: :head_content
38
- end
39
-
40
- private
41
-
42
- # this is a temporary fix to try to debug a recurring encoding-related error
43
- # TODO: remove the following after tracking down wikirate encoding bug
44
- def capture_the_freak
45
- yield
46
- rescue Card::Error::ServerError => e
47
- if e.message.match?(/invalid byte sequence/)
48
- Card::Lexicon.cache.reset
49
- Rails.logger.info "reset name cache to prevent encoding freakiness"
50
- end
51
- raise e
52
- end
53
- end