openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Replace the Wikipedia citation dialog with an ol-popover

Open lokesh opened this issue 2 months ago • 4 comments

Summary

On edition pages (/books/OL…M), the "Wikipedia citation" link at the bottom of the page opens an old jQuery dialog with a <textarea> holding the {{cite book|…}} code. Replace it with an <ol-popover> that has a one-click copy button, and style the link and copy button like the ones on the Icons design page. Click any icon there to see the popover.

Image Image

Where it lives

  • Template: openlibrary/templates/lib/exports.html. It renders the #wikilink trigger (.dialog--open) and the hidden #wikicode dialog.
  • JS: openlibrary/plugins/openlibrary/js/dialog.js (.dialog--open / .dialog--close), wired up in js/main.js
  • Data: Edition.wp_citation_fields in openlibrary/plugins/upstream/models.py. It only exists on editions, so the link only appears on /books/… URLs, not on work or author pages.

Reference implementation

  • Popover and copy well: the icon_popover() macro in openlibrary/templates/design/icons.html.jinja
  • Styles: .ds-icon-popover__* in static/css/page-design.css. When you click, the copy glyph swaps for a check.
  • Copy handler: openlibrary/plugins/openlibrary/js/design-system/index.js (data-ds-copy)
  • Popover component: openlibrary/components/lit/OlPopover.js, documented under Popover on the Components design page (examples plus the API reference)

Acceptance criteria

  • [ ] Clicking "Wikipedia citation" opens an <ol-popover> anchored to the link, and a bottom tray on mobile.
  • [ ] The popover shows the {{cite book|…}} code, a copy button with copied feedback, and the existing "Need help?" link to Wikipedia's Cite book template.
  • [ ] The link and copy button match the styling on the Icons page. Move shared styles out of page-design.css rather than reusing ds- classes on book pages.
  • [ ] The citation wraps or scrolls legibly. It is much longer than an icon snippet.
  • [ ] The old #wikicode markup is removed. Leave dialog.js alone, since other templates still use .dialog--open.
  • [ ] Keyboard works end to end: open, Tab to copy, Escape closes and focus returns to the link.
  • [ ] Strings stay translatable, following docs/ai/i18n.md.

Getting started

  • Read docs/ai/design.md and docs/ai/web-components.md first.
  • Test on a local edition page, e.g. http://localhost:8080/books/OL6M.

lokesh avatar Sep 16 '26 22:09 lokesh

Hi @lokesh, I would like to work on this issue. I will replace the current Wikipedia citation dialog with the new ol-popover component and make sure the existing citation and copy functionality continues to work.

iamshravanijadhav avatar Sep 17 '26 04:09 iamshravanijadhav

Go for it! Let me know if you have any questions.

lokesh avatar Sep 17 '26 04:09 lokesh

can I also work on this or only one person is allowed?

dproios avatar Sep 17 '26 19:09 dproios

@dproios just one person per Issue in the vast majority of cases. I'm going to be creating additional UI related issues this week so keep an eye out.

lokesh avatar Sep 17 '26 19:09 lokesh