forked from Restream/redmine_tagging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tagging_patches.rb
executable file
·94 lines (72 loc) · 2.3 KB
/
tagging_patches.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require_dependency 'issue'
require_dependency 'wiki_page'
module TaggingPlugin
module WikiPagePatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
acts_as_taggable
has_many :wiki_page_tags
end
end
module ClassMethods
end
module InstanceMethods
end
end
module IssuePatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
acts_as_taggable
has_many :issue_tags
end
end
module ClassMethods
end
module InstanceMethods
end
end
module WikiControllerPatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
alias_method_chain :edit, :save_tags
end
end
module ClassMethods
end
module InstanceMethods
def edit_with_save_tags
if ! request.get?
page = @wiki.find_page(params[:page])
content = page.content_for_version(params[:version])
txt = content.text.to_s
# if the body text wasn't change the after_save hook doesn't
# get called. This either forces a new space at the end, or
# removes it if it was already present. This fully undoes the
# performance gain that was intended by not saving the object
# because it will always perform 2 requests _and_ save the
# object, but whatyagonnado...
if params[:content][:text] == txt
if txt =~ / $/
params[:content][:text].rstrip!
else
params[:content][:text] += ' '
end
end
end
return edit_without_save_tags
end
end
end
end
Issue.send(:include, TaggingPlugin::IssuePatch) unless Issue.included_modules.include? TaggingPlugin::IssuePatch
WikiPage.send(:include, TaggingPlugin::WikiPagePatch) unless WikiPage.included_modules.include? TaggingPlugin::WikiPagePatch
WikiController.send(:include, TaggingPlugin::WikiControllerPatch) unless WikiController.included_modules.include? TaggingPlugin::WikiControllerPatch