mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-10 20:38:32 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9455348001 |
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -10,16 +10,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
- uses: actions/setup-node@v2-beta
|
- uses: actions/setup-node@v2-beta
|
||||||
with:
|
with:
|
||||||
node-version: '12'
|
node-version: '12'
|
||||||
|
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm test
|
- run: npm test
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,4 +15,3 @@ tags.lock
|
|||||||
tags.temp
|
tags.temp
|
||||||
src/config.js
|
src/config.js
|
||||||
src/local.config.js
|
src/local.config.js
|
||||||
src/config.js
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ LABEL authors="Lachlan Kermode <lk@forensic-architecture.org>"
|
|||||||
|
|
||||||
# Install app dependencies
|
# Install app dependencies
|
||||||
COPY package.json /www/package.json
|
COPY package.json /www/package.json
|
||||||
RUN cd /www; npm install
|
RUN cd /www; yarn
|
||||||
|
|
||||||
# Copy app source
|
# Copy app source
|
||||||
COPY . /www
|
COPY . /www
|
||||||
WORKDIR /www
|
WORKDIR /www
|
||||||
RUN npm run build
|
RUN yarn build
|
||||||
RUN mkdir -p data
|
RUN mkdir -p data
|
||||||
|
|
||||||
# set your port
|
# set your port
|
||||||
@@ -17,4 +17,4 @@ ENV PORT 4040
|
|||||||
EXPOSE 4040
|
EXPOSE 4040
|
||||||
|
|
||||||
# start command as per package.json
|
# start command as per package.json
|
||||||
CMD ["npm", "start"]
|
CMD ["yarn", "start"]
|
||||||
|
|||||||
@@ -59,11 +59,6 @@ Clone the repository to your local:
|
|||||||
git clone https://www.github.com/forensic-architecture/datasheet-server
|
git clone https://www.github.com/forensic-architecture/datasheet-server
|
||||||
```
|
```
|
||||||
|
|
||||||
Copy [src/example.config.js](src/example.config.js) into `src/config.js` and modify
|
|
||||||
```
|
|
||||||
cp src/example.config.js src/config.js
|
|
||||||
```
|
|
||||||
|
|
||||||
Follow the steps in the [configuration](#configuration) section of this
|
Follow the steps in the [configuration](#configuration) section of this
|
||||||
document.
|
document.
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
9480
package-lock.json
generated
9480
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -30,10 +30,10 @@ export default ({ config, controller }) => {
|
|||||||
success: msg
|
success: msg
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.catch(err => {
|
.catch(err =>
|
||||||
res.status(404)
|
res.status(404)
|
||||||
.send({ error: err.message, err })
|
.send({ error: err.message, err })
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
api.get('/:sheet/:tab/:resource/:frag', (req, res) => {
|
api.get('/:sheet/:tab/:resource/:frag', (req, res) => {
|
||||||
|
|||||||
12
src/config.js
Normal file
12
src/config.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { timemap } from './lib'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
gsheets: [],
|
||||||
|
xlsx: [
|
||||||
|
{
|
||||||
|
name: 'timemap_data',
|
||||||
|
path: 'data/timemap_data.xlsx',
|
||||||
|
tabs: timemap.default
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
1
src/datasheet.config.js
Symbolic link
1
src/datasheet.config.js
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
CONFIG=../configs/timemap/grenfell/datasheet.config.js
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { timemap } from './lib'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
gsheets: [],
|
|
||||||
xlsx: [
|
|
||||||
{
|
|
||||||
name: 'timemap_data',
|
|
||||||
path: 'data/timemap_data.xlsx',
|
|
||||||
tabs: timemap.default
|
|
||||||
}
|
|
||||||
],
|
|
||||||
cors: {
|
|
||||||
active: false,
|
|
||||||
corsOptions: { // meaningless unless active=true
|
|
||||||
origin: 'http://example.com',
|
|
||||||
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
16
src/index.js
16
src/index.js
@@ -7,14 +7,6 @@ import api from './api'
|
|||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
const hbs = require('express-handlebars')
|
const hbs = require('express-handlebars')
|
||||||
|
|
||||||
|
|
||||||
let configJS
|
|
||||||
try {
|
|
||||||
configJS = require('./local.config.js').default
|
|
||||||
} catch (_) {
|
|
||||||
configJS = require('./config.js').default
|
|
||||||
}
|
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
let app = express()
|
let app = express()
|
||||||
@@ -25,17 +17,13 @@ app.engine('.hbs', hbs({
|
|||||||
}))
|
}))
|
||||||
app.set('view engine', '.hbs')
|
app.set('view engine', '.hbs')
|
||||||
|
|
||||||
// enable cross origin requests explicitly in development OR if active in prod
|
// enable cross origin requests explicitly in development
|
||||||
const cors = require('cors')
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
const cors = require('cors')
|
||||||
console.log('Enabling CORS in development...')
|
console.log('Enabling CORS in development...')
|
||||||
app.use(cors())
|
app.use(cors())
|
||||||
} else if (configJS.cors.active === true) {
|
|
||||||
console.log('Enabling CORS in from config.js in prod...')
|
|
||||||
app.use(cors(configJS.cors.corsOptions))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const config = process.env
|
const config = process.env
|
||||||
|
|
||||||
initialize(controller => {
|
initialize(controller => {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ function prefixedTabs (prefix, cfg) {
|
|||||||
[`${prf('events')}export_events`]: BP.deeprows,
|
[`${prf('events')}export_events`]: BP.deeprows,
|
||||||
[`${prf('associations')}export_associations`]: BP.deeprows,
|
[`${prf('associations')}export_associations`]: BP.deeprows,
|
||||||
[`${prf('sources')}export_sources`]: BP.deepids,
|
[`${prf('sources')}export_sources`]: BP.deepids,
|
||||||
[`${prf('shapes')}export_shapes`]: BP.deeprows,
|
|
||||||
[`${prf('sites')}export_sites`]: BP.rows
|
[`${prf('sites')}export_sites`]: BP.rows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import copy from '../copy/en'
|
import copy from '../copy/en'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class
|
* Controller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Controller {
|
class Controller {
|
||||||
|
|||||||
@@ -217,10 +217,7 @@ class GsheetFetcher extends Fetcher {
|
|||||||
})
|
})
|
||||||
.then(this._buildBlueprintsAsync())
|
.then(this._buildBlueprintsAsync())
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch((err) => {
|
.catch(() => false)
|
||||||
console.log(`Error fetching gsheets: ${err.message} `)
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class StoreJson {
|
|||||||
|
|
||||||
save (url, data) {
|
save (url, data) {
|
||||||
const parts = url.split('/')
|
const parts = url.split('/')
|
||||||
|
|
||||||
return fs.writeFile(
|
return fs.writeFile(
|
||||||
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
||||||
JSON.stringify(data)
|
JSON.stringify(data)
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ const egInput1 = [
|
|||||||
[4, 5, 6]
|
[4, 5, 6]
|
||||||
]
|
]
|
||||||
|
|
||||||
// Test default blueprint exports
|
|
||||||
// Smoke tests
|
|
||||||
test('defaultBlueprint exports', t => {
|
test('defaultBlueprint exports', t => {
|
||||||
const expected = {
|
const expected = {
|
||||||
sheet: {
|
sheet: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fetch from 'node-fetch'
|
|||||||
import childProcess from 'child_process'
|
import childProcess from 'child_process'
|
||||||
|
|
||||||
const SERVER_LAUNCH_WAIT_TIME = 10 * 1000
|
const SERVER_LAUNCH_WAIT_TIME = 10 * 1000
|
||||||
const SERVER_ROOT = ''
|
const SERVER_ROOT = 'http://localhost:4040'
|
||||||
let serverProc = null
|
let serverProc = null
|
||||||
let serverExited = false
|
let serverExited = false
|
||||||
function checkStatus (res) {
|
function checkStatus (res) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="bp-source">{{ source }}</div>
|
<div class="bp-source">{{ source }}</div>
|
||||||
</div>
|
</div>
|
||||||
{{#each urls}}
|
{{#each urls}}
|
||||||
<div><a target="_blank" href="{{ this }}">{{ this }}</a></div>
|
<div><a target="_blank" href="http://localhost:4040{{ this }}">{{ this }}</a></div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="bp-update-container" target="_blank" href="/api/update">
|
<a class="bp-update-container" target="_blank" href="http://localhost:4040/api/update">
|
||||||
<div class="bp-button">Update</div>
|
<div class="bp-button">Update</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user