discourse/plugins/discourse-lazy-videos/plugin.rb
Martin Brennan 97a812f022
FIX: Hide core plugins from the admin Plugins list (#23328)
Most of the core plugins were already hidden, this hides
chat, styleguide, and checklist to avoid potential confusion
for end users.

Also removes respond_to? :hide_plugin, since that API has been
in place for a while now.
2023-08-31 10:01:01 +10:00

29 lines
738 B
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
hide_plugin
enabled_site_setting :lazy_videos_enabled
register_asset "stylesheets/lazy-videos.scss"
require_relative "lib/lazy-videos/lazy_youtube"
require_relative "lib/lazy-videos/lazy_vimeo"
require_relative "lib/lazy-videos/lazy_tiktok"
after_initialize do
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