update config

This commit is contained in:
Lachlan Kermode
2020-06-14 18:58:22 +02:00
parent 63c26bdb12
commit 8a91c6af56
13 changed files with 44 additions and 58 deletions

3
.gitignore vendored
View File

@@ -7,12 +7,9 @@
.env
*service-account-key\.json
src/config.js
/yarn-error.log
*.pem
.travis.yml.old
tags
tags.lock
tags.temp
src/sheets_config.js

View File

@@ -10,7 +10,7 @@ RUN cd /www; yarn
COPY . /www
WORKDIR /www
RUN yarn build
RUN mkdir -p temp
RUN mkdir -p data
# set your port
ENV PORT 8080

View File

@@ -76,7 +76,7 @@ Other configuration options, such as the port at which the server will expose
resources, are also modifiable from the .env file.
#### [Sources](#sources)
Sources are specified in [src/sheets_config.js](https://github.com/forensic-architecture/datasheet-server/blob/develop/src/sheets_config.js). Datasheet server currently only supports Google Sheets as a source.
Sources are specified in [src/config.js](https://github.com/forensic-architecture/datasheet-server/blob/develop/src/config.js). Datasheet server currently only supports Google Sheets as a source.
###### [Google Sheets](#source-google-sheets)
| sheets | A list of objects, one for each sheet that is being used as a source. Each sheet object has a `name` (String), an `id` (String), and a `tabs` (object) field, which are explained below. | object |

3
data/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*
!.gitignore
!timemap_data.xlsx

BIN
data/timemap_data.xlsx Normal file

Binary file not shown.

View File

@@ -8,10 +8,10 @@ management of the sheets it represents.
It exposes an API with four endpoints:
* `/:sheet/:tab/:resource` - the primary means of accessing data in the
server. The name of a sheet is specified in
[sheets_config.js](https://github.com/forensic-architecture/datasheet-server/blob/develop/src/sheets_config.js#L7).
[_config.js](https://github.com/forensic-architecture/datasheet-server/blob/develop/src/config.js#L7).
Each tab on the sheet is in lower case, with spaces replaced by
underscores. The resource name is the same as the name of the blueprinter
specified for the tab is sheets_config.js.
specified for the tab is config.js.
* `/:sheet/:tab/:resource/:id` - when the resource is a list, items in the list
can be accessed individually as well.
* `/update` - when this route is queried with a GET request, each of the

12
src/config.js Normal file
View File

@@ -0,0 +1,12 @@
import { tabs, prefixedTabs } from './lib'
export default {
gsheets: [],
xlsx: [
{
name: 'timemap_data',
path: 'data/timemap_data.xlsx',
tabs
}
]
}

View File

@@ -3,7 +3,6 @@ import express from 'express'
import initialize from './initialize'
import middleware from './middleware'
import api from './api'
// import config from './sheets_config'
import dotenv from 'dotenv'
const hbs = require('express-handlebars')
@@ -41,6 +40,8 @@ initialize(controller => {
})
)
app.use(express.static(__dirname + '/public'))
app.server.listen(process.env.PORT || 4040, () => {
console.log('===========================================')
console.log(`Server running on port ${app.server.address().port}`)

View File

@@ -1,7 +1,7 @@
import StoreJson from './models/StoreJson'
import fetchers from './lib/Fetcher'
import Controller from './lib/Controller'
import config from './sheets_config'
import config from './config'
import R from 'ramda'
const isntNull = n => n !== null

21
src/lib.js Normal file
View File

@@ -0,0 +1,21 @@
import BP from './lib/blueprinters'
export function prefixedTabs (prefix) {
return {
[`${prefix}_export_events`]: BP.deeprows,
[`${prefix}_export_categories`]: [BP.groups, BP.rows],
[`${prefix}_export_filters`]: BP.tree,
[`${prefix}_export_narratives`]: BP.rows,
[`${prefix}_export_sources`]: BP.deepids,
[`${prefix}_export_sites`]: BP.rows
}
}
export const tabs = {
export_events: BP.deeprows,
export_categories: [BP.groups, BP.rows],
export_filters: BP.tree,
export_narratives: BP.rows,
export_sources: BP.deepids,
export_sites: BP.rows
}

View File

@@ -1,7 +1,7 @@
import fs from 'mz/fs'
import errors from '../lib/errors'
const STORAGE_DIRNAME = 'temp'
const STORAGE_DIRNAME = 'data'
function partsFromFilename (fname) {
const body = fname.slice(0, -5)

View File

@@ -1,46 +0,0 @@
import BP from './lib/blueprinters'
const timemapStructure = {
export_events: BP.deeprows,
export_categories: [BP.groups, BP.rows],
export_narratives: BP.rows,
export_sources: BP.deepids,
export_sites: BP.rows,
export_tags: BP.tree
}
const treatyStructure = {
treaty_export_events: BP.deeprows,
treaty_export_categories: [BP.groups, BP.rows],
export_narratives: BP.rows,
treaty_export_sources: BP.deepids,
export_sites: BP.rows,
export_tags: BP.tree
}
const moraldriftStructure = {
moraldrift_export_events: BP.deeprows,
moraldrift_export_categories: [BP.groups, BP.rows],
moraldrift_export_narratives: BP.rows,
moraldrift_export_sources: BP.deepids,
moraldrift_export_sites: BP.rows,
moraldrift_export_tags: BP.tree
}
export default {
gsheets: [{
name: 'example',
id: '1UC7DkCFeUXHfpUxUGruExwFbP4pqVBdJLOKfo6wDDGk',
tabs: timemapStructure,
}],
xlsx: [
/** {
name: 'my_local_sheet',
tabs: timemapStructure,
path: 'temp/my_local_sheet.xlsx'
} **/
]
}

2
temp/.gitignore vendored
View File

@@ -1,2 +0,0 @@
*
!.gitignore