A Javascript API to modify content in a Texture article. This is particularly useful for collecting metadata, such as authors, affiliations, references, keywords etc. This is a format-agnostic abstraction. So it means the data can be serialised in different ways, so Texture is not tightly bound to JATS. We could also use HTML + JSON to represent an article and its metadata.
Manage contributor data, such as authors, editors, affiliations, awards.
let contribs = api.getContribsModel()Print affiliations, depending on the order of authors. If you haven't assigned any affiliations, this list will be empty.
contribs.getAffiliations() [{ id: 'aff1', ... }, ...]Add new affiliation:
contribs.addAffiliation({
id: 'aff1',
name: 'German Primate Center GmbH',
division1: 'Neurobiology Laboratory',
city: 'Göttingen',
country: 'Germany'
})Get affiliation:
contribs.getAffiliation('aff1')Update an affiliation:
contribs.updateAffiliation('aff1', {...})Remove an affiliation:
contribs.deleteAffiliation('aff1')Get all authors in order:
contribs.getAuthors()[
{
id: 'author1',
type: 'person',
surname: 'Schaffelhofer',
givenNames: 'Stefan',
suffix: 'Phd',
email: 'stefan@schaffelhofer.com',
// affiliations related to this paper
affiliations: ['org1'],
presentAffiliation: ['org1'],
// awards related to this paper
awards: ['fund1'],
equalContrib: true,
corresp: true,
},
// Groups are considered one independent entity (not reusing person entry for members)
// When updating via API, a whole new record is written
{
id: 'author2',
type: 'group',
affiliations: ['org2'],
presentAffiliation: ['org2'],
awards: ['fund1'],
members: [
{
surname: 'Kelly',
givenNames: 'Laura A.',
email: 'stefan@schaffelhofer.com',
affiliations: ['org2'],
awards: ['fund1'],
role: 'Writing Group'
},
{
surname: 'Randall',
givenNames: 'Daniel Lee',
suffix: 'Jr.',
email: 'stefan@schaffelhofer.com',
affiliations: ['org3'],
awards: ['fund1'],
role: 'Lab Group'
}
]
}
]To add a new author:
contribs.addAuthor({...})Update an author:
contribs.updateAuthor('author1', {...})Delete an author:
contribs.deleteAuthor('author3')To change the position of an author in the author list:
contribs.moveAuthor('author4', 0) // move to position 0Pretty much the same as with authors, except there's no type attribute needed. Use the following methods:
contribs.getEditors(data)
contribs.addEditor(data)
contribs.updateEditor(id, data)
contribs.moveEditor(id, pos)
contribs.deleteEditor(id)Add an award (grant), which can then be referenced from an author using the awards property.
contribs.addAward({
id: 'fund1',
institution: 'Howard Huges Medical Institute',
awardId: 'F32 GM089018'
})let references = this.context.api.getReferences()references.getReference('r1')Result:
{
"type": "book",
"id": "r1",
"authors": [
{
"givenNames": "JA",
"surname": "Coyne"
},
{
"givenNames": "HA",
"surname": "Orr"
}
],
"translators": [],
"title": "Speciation and its consequences",
"volume": "",
"edition": "",
"publisherLoc": "Sunderland, MA",
"publisherName": "Sinauer Associates",
"year": "1989"
}references.addReference({
id: "r2",
type: "journal-article",
"title": "....",
...
})references.updateReference('r2', {
"title": "....",
...
})references.getLabel('r2') // => e.g. [2]Returns the rendered HTML string (without label)
references.renderReference('r2')references.getBibliography()Result:
[
{
label: '[1]',
data: {id: 'r1', type: 'book', ...}
}
]let meta = api.getMeta()Add a keyword:
meta.addKeyword('optogenetics', 'author-keyword')
meta.addKeyword('two-photon', 'author-keyword')
meta.addKeyword('Mouse', 'research-organism')List all available keyword categories:
meta.getKeywordCategories()Result:
['author-keyword', 'research-organism']List keywords for a given category:
meta.getKeywords('author-keyword')['optogenetics', 'two-photon']Add a subject:
meta.addSubject('Research Article', 'article-type')
meta.addSubject('Computational and Systems Biology', 'research-subject')
meta.addSubject('Epidemiology and Global Health', 'research-subject')List all available keyword categories:
meta.getSubjectCategories()Result:
['article-type', 'research-subject']List keywords for a given category:
meta.getSubjects('research-subject')['Computational and Systems Biology', 'Epidemiology and Global Health']Set or overwrite publication date (month and day are optional)
meta.setPubDate(2016, 3, 1)Add publication history record:
meta.addPubHistoryRecord('received', 2016, 3, 1)Remove publication history record:
meta.clearPubHistoryRecord('received')