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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1390f6e3757bd6b696874a8eb4e02c06e31a3c51d03a85bb25880e6536133fd
4
- data.tar.gz: e55f6e430f6b88974ca1c73b8353fe2869936b43c784027fb7c443eebce94170
3
+ metadata.gz: e7013a9e0dc84a12fb9b6ed9e54e691c69153105e776dfadcc20c2f4aad877ec
4
+ data.tar.gz: a582750f5f80679ee4aaf7004bf0c30487f1f1c517c5738b509990597024636f
5
5
  SHA512:
6
- metadata.gz: d685048894b2c9ef5821c845c1630e8b375ccb9192cff406a1d58fc38475f07b03055c28c9d1568489a6bbd8c68ba856f359feb780d3a4fe4bba0355e9994d41
7
- data.tar.gz: 2a3593117293b05a325d140a58f60cdfd34218b40222f7a13ccf7f9c1d62a07a244e08ee894fd5b991efa0d2da6c7521c8fde8e8fb5fa33eec62529e2ca1cb6a
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.urlTarget)
16
- .then((response) => response.text())
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 = this.findOEmbedEndPoint(body)
21
+ const oEmbedEndPoint = OembedController.findOEmbedEndPoint(body)
19
22
  if (!oEmbedEndPoint || oEmbedEndPoint.length === 0) {
20
- console.warn(`No oEmbed endpoint found in <head> at ${this.urlTarget}`)
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')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arclight
4
- VERSION = '1.0.0.beta2'
4
+ VERSION = '1.0.0.beta3'
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arclight",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "The frontend for arclight",
5
5
  "main": "app/assets/javascript/arclight/arclight.js",
6
6
  "files": [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arclight
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Hardy