card-mod-format 0.19.1 → 0.20.0

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: 8fc4d1dcf48d5a8967ef40a89fbe5eb1039de00f4a262434014a4e4a23c716f2
4
- data.tar.gz: 69df359302308e13aef004d1ec0c7caa0f73551d8aeac49527cf66077c88d46a
3
+ metadata.gz: 7b412a79eac220252ee7d4e94acb7c4fecc356d731efe79481d7e9d1903d543d
4
+ data.tar.gz: 2fcaf8e3659f63cccc6e6721a401e3f40f780422531364e45d877a599e0cec79
5
5
  SHA512:
6
- metadata.gz: 3777d94b13161662a563486a9c8c24ead1475db20b5257fa5aa78169a8e1911bc36025c2e5de0e65d2839499cfb9e9405aee30f2300b3b86b2655008c44232c4
7
- data.tar.gz: 662c4507e8bf881665850be12882e08c350f874fd8e60a20bda1931bcbe388ba40dda963799fa7b9768a07ed82c24224be85c838b95e3377c57e7affe7ff9a2d
6
+ metadata.gz: a41d0a3c0dcf4cd884f9c914530eff9762ec01de3950273547e7bb49ad42cb201bafb86767833e4dfa3a66582e32d6447dabef77fa89996fd5d891160a2ec8d6
7
+ data.tar.gz: 0130640be94ac43b27458b04f7e0285093d328bacb6e81f5877f66cfbb6487b13861151e6a0f9d4e5dc57a8677a2e3a5b6eda7e506796ca15dc7fb93a204bc6b
@@ -7,7 +7,7 @@ class Card
7
7
  register :json
8
8
 
9
9
  def mime_type
10
- "text/json"
10
+ "application/json"
11
11
  end
12
12
 
13
13
  def expand_stubs content
@@ -0,0 +1,18 @@
1
+ class Card
2
+ class Format
3
+ # card format class for json (JavaScript Object Notation) views
4
+ class JsonldFormat < JsonFormat
5
+ Mime::Type.register "application/ld+json", :jsonld
6
+ register :jsonld
7
+
8
+ def mime_type
9
+ "application/ld+json"
10
+ end
11
+
12
+ # overrides #page_details in Json format, which adds standard info to every request
13
+ def page_details obj
14
+ obj
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ format :jsonld do
2
+ def jsonld_supported? = true
3
+
4
+ def resource_iri
5
+ path(mark: card.name, format: nil)
6
+ end
7
+ end
8
+
9
+ def export_formats
10
+ %i[csv json jsonld]
11
+ end
data/set/all/error.rb CHANGED
@@ -70,3 +70,36 @@ format :json do
70
70
  render_errors
71
71
  end
72
72
  end
73
+
74
+ format :jsonld do
75
+ view :test do
76
+ raise "blah"
77
+ end
78
+
79
+ view :not_found, perms: :none do
80
+ error_result 404, "Not Found"
81
+ end
82
+
83
+ view :denial, perms: :none do
84
+ error_result 403, "Permission denied"
85
+ end
86
+
87
+ view :errors, perms: :none do
88
+ error_result error_status, error_messages
89
+ end
90
+
91
+ view :format_unsupported, perms: :none do
92
+ root.error_status = 406
93
+ error_result 406, "JSON-LD is not available for this resource"
94
+ end
95
+
96
+ view :server_error, :errors, perms: :none
97
+
98
+ def error_result status=500, message="Internal Server Error"
99
+ {
100
+ "@context": "https://www.w3.org/ns/hydra/core#",
101
+ "@type": "hydra:Error",
102
+ "hydra:title": "#{status} | #{message}"
103
+ }.to_json
104
+ end
105
+ end
@@ -210,7 +210,7 @@ format :html do
210
210
  when Auth.signed_in?
211
211
  t(:format_need_permission_task, task: to_task)
212
212
  else
213
- Env.save_interrupted_action request.env["REQUEST_URI"]
213
+ # Env.save_interrupted_action request.env["REQUEST_URI"]
214
214
  sign_in_or_up_links to_do_unauthorized_task
215
215
  end
216
216
  end
data/set/all/html/head.rb CHANGED
@@ -28,7 +28,7 @@ end
28
28
  format :html do
29
29
  delegate :noindex?, to: :card
30
30
 
31
- view :head, unknown: true, perms: :none, cache: :yes do
31
+ view :head, unknown: true, perms: :none, cache: :always do
32
32
  basket[:head_views].map { |viewname| render viewname }.flatten.compact.join "\n"
33
33
  end
34
34
 
data/set/all/html/menu.rb CHANGED
@@ -179,7 +179,7 @@ format :html do
179
179
  end
180
180
 
181
181
  def menu_link_classes
182
- "nodblclick#{show_view?(:hover_link) ? ' _show-on-hover' : ''}"
182
+ "nodblclick#{' _show-on-hover' if show_view?(:hover_link)}"
183
183
  end
184
184
 
185
185
  def menu_icon
data/set/all/html.rb CHANGED
@@ -22,3 +22,12 @@ format :html do
22
22
  :bar
23
23
  end
24
24
  end
25
+
26
+ format do
27
+ # Sanitizer that strips all html tags
28
+ def sanitize_html value
29
+ return if value.blank?
30
+
31
+ (@full_sanitizer ||= Rails::Html::FullSanitizer.new).sanitize(value.to_s).presence
32
+ end
33
+ end
data/set/all/jsonld.rb ADDED
@@ -0,0 +1,21 @@
1
+ format :jsonld do
2
+ # Default: JSON-LD not supported (can be overridden by any set)
3
+ def jsonld_supported? = false
4
+
5
+ view :items, cache: :never do
6
+ listing_list item_cards, view: voo_items_view || :molecule
7
+ end
8
+
9
+ def show view, args
10
+ jsonld_supported? ? super : render_format_unsupported
11
+ end
12
+
13
+ def molecule
14
+ {
15
+ "@id": path,
16
+ "@context": "https://www.w3.org/ns/hydra/core#",
17
+ "@type": "hydra:Collection",
18
+ "hydra:member": _render_items
19
+ }.compact
20
+ end
21
+ end
data/set/all/links.rb CHANGED
@@ -8,7 +8,7 @@ format do
8
8
  # @param text [String] optional string associated with link
9
9
  # @param opts [Hash] optional Hash. In simple formats, :path is usually the only key
10
10
  def link_to text=nil, opts={}
11
- path = path((opts.delete(:path) || {}))
11
+ path = path(opts.delete(:path) || {})
12
12
  if text && path != text
13
13
  "#{text}[#{path}]"
14
14
  else
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.19.1
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.109.1
20
+ version: 1.110.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.109.1
27
+ version: 1.110.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: card-mod-content
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 0.19.1
34
+ version: 0.20.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 0.19.1
41
+ version: 0.20.0
42
42
  description: ''
43
43
  email:
44
44
  - info@decko.org
@@ -76,6 +76,7 @@ files:
76
76
  - lib/card/format/html_format.rb
77
77
  - lib/card/format/js_format.rb
78
78
  - lib/card/format/json_format.rb
79
+ - lib/card/format/jsonld_format.rb
79
80
  - lib/card/format/rss_format.rb
80
81
  - lib/card/format/scss_format.rb
81
82
  - lib/card/format/text_format.rb
@@ -84,6 +85,7 @@ files:
84
85
  - lib/card/mod/format.rb
85
86
  - lib/card/path.rb
86
87
  - lib/card/path/cast_params.rb
88
+ - set/abstract/jsonld_support.rb
87
89
  - set/all/base.rb
88
90
  - set/all/content.rb
89
91
  - set/all/css.rb
@@ -110,6 +112,7 @@ files:
110
112
  - set/all/html/wrap.rb
111
113
  - set/all/js.rb
112
114
  - set/all/json.rb
115
+ - set/all/jsonld.rb
113
116
  - set/all/links.rb
114
117
  - set/all/path.rb
115
118
  - set/all/rss.rb
@@ -228,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
231
  - !ruby/object:Gem::Version
229
232
  version: '0'
230
233
  requirements: []
231
- rubygems_version: 3.6.8
234
+ rubygems_version: 3.7.2
232
235
  specification_version: 4
233
236
  summary: format
234
237
  test_files: []