mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-09 20:08:32 +03:00
Compare commits
22 Commits
feature/ve
...
main
| 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 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@ tags.lock
|
||||
tags.temp
|
||||
src/config.js
|
||||
src/local.config.js
|
||||
src/config.js
|
||||
|
||||
@@ -4,12 +4,12 @@ LABEL authors="Lachlan Kermode <lk@forensic-architecture.org>"
|
||||
|
||||
# Install app dependencies
|
||||
COPY package.json /www/package.json
|
||||
RUN cd /www; yarn
|
||||
RUN cd /www; npm install
|
||||
|
||||
# Copy app source
|
||||
COPY . /www
|
||||
WORKDIR /www
|
||||
RUN yarn build
|
||||
RUN npm run build
|
||||
RUN mkdir -p data
|
||||
|
||||
# set your port
|
||||
@@ -17,4 +17,4 @@ ENV PORT 4040
|
||||
EXPOSE 4040
|
||||
|
||||
# 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
|
||||
```
|
||||
|
||||
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
|
||||
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
|
||||
})
|
||||
)
|
||||
.catch(err =>
|
||||
.catch(err => {
|
||||
res.status(404)
|
||||
.send({ error: err.message, err })
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
api.get('/:sheet/:tab/:resource/:frag', (req, res) => {
|
||||
|
||||
@@ -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'
|
||||
const hbs = require('express-handlebars')
|
||||
|
||||
|
||||
let configJS
|
||||
try {
|
||||
configJS = require('./local.config.js').default
|
||||
} catch (_) {
|
||||
configJS = require('./config.js').default
|
||||
}
|
||||
|
||||
dotenv.config()
|
||||
|
||||
let app = express()
|
||||
@@ -17,13 +25,17 @@ app.engine('.hbs', 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') {
|
||||
const cors = require('cors')
|
||||
console.log('Enabling CORS in development...')
|
||||
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
|
||||
|
||||
initialize(controller => {
|
||||
|
||||
@@ -6,8 +6,8 @@ function prefixedTabs (prefix, cfg) {
|
||||
return {
|
||||
[`${prf('events')}export_events`]: BP.deeprows,
|
||||
[`${prf('associations')}export_associations`]: BP.deeprows,
|
||||
[`${prf('editorials')}export_editorials`]: BP.deeprows,
|
||||
[`${prf('sources')}export_sources`]: BP.deepids,
|
||||
[`${prf('shapes')}export_shapes`]: BP.deeprows,
|
||||
[`${prf('sites')}export_sites`]: BP.rows
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import copy from '../copy/en'
|
||||
|
||||
/**
|
||||
* Controller
|
||||
* Controller class
|
||||
*
|
||||
*/
|
||||
class Controller {
|
||||
|
||||
@@ -217,7 +217,10 @@ class GsheetFetcher extends Fetcher {
|
||||
})
|
||||
.then(this._buildBlueprintsAsync())
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
.catch((err) => {
|
||||
console.log(`Error fetching gsheets: ${err.message} `)
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class StoreJson {
|
||||
|
||||
save (url, data) {
|
||||
const parts = url.split('/')
|
||||
|
||||
return fs.writeFile(
|
||||
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
||||
JSON.stringify(data)
|
||||
|
||||
@@ -12,6 +12,8 @@ const egInput1 = [
|
||||
[4, 5, 6]
|
||||
]
|
||||
|
||||
// Test default blueprint exports
|
||||
// Smoke tests
|
||||
test('defaultBlueprint exports', t => {
|
||||
const expected = {
|
||||
sheet: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import fetch from 'node-fetch'
|
||||
import childProcess from 'child_process'
|
||||
|
||||
const SERVER_LAUNCH_WAIT_TIME = 10 * 1000
|
||||
const SERVER_ROOT = 'http://localhost:4040'
|
||||
const SERVER_ROOT = ''
|
||||
let serverProc = null
|
||||
let serverExited = false
|
||||
function checkStatus (res) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="bp-source">{{ source }}</div>
|
||||
</div>
|
||||
{{#each urls}}
|
||||
<div><a target="_blank" href="http://localhost:4040{{ this }}">{{ this }}</a></div>
|
||||
<div><a target="_blank" href="{{ this }}">{{ this }}</a></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{ else }}
|
||||
@@ -16,7 +16,7 @@
|
||||
{{/each}}
|
||||
</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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user