@knight-lab/timelinejs 3.9.3 → 3.9.4

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.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@knight-lab/timelinejs",
3
- "version": "3.9.3",
3
+ "version": "3.9.4",
4
4
  "license": "MPL-2.0",
5
5
  "description": "TimelineJS v3: A Storytelling Timeline built in JavaScript, made by Northwestern University Knight Lab.",
6
6
  "dependencies": {
7
- "dompurify": "^2.2.7",
7
+ "dompurify": "^3.1.7",
8
8
  "wicg-inert": "^3.1.2"
9
9
  },
10
10
  "devDependencies": {
@@ -65,7 +65,8 @@ function extractEventFromCSVObject(orig_row) {
65
65
  caption: row['Media Caption'] || '',
66
66
  credit: row['Media Credit'] || '',
67
67
  url: row['Media'] || '',
68
- thumbnail: row['Media Thumbnail'] || ''
68
+ thumbnail: row['Media Thumbnail'] || '',
69
+ alt: row['Alt Text'] || ''
69
70
  },
70
71
  text: {
71
72
  headline: row['Headline'] || '',
@@ -223,7 +224,7 @@ var buildGoogleFeedURL = function(key, api_version) {
223
224
  }
224
225
  }
225
226
 
226
- async function jsonFromGoogleURL(google_url, options) {
227
+ export async function jsonFromGoogleURL(google_url, options) {
227
228
 
228
229
  if (!options['sheets_proxy']) {
229
230
  throw new TLError("Proxy option must be set to read data from Google")
package/src/js/index.js CHANGED
@@ -1,7 +1,4 @@
1
1
  import "../less/TL.Timeline.less"
2
- export { Timeline }
3
- from "./timeline/Timeline"
4
- export { parseGoogleSpreadsheetURL }
5
- from "./core/ConfigFactory"
6
- export { lookupMediaType }
7
- from "./media/MediaType"
2
+ export { Timeline, exportJSON } from "./timeline/Timeline"
3
+ export { parseGoogleSpreadsheetURL } from "./core/ConfigFactory"
4
+ export { lookupMediaType } from "./media/MediaType"
@@ -44,7 +44,7 @@ export default class WikipediaImage extends Media {
44
44
 
45
45
  _loadMedia() {
46
46
  var api_url,
47
- image_width = this.options.width || 1000,
47
+ image_width = Math.round(this.options.width) || 1000, // value to WP API must be int
48
48
  language_code = this.getLanguage().lang.toLowerCase(),
49
49
  self = this;
50
50
 
@@ -140,8 +140,9 @@ export default class WikipediaImage extends Media {
140
140
 
141
141
  _getImageURL(w, h) {
142
142
  if (w && this.base_image_url) {
143
- let match = this.base_image_url.match(/(\/\d+px-)/)
143
+ let match = this.base_image_url.match(/(\/[\d\.]+px-)/)
144
144
  if (match) {
145
+ w = Math.round(w) // WP image URLS 404 if floats are used so round it.
145
146
  return this.base_image_url.replace(match[1], `/${w}px-`) // Wikipedia will autoscale the image for us
146
147
  }
147
148
  }
@@ -156,4 +157,4 @@ export default class WikipediaImage extends Media {
156
157
  *
157
158
  * https://commons.wikimedia.org/w/api.php?action=query&titles=File:Beryl-Quartz-Emerald-Zambia-33mm_0885.jpg&prop=imageinfo&iiprop=url&&iiurlwidth=1000
158
159
  * https://commons.wikimedia.org/wiki/File:Beryl-Quartz-Emerald-Zambia-33mm_0885.jpg
159
- */
160
+ */
@@ -5,7 +5,7 @@ import Message from "../ui/Message"
5
5
  import { Language, fallback, loadLanguage } from "../language/Language"
6
6
  import { I18NMixins } from "../language/I18NMixins";
7
7
  import Events from "../core/Events";
8
- import { makeConfig } from "../core/ConfigFactory"
8
+ import { makeConfig, jsonFromGoogleURL } from "../core/ConfigFactory"
9
9
  import { TimelineConfig } from "../core/TimelineConfig"
10
10
  import { TimeNav } from "../timenav/TimeNav"
11
11
  import * as Browser from "../core/Browser"
@@ -1018,4 +1018,14 @@ class Timeline {
1018
1018
 
1019
1019
  classMixin(Timeline, I18NMixins, Events)
1020
1020
 
1021
- export { Timeline }
1021
+ async function exportJSON(url, proxy_url) {
1022
+
1023
+ if (!proxy_url) {
1024
+ proxy_url = 'https://sheets-proxy.knightlab.com/proxy/'
1025
+ }
1026
+
1027
+ let json = await jsonFromGoogleURL(url, {sheets_proxy: proxy_url})
1028
+ return json
1029
+ }
1030
+
1031
+ export { Timeline, exportJSON }
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "text": {
9
9
  "headline": "TimelineJS Media Types",
10
- "text": "<p>TimelineJS supports many media types. This provides a simple way to test them all. This page tests a simple image on a remote server. Also, if the Timeline was created with the <code>soundcite</code> option set to <code>true</code> then <span class='soundcite' data-url='https://soundcite.knightlab.com/media/bach-cello-suite.mp3' data-start='0' data-end='164000' data-plays='1'>this should be an active SoundCite player.</span></p>"
10
+ "text": "<p>TimelineJS supports many media types. This provides a simple way to test them all. This page tests a simple image on a remote server. Also, if the Timeline was created with the <code>soundcite</code> option set to <code>true</code> then <span class='soundcite' data-url='https://soundcite.knightlab.com/media/bach-cello-suite.mp3' data-start='0' data-end='164000' data-plays='1'>this should be an active SoundCite player.</span></p><p><a target=\"_self\" href=\"#wikipedia-images\">click to jump to Wikipedia Images</a></p>"
11
11
  },
12
12
  "background": {
13
13
  "color": "papayawhip"
@@ -388,10 +388,10 @@
388
388
 
389
389
  {
390
390
  "media": {
391
- "url": "https://en.wikipedia.org/wiki/1997_International_Tennis_Championships_%E2%80%93_Doubles",
391
+ "url": "https://fr.wikipedia.org/wiki/Bataille_de_Champigny#/media/Fichier:Champigny,_le_four_%C3%A0_chaux_(d%C3%A9tail).jpg",
392
392
  "caption": "1997 International Tennis Championships - Doubles",
393
393
  "credit": "Wikipedia",
394
- "link": "https://en.wikipedia.org/wiki/1997_International_Tennis_Championships_%E2%80%93_Doubles"
394
+ "link": "https://fr.wikipedia.org/wiki/Bataille_de_Champigny#/media/Fichier:Champigny,_le_four_%C3%A0_chaux_(d%C3%A9tail).jpg"
395
395
  },
396
396
  "start_date": {
397
397
  "year": "1920"
@@ -519,7 +519,7 @@
519
519
  },
520
520
  {
521
521
  "media": {
522
- "url": "https://file-examples.com/storage/fef12739526267ac9a2b543/2017/04/file_example_MP4_480_1_5MG.mp4",
522
+ "url": "https://file-examples.com/storage/febf69dcf3656dfd992b0fa/2017/04/file_example_MP4_480_1_5MG.mp4",
523
523
  "credit": "file-examples.com"
524
524
  },
525
525
  "start_date": {
@@ -548,6 +548,7 @@
548
548
  "group": "Video"
549
549
  },
550
550
  {
551
+ "unique_id": "wistia",
551
552
  "media": {
552
553
  "url": "https://lakeshore.wistia.com/medias/g2h5ddrucc",
553
554
  "credit": "Wistia"
@@ -562,6 +563,7 @@
562
563
  "group": "Video"
563
564
  },
564
565
  {
566
+ "unique_id": "wikipedia-images",
565
567
  "media": {
566
568
  "url": "https://de.wikipedia.org/wiki/Beryllium#/media/Datei:Beryl-Quartz-Emerald-Zambia-33mm_0885.jpg",
567
569
  "credit": "Wikipedia"
@@ -576,6 +578,7 @@
576
578
  "group": "Image"
577
579
  },
578
580
  {
581
+ "unique_id": "wikipedia-commons",
579
582
  "media": {
580
583
  "url": "https://commons.wikimedia.org/wiki/File:David-Bowie_Chicago_2002-08-08_photoby_Adam-Bielawski-cropped.jpg",
581
584
  "credit": "Wikipedia"
@@ -590,4 +593,4 @@
590
593
  "group": "Image"
591
594
  }
592
595
  ]
593
- }
596
+ }