Skip to content
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

Access form with citation.js #3

Open
3 of 7 tasks
nichtich opened this issue Oct 24, 2018 · 4 comments
Open
3 of 7 tasks

Access form with citation.js #3

nichtich opened this issue Oct 24, 2018 · 4 comments

Comments

@nichtich
Copy link
Contributor

nichtich commented Oct 24, 2018

http://wikicite.org/access.html contains an input form to lookup and format bibliographic items from Wikidata, implemented with citation.js. This is a hack to be improved:

  • async loading
  • select CSL template (only "apa" seems to work?)
  • disable verbose citation.js logging to console
  • filter out or warn on non-bibliographic items
  • provide examples to click on
  • support switching languages
  • typeahead search form
@larsgw
Copy link

larsgw commented Oct 24, 2018

  • select CSL template (only "apa" seems to work?)

Based on the code in access.js this looks like a misunderstanding in the docs. To get BibTeX, the first parameter to Cite#format is used. Example:

example.format('bibtex', {
  format: 'html'
})

// same goes for ris: example.format('ris', {...})

For CSL bibliographies your current usage is correct:

example.format('bibliography', {
  format: 'html',
  template: format,
  lang: 'en-US'
})

Other templates, like vancouver and harvard1, should work like apa does. This works on my end, please report if it doesn't one yours.

For citations, change 'bibliography' to 'citation'. Here's more detailed information about possible output types. The first table shows the plugin names (i.e. the first argument to Cite#format), and the other tables show options for each of those plugins, that can be passed in an object as the second argument. To extend the output types, you can look into output plugins, adding csl templates & locales and adding different output formats (i.e. HTML, plain text, markdown, etc.).

  • disable verbose citation.js logging to console

I'm getting quite annoyed by that myself too, I'm changing that once I get back on track with releases.

@larsgw
Copy link

larsgw commented Oct 24, 2018

As for @egonw's comment on twitter:

check my homepage... that is using Vancouver and adds an @altmetric icon too: https://t.co/kVjaM7WpOa

Does that work? If not, maybe a regression?

— Egon Willighⓐgen (@egonwillighagen) October 24, 2018

He's using an older API with Cite#get, which could help in your case, as it is more of a drop-in fix for your code. However, due to the fact option conversions between the two methods are hard-coded, you can't use new output formats with Cite#get (you can however use different CSL templates & locales in the same way as described in the docs above).

nichtich added a commit that referenced this issue Oct 24, 2018
@nichtich
Copy link
Contributor Author

Thanks, I found https://larsgw.github.io/citation.js-form/demo/ and improved the form, see http://wikicite.org/access.html?id=Q163335 for an example. Which CSL templates are already registered by default (apa, harvard1, vancouver...?).

See also WDscholia/scholia#323 for adding the same functionality to Scholia.

@larsgw
Copy link

larsgw commented Oct 25, 2018

Those three are included by default, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants