discourse/plugins/discourse-lazy-videos/plugin.rb
Kris 59d53dc18a
UX: add admin sidebar icons for preinstalled plugins (#36764)
Currently all our preinstalled plugins use the default "gear" icon from
fontawesome — this PR adds unique icons for each of them using a new
plugin API method, `setAdminPluginIcon()`. Plugins without an icon
defined will still fall back to the gear icon.


Before:
<img width="250" alt="image"
src="https://github.com/user-attachments/assets/06b5c6e7-0aae-44f8-b8ee-1486b98bfc6b"
/>


After: 
<img width="250" alt="image"
src="https://github.com/user-attachments/assets/46d45d4b-6c75-4473-ae53-1a0e71c4d6fb"
/>
2025-12-18 16:39:00 -05:00

36 lines
1 KiB
Ruby

# frozen_string_literal: true
# name: discourse-lazy-videos
# about: Lazy loading for embedded videos
# version: 0.1
# authors: Jan Cernik
# url: https://github.com/discourse/discourse-lazy-videos
enabled_site_setting :lazy_videos_enabled
register_svg_icon "bed"
register_asset "stylesheets/lazy-videos.scss"
module ::DiscourseLazyVideos
end
require_relative "lib/discourse_lazy_videos/lazy_youtube"
require_relative "lib/discourse_lazy_videos/lazy_vimeo"
require_relative "lib/discourse_lazy_videos/lazy_tiktok"
require_relative "lib/discourse_lazy_videos/crawler_post_end"
after_initialize do
register_html_builder("server:topic-show-crawler-post-end") do |controller, post:|
DiscourseLazyVideos::CrawlerPostEnd.new(controller, post).html
end
on(:reduce_cooked) do |fragment|
fragment
.css(".lazy-video-container")
.each do |video|
title = video["data-video-title"]
href = video.at_css("a")["href"]
video.replace("<p><a href=\"#{href}\">#{title}</a></p>")
end
end
end