discourse-tooltips/plugin.rb
David Taylor 2396399542
DEV: Simplify plugin implementation (#81)
When this plugin was originally created, we were apprehensive about shipping excerpts for every topic in the main topic-list payload. Therefore, this plugin fetched the excerpts asynchronously, with all the associated batching, caching and rate-limiting logic.

Nowadays, it is very common for Discourse themes and plugins to enable excerpt-shipping in the topic-list serializer. Using this technique makes things much simpler, and much simpler for users.

Note: this plugin still uses JQuery, and is incompatible with the new topic-list implementation. Those things will be improved in follow-up commits.
2025-01-13 20:13:46 +00:00

22 lines
572 B
Ruby

# frozen_string_literal: true
# name: discourse-tooltips
# about: Allows for the previewing of the contents of topics on hover.
# meta_topic_id: 69304
# version: 0.1
# authors: Robin Ward
# url: https://github.com/discourse/discourse-tooltips
enabled_site_setting :tooltips_enabled
register_asset "stylesheets/d-tooltip.scss"
after_initialize do
module TopicSerializerExtension
def include_excerpt?
return true if SiteSetting.tooltips_enabled
super
end
end
reloadable_patch { ::ListableTopicSerializer.prepend(TopicSerializerExtension) }
end