2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-10-31 20:02:26 +08:00
|
|
|
class Admin::PluginsController < Admin::StaffController
|
2015-02-07 06:32:59 +08:00
|
|
|
def index
|
2023-12-18 09:42:55 +08:00
|
|
|
render_serialized(
|
2023-12-21 09:37:20 +08:00
|
|
|
Discourse.plugins_sorted_by_name(enabled_only: false),
|
2023-12-18 09:42:55 +08:00
|
|
|
AdminPluginSerializer,
|
|
|
|
root: "plugins",
|
|
|
|
)
|
2015-02-07 06:32:59 +08:00
|
|
|
end
|
2024-03-13 11:15:12 +08:00
|
|
|
|
|
|
|
def show
|
|
|
|
plugin = Discourse.plugins_by_name[params[:plugin_id]]
|
|
|
|
|
|
|
|
# An escape hatch in case a plugin is using an un-prefixed
|
|
|
|
# version of their plugin name for a route.
|
|
|
|
plugin = Discourse.plugins_by_name["discourse-#{params[:plugin_id]}"] if !plugin
|
|
|
|
|
2024-04-02 21:26:15 +08:00
|
|
|
raise Discourse::NotFound if !plugin&.visible?
|
2024-03-13 11:15:12 +08:00
|
|
|
|
|
|
|
render_serialized(plugin, AdminPluginSerializer, root: nil)
|
|
|
|
end
|
2015-02-07 06:32:59 +08:00
|
|
|
end
|