Skip to content

Commit

Permalink
Merge 1de1e4a into 5f63765
Browse files Browse the repository at this point in the history
  • Loading branch information
parkan committed Jan 11, 2017
2 parents 5f63765 + 1de1e4a commit ab40687
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion scripts/publish-500px.sh
Expand Up @@ -11,7 +11,8 @@ SKIP_VALIDATION='--skipSchemaValidation'

mcclient publish ${SKIP_VALIDATION} \
--jqFilter '._source | del(.aesthetics)' \
--idFilter '.native_id' \
--prefix '500px'
--idFilter '.native_id | sub("500px[^_]*_(?<id>\\d+)"; "\(.id)")' \
${NAMESPACE} \
${SCHEMA_HASH} \
$1 > /dev/null
Expand Down
3 changes: 2 additions & 1 deletion scripts/publish-dpla.sh
Expand Up @@ -12,7 +12,8 @@ SKIP_VALIDATION='--skipSchemaValidation'

mcclient publish ${SKIP_VALIDATION} \
--jqFilter '._source | del(.aesthetics)' \
--idFilter '.native_id | sub("dpla_http://dp.la/api/items/(?<id>.+)"; "dpla_\(.id)")' \
--idFilter '.native_id | sub("dpla_http://dp.la/api/items/(?<id>.+)"; "\(.id)")' \
--prefix 'dpla'
${NAMESPACE} \
${SCHEMA_HASH} \
$1 > /dev/null
Expand Down
3 changes: 2 additions & 1 deletion scripts/publish-flickr-c10.sh
Expand Up @@ -7,7 +7,8 @@ COMPOUND="--compound 10"
mcclient publish ${COMPOUND} \
--skipSchemaValidation \
--jqFilter '._source | del(.aesthetics)' \
--idFilter '.native_id' \
--idFilter '.native_id | sub("flickr[^_]*_(?<id>\\d+)"; "\(.id)")' \
--prefix 'flickr'
${NAMESPACE} \
${SCHEMA_HASH} \
$1 > /dev/null
Expand Down
3 changes: 2 additions & 1 deletion scripts/publish-flickr-c100.sh
Expand Up @@ -7,7 +7,8 @@ COMPOUND="--compound 100"
mcclient publish ${COMPOUND} \
--skipSchemaValidation \
--jqFilter '._source | del(.aesthetics)' \
--idFilter '.native_id' \
--idFilter '.native_id | sub("flickr[^_]*_(?<id>\\d+)"; "\(.id)")' \
--prefix 'flickr'
${NAMESPACE} \
${SCHEMA_HASH} \
$1 > /dev/null
Expand Down
3 changes: 2 additions & 1 deletion scripts/publish-flickr.sh
Expand Up @@ -12,7 +12,8 @@ SKIP_VALIDATION='--skipSchemaValidation'

mcclient publish ${SKIP_VALIDATION} \
--jqFilter '._source | del(.aesthetics)' \
--idFilter '.native_id' \
--idFilter '.native_id | sub("flickr[^_]*_(?<id>\\d+)"; "\(.id)")' \
--prefix 'flickr'
${NAMESPACE} \
${SCHEMA_HASH} \
$1 > /dev/null
Expand Down
3 changes: 2 additions & 1 deletion scripts/publish-pexels.sh
Expand Up @@ -11,7 +11,8 @@ SKIP_VALIDATION='--skipSchemaValidation'

mcclient publish ${SKIP_VALIDATION} \
--jqFilter '._source | del(.aesthetics)' \
--idFilter '.native_id' \
--idFilter '.native_id | sub("flickr[^_]*_(?<id>\\d+)"; "\(.id)")' \
--prefix 'pexels'
${NAMESPACE} \
${SCHEMA_HASH} \
$1 > /dev/null
Expand Down
15 changes: 13 additions & 2 deletions src/client/cli/commands/publish.js
Expand Up @@ -41,6 +41,12 @@ module.exports = {
description: 'A jq filter that produces a mediachain identifier from your input object. ' +
'Will be applied after `jqFilter`, and does not modify the object itself.\n'
},
prefix: {
required: true,
type: 'string',
description: 'Prefix for the WKI. ' +
'The WKI is formed by joining the `prefix` (e.g. "moma") and the identifier extracted by `idFilter` with a colon (e.g. "moma:67350")'
},
jqFilter: {
type: 'string',
description: 'A jq filter string to use to pre-process your input data.\n',
Expand Down Expand Up @@ -71,7 +77,7 @@ module.exports = {
},

handler: subcommand((opts: HandlerOptions) => {
const {client, namespace, schemaReference, batchSize, filename, dryRun, skipSchemaValidation, jqFilter, idFilter, compound} = opts
const {client, namespace, schemaReference, batchSize, filename, dryRun, skipSchemaValidation, jqFilter, prefix, idFilter, compound} = opts
const publishOpts = {namespace, compound}

let stream: Readable
Expand Down Expand Up @@ -114,6 +120,7 @@ module.exports = {
publishOpts,
schemaReference,
schema,
prefix,
jqFilter: composeJQFilters(jqFilter, idFilter)})
)
})
Expand All @@ -129,6 +136,7 @@ function publishStream (opts: {
publishOpts: {namespace: string, compound?: number},
schemaReference?: string,
schema: ?SelfDescribingSchema,
prefix: string,
jqFilter: string
}): Promise<*> {
const {
Expand All @@ -141,6 +149,7 @@ function publishStream (opts: {
skipSchemaValidation,
schemaReference,
schema,
prefix,
jqFilter
} = opts

Expand Down Expand Up @@ -216,7 +225,9 @@ function publishStream (opts: {

wki = wki.toString()

const refs = [ wki ]
wkiWithPrefix = [ prefix, wki ].join(':')

const refs = [ wkiWithPrefix ]
const tags = [] // TODO: support extracting tags
const deps = []

Expand Down

0 comments on commit ab40687

Please sign in to comment.