gretel-jsonld 0.1.1 → 0.3.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 +5 -5
- data/CHANGELOG.md +10 -1
- data/README.md +114 -9
- data/Rakefile +1 -1
- data/lib/gretel/jsonld/breadcrumb/list.rb +4 -2
- data/lib/gretel/jsonld/breadcrumb/list_item.rb +3 -1
- data/lib/gretel/jsonld/railtie.rb +2 -1
- data/lib/gretel/jsonld/renderer.rb +4 -2
- data/lib/gretel/jsonld/version.rb +2 -2
- data/lib/gretel/jsonld/view_helpers.rb +3 -3
- metadata +18 -9
- data/lib/tasks/gretel/jsonld_tasks.rake +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1e7bf55860ae8f21a3d5a931806e9c550cf4e1d31af9546703d86d125d14c00e
|
|
4
|
+
data.tar.gz: 3286dab9d4dbcc9b9e61a7e4528359ada4e3cb63e59af75a40c765497d2e3c68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79b86b733f968da7bca93b29a9ca65486783bb814ebf396d3906ae7ca9646d3b952c36f65a26c99ba191d4edc954ce7af855999b51a320f46ce9d50d7472564c
|
|
7
|
+
data.tar.gz: 16b507af8635110bece74b61f433cc401ae4bf2140414f0ab0ac3c73abb07c9eedc7cb7191b4988660c5d94b760f67c3f648c74cfcbe90530704ec1bafdae804
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
|
+
## [0.3.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.3.0) (July 22, 2026)
|
|
3
|
+
* [Test against Rails 6 through 8](https://github.com/yasaichi/gretel-jsonld/pull/18)
|
|
4
|
+
* [Drop support for Ruby 2.4 and earlier](https://github.com/yasaichi/gretel-jsonld/pull/16)
|
|
5
|
+
|
|
6
|
+
## [0.2.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.2.0) (November 25, 2017)
|
|
7
|
+
* [Write README](https://github.com/yasaichi/gretel-jsonld/pull/7)
|
|
8
|
+
* [Use `JSONLD` as module name instead of `Jsonld`](https://github.com/yasaichi/gretel-jsonld/pull/6)
|
|
9
|
+
* [Specify the required Ruby version](https://github.com/yasaichi/gretel-jsonld/pull/5)
|
|
10
|
+
|
|
2
11
|
## [0.1.1](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.1.1) (November 25, 2017)
|
|
3
|
-
* Cope with Rails 4.0 or former
|
|
12
|
+
* [Cope with Rails 4.0 or former](https://github.com/yasaichi/gretel-jsonld/pull/4)
|
|
4
13
|
|
|
5
14
|
## [0.1.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.1.0) (November 23, 2017)
|
|
6
15
|
* The initial release to reserve the gem name
|
data/README.md
CHANGED
|
@@ -1,28 +1,133 @@
|
|
|
1
|
-
#
|
|
2
|
-
Short description and motivation.
|
|
1
|
+
# gretel-jsonld
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
[](http://badge.fury.io/rb/gretel-jsonld)
|
|
4
|
+
[](https://github.com/yasaichi/gretel-jsonld/actions/workflows/ci.yml)
|
|
5
|
+
[](https://qlty.sh/gh/yasaichi/projects/gretel-jsonld)
|
|
6
|
+
[](https://qlty.sh/gh/yasaichi/projects/gretel-jsonld)
|
|
7
|
+
|
|
8
|
+
gretel-jsonld enables gretel gem to handle JSON-LD based breadcrumbs.
|
|
6
9
|
|
|
7
10
|
## Installation
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
Add this line to your application's `Gemfile`:
|
|
9
13
|
|
|
10
14
|
```ruby
|
|
11
15
|
gem 'gretel-jsonld'
|
|
12
16
|
```
|
|
13
17
|
|
|
14
18
|
And then execute:
|
|
19
|
+
|
|
15
20
|
```bash
|
|
16
21
|
$ bundle
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
First, run the installation generator with:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
$ rails generate gretel:install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Next, define "crumbs" in `config/breadcrumbs.rb`:
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
# See also: https://github.com/lassebunk/gretel#more-examples
|
|
36
|
+
|
|
37
|
+
# Root crumb
|
|
38
|
+
crumb :root do
|
|
39
|
+
link 'Home', root_path
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Issue list
|
|
43
|
+
crumb :issues do
|
|
44
|
+
link 'All issues', issues_path
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Issue
|
|
48
|
+
crumb :issue do |issue|
|
|
49
|
+
link issue.title, issue
|
|
50
|
+
parent :issues
|
|
51
|
+
end
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then, add this line to your application's layout:
|
|
55
|
+
|
|
56
|
+
```erb
|
|
57
|
+
<%= jsonld_breadcrumbs %>
|
|
22
58
|
```
|
|
23
59
|
|
|
60
|
+
Finally, specify a current breadcrumb in each view:
|
|
61
|
+
|
|
62
|
+
```erb
|
|
63
|
+
<% breadcrumb :issue, @issue %>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This will generate the following breadcrumbs, marked up with JSON-LD (indented for readability):
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<script type="application/ld+json">
|
|
70
|
+
{
|
|
71
|
+
"@context": "http://schema.org",
|
|
72
|
+
"@type": "BreadcrumbList",
|
|
73
|
+
"itemListElement": [
|
|
74
|
+
{
|
|
75
|
+
"@type": "ListItem",
|
|
76
|
+
"position": 1,
|
|
77
|
+
"item": {
|
|
78
|
+
"@id": "/",
|
|
79
|
+
"name": "Home"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"@type": "ListItem",
|
|
84
|
+
"position": 2,
|
|
85
|
+
"item": {
|
|
86
|
+
"@id": "/issues",
|
|
87
|
+
"name": "All issues"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"@type": "ListItem",
|
|
92
|
+
"position": 3,
|
|
93
|
+
"item": {
|
|
94
|
+
"@id": "/issues/46",
|
|
95
|
+
"name": "My Issue"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Options
|
|
104
|
+
|
|
105
|
+
You can pass `jsonld_breadcrumbs` the same options as `breadcrumbs`:
|
|
106
|
+
|
|
107
|
+
```erb
|
|
108
|
+
<%= jsonld_breadcrumbs link_current_to_request_path: false %>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For further information, please see [gretel's documentation](https://github.com/WilHall/gretel/blob/develop/README.md#options).
|
|
112
|
+
|
|
113
|
+
## Supported versions
|
|
114
|
+
|
|
115
|
+
Note that gretel-jsonld doesn't support all versions of gretel, Ruby and Rails:
|
|
116
|
+
|
|
117
|
+
- gretel: gretel-jsonld supports **only 3.x** for now
|
|
118
|
+
- Ruby: gretel 3.x supports **1.9.3 or later**, but gretel-jsonld does **only 2.5 or later**
|
|
119
|
+
- Rails: gretel 3.x supports **3.1 or later**, but gretel-jsonld does **only 5 or later**
|
|
120
|
+
|
|
24
121
|
## Contributing
|
|
25
|
-
|
|
122
|
+
|
|
123
|
+
You should follow the steps below:
|
|
124
|
+
|
|
125
|
+
1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
|
|
126
|
+
2. Create a feature branch: `git checkout -b add-new-feature`
|
|
127
|
+
3. Commit your changes: `git commit -am 'Add new feature'`
|
|
128
|
+
4. Push the branch: `git push origin add-new-feature`
|
|
129
|
+
5. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)
|
|
26
130
|
|
|
27
131
|
## License
|
|
132
|
+
|
|
28
133
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
|
@@ -10,7 +10,7 @@ require "rdoc/task"
|
|
|
10
10
|
|
|
11
11
|
RDoc::Task.new(:rdoc) do |rdoc|
|
|
12
12
|
rdoc.rdoc_dir = "rdoc"
|
|
13
|
-
rdoc.title = "Gretel::
|
|
13
|
+
rdoc.title = "Gretel::JSONLD"
|
|
14
14
|
rdoc.options << "--line-numbers"
|
|
15
15
|
rdoc.rdoc_files.include("README.md")
|
|
16
16
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require "active_support"
|
|
5
|
+
require "active_support/json/encoding"
|
|
4
6
|
require "gretel/jsonld/breadcrumb/list_item"
|
|
5
7
|
|
|
6
8
|
module Gretel
|
|
7
|
-
module
|
|
9
|
+
module JSONLD
|
|
8
10
|
module Breadcrumb
|
|
9
11
|
class List
|
|
10
12
|
def initialize(link_collection)
|
|
@@ -28,7 +30,7 @@ module Gretel
|
|
|
28
30
|
|
|
29
31
|
def item_list_element
|
|
30
32
|
@link_collection.map.with_index(1) do |link, index|
|
|
31
|
-
::Gretel::
|
|
33
|
+
::Gretel::JSONLD::Breadcrumb::ListItem.new(
|
|
32
34
|
id: link.url,
|
|
33
35
|
name: link.text,
|
|
34
36
|
position: index,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "active_support"
|
|
3
4
|
require "active_support/lazy_load_hooks"
|
|
4
5
|
require "rails/railtie"
|
|
5
6
|
|
|
6
7
|
module Gretel
|
|
7
|
-
module
|
|
8
|
+
module JSONLD
|
|
8
9
|
class Railtie < ::Rails::Railtie
|
|
9
10
|
initializer "gretel.jsonld" do
|
|
10
11
|
::ActiveSupport.on_load(:action_view) do
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require "active_support"
|
|
5
|
+
require "active_support/core_ext/string/output_safety"
|
|
4
6
|
require "gretel/jsonld/breadcrumb/list"
|
|
5
7
|
|
|
6
8
|
module Gretel
|
|
7
|
-
module
|
|
9
|
+
module JSONLD
|
|
8
10
|
class Renderer
|
|
9
11
|
def initialize(view_context)
|
|
10
12
|
@view_context = view_context
|
|
@@ -15,7 +17,7 @@ module Gretel
|
|
|
15
17
|
|
|
16
18
|
@view_context.content_tag(
|
|
17
19
|
:script,
|
|
18
|
-
JSON.generate(::Gretel::
|
|
20
|
+
JSON.generate(::Gretel::JSONLD::Breadcrumb::List.new(link_collection)).html_safe,
|
|
19
21
|
type: "application/ld+json",
|
|
20
22
|
)
|
|
21
23
|
end
|
|
@@ -5,7 +5,7 @@ require "gretel"
|
|
|
5
5
|
require "gretel/jsonld/renderer"
|
|
6
6
|
|
|
7
7
|
module Gretel
|
|
8
|
-
module
|
|
8
|
+
module JSONLD
|
|
9
9
|
module ViewHelpers
|
|
10
10
|
def jsonld_breadcrumbs(options = {})
|
|
11
11
|
gretel_jsonld_renderer.render(breadcrumbs(options))
|
|
@@ -14,10 +14,10 @@ module Gretel
|
|
|
14
14
|
private
|
|
15
15
|
|
|
16
16
|
def gretel_jsonld_renderer
|
|
17
|
-
@_gretel_jsonld_renderer ||= ::Gretel::
|
|
17
|
+
@_gretel_jsonld_renderer ||= ::Gretel::JSONLD::Renderer.new(self)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
ActionView::Base.include(Gretel::
|
|
23
|
+
ActionView::Base.include(Gretel::JSONLD::ViewHelpers)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gretel-jsonld
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yasaichi
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: gretel
|
|
@@ -94,6 +93,20 @@ dependencies:
|
|
|
94
93
|
- - ">="
|
|
95
94
|
- !ruby/object:Gem::Version
|
|
96
95
|
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: rubocop-performance
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
|
98
111
|
name: simplecov
|
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -126,12 +139,10 @@ files:
|
|
|
126
139
|
- lib/gretel/jsonld/renderer.rb
|
|
127
140
|
- lib/gretel/jsonld/version.rb
|
|
128
141
|
- lib/gretel/jsonld/view_helpers.rb
|
|
129
|
-
- lib/tasks/gretel/jsonld_tasks.rake
|
|
130
142
|
homepage: https://github.com/yasaichi/gretel-jsonld
|
|
131
143
|
licenses:
|
|
132
144
|
- MIT
|
|
133
145
|
metadata: {}
|
|
134
|
-
post_install_message:
|
|
135
146
|
rdoc_options: []
|
|
136
147
|
require_paths:
|
|
137
148
|
- lib
|
|
@@ -139,16 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
139
150
|
requirements:
|
|
140
151
|
- - ">="
|
|
141
152
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: '
|
|
153
|
+
version: '2.5'
|
|
143
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
155
|
requirements:
|
|
145
156
|
- - ">="
|
|
146
157
|
- !ruby/object:Gem::Version
|
|
147
158
|
version: '0'
|
|
148
159
|
requirements: []
|
|
149
|
-
|
|
150
|
-
rubygems_version: 2.5.2.1
|
|
151
|
-
signing_key:
|
|
160
|
+
rubygems_version: 4.0.16
|
|
152
161
|
specification_version: 4
|
|
153
162
|
summary: Gretel extension for supporting JSON-LD breadcrumbs
|
|
154
163
|
test_files: []
|