-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.rb
More file actions
39 lines (26 loc) · 1.17 KB
/
plugin.rb
File metadata and controls
39 lines (26 loc) · 1.17 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
# frozen_string_literal: true
# name: discourse-modifications
# about: TODO
# meta_topic_id: TODO
# version: 0.0.1
# authors: Alteras1, Ghan
# url: TODO
# required_version: 2.7.0
gem 'any_ascii', '0.3.2'
enabled_site_setting :discourse_modifications_enabled
module ::DiscourseModifications
PLUGIN_NAME = "discourse-modifications"
XF_TOPIC_LINK_NORMALIZATION = '/threads\/[^.]+\.([0-9]+)\/?/threads/\1'
end
require_relative "lib/discourse_modifications/engine"
after_initialize do
# Code which should run after Rails has finished booting
# Note: if this file gets too large, consider moving code into separate files in the lib directory
# and applying a Initializer pattern to load them.
Topic.slug_computed_callbacks << ::DiscourseModifications::TopicSlug.method(:slug_for_topic)
# add permalink normalization
normalizations = SiteSetting.permalink_normalizations
normalizations = normalizations.blank? ? [] : normalizations.split("|")
normalizations << ::DiscourseModifications::XF_TOPIC_LINK_NORMALIZATION if normalizations.exclude?(::DiscourseModifications::XF_TOPIC_LINK_NORMALIZATION)
SiteSetting.permalink_normalizations = normalizations.join("|")
end