-
Notifications
You must be signed in to change notification settings - Fork 16
/
init.rb
73 lines (62 loc) · 2.32 KB
/
init.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
# redmine_pastebin -- A real pastebin plugin for Redmine.
#
# Copyright (C) 2011 Alex Shuglin <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
require 'redmine'
Redmine::Plugin.register :redmine_pastebin do
name 'Redmine Pastebin plugin'
author 'Alex Shulgin <[email protected]>'
description 'A real pastebin plugin for redmine'
version '0.2.0'
url 'https://github.com/commandprompt/redmine_pastebin/'
# author_url 'http://example.com/about'
requires_redmine :version_or_higher => '2.0.x'
project_module :pastes do
permission :view_pastes, :pastes => [:index, :show, :download]
permission :add_pastes, :pastes => [:new, :create]
permission :edit_pastes, :pastes => [:edit, :update]
permission :delete_pastes, :pastes => [:destroy]
end
menu :project_menu, :pastes, { :controller => 'pastes', :action => 'index' },
:caption => :label_paste_plural, :after => :label_wiki,
:param => :project_id
end
Redmine::Activity.map do |activity|
activity.register :pastes
end
Redmine::Search.map do |search|
search.register :pastes
end
Redmine::WikiFormatting::Macros.register do
desc "A link to paste by id: {{paste(NNN)}}"
macro :paste do |obj, args|
id = args.first
unless id.blank? or Paste.secure_id?(id)
paste = Paste.find_by_id(id)
link_to(paste.title, paste_path(id)) if paste
end
end
end
prepare_block = Proc.new do
Project.send(:include, RedminePastebin::ProjectPastesPatch)
User.send(:include, RedminePastebin::UserPastesPatch)
end
if Rails.env.development?
ActionDispatch::Reloader.to_prepare { prepare_block.call }
else
prepare_block.call
end
require_dependency 'redmine_pastebin/view_hooks'