-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.rb
More file actions
72 lines (56 loc) · 1.66 KB
/
plugin.rb
File metadata and controls
72 lines (56 loc) · 1.66 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# frozen_string_literal: true
# name: discourse-collections
# about: Discourse Collections Plugin
# meta_topic_id: 372817
# version: 1.0.7
# authors: Alteras1
# url: https://github.com/Alteras1/discourse-collections
# required_version: 3.4.0
enabled_site_setting :collections_enabled
register_asset "stylesheets/common/index.scss"
register_asset "stylesheets/mobile/mobile.scss", :mobile
module ::Collections
PLUGIN_NAME = "discourse-collections"
# names for serializer
COLLECTION = "collection"
SUBCOLLECTION = "subcollection"
# topic custom fields
COLLECTION_ID = "collection_id"
SUBCOLLECTION_ID = "subcollection_id"
class Initializer
attr_reader :plugin
# @param [Plugin::Instance] plugin
def initialize(plugin)
@plugin = plugin
end
def apply
raise NotImplementedError
end
end
module Initializers
module_function
def apply(plugin)
constants.each do |const_name|
klass = const_get(const_name)
klass.new(plugin).apply if klass.is_a?(Class) && klass < Initializer
end
end
end
end
require_relative "lib/collections/engine"
after_initialize do
register_svg_icon "collections-add"
register_svg_icon "collections-remove"
register_svg_icon "collection-pip"
reloadable_patch { |plugin| Guardian.prepend Collections::GuardianExtensions }
# register_search_advanced_filter(/is:collection/) do |post|
# if SiteSetting.collections_enabled
# post.where(
# "topics.id IN (SELECT topic_id FROM topic_custom_fields WHERE name = '#{Collections::IS_COLLECTION}' AND value = 't')",
# )
# else
# post
# end
# end
Collections::Initializers.apply(self)
end