forked from nunof07/discourse-mumble
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.rb
executable file
·46 lines (34 loc) · 1.15 KB
/
plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# name: Mumble
# about: Displays channel and user information from a Mumble server
# version: 0.3.0
# authors: Nuno Freitas (nunofreitas@gmail.com)
# url: https://github.com/nunof07/discourse-mumble
enabled_site_setting :mumble_enabled
after_initialize {
require_dependency File.expand_path("../jobs/mumble_job.rb", __FILE__)
module ::Mumble
def self.fetch_data
if SiteSetting.mumble_enabled && !SiteSetting.mumble_cvp.blank?
response = Net::HTTP.get_response(URI(SiteSetting.mumble_cvp))
SiteSetting.mumble_xml ? Hash.from_xml(response.body) : JSON.parse(response.body)
end
end
class Engine < ::Rails::Engine
engine_name "mumble"
isolate_namespace Mumble
end
end
Mumble::Engine.routes.draw do
get "/list" => "mumble#list"
end
Discourse::Application.routes.append do
mount ::Mumble::Engine, at: "/mumble"
end
require_dependency "application_controller"
class Mumble::MumbleController < ::ApplicationController
def list
render json: {data: Mumble.fetch_data}
end
end
}
register_asset "stylesheets/mumble.scss"