forked from sylque/discpage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.rb
32 lines (27 loc) · 1.29 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
# name: discpage
# about: Create static pages and attach discussions to them
# version: 1.0.44
# authors: Sylvain Quendez
# url: https://github.com/sylque/discpage
# Load styles
register_asset "stylesheets/discpage.css"
register_asset "stylesheets/discpage-mobile.css", :mobile
# Load icons
register_svg_icon "comment" if respond_to?(:register_svg_icon)
register_svg_icon "history" if respond_to?(:register_svg_icon)
# Register admin settings
enabled_site_setting :discpage_enabled
# Register the template to restore the create topic button
register_asset "javascripts/discourse/templates/components/create-topic-button.hbs"
# In Discourse, editing the *last* post of a topic bumps the topic. A DiscPage
# static page is almost always the only post of a topic (because further posts
# are never displayed). It means any minor edit in the static page will bump it.
# Hence this option to prevent static pages from ever getting bumped.
# https://meta.discourse.org/t/discourse-no-bump-prevent-users-from-bumping-topics/78186
# https://github.com/discourse/discourse-no-bump/blob/master/plugin.rb#L34
after_initialize do
add_to_class :post_revisor, :bypass_bump? do
return false unless SiteSetting.discpage_never_bump_pages
SiteSetting.discpage_page_categories.include?(@topic.category_id.to_s)
end
end