oembed_proxy 0.2.0 → 0.2.1
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 +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -1
- data/README.md +7 -0
- data/lib/oembed_proxy/npr.rb +32 -0
- data/lib/oembed_proxy/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a43df03a51da4690d5afdfca411f45d466a129c524d2bdbf669efa39800a3c
|
4
|
+
data.tar.gz: 2bb0f79c2535a1e1bba1789446df519ad1a9ee03babdc692dc4118d3cd6c16e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e66dfae3a409b0befdb1be2f130a86d8fd77e37f386bf22b1e503efed528206872a97afadba30fd126e1c7daaa1a3bb07af8cd6d455b8ef26df55ed150ed8c74
|
7
|
+
data.tar.gz: '0123193339dd7e80f19ef3374a9f4f8cf4a1d6b2507da1bbbe62aa7c45d66edf3211a1e31c46c7ac64b61b03eef9912891f5e2801ae8652062e141ce86d9f648'
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -95,6 +95,13 @@ Once providers have been registered, calling `#handles_url?` and `#get_data` on
|
|
95
95
|
|
96
96
|
You are able to easily implement additional providers by creating an object which implements the `#handles_url?(url)` and `#get_data(url, other_params)` methods. Take a look at the existing provider classes for examples.
|
97
97
|
|
98
|
+
### Note on the NPR
|
99
|
+
|
100
|
+
The NPR embed is what we call a fauxembed. NPR does not implement the oembed
|
101
|
+
specification so we fake it by wrapping the embed url in a side-chain
|
102
|
+
element. Then you must load the NPR Sidechain library on your site. See
|
103
|
+
[Sidechain](https://github.com/nprapps/sidechain).
|
104
|
+
|
98
105
|
## Development
|
99
106
|
|
100
107
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Before sending a pull request, you will want to run `bin/rubocop` to lint your work.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'oembed_proxy/inactive_support'
|
4
|
+
|
5
|
+
module OembedProxy
|
6
|
+
# NPR Fauxembed
|
7
|
+
class Npr
|
8
|
+
using InactiveSupport
|
9
|
+
NPR_REGEX = %r{\Ahttps:\/\/(?:[a-z0-9-]+\.)+npr\.org\/.+}.freeze
|
10
|
+
|
11
|
+
def handles_url?(url)
|
12
|
+
!NPR_REGEX.match(url).nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_data(url, _other_params = {}) # rubocop:disable Metrics/MethodLength
|
16
|
+
return nil unless handles_url? url
|
17
|
+
|
18
|
+
escaped_url = url.gsub('"', '"')
|
19
|
+
{
|
20
|
+
'type' => 'rich',
|
21
|
+
'version' => '1.0',
|
22
|
+
'provider_name' => 'NPR',
|
23
|
+
'provider_url' => 'https://www.npr.org/',
|
24
|
+
'html' => <<~HTML,
|
25
|
+
<div class='sidechain-wrapper'>
|
26
|
+
<side-chain src="#{escaped_url}"></side-chain>
|
27
|
+
</div>
|
28
|
+
HTML
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/oembed_proxy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oembed_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/oembed_proxy/google_spreadsheet.rb
|
83
83
|
- lib/oembed_proxy/handler.rb
|
84
84
|
- lib/oembed_proxy/inactive_support.rb
|
85
|
+
- lib/oembed_proxy/npr.rb
|
85
86
|
- lib/oembed_proxy/oembed_exception.rb
|
86
87
|
- lib/oembed_proxy/tableau.rb
|
87
88
|
- lib/oembed_proxy/utility.rb
|