indieweb-post_types 0.1.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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/indieweb-post_types.gemspec +33 -0
- data/lib/indieweb/post_types.rb +17 -0
- data/lib/indieweb/post_types/configuration.rb +65 -0
- data/lib/indieweb/post_types/identifier/article.rb +87 -0
- data/lib/indieweb/post_types/identifier/base.rb +39 -0
- data/lib/indieweb/post_types/identifier/like.rb +20 -0
- data/lib/indieweb/post_types/identifier/note.rb +17 -0
- data/lib/indieweb/post_types/identifier/photo.rb +20 -0
- data/lib/indieweb/post_types/identifier/reply.rb +20 -0
- data/lib/indieweb/post_types/identifier/repost.rb +20 -0
- data/lib/indieweb/post_types/identifier/rsvp.rb +24 -0
- data/lib/indieweb/post_types/identifier/video.rb +20 -0
- data/lib/indieweb/post_types/version.rb +5 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebbfe2743761fe033746c07af9be65e9bf22db64
|
4
|
+
data.tar.gz: cefdae9741c7aee72a2bcc2c58860aab02a3ecbc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c247471160b7e40e3817a66f09d97b23eda446b4e27bb160c36029b1732987871b2d4043080067d3356478ba37bf76ac108bb6426222afdb13d06caad26e3c7
|
7
|
+
data.tar.gz: c781c672092a7be2b2ab18ca777e18a8a7824a46c489c4ac092bb2fbe3f43d3b0aa977edb768238deb835b0e0646e98df330c2c0e50abd06085b41dfdaa0a041
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.1.0] - 2018-06-11
|
10
|
+
|
11
|
+
### Added
|
12
|
+
- Initial release.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at coc+posttypes@deeden.co.uk. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Stephen Rushe
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Indieweb::PostTypes
|
2
|
+
|
3
|
+
Indieweb::PostTypes is a Ruby gem for performing [post type discovery](https://indieweb.org/post-type-discovery) for Microformats 2 JSON data.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'indieweb-post_types'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install indieweb-post_types
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Identify a post type from the provided data
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
post_type = Indieweb::PostTypes.type_from(data)
|
27
|
+
```
|
28
|
+
|
29
|
+
This will return a string containing the post type, such as `note`, `rsvp` etc.
|
30
|
+
|
31
|
+
## Identifiers
|
32
|
+
|
33
|
+
### Built-in
|
34
|
+
|
35
|
+
The following identifiers are built-in to the gem, and used in the order shown, returning the type specified.
|
36
|
+
|
37
|
+
| Class | Type |
|
38
|
+
| ----- | ---- |
|
39
|
+
| Indieweb::PostTypes::Identifier::Rsvp | rsvp |
|
40
|
+
| Indieweb::PostTypes::Identifier::Reply | reply |
|
41
|
+
| Indieweb::PostTypes::Identifier::Repost | repost |
|
42
|
+
| Indieweb::PostTypes::Identifier::Like | like |
|
43
|
+
| Indieweb::PostTypes::Identifier::Video | video |
|
44
|
+
| Indieweb::PostTypes::Identifier::Photo | photo |
|
45
|
+
| Indieweb::PostTypes::Identifier::Article | article |
|
46
|
+
| Indieweb::PostTypes::Identifier::Note | note |
|
47
|
+
|
48
|
+
### Writing your own identifier
|
49
|
+
|
50
|
+
It is also possible to write your own identifier to be used by the gem. All that is required for a new identifier is to create a new module with a class method called `type_from`, which takes as it's only parameter the data that should the checked, and returns as it's only response either `nil` (when it can't identify the post type), or a string containing the post type. You can perform any checks you require in the module, such as validating that certain fields are provided, or certain values set.
|
51
|
+
|
52
|
+
A simple example, which merely checks for the presence of a category called "[chicken](https://indieweb.org/chicken)" might be...
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
module PostType
|
56
|
+
module Chicken
|
57
|
+
extend Indieweb::PostTypes::Identifier::Base
|
58
|
+
|
59
|
+
class << self
|
60
|
+
def identifier_from(data)
|
61
|
+
return unless data.key?('category')
|
62
|
+
return unless data['category'].include?('chicken')
|
63
|
+
|
64
|
+
'chicken'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
## Configuration
|
72
|
+
|
73
|
+
### Identifiers
|
74
|
+
|
75
|
+
The identifiers listed above are always available, however it is possible to add other identifiers into the list of possible identifiers.
|
76
|
+
|
77
|
+
#### Adding a custom identifier
|
78
|
+
|
79
|
+
Assuming you have a new post type identifier you'd like to add (such as the "chicken" example above), you can configure `Indieweb::PostTypes` before using it as follows:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
Indieweb::PostTypes.configure do |config|
|
83
|
+
config.insert_identifier(klass: PostType::Chicken,
|
84
|
+
before: Indieweb::PostTypes::Identifier::Article)
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
`klass` refers to the new post type module you wish to add, whereas `before` refers to the module this should be added before. No new post type identifier may be added after `Indieweb::PostTypes::Identifier::Note` as that is the fallback option within post type discovery, and any unidentified entry will be identified as a `note`.
|
89
|
+
|
90
|
+
You can include multiple `insert_identifier` entries within the `configure` section, for cases where you wish to add more than one new post type.
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/srushe/indieweb-post_types. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
99
|
+
|
100
|
+
## Code of Conduct
|
101
|
+
|
102
|
+
Everyone interacting in the Indieweb::PostTypes project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/srushe/indieweb-post_types/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'indieweb/post_types'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'indieweb/post_types/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'indieweb-post_types'
|
7
|
+
spec.version = Indieweb::PostTypes::VERSION
|
8
|
+
spec.authors = ['Stephen Rushe']
|
9
|
+
spec.email = ['steve+posttypes@deeden.co.uk']
|
10
|
+
|
11
|
+
spec.summary = 'IndieWeb Post Type Discovery for Microformats 2 JSON.'
|
12
|
+
spec.description = 'IndieWeb Post Type Discovery for Microformats 2 JSON.'
|
13
|
+
spec.homepage = 'https://github.com/srushe/indieweb-post_types'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata = {
|
17
|
+
'bug_tracker_uri' => 'https://github.com/srushe/indieweb-post_types/issues',
|
18
|
+
'changelog_uri' => 'https://github.com/srushe/indieweb-post_types/CHANGELOG.md',
|
19
|
+
'homepage_uri' => 'https://github.com/srushe/indieweb-post_types/'
|
20
|
+
}
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
f.match(%r{^(test|spec|features)/})
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rubocop'
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'indieweb/post_types/version'
|
2
|
+
require 'indieweb/post_types/configuration'
|
3
|
+
|
4
|
+
module Indieweb
|
5
|
+
module PostTypes
|
6
|
+
extend Configuration
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def type_from(data)
|
10
|
+
identifiers.each do |klass|
|
11
|
+
type = klass.type_from(data)
|
12
|
+
return type unless type.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'indieweb/post_types/identifier/base'
|
3
|
+
require 'indieweb/post_types/identifier/article'
|
4
|
+
require 'indieweb/post_types/identifier/like'
|
5
|
+
require 'indieweb/post_types/identifier/note'
|
6
|
+
require 'indieweb/post_types/identifier/photo'
|
7
|
+
require 'indieweb/post_types/identifier/reply'
|
8
|
+
require 'indieweb/post_types/identifier/repost'
|
9
|
+
require 'indieweb/post_types/identifier/rsvp'
|
10
|
+
require 'indieweb/post_types/identifier/video'
|
11
|
+
|
12
|
+
module Indieweb
|
13
|
+
module PostTypes
|
14
|
+
module Configuration
|
15
|
+
attr_accessor :logger
|
16
|
+
attr_accessor :identifiers
|
17
|
+
|
18
|
+
def configure
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
def reset_configuration!
|
23
|
+
set_default_configuration
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.extended(base)
|
27
|
+
base.set_default_configuration
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_identifiers
|
31
|
+
[
|
32
|
+
Indieweb::PostTypes::Identifier::Rsvp,
|
33
|
+
Indieweb::PostTypes::Identifier::Reply,
|
34
|
+
Indieweb::PostTypes::Identifier::Repost,
|
35
|
+
Indieweb::PostTypes::Identifier::Like,
|
36
|
+
Indieweb::PostTypes::Identifier::Video,
|
37
|
+
Indieweb::PostTypes::Identifier::Photo,
|
38
|
+
Indieweb::PostTypes::Identifier::Article,
|
39
|
+
Indieweb::PostTypes::Identifier::Note
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
# TODO: Stop a class being inserted twice?
|
44
|
+
def insert_identifier(klass:, before:)
|
45
|
+
raise unless identifiers.include?(before)
|
46
|
+
identifiers.insert(identifiers.index(before), klass)
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_default_configuration
|
50
|
+
self.logger = default_logger
|
51
|
+
self.identifiers = default_identifiers
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# @private
|
57
|
+
def default_logger
|
58
|
+
Logger.new(STDOUT).tap do |logger|
|
59
|
+
logger.progname = 'IndiewebPostTypes'
|
60
|
+
logger.level = Logger::WARN
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Article
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless applicable_data?(data)
|
12
|
+
return if content_or_summary_starts_with_name?(data)
|
13
|
+
|
14
|
+
'article'
|
15
|
+
end
|
16
|
+
|
17
|
+
def applicable_data?(data)
|
18
|
+
(non_empty_content?(data) || non_empty?('summary', data)) &&
|
19
|
+
non_empty_name?(data)
|
20
|
+
end
|
21
|
+
|
22
|
+
def content_or_summary_starts_with_name?(data)
|
23
|
+
non_empty_content_or_summary(data).start_with?(non_empty_name(data))
|
24
|
+
end
|
25
|
+
|
26
|
+
def non_empty_content?(data)
|
27
|
+
return false unless data.fetch('content', nil).is_a?(Array)
|
28
|
+
|
29
|
+
data['content'].any? do |content|
|
30
|
+
if content.is_a?(Hash)
|
31
|
+
content.any? { |_key, value| !value.strip.empty? }
|
32
|
+
else
|
33
|
+
content.any? { |entry| !entry.strip.empty? }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def non_empty_name?(data)
|
39
|
+
non_empty?('name', data)
|
40
|
+
end
|
41
|
+
|
42
|
+
def non_empty?(field, data)
|
43
|
+
return false unless data.key?(field)
|
44
|
+
|
45
|
+
if data[field].is_a?(Hash)
|
46
|
+
data[field].any? { |_key, value| !value.strip.empty? }
|
47
|
+
else
|
48
|
+
Array(data[field]).any? { |entry| !entry.strip.empty? }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def non_empty_content_or_summary(data)
|
53
|
+
value = first_non_empty_content_for(data) ||
|
54
|
+
first_non_empty_for('summary', data)
|
55
|
+
value.strip.squeeze(' ')
|
56
|
+
end
|
57
|
+
|
58
|
+
def non_empty_name(data)
|
59
|
+
first_non_empty_for('name', data).strip.squeeze(' ')
|
60
|
+
end
|
61
|
+
|
62
|
+
def first_non_empty_content_for(data)
|
63
|
+
data['content'].each do |content|
|
64
|
+
if content.is_a?(Hash)
|
65
|
+
%w[value html].each do |key|
|
66
|
+
next unless content.key?(key)
|
67
|
+
return content[key] unless content[key].strip.empty?
|
68
|
+
end
|
69
|
+
else
|
70
|
+
return content unless content.strip.empty?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def first_non_empty_for(field, data)
|
76
|
+
if data[field].is_a?(Hash)
|
77
|
+
possibles = data[field].reject { |_, value| value.strip.empty? }
|
78
|
+
possibles.values.first
|
79
|
+
else
|
80
|
+
Array(data[field]).find { |entry| !entry.strip.empty? }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Indieweb
|
4
|
+
module PostTypes
|
5
|
+
module Identifier
|
6
|
+
module Base
|
7
|
+
def type_from(data)
|
8
|
+
data = entry_data_from(data)
|
9
|
+
identifier_from(data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid_url?(url)
|
13
|
+
uri = URI(actual_url_from(url))
|
14
|
+
%w[http https].include?(uri.scheme)
|
15
|
+
rescue URI::InvalidURIError
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def entry_data_from(data)
|
22
|
+
return data['properties'] if data['properties']
|
23
|
+
return data unless data.key?('items')
|
24
|
+
data['items'].first['properties']
|
25
|
+
end
|
26
|
+
|
27
|
+
def actual_url_from(url)
|
28
|
+
return url if url.is_a?(String)
|
29
|
+
return url[0] unless url[0].is_a?(Hash)
|
30
|
+
url_from_citation(url[0])
|
31
|
+
end
|
32
|
+
|
33
|
+
def url_from_citation(data)
|
34
|
+
data['properties']['url'][0]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Like
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless data.key?('like-of')
|
12
|
+
return unless valid_url?(data['like-of'])
|
13
|
+
|
14
|
+
'like'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Photo
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless data.key?('photo')
|
12
|
+
return unless valid_url?(data['photo'])
|
13
|
+
|
14
|
+
'photo'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Reply
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless data.key?('in-reply-to')
|
12
|
+
return unless valid_url?(data['in-reply-to'])
|
13
|
+
|
14
|
+
'reply'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Repost
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless data.key?('repost-of')
|
12
|
+
return unless valid_url?(data['repost-of'])
|
13
|
+
|
14
|
+
'repost'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Rsvp
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless data.key?('rsvp')
|
12
|
+
return unless valid_value?(data['rsvp'][0])
|
13
|
+
|
14
|
+
'rsvp'
|
15
|
+
end
|
16
|
+
|
17
|
+
def valid_value?(value)
|
18
|
+
%w[yes no maybe interested].include?(value.downcase)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Indieweb
|
2
|
+
module PostTypes
|
3
|
+
module Identifier
|
4
|
+
module Video
|
5
|
+
extend Indieweb::PostTypes::Identifier::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def identifier_from(data)
|
11
|
+
return unless data.key?('video')
|
12
|
+
return unless valid_url?(data['video'])
|
13
|
+
|
14
|
+
'video'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: indieweb-post_types
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Rushe
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
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
|
+
description: IndieWeb Post Type Discovery for Microformats 2 JSON.
|
70
|
+
email:
|
71
|
+
- steve+posttypes@deeden.co.uk
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- indieweb-post_types.gemspec
|
88
|
+
- lib/indieweb/post_types.rb
|
89
|
+
- lib/indieweb/post_types/configuration.rb
|
90
|
+
- lib/indieweb/post_types/identifier/article.rb
|
91
|
+
- lib/indieweb/post_types/identifier/base.rb
|
92
|
+
- lib/indieweb/post_types/identifier/like.rb
|
93
|
+
- lib/indieweb/post_types/identifier/note.rb
|
94
|
+
- lib/indieweb/post_types/identifier/photo.rb
|
95
|
+
- lib/indieweb/post_types/identifier/reply.rb
|
96
|
+
- lib/indieweb/post_types/identifier/repost.rb
|
97
|
+
- lib/indieweb/post_types/identifier/rsvp.rb
|
98
|
+
- lib/indieweb/post_types/identifier/video.rb
|
99
|
+
- lib/indieweb/post_types/version.rb
|
100
|
+
homepage: https://github.com/srushe/indieweb-post_types
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata:
|
104
|
+
bug_tracker_uri: https://github.com/srushe/indieweb-post_types/issues
|
105
|
+
changelog_uri: https://github.com/srushe/indieweb-post_types/CHANGELOG.md
|
106
|
+
homepage_uri: https://github.com/srushe/indieweb-post_types/
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: IndieWeb Post Type Discovery for Microformats 2 JSON.
|
127
|
+
test_files: []
|