mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 21:08:33 +03:00
Compare commits
15 Commits
topic/cust
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
854d744806 | ||
|
|
0155830cad | ||
|
|
96558a0cf7 | ||
|
|
b3d6d08289 | ||
|
|
315adf0653 | ||
|
|
b19664ae33 | ||
|
|
4e748a156a | ||
|
|
14d6fe6db2 | ||
|
|
a6337e9cba | ||
|
|
18b20356b5 | ||
|
|
75cb1a43cf | ||
|
|
71a8687003 | ||
|
|
63d168a964 | ||
|
|
4d310270d5 | ||
|
|
a6cc9491c6 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@ 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; yarn
|
RUN cd /www; npm install
|
||||||
|
|
||||||
# Copy app source
|
# Copy app source
|
||||||
COPY . /www
|
COPY . /www
|
||||||
WORKDIR /www
|
WORKDIR /www
|
||||||
RUN yarn build
|
RUN npm run 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 ["yarn", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ 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
@@ -1,12 +0,0 @@
|
|||||||
import { timemap } from './lib'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
gsheets: [],
|
|
||||||
xlsx: [
|
|
||||||
{
|
|
||||||
name: 'timemap_data',
|
|
||||||
path: 'data/timemap_data.xlsx',
|
|
||||||
tabs: timemap.default
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
19
src/example.config.js
Normal file
19
src/example.config.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
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,6 +7,14 @@ 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()
|
||||||
@@ -17,13 +25,17 @@ app.engine('.hbs', hbs({
|
|||||||
}))
|
}))
|
||||||
app.set('view engine', '.hbs')
|
app.set('view engine', '.hbs')
|
||||||
|
|
||||||
// enable cross origin requests explicitly in development
|
// enable cross origin requests explicitly in development OR if active in prod
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
const cors = require('cors')
|
const cors = require('cors')
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
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,6 +7,7 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import path from 'path'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import R from 'ramda'
|
import R from 'ramda'
|
||||||
|
|
||||||
const defaultBlueprint = {
|
export const defaultBlueprint = {
|
||||||
name: null,
|
name: null,
|
||||||
sheet: {
|
sheet: {
|
||||||
name: null,
|
name: null,
|
||||||
@@ -11,11 +11,11 @@ const defaultBlueprint = {
|
|||||||
resources: {}
|
resources: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultResource = {
|
export const defaultResource = {
|
||||||
data: []
|
data: []
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDesaturated (sheetId, sheetName, tab, resources) {
|
export function buildDesaturated (sheetId, sheetName, tab, resources) {
|
||||||
const bp = R.clone(defaultBlueprint)
|
const bp = R.clone(defaultBlueprint)
|
||||||
bp.sheet.name = sheetName
|
bp.sheet.name = sheetName
|
||||||
bp.sheet.id = sheetId
|
bp.sheet.id = sheetId
|
||||||
@@ -50,25 +50,10 @@ fs.readdirSync(normalizedPath).forEach(file => {
|
|||||||
allBps[bpName] = buildBlueprinter(bpName, datafier)
|
allBps[bpName] = buildBlueprinter(bpName, datafier)
|
||||||
})
|
})
|
||||||
|
|
||||||
function deeprowsWithSchema (datafierName, schema) {
|
|
||||||
const datafier = data => {
|
|
||||||
const transformedData = allBps.deeprows('', '', '', data).resources.deeprows.data
|
|
||||||
return transformedData.map(row => {
|
|
||||||
Object.keys(schema).forEach(key => {
|
|
||||||
row[key] = schema[key](row[key])
|
|
||||||
})
|
|
||||||
return row
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return buildBlueprinter(`deeprows_${datafierName}`, datafier)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NB: revert to ES5 'module.exports' required to make blueprinters from
|
// NB: revert to ES5 'module.exports' required to make blueprinters from
|
||||||
// each file in blueprinters folder available for granular import from here.
|
// each file in blueprinters folder available for granular import from here.
|
||||||
module.exports = Object.assign({
|
module.exports = Object.assign({
|
||||||
defaultBlueprint,
|
defaultBlueprint,
|
||||||
defaultResource,
|
defaultResource,
|
||||||
buildDesaturated,
|
buildDesaturated
|
||||||
deeprowsWithSchema
|
|
||||||
}, allBps)
|
}, allBps)
|
||||||
|
|||||||
@@ -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 = 'http://localhost:4040'
|
const SERVER_ROOT = ''
|
||||||
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="http://localhost:4040{{ this }}">{{ this }}</a></div>
|
<div><a target="_blank" href="{{ 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="http://localhost:4040/api/update">
|
<a class="bp-update-container" target="_blank" href="/api/update">
|
||||||
<div class="bp-button">Update</div>
|
<div class="bp-button">Update</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user