mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 19:44:59 +08:00
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" />
36 lines
1 KiB
Ruby
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
|