id-presets-builder
v4.0.0
Published
Build iD presets
Downloads
1,740
Readme
id-presets-builder
Build preset files for iDEditor
Will take a collection of iD preset, field and category definition files, verify that the schema is correct and definitions are valid, and builds a preset file, translations, and a YAML file for translation. Useful for deploying iD Editor with custom preset files.
Table of Contents
Install
$ npm install --global id-presets-builder
Usage
$ id-presets build
Looks for iD preset files in ./presets/
, field files in ./fields/
, categories in ./categories/
and defaults in ./defaults.json
. Please see the iD Presets README.md for details about iD presets. Outputs presets.json
, translations.json
and translate.yaml
in ./build/
.
$ id-presets lint
Lints the presets files without writing anything.
API
var presetsBuilder = require('id-presets-builder')
presetsBuilder.generatePresets([dir], callback)
Looks for preset, field and category files in dirs ${dir}/presets/
, ${dir}/fields/
, ${dir}/categories/
and ${dir}/defaults.json
. dir
defaults to process.cwd()
. Callback is called with a presets object:
{
presets: {...},
categories: {...},
fields: {...},
defaults: {...}
}
presetsBuilder.generateTranslations(categories, fields, presets)
Generates an object of localized names for presets that can be used in iD editor for localized names of presets in the UI.
presetsBuilder.generateTranslate(fields, presets, translations)
Generates a translate object that defines preset terms that need translation, for use in transifex or similar localization platform.
Contribute
PRs accepted.
Small note: If editing the Readme, please conform to the standard-readme specification.
License
MIT © Gregor MacLennan / Digital Democracy