gretel-jsonld 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +24 -0
- data/lib/gretel/jsonld.rb +9 -0
- data/lib/gretel/jsonld/breadcrumb/list.rb +36 -0
- data/lib/gretel/jsonld/breadcrumb/list_item.rb +28 -0
- data/lib/gretel/jsonld/railtie.rb +16 -0
- data/lib/gretel/jsonld/renderer.rb +24 -0
- data/lib/gretel/jsonld/version.rb +7 -0
- data/lib/gretel/jsonld/view_helpers.rb +23 -0
- data/lib/tasks/gretel/jsonld_tasks.rake +5 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d3c3259c95025ca3013246ffef2562de36cd01d
|
4
|
+
data.tar.gz: cac38755ad0fafd73912c5e46c8f95900a9c70fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e20f0fa070a8350e10ae6bb0b8aac604e90b5ce58c167fd914159cee6722a0a1a5b8c3cedc9338324c6ea59f0a282ca729059fe589e5bf8e15c9ff32dd9c80d
|
7
|
+
data.tar.gz: 8232b6731349a1bb5d49b6b8c510a2bc595d3d72314bf3837756e60d3737ba8dc1c633612a742d34876bd1aaa353d9da53835aedcd7fb98f9e12d703556b506f
|
data/CHANGELOG.md
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 yasaichi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Gretel::Jsonld
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'gretel-jsonld'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install gretel-jsonld
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "bundler/setup"
|
5
|
+
rescue LoadError
|
6
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
7
|
+
end
|
8
|
+
|
9
|
+
require "rdoc/task"
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = "rdoc"
|
13
|
+
rdoc.title = "Gretel::Jsonld"
|
14
|
+
rdoc.options << "--line-numbers"
|
15
|
+
rdoc.rdoc_files.include("README.md")
|
16
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "gretel/jsonld/breadcrumb/list_item"
|
5
|
+
|
6
|
+
module Gretel
|
7
|
+
module Jsonld
|
8
|
+
module Breadcrumb
|
9
|
+
class List
|
10
|
+
def initialize(link_collection)
|
11
|
+
@link_collection = link_collection
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_json(*args)
|
15
|
+
{
|
16
|
+
"@context": "http://schema.org",
|
17
|
+
"@type": "BreadcrumbList",
|
18
|
+
itemListElement: item_list_element,
|
19
|
+
}.to_json(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def item_list_element
|
25
|
+
@link_collection.map.with_index(1) do |link, index|
|
26
|
+
::Gretel::Jsonld::Breadcrumb::ListItem.new(
|
27
|
+
id: link.url,
|
28
|
+
name: link.text,
|
29
|
+
position: index,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Gretel
|
6
|
+
module Jsonld
|
7
|
+
module Breadcrumb
|
8
|
+
class ListItem
|
9
|
+
def initialize(id:, name:, position:)
|
10
|
+
@id = id
|
11
|
+
@name = name
|
12
|
+
@position = position
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_json(*args)
|
16
|
+
{
|
17
|
+
"@type": "ListItem",
|
18
|
+
position: @position,
|
19
|
+
item: {
|
20
|
+
"@id": @id,
|
21
|
+
name: @name,
|
22
|
+
}
|
23
|
+
}.to_json(*args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/lazy_load_hooks"
|
4
|
+
require "rails/railtie"
|
5
|
+
|
6
|
+
module Gretel
|
7
|
+
module Jsonld
|
8
|
+
class Railtie < ::Rails::Railtie
|
9
|
+
initializer "gretel.jsonld" do
|
10
|
+
::ActiveSupport.on_load(:action_view) do
|
11
|
+
require "gretel/jsonld/view_helpers"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "gretel/jsonld/breadcrumb/list"
|
5
|
+
|
6
|
+
module Gretel
|
7
|
+
module Jsonld
|
8
|
+
class Renderer
|
9
|
+
def initialize(view_context)
|
10
|
+
@view_context = view_context
|
11
|
+
end
|
12
|
+
|
13
|
+
def render(link_collection)
|
14
|
+
return "" if link_collection.empty?
|
15
|
+
|
16
|
+
@view_context.content_tag(
|
17
|
+
:script,
|
18
|
+
JSON.generate(::Gretel::Jsonld::Breadcrumb::List.new(link_collection)).html_safe,
|
19
|
+
type: "application/ld+json",
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view"
|
4
|
+
require "gretel"
|
5
|
+
require "gretel/jsonld/renderer"
|
6
|
+
|
7
|
+
module Gretel
|
8
|
+
module Jsonld
|
9
|
+
module ViewHelpers
|
10
|
+
def jsonld_breadcrumbs(options = {})
|
11
|
+
gretel_jsonld_renderer.render(breadcrumbs(options))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def gretel_jsonld_renderer
|
17
|
+
@_gretel_jsonld_renderer ||= ::Gretel::Jsonld::Renderer.new(self)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
ActionView::Base.include(Gretel::Jsonld::ViewHelpers)
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gretel-jsonld
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yasaichi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gretel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: reek
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: gretel-json-ld enables gretel gem to handle JSON-LD based breadcrumbs.
|
98
|
+
email:
|
99
|
+
- yasaichi@users.noreply.github.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- CHANGELOG.md
|
105
|
+
- MIT-LICENSE
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/gretel/jsonld.rb
|
109
|
+
- lib/gretel/jsonld/breadcrumb/list.rb
|
110
|
+
- lib/gretel/jsonld/breadcrumb/list_item.rb
|
111
|
+
- lib/gretel/jsonld/railtie.rb
|
112
|
+
- lib/gretel/jsonld/renderer.rb
|
113
|
+
- lib/gretel/jsonld/version.rb
|
114
|
+
- lib/gretel/jsonld/view_helpers.rb
|
115
|
+
- lib/tasks/gretel/jsonld_tasks.rake
|
116
|
+
homepage: https://github.com/yasaichi/gretel-jsonld
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.6.13
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Gretel extension for supporting JSON-LD breadcrumbs
|
140
|
+
test_files: []
|