diff --git a/.rubocop.yml b/.rubocop.yml
index d9dee42..fb14dfa 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,2 +1,2 @@
inherit_gem:
- rubocop-discourse: stree-compat.yml
\ No newline at end of file
+ rubocop-discourse: stree-compat.yml
diff --git a/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-antivirus-stats.js b/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-antivirus-stats.js
new file mode 100644
index 0000000..46db9dd
--- /dev/null
+++ b/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-antivirus-stats.js
@@ -0,0 +1,8 @@
+import { ajax } from "discourse/lib/ajax";
+import DiscourseRoute from "discourse/routes/discourse";
+
+export default class DiscourseAntivirusStatsRoute extends DiscourseRoute {
+ model() {
+ return ajax("/admin/plugins/discourse-antivirus/stats");
+ }
+}
diff --git a/admin/assets/javascripts/discourse/templates/admin-plugins/show/discourse-antivirus-stats/index.hbs b/admin/assets/javascripts/discourse/templates/admin-plugins/show/discourse-antivirus-stats/index.hbs
new file mode 100644
index 0000000..2cb26b7
--- /dev/null
+++ b/admin/assets/javascripts/discourse/templates/admin-plugins/show/discourse-antivirus-stats/index.hbs
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ {{i18n "antivirus.version"}} |
+ {{i18n "antivirus.database_version"}} |
+ {{i18n "antivirus.database_updated_at"}} |
+
+
+
+ {{#each this.model.versions as |version|}}
+
+ {{version.antivirus}} |
+ {{version.database}} |
+ {{version.updated_at}} |
+
+ {{/each}}
+
+
+
+
+
+
+ {{i18n "antivirus.stats.total_scans"}} |
+ {{i18n "antivirus.stats.recently_scanned"}} |
+ {{i18n "antivirus.stats.quarantined"}} |
+ {{i18n "antivirus.stats.found"}} |
+
+
+
+
+ {{this.model.stats.scans}} |
+ {{this.model.stats.recently_scanned}} |
+ {{this.model.stats.quarantined}} |
+ {{this.model.stats.found}} |
+
+
+
+
+
\ No newline at end of file
diff --git a/app/controllers/discourse_antivirus/admin/antivirus_controller.rb b/app/controllers/discourse_antivirus/admin/antivirus_controller.rb
new file mode 100644
index 0000000..d3733a3
--- /dev/null
+++ b/app/controllers/discourse_antivirus/admin/antivirus_controller.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module DiscourseAntivirus
+ module Admin
+ class AntivirusController < ::Admin::AdminController
+ requires_plugin ::DiscourseAntivirus::PLUGIN_NAME
+
+ def index
+ antivirus = DiscourseAntivirus::ClamAv.instance
+
+ render json: DiscourseAntivirus::BackgroundScan.new(antivirus).stats
+ end
+ end
+ end
+end
diff --git a/app/controllers/discourse_antivirus/antivirus_controller.rb b/app/controllers/discourse_antivirus/antivirus_controller.rb
deleted file mode 100644
index dacfcf8..0000000
--- a/app/controllers/discourse_antivirus/antivirus_controller.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-module DiscourseAntivirus
- class AntivirusController < Admin::AdminController
- requires_plugin "discourse-antivirus"
-
- def index
- antivirus = DiscourseAntivirus::ClamAV.instance
-
- render json: DiscourseAntivirus::BackgroundScan.new(antivirus).stats
- end
- end
-end
diff --git a/assets/javascripts/discourse/admin-discourse-antivirus-plugin-route-map.js b/assets/javascripts/discourse/admin-discourse-antivirus-plugin-route-map.js
new file mode 100644
index 0000000..062aedd
--- /dev/null
+++ b/assets/javascripts/discourse/admin-discourse-antivirus-plugin-route-map.js
@@ -0,0 +1,8 @@
+export default {
+ resource: "admin.adminPlugins.show",
+ path: "/plugins",
+
+ map() {
+ this.route("discourse-antivirus-stats", { path: "stats" });
+ },
+};
diff --git a/assets/javascripts/discourse/antivirus-route-map.js b/assets/javascripts/discourse/antivirus-route-map.js
deleted file mode 100644
index eb15794..0000000
--- a/assets/javascripts/discourse/antivirus-route-map.js
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
- resource: "admin.adminPlugins",
- path: "/plugins",
-
- map() {
- this.route("antivirus");
- },
-};
diff --git a/assets/javascripts/discourse/initializers/admin-plugin-configuration-nav.js b/assets/javascripts/discourse/initializers/admin-plugin-configuration-nav.js
new file mode 100644
index 0000000..9798055
--- /dev/null
+++ b/assets/javascripts/discourse/initializers/admin-plugin-configuration-nav.js
@@ -0,0 +1,26 @@
+import { PLUGIN_NAV_MODE_TOP } from "discourse/lib/admin-plugin-config-nav";
+import { withPluginApi } from "discourse/lib/plugin-api";
+
+export default {
+ name: "discourse-antivirus-admin-plugin-configuration-nav",
+
+ initialize(container) {
+ const currentUser = container.lookup("service:current-user");
+ if (!currentUser || !currentUser.admin) {
+ return;
+ }
+
+ withPluginApi("1.1.0", (api) => {
+ api.addAdminPluginConfigurationNav(
+ "discourse-antivirus",
+ PLUGIN_NAV_MODE_TOP,
+ [
+ {
+ label: "antivirus.stats.title",
+ route: "adminPlugins.show.discourse-antivirus-stats",
+ },
+ ]
+ );
+ });
+ },
+};
diff --git a/assets/javascripts/discourse/routes/admin-plugins-antivirus.js b/assets/javascripts/discourse/routes/admin-plugins-antivirus.js
deleted file mode 100644
index f1e6761..0000000
--- a/assets/javascripts/discourse/routes/admin-plugins-antivirus.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import Route from "@ember/routing/route";
-import { ajax } from "discourse/lib/ajax";
-
-export default Route.extend({
- controllerName: "admin-plugins-antivirus",
-
- model() {
- return ajax("/admin/plugins/antivirus");
- },
-
- setupController(controller, model) {
- controller.setProperties({
- model,
- background_scan_stats: model.background_scan_stats,
- });
- },
-});
diff --git a/assets/javascripts/discourse/templates/admin/plugins-antivirus.hbs b/assets/javascripts/discourse/templates/admin/plugins-antivirus.hbs
deleted file mode 100644
index 4f2b263..0000000
--- a/assets/javascripts/discourse/templates/admin/plugins-antivirus.hbs
+++ /dev/null
@@ -1,43 +0,0 @@
-
{{i18n "antivirus.version_title"}}
-
-
-
-
- {{i18n "antivirus.version"}} |
- {{i18n "antivirus.database_version"}} |
- {{i18n "antivirus.database_updated_at"}} |
-
-
-
- {{#each model.versions as |version|}}
-
- {{version.antivirus}} |
- {{version.database}} |
- {{version.updated_at}} |
-
- {{/each}}
-
-
-
-
-
-{{i18n "antivirus.stats_title"}}
-
-
-
-
- {{i18n "antivirus.stats.total_scans"}} |
- {{i18n "antivirus.stats.recently_scanned"}} |
- {{i18n "antivirus.stats.quarantined"}} |
- {{i18n "antivirus.stats.found"}} |
-
-
-
-
- {{background_scan_stats.scans}} |
- {{background_scan_stats.recently_scanned}} |
- {{background_scan_stats.quarantined}} |
- {{background_scan_stats.found}} |
-
-
-
\ No newline at end of file
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 596976e..a8ba79b 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -19,6 +19,7 @@ en:
clamav_unavailable: We cannot establish a connection with the antivirus software. File scanning will be temporarily disabled.
stats:
+ title: Stats
total_scans: Scanned Files
recently_scanned: Recently Scanned
quarantined: Quarantined
diff --git a/config/routes.rb b/config/routes.rb
index 0e6a4cb..4ab033e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,12 +1,7 @@
# frozen_string_literal: true
-#DiscourseAntivirus::Engine.routes.draw do
-# root to: "antivirus#index"
-# get "/stats" => "antivirus#index"
-#end
-
Discourse::Application.routes.draw do
- scope "/admin/plugins/antivirus", constraints: AdminConstraint.new do
- get "/stats" => "antivirus#index"
+ scope "/admin/plugins/discourse-antivirus", constraints: AdminConstraint.new do
+ get "/stats" => "discourse_antivirus/admin/antivirus#index"
end
end
diff --git a/lib/discourse_antivirus/background_scan.rb b/lib/discourse_antivirus/background_scan.rb
index e6d0e74..046d736 100644
--- a/lib/discourse_antivirus/background_scan.rb
+++ b/lib/discourse_antivirus/background_scan.rb
@@ -17,7 +17,7 @@ def stats
{
versions: @antivirus.versions,
- background_scan_stats: {
+ stats: {
scans: scanned_upload_stats[0] || 0,
recently_scanned: scanned_upload_stats[1] || 0,
quarantined: scanned_upload_stats[2] || 0,
diff --git a/plugin.rb b/plugin.rb
index 0e01100..22d781e 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-antivirus
-# about: Scan uploads
+# about: Scan your Discourse uploads using ClamAV
# version: 0.1
# authors: romanrizzi
# url: https://github.com/discourse/discourse-antivirus
@@ -18,7 +18,7 @@ module ::DiscourseAntivirus
require_relative "lib/discourse_antivirus/engine"
-add_admin_route "antivirus.title", "antivirus"
+add_admin_route("antivirus.title", "antivirus", { use_new_show_route: true })
after_initialize do
register_reviewable_type ReviewableUpload