mirror of
https://ghfast.top/https://github.com/discourse/discourse-tooltips.git
synced 2026-05-05 18:32:35 +08:00
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.
22 lines
572 B
Ruby
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
|