Skip to content
Snippets Groups Projects
Commit d4d1a9a9 authored by Xiao Gui's avatar Xiao Gui
Browse files

feat: downloadzip ships with license and readme

parent fa6ee2be
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,11 @@ const bodyParser = require('body-parser')
datasetsRouter.use(bodyParser.urlencoded({ extended: false }))
datasetsRouter.use(bodyParser.json())
init().catch(e => {
console.warn(`dataset init failed`, e)
})
init()
.then(() => console.log(`dataset init success`))
.catch(e => {
console.warn(`dataset init failed`, e)
})
const cacheMaxAge24Hr = (_req, res, next) => {
const oneDay = 24 * 60 * 60
......
......@@ -240,16 +240,15 @@ const getDatasetFromId = async ({ user, kgId, returnAsStream = false }) => {
const renderPublication = ({ name, cite, doi }) => `${name}
${cite}
https://doi.org/${doi}
DOI: ${doi}
`
const prepareDatasetMetadata = ({ name, kgReference, contributors, publications }) => {
const prepareDatasetMetadata = ({ name, description, kgReference, contributors, publications }) => {
return `${name}
Contributors: ${contributors.join(', ')}
${description}
Publications:
${publications.map(renderPublication).join('\n')}
`
}
......@@ -263,6 +262,10 @@ fs.readFile(path.join(__dirname, 'kgtos.md') , 'utf-8', (err, data) => {
const getTos = () => kgtos
const getLicense = ({ licenseInfo }) => licenseInfo.map(({ name, url }) => `${name}
<${url}>
`).join('\n')
const getDatasetFileAsZip = async ({ user, kgId } = {}) => {
if (!kgId) {
throw new Error('kgId must be defined')
......@@ -276,15 +279,15 @@ const getDatasetFileAsZip = async ({ user, kgId } = {}) => {
* append citation information
*/
zip.append(prepareDatasetMetadata(dataset), {
name: `${datasetName}.txt`
name: `README.txt`
})
/**
* append kg citation policy
*/
zip.append(getTos(), {
name: `Terms Of Use.md`
zip.append(getLicense(dataset), {
name: `LICENSE.md`
})
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment