mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 07:11:26 +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" />
59 lines
2 KiB
Ruby
59 lines
2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# name: discourse-github
|
|
# about: Allows staff to assign badges to users based on GitHub contributions, and allows users to create Github Linkbacks and Permalinks
|
|
# meta_topic_id: 99895
|
|
# version: 0.3
|
|
# authors: Robin Ward, Sam Saffron
|
|
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-github
|
|
|
|
require "sawyer"
|
|
require "octokit"
|
|
|
|
# Site setting validators must be loaded before initialize
|
|
require_relative "app/lib/github_badges_repo_setting_validator"
|
|
require_relative "app/lib/github_linkback_access_token_setting_validator"
|
|
|
|
enabled_site_setting :enable_discourse_github_plugin
|
|
|
|
register_svg_icon "fab-github"
|
|
register_asset "stylesheets/common/github-pr-status.scss"
|
|
|
|
after_initialize do
|
|
require_relative "app/controllers/discourse_github/webhooks_controller"
|
|
require_relative "app/jobs/regular/rebake_github_pr_posts"
|
|
|
|
Discourse::Application.routes.append do
|
|
post "/discourse-github/webhooks/github" => "discourse_github/webhooks#github"
|
|
end
|
|
|
|
%w[
|
|
../app/models/github_commit.rb
|
|
../app/models/github_repo.rb
|
|
../app/lib/github_linkback.rb
|
|
../app/lib/github_badges.rb
|
|
../app/lib/github_permalinks.rb
|
|
../app/lib/commits_populator.rb
|
|
../app/jobs/regular/create_github_linkback.rb
|
|
../app/jobs/scheduled/grant_github_badges.rb
|
|
../app/jobs/regular/replace_github_non_permalinks.rb
|
|
].each { |path| require File.expand_path(path, __FILE__) }
|
|
|
|
on(:post_created) do |post|
|
|
if SiteSetting.github_linkback_enabled? && SiteSetting.enable_discourse_github_plugin?
|
|
GithubLinkback.new(post).enqueue
|
|
end
|
|
end
|
|
|
|
on(:post_edited) do |post|
|
|
if SiteSetting.github_linkback_enabled? && SiteSetting.enable_discourse_github_plugin?
|
|
GithubLinkback.new(post).enqueue
|
|
end
|
|
end
|
|
|
|
on(:before_post_process_cooked) do |doc, post|
|
|
if SiteSetting.github_permalinks_enabled? && SiteSetting.enable_discourse_github_plugin?
|
|
GithubPermalinks.replace_github_non_permalinks(post)
|
|
end
|
|
end
|
|
end
|