mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-10 20:38:32 +03:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
854d744806 | ||
|
|
0155830cad | ||
|
|
96558a0cf7 | ||
|
|
b3d6d08289 | ||
|
|
315adf0653 | ||
|
|
b19664ae33 | ||
|
|
4e748a156a | ||
|
|
14d6fe6db2 | ||
|
|
a6337e9cba | ||
|
|
18b20356b5 | ||
|
|
75cb1a43cf | ||
|
|
71a8687003 | ||
|
|
63d168a964 | ||
|
|
4d310270d5 | ||
|
|
a6cc9491c6 | ||
|
|
0ee207dc75 | ||
|
|
7e97c5c227 | ||
|
|
978d572660 | ||
|
|
8bd5f38ac4 | ||
|
|
6ab37ccb70 | ||
|
|
4976bfd985 | ||
|
|
d713a15879 | ||
|
|
679407f421 | ||
|
|
3eebf811fb | ||
|
|
be03a3983a | ||
|
|
d6d565a0fc | ||
|
|
ca104e4abe | ||
|
|
c18c935b54 | ||
|
|
828a739d72 | ||
|
|
ac80c8f256 | ||
|
|
79999342d1 | ||
|
|
224a5e6fe4 | ||
|
|
6f7a5a19ad | ||
|
|
386407138f | ||
|
|
17607cf69f | ||
|
|
f3f574380c | ||
|
|
64f7775a83 | ||
|
|
7dd9d69d1f | ||
|
|
848d5b20f7 | ||
|
|
f5ada3d326 | ||
|
|
8dad1de61e | ||
|
|
eaa4d1f2c1 | ||
|
|
29182f8ec2 | ||
|
|
1c600bc222 | ||
|
|
8492c5cbaa | ||
|
|
2e1d098d12 | ||
|
|
e5288c2599 | ||
|
|
ea52a8bd8c | ||
|
|
5068ea8543 | ||
|
|
1e2a991708 | ||
|
|
35f8460eb4 | ||
|
|
98ec281973 | ||
|
|
2a11bf1ec7 | ||
|
|
75831cbb52 | ||
|
|
9dd2a66ce1 | ||
|
|
ae12de5933 | ||
|
|
5c25a8d1d0 | ||
|
|
fba74d8e9c | ||
|
|
f3115007e2 | ||
|
|
70149b905f | ||
|
|
afa52bffb6 | ||
|
|
533ab6e6f9 | ||
|
|
d06f4a5b68 | ||
|
|
95cb7a6f80 |
19
.github/workflows/cd.yml
vendored
Normal file
19
.github/workflows/cd.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: CD
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ develop ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ develop ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Trigger CD build
|
||||||
|
uses: peter-evans/repository-dispatch@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CI_DISPATCH_TOKEN }}
|
||||||
|
repository: forensic-architecture/configs
|
||||||
|
event-type: remote-build
|
||||||
|
client-payload: '{"runtime_args": "datasheet", "branch": "${GITHUB_REF##*/}"}'
|
||||||
|
|
||||||
25
.github/workflows/ci.yml
vendored
Normal file
25
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ develop ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ develop ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- uses: actions/setup-node@v2-beta
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
|
||||||
|
- run: npm install
|
||||||
|
- run: npm test
|
||||||
|
env:
|
||||||
|
CI: true
|
||||||
|
- run: npm run lint
|
||||||
|
env:
|
||||||
|
CI: true
|
||||||
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
|
||||||
|
|||||||
14
.travis.yml
14
.travis.yml
@@ -1,14 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- stable
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- node_modules
|
|
||||||
before_script:
|
|
||||||
- npm install -g yarn
|
|
||||||
install:
|
|
||||||
- yarn
|
|
||||||
script:
|
|
||||||
- yarn build
|
|
||||||
- yarn lint
|
|
||||||
- yarn test
|
|
||||||
10
Dockerfile
10
Dockerfile
@@ -4,17 +4,17 @@ 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
|
||||||
ENV PORT 8080
|
ENV PORT 4040
|
||||||
EXPOSE 8080
|
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,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
ENCRYPT_MESSAGE="\nThe .env.enc file has not changed its contents from the version on origin/develop.\nTo ensure that tests pass in Travis, you need to encrypt the contents of .env before pushing to the remote, so that the Travis server can use your service account credentials.\nEnsure that the Travis CLI is installed on your local, run\n\n\tnpm run travis-encrypt\n\nand then push to the remote again.\nIf you don't care whether your build passes on Travis, you can run:\n\n\tgit push --no-verify\n\nand bypass this check.\n\n"
|
|
||||||
|
|
||||||
# check whether .env.enc has changed
|
|
||||||
if [ -z "`git diff origin/develop -- .env.enc`" ]; then
|
|
||||||
echo $ENCRYPT_MESSAGE
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "Encrypting .env file for Travis..."
|
|
||||||
|
|
||||||
# confirm that the user has the core repo as origin, and is therefore a maintainer
|
|
||||||
# if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then
|
|
||||||
# echo "Travis encryption not required for satellite contributors, continuing.."
|
|
||||||
# exit 0
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# confirm travis is installed
|
|
||||||
if [ ! hash travis 2>/dev/null ]; then
|
|
||||||
echo "============================================================================================"
|
|
||||||
echo "ERROR: Travis CLI is not installed on your local. Please install from:"
|
|
||||||
echo "\thttps://github.com/travis-ci/travis.rb"
|
|
||||||
echo "After installing, make sure that you login with:"
|
|
||||||
echo "\ttravis login --pro"
|
|
||||||
echo "============================================================================================"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
# confirm there is a .env file to encrypt
|
|
||||||
if [ ! -f .env ]; then
|
|
||||||
echo "============================================================================================"
|
|
||||||
echo "ERROR: You must create a .env file and add your credentials. See .env.example for an example"
|
|
||||||
echo "============================================================================================"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
# regex to match and delete 'before_install' and everything after it
|
|
||||||
# necessary to delete these lines to get Travis to build for multiple accounts
|
|
||||||
echo "creating new .travis.yml configuration"
|
|
||||||
sed -i.old '/^before_install.*/,$ d' .travis.yml
|
|
||||||
echo "old config file saved as .travis.yml.old"
|
|
||||||
|
|
||||||
travis encrypt-file .env --add --force --org
|
|
||||||
git add .env.enc
|
|
||||||
git add .travis.yml
|
|
||||||
echo ".env.enc created and added to commit"
|
|
||||||
@@ -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) => {
|
||||||
|
|||||||
@@ -63,10 +63,7 @@ export default (data) => {
|
|||||||
structure.__flat.forEach(label => {
|
structure.__flat.forEach(label => {
|
||||||
deepRow[label] = baseRow[label]
|
deepRow[label] = baseRow[label]
|
||||||
})
|
})
|
||||||
if (!Object.keys(deepRow).every(k => (
|
if (!Object.keys(deepRow).every(k => deepRow[k] === '')) {
|
||||||
(deepRow[k] === '') ||
|
|
||||||
(Array.isArray(deepRow[k]) && deepRow[k].length === 0)
|
|
||||||
))) {
|
|
||||||
output.push(deepRow)
|
output.push(deepRow)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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
|
||||||
|
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,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import copy from '../copy/en'
|
import copy from '../copy/en'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller
|
* Controller class
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Controller {
|
class Controller {
|
||||||
|
|||||||
@@ -217,7 +217,10 @@ class GsheetFetcher extends Fetcher {
|
|||||||
})
|
})
|
||||||
.then(this._buildBlueprintsAsync())
|
.then(this._buildBlueprintsAsync())
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false)
|
.catch((err) => {
|
||||||
|
console.log(`Error fetching gsheets: ${err.message} `)
|
||||||
|
return false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ 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,6 +12,8 @@ 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 = 'http://localhost:4040'
|
const SERVER_ROOT = ''
|
||||||
let serverProc = null
|
let serverProc = null
|
||||||
let serverExited = false
|
let serverExited = false
|
||||||
function checkStatus (res) {
|
function checkStatus (res) {
|
||||||
@@ -54,7 +54,7 @@ test('should launch', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const passUrls = [
|
const passUrls = [
|
||||||
'/api/',
|
'/api/'
|
||||||
]
|
]
|
||||||
|
|
||||||
const failUrls = [
|
const failUrls = [
|
||||||
|
|||||||
@@ -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