New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make custom template and locale functioning easier #40

Closed
larsgw opened this Issue Apr 7, 2017 · 3 comments

Comments

Projects
2 participants
@larsgw
Owner

larsgw commented Apr 7, 2017

The current way of using custom templates and locales is confusing to say the best (see #28). Expected features:

  • default and custom template and locale registers, with appropriate methods
  • way to amend templates
@larsgw

This comment has been minimized.

Show comment
Hide comment
@larsgw

larsgw Jul 26, 2017

Owner

I outlined some possible APIs in a recent blogpost:

const template = '...'
const templateName = 'custom'

// Suggested new API
Cite.CSL.template.register(templateName, template)

// Nothing new, will stay the same
const data = new Cite(...)
data.get({
  type: 'html',
  style: 'citation-' + templateName
})
// prepends the id like this: "[$ID]: "
const prepend = ({id}) => `[${id}]: `
// appends an altmetric widget
const append = ({DOI}) => `<span class='altmetric-embed' data-doi='${DOI}'></span>`

// Nothing new, will stay the same
const data = new Cite(...)
data.get({
  type: 'html',
  style: 'citation-' + templateName,
  // Suggested new API
  // both properties either function or constant string
  append: append,
  prepend: prepend
})

I'm currently working on the implementation, and it will be slightly different, but not structurally (probably only method names):

const template = '...'
const templateName = 'custom'

// Suggested new API
Cite.CSL.register.addTemplate(templateName, template)

// Nothing new, will stay the same
const data = new Cite(...)
data.get({
  type: 'html',
  style: 'citation-' + templateName
})
Owner

larsgw commented Jul 26, 2017

I outlined some possible APIs in a recent blogpost:

const template = '...'
const templateName = 'custom'

// Suggested new API
Cite.CSL.template.register(templateName, template)

// Nothing new, will stay the same
const data = new Cite(...)
data.get({
  type: 'html',
  style: 'citation-' + templateName
})
// prepends the id like this: "[$ID]: "
const prepend = ({id}) => `[${id}]: `
// appends an altmetric widget
const append = ({DOI}) => `<span class='altmetric-embed' data-doi='${DOI}'></span>`

// Nothing new, will stay the same
const data = new Cite(...)
data.get({
  type: 'html',
  style: 'citation-' + templateName,
  // Suggested new API
  // both properties either function or constant string
  append: append,
  prepend: prepend
})

I'm currently working on the implementation, and it will be slightly different, but not structurally (probably only method names):

const template = '...'
const templateName = 'custom'

// Suggested new API
Cite.CSL.register.addTemplate(templateName, template)

// Nothing new, will stay the same
const data = new Cite(...)
data.get({
  type: 'html',
  style: 'citation-' + templateName
})

@larsgw larsgw moved this from TODO to In Progress in Version 0.3 Jul 28, 2017

@larsgw

This comment has been minimized.

Show comment
Hide comment
@larsgw

larsgw Aug 1, 2017

Owner

I failed to mention this here earlier, but the first part of the API change happened in 3aaaf7c (or v0.3.0-11). For current API, see here for templates and here for locales. Ping @austinjp.

Owner

larsgw commented Aug 1, 2017

I failed to mention this here earlier, but the first part of the API change happened in 3aaaf7c (or v0.3.0-11). For current API, see here for templates and here for locales. Ping @austinjp.

@austinjp

This comment has been minimized.

Show comment
Hide comment
@austinjp

austinjp Aug 1, 2017

Great work @larsgw , really appreciate it. I'll have a detailed look another day!

austinjp commented Aug 1, 2017

Great work @larsgw , really appreciate it. I'll have a detailed look another day!

@larsgw larsgw moved this from In Progress to Done in Version 0.3 Aug 24, 2017

@larsgw larsgw closed this in 2ada412 Aug 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment