mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +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" />
89 lines
2.8 KiB
Ruby
Executable file
Vendored
89 lines
2.8 KiB
Ruby
Executable file
Vendored
# frozen_string_literal: true
|
|
|
|
# name: discourse-adplugin
|
|
# about: Allows admins to configure advertisements, and integrates with external ad platforms.
|
|
# meta_topic_id: 33734
|
|
# version: 1.2.5
|
|
# authors: Vi and Sarah (@ladydanger and @cyberkoi)
|
|
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-adplugin
|
|
|
|
register_asset "stylesheets/adplugin.scss"
|
|
register_svg_icon "rectangle-ad"
|
|
|
|
add_admin_route "admin.adplugin.house_ads.title", "houseAds"
|
|
|
|
enabled_site_setting :discourse_adplugin_enabled
|
|
|
|
module ::AdPlugin
|
|
PLUGIN_NAME = "discourse-adplugin"
|
|
end
|
|
|
|
require_relative "lib/adplugin/engine"
|
|
require_relative "lib/ad_plugin/ad_type"
|
|
|
|
after_initialize do
|
|
require_relative "app/controllers/ad_plugin/house_ad_settings_controller"
|
|
require_relative "app/controllers/ad_plugin/house_ads_controller"
|
|
require_relative "app/controllers/adstxt_controller"
|
|
require_relative "app/controllers/ad_plugin/ad_impressions_controller"
|
|
require_relative "app/serializers/ad_plugin/house_ad_serializer"
|
|
|
|
require_relative "app/models/ad_plugin/house_ad_setting"
|
|
require_relative "app/models/ad_plugin/house_ad"
|
|
require_relative "app/models/ad_plugin/ad_impression"
|
|
require_relative "app/models/concerns/reports/ad_plugin"
|
|
require_relative "lib/adplugin/guardian_extensions"
|
|
|
|
reloadable_patch do
|
|
Guardian.prepend AdPlugin::GuardianExtensions
|
|
Report.include(Reports::AdPlugin)
|
|
end
|
|
|
|
Discourse::Application.routes.append do
|
|
get "/ads.txt" => "adstxt#index"
|
|
|
|
post "/ad_plugin/ad_impressions/:id" => "ad_plugin/ad_impressions#update"
|
|
patch "/ad_plugin/ad_impressions/:id" => "ad_plugin/ad_impressions#update"
|
|
post "/ad_plugin/ad_impressions" => "ad_plugin/ad_impressions#create"
|
|
|
|
mount AdPlugin::Engine, at: "/admin/plugins/pluginad", constraints: AdminConstraint.new
|
|
end
|
|
|
|
add_to_serializer :site, :house_creatives do
|
|
AdPlugin::HouseAdSetting.settings_and_ads(for_anons: scope.anonymous?, scope: scope)
|
|
end
|
|
|
|
add_to_serializer :site, :ad_types do
|
|
AdPlugin::AdType.types
|
|
end
|
|
|
|
add_to_serializer :topic_view, :tags_disable_ads do
|
|
return false if !SiteSetting.tagging_enabled || !SiteSetting.no_ads_for_tags.present?
|
|
return false if object.topic.tags.empty?
|
|
!(SiteSetting.no_ads_for_tags.split("|") & object.topic.tags.map(&:name)).empty?
|
|
end
|
|
|
|
add_to_serializer :current_user, :show_dfp_ads do
|
|
scope.show_dfp_ads?
|
|
end
|
|
|
|
add_to_serializer :current_user, :show_adsense_ads do
|
|
scope.show_adsense_ads?
|
|
end
|
|
|
|
add_to_serializer :current_user, :show_carbon_ads do
|
|
scope.show_carbon_ads?
|
|
end
|
|
|
|
add_to_serializer :current_user, :show_amazon_ads do
|
|
scope.show_amazon_ads?
|
|
end
|
|
|
|
add_to_serializer :current_user, :show_adbutler_ads do
|
|
scope.show_adbutler_ads?
|
|
end
|
|
|
|
add_to_serializer :current_user, :show_to_groups do
|
|
scope.show_to_groups?
|
|
end
|
|
end
|