arclight 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/arclight/oembed_controller.js +10 -19
- data/lib/arclight/version.rb +1 -1
- data/package.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7013a9e0dc84a12fb9b6ed9e54e691c69153105e776dfadcc20c2f4aad877ec
|
4
|
+
data.tar.gz: a582750f5f80679ee4aaf7004bf0c30487f1f1c517c5738b509990597024636f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1934764433941e5bd519c1ac95646109b766fc36df6826fb273d285f0abbc6a3de6b3d58a2f7cd321c0edbbe402d03eef257f63dcf890508c2f1ac9a53104910
|
7
|
+
data.tar.gz: fca59f728f58b919dfabb27f37bf1190e6513680e29cb6ddd55ef5f9fe5c622b7d35657076a7e3beef5d0d1b8d3b828cce7411d6452745ae9560a14e3a142934
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Controller } from '@hotwired/stimulus'
|
2
2
|
|
3
|
-
export default class extends Controller {
|
3
|
+
export default class OembedController extends Controller {
|
4
4
|
static values = {
|
5
5
|
url: String
|
6
6
|
}
|
@@ -12,32 +12,23 @@ export default class extends Controller {
|
|
12
12
|
return
|
13
13
|
}
|
14
14
|
|
15
|
-
fetch(this.
|
16
|
-
.then((response) =>
|
15
|
+
fetch(this.urlValue)
|
16
|
+
.then((response) => {
|
17
|
+
if (response.ok) return response.text()
|
18
|
+
throw new Error(`HTTP error, status = ${response.status}`)
|
19
|
+
})
|
17
20
|
.then((body) => {
|
18
|
-
const oEmbedEndPoint =
|
21
|
+
const oEmbedEndPoint = OembedController.findOEmbedEndPoint(body)
|
19
22
|
if (!oEmbedEndPoint || oEmbedEndPoint.length === 0) {
|
20
|
-
console.warn(`No oEmbed endpoint found in <head> at ${this.
|
23
|
+
console.warn(`No oEmbed endpoint found in <head> at ${this.urlValue}`)
|
21
24
|
return
|
22
25
|
}
|
23
26
|
this.loadEndPoint(oEmbedEndPoint)
|
27
|
+
}).catch(error => {
|
28
|
+
console.error(error)
|
24
29
|
})
|
25
30
|
}
|
26
31
|
|
27
|
-
// Convert data-arclight-oembed-* attributes to URL parameters for the viewer
|
28
|
-
static normalizeParams(attributes) {
|
29
|
-
return Object.keys(attributes).reduce((acc, attribute) => {
|
30
|
-
// Reverse data attribute name conversion. See:
|
31
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset#name_conversion
|
32
|
-
const parameterName = attribute.replace('arclightOembed', '')
|
33
|
-
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
34
|
-
.toLowerCase()
|
35
|
-
|
36
|
-
acc[parameterName] = attributes[attribute]
|
37
|
-
return acc
|
38
|
-
}, {})
|
39
|
-
}
|
40
|
-
|
41
32
|
static findOEmbedEndPoint(body, extraParams = {}) {
|
42
33
|
// Parse out link elements so image assets are not loaded
|
43
34
|
const template = document.createElement('template')
|
data/lib/arclight/version.rb
CHANGED
data/package.json
CHANGED