Skip to content

Commit

Permalink
begin to support JSON export
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGermuska committed Oct 11, 2024
1 parent 0bdcf67 commit d153d53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/js/core/ConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ var buildGoogleFeedURL = function(key, api_version) {
}
}

async function jsonFromGoogleURL(google_url, options) {
export async function jsonFromGoogleURL(google_url, options) {

if (!options['sheets_proxy']) {
throw new TLError("Proxy option must be set to read data from Google")
Expand Down
9 changes: 3 additions & 6 deletions src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import "../less/TL.Timeline.less"
export { Timeline }
from "./timeline/Timeline"
export { parseGoogleSpreadsheetURL }
from "./core/ConfigFactory"
export { lookupMediaType }
from "./media/MediaType"
export { Timeline, exportJSON } from "./timeline/Timeline"
export { parseGoogleSpreadsheetURL } from "./core/ConfigFactory"
export { lookupMediaType } from "./media/MediaType"
14 changes: 12 additions & 2 deletions src/js/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Message from "../ui/Message"
import { Language, fallback, loadLanguage } from "../language/Language"
import { I18NMixins } from "../language/I18NMixins";
import Events from "../core/Events";
import { makeConfig } from "../core/ConfigFactory"
import { makeConfig, jsonFromGoogleURL } from "../core/ConfigFactory"
import { TimelineConfig } from "../core/TimelineConfig"
import { TimeNav } from "../timenav/TimeNav"
import * as Browser from "../core/Browser"
Expand Down Expand Up @@ -1018,4 +1018,14 @@ class Timeline {

classMixin(Timeline, I18NMixins, Events)

export { Timeline }
async function exportJSON(url, proxy_url) {

if (!proxy_url) {
proxy_url = 'https://sheets-proxy.knightlab.com/proxy/'
}

let json = await jsonFromGoogleURL(url, {sheets_proxy: proxy_url})
return json
}

export { Timeline, exportJSON }

0 comments on commit d153d53

Please sign in to comment.