Kanka Mention Previewer

Adds the ability to load a preview of any mentioned entity in a modal.

Autor
Salvatos
Instalações hoje
0
Total de instalações
11
Avaliações
0 0 0
Versão
0.8
Criado
16/08/2022
Atualizado
12/11/2023
Licença
MIT
Aplicável a

This script adds an icon next to every entity mention in Kanka, which you can click to view the target entity’s full entry, posts, pinned attributes and images in a modal without leaving the current page. The content displayed is of course subject to viewing permissions.

Example

This option is added to most entity links that normally show a tooltip (for example in entity lists), not just user-generated mentions inside entities. It does not however apply to tags in entity headers, by design.

Features

  • The previewer is added recursively – if the entry you are previewing contains mentions, you can switch to those entities without ever leaving the current modal. The header remains visible at all times so you always know where you’re at when jumping from preview to preview =) Note that there is no "Back" or breadcrumb option for the time being, but I might add one.
  • The script partly imitates entry and post blocks in its design and adapts to the active theme’s background, text and link colors. This may not give the best results in some campaigns, but you can optimize it for your own campaign by creating a style specifically for #MentionPreviewer and its content. (Keep in mind that since the user script’s styles are loaded after the campaign styles, your selectors will need to be more specific than the script’s to take precedence.)
  • Some styling is forced to e.g. make banner images accommodate the available space and keep titles visible over them. This is also meant to give the best "universal" results, but may not always be perfect.
  • The sidebar only appears when an entity image and/or pinned attributes are present, leaving more room for the actual content otherwise. Posts are included after the Entry and separated by horizontal lines, in the order they were created.

If you want to go crazy with this script on your campaign, the modal can be styled based on the entity’s tags via the data-entity-tags attribute, which it inherits from the mention link it is bound to. For example, an entity with the Nation tag could have its modal styled using the following selector:

#MentionPreviewer[data-entity-tags~="nation"] {}

Known Issues

  • The trigger icon can become separated from its mention by a line break when they occur at the end of a line. Trying to prevent it causes other issues with mention tooltips, so this likely won’t be fixed.
  • Posts appear in the order they were created rather than their custom position, and entries are always at the top. Custom positions are tricky, so I would probably require a commission to look into this.

Possible developments

If there is enough demand, I may add or fix some of the following:

  • Show tags in the modal?
  • Add a Back button to return to the previous preview (single-level) or breadcrumbs (full history)?
  • Add assets such as external links or files to the sidebar?
  • Add pinned relations to the sidebar? Those would require additional calls to the server, so I’ve deliberately avoided them for now.
  • Respect the actual order of entry and posts?


If my scripts are making your life easier, please consider tipping via Ko-fi (no account needed):

Support me on Ko-fi.com