[add] dynamically grabs all spreadsheets

This commit is contained in:
Daniel 2017-10-14 18:42:49 -04:00
parent 05fb08d089
commit 6ddc437c05
4 changed files with 22 additions and 17 deletions

View File

@ -5,21 +5,29 @@ class URLS {
static base_url = "https://spreadsheets.google.com/feeds/list/";
static data_format = "/od6/public/values?alt=json";
// + "/od6/public/basic?alt=json"; // Alternate data format
static base_spreadsheet = "1cUNmwV693zl2zqbH_IG4Wz8o9Va_sOHe7pAZF6M59Es";
get base_image() { return "https://drive.google.com/uc?id="; }
constructor() {}
// Singleton
static instance = null;
static createInstance() {
var object = new URLS();
return object;
static path(spreadsheetID) {
return URLS.base_url + spreadsheetID + URLS.data_format;
}
constructor() {
// This sets up urls
this.urls = {};
var self = this;
this.getSpreadsheet(URLS.path(URLS.base_spreadsheet), function(data) {
data.forEach(function(d) {
if (!self.urls[d.gsx$type.$t]) self.urls[d.gsx$type.$t] = {};
self.urls[d.gsx$type.$t][d.gsx$subtype.$t] = d.gsx$url.$t;
});
});
}
// Singleton
instance = null;
static getInstance() {
if (!URLS.instance) {
URLS.instance = URLS.createInstance();
}
if (!URLS.instance) { URLS.instance = new URLS(); }
return URLS.instance;
}
@ -35,11 +43,8 @@ class URLS {
});
}
static path(spreadsheetID) {
return URLS.base_url + spreadsheetID + URLS.data_format;
}
/* Creatures */
/* TODO remove legacy getters when introducing state management*/
get Creatures_Card_Data() {
return URLS.path("1fUFYhG1NLLkSTzrdbevm6ZMKNP6xLiKUZvM1sY10pVI");
}

View File

@ -2,7 +2,7 @@ import React from 'react';
import Interactive from 'react-interactive';
import { Link } from 'react-router';
import PageNotFound from '../../PageNotFound';
import API from '../../Spreadsheet';
import API from '../../SpreadsheetData';
import s from '../../../styles/app.style';
export default class Creatures extends React.Component {

View File

@ -3,7 +3,7 @@ import Interactive from 'react-interactive';
import { Link } from 'react-router';
import UnderConstruction from '../../UnderConstruction';
import PageNotFound from '../../PageNotFound';
import API from '../../Spreadsheet';
import API from '../../SpreadsheetData';
import s from '../../../styles/app.style';
export default class Mugic extends React.Component {

View File

@ -4,7 +4,7 @@ import { Link } from 'react-router';
// import {browserHistory} from 'react-router';
import PageNotFound from '../../PageNotFound';
import UnderConstruction from '../../UnderConstruction';
import API from '../../Spreadsheet';
import API from '../../SpreadsheetData';
import s from '../../../styles/app.style';
export default class SingleCreature extends React.Component {