##// END OF EJS Templates
Adds experimental support for Markdown formatting with redcarpet (#15520)....
Jean-Philippe Lang -
r12177:471e01ca5059
parent child
Show More
@@ -0,0 +1,136
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require 'cgi'
19
20 module Redmine
21 module WikiFormatting
22 module Markdown
23 class HTML < Redcarpet::Render::HTML
24 include ActionView::Helpers::TagHelper
25
26 def link(link, title, content)
27 css = nil
28 unless link && link.starts_with?('/')
29 css = 'external'
30 end
31 content_tag('a', content.html_safe, :href => link, :title => title, :class => css)
32 end
33
34 def block_code(code, language)
35 if language.present?
36 "<pre><code class=\"#{CGI.escapeHTML language} syntaxhl\">" +
37 Redmine::SyntaxHighlighting.highlight_by_language(code, language) +
38 "</code></pre>"
39 else
40 "<pre>" + CGI.escapeHTML(code) + "</pre>"
41 end
42 end
43 end
44
45 class Formatter
46 def initialize(text)
47 @text = text
48 end
49
50 def to_html(*args)
51 html = formatter.render(@text)
52 # restore wiki links eg. [[Foo]]
53 html.gsub!(%r{\[<a href="(.*?)">(.*?)</a>\]}) do
54 "[[#{$2}]]"
55 end
56 # restore Redmine links with double-quotes, eg. version:"1.0"
57 html.gsub!(/(\w):&quot;(.+?)&quot;/) do
58 "#{$1}:\"#{$2}\""
59 end
60 html
61 end
62
63 def get_section(index)
64 section = extract_sections(index)[1]
65 hash = Digest::MD5.hexdigest(section)
66 return section, hash
67 end
68
69 def update_section(index, update, hash=nil)
70 t = extract_sections(index)
71 if hash.present? && hash != Digest::MD5.hexdigest(t[1])
72 raise Redmine::WikiFormatting::StaleSectionError
73 end
74 t[1] = update unless t[1].blank?
75 t.reject(&:blank?).join "\n\n"
76 end
77
78 def extract_sections(index)
79 sections = ['', '', '']
80 offset = 0
81 i = 0
82 l = 1
83 inside_pre = false
84 @text.split(/(^(?:.+\r?\n\r?(?:\=+|\-+)|#+.+|~~~.*)\s*$)/).each do |part|
85 level = nil
86 if part =~ /\A~{3,}(\S+)?\s*$/
87 if $1
88 if !inside_pre
89 inside_pre = true
90 end
91 else
92 inside_pre = !inside_pre
93 end
94 elsif inside_pre
95 # nop
96 elsif part =~ /\A(#+).+/
97 level = $1.size
98 elsif part =~ /\A.+\r?\n\r?(\=+|\-+)\s*$/
99 level = $1.include?('=') ? 1 : 2
100 end
101 if level
102 i += 1
103 if offset == 0 && i == index
104 # entering the requested section
105 offset = 1
106 l = level
107 elsif offset == 1 && i > index && level <= l
108 # leaving the requested section
109 offset = 2
110 end
111 end
112 sections[offset] << part
113 end
114 sections.map(&:strip)
115 end
116
117 private
118
119 def formatter
120 @@formatter ||= Redcarpet::Markdown.new(
121 Redmine::WikiFormatting::Markdown::HTML.new(
122 :filter_html => true,
123 :hard_wrap => true
124 ),
125 :autolink => true,
126 :fenced_code_blocks => true,
127 :space_after_headers => true,
128 :tables => true,
129 :strikethrough => true,
130 :superscript => true
131 )
132 end
133 end
134 end
135 end
136 end
@@ -0,0 +1,45
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 module Redmine
19 module WikiFormatting
20 module Markdown
21 module Helper
22 def wikitoolbar_for(field_id)
23 heads_for_wiki_formatter
24 javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.draw();")
25 end
26
27 def initial_page_content(page)
28 "# #{@page.pretty_title}"
29 end
30
31 def heads_for_wiki_formatter
32 unless @heads_for_wiki_formatter_included
33 content_for :header_tags do
34 javascript_include_tag('jstoolbar/jstoolbar') +
35 javascript_include_tag('jstoolbar/markdown') +
36 javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
37 stylesheet_link_tag('jstoolbar')
38 end
39 @heads_for_wiki_formatter_included = true
40 end
41 end
42 end
43 end
44 end
45 end
@@ -0,0 +1,194
1 /* ***** BEGIN LICENSE BLOCK *****
2 * This file is part of DotClear.
3 * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
4 * rights reserved.
5 *
6 * DotClear is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * DotClear is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with DotClear; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * ***** END LICENSE BLOCK *****
21 */
22
23 /* Modified by JP LANG for markdown formatting */
24
25 // strong
26 jsToolBar.prototype.elements.strong = {
27 type: 'button',
28 title: 'Strong',
29 fn: {
30 wiki: function() { this.singleTag('**') }
31 }
32 }
33
34 // em
35 jsToolBar.prototype.elements.em = {
36 type: 'button',
37 title: 'Italic',
38 fn: {
39 wiki: function() { this.singleTag("*") }
40 }
41 }
42
43 // del
44 jsToolBar.prototype.elements.del = {
45 type: 'button',
46 title: 'Deleted',
47 fn: {
48 wiki: function() { this.singleTag('~~') }
49 }
50 }
51
52 // code
53 jsToolBar.prototype.elements.code = {
54 type: 'button',
55 title: 'Code',
56 fn: {
57 wiki: function() { this.singleTag('`') }
58 }
59 }
60
61 // spacer
62 jsToolBar.prototype.elements.space1 = {type: 'space'}
63
64 // headings
65 jsToolBar.prototype.elements.h1 = {
66 type: 'button',
67 title: 'Heading 1',
68 fn: {
69 wiki: function() {
70 this.encloseLineSelection('# ', '',function(str) {
71 str = str.replace(/^#+\s+/, '')
72 return str;
73 });
74 }
75 }
76 }
77 jsToolBar.prototype.elements.h2 = {
78 type: 'button',
79 title: 'Heading 2',
80 fn: {
81 wiki: function() {
82 this.encloseLineSelection('## ', '',function(str) {
83 str = str.replace(/^#+\s+/, '')
84 return str;
85 });
86 }
87 }
88 }
89 jsToolBar.prototype.elements.h3 = {
90 type: 'button',
91 title: 'Heading 3',
92 fn: {
93 wiki: function() {
94 this.encloseLineSelection('### ', '',function(str) {
95 str = str.replace(/^#+\s+/, '')
96 return str;
97 });
98 }
99 }
100 }
101
102 // spacer
103 jsToolBar.prototype.elements.space2 = {type: 'space'}
104
105 // ul
106 jsToolBar.prototype.elements.ul = {
107 type: 'button',
108 title: 'Unordered list',
109 fn: {
110 wiki: function() {
111 this.encloseLineSelection('','',function(str) {
112 str = str.replace(/\r/g,'');
113 return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
114 });
115 }
116 }
117 }
118
119 // ol
120 jsToolBar.prototype.elements.ol = {
121 type: 'button',
122 title: 'Ordered list',
123 fn: {
124 wiki: function() {
125 this.encloseLineSelection('','',function(str) {
126 str = str.replace(/\r/g,'');
127 return str.replace(/(\n|^)[*-]?\s*/g,"$11. ");
128 });
129 }
130 }
131 }
132
133 // spacer
134 jsToolBar.prototype.elements.space3 = {type: 'space'}
135
136 // bq
137 jsToolBar.prototype.elements.bq = {
138 type: 'button',
139 title: 'Quote',
140 fn: {
141 wiki: function() {
142 this.encloseLineSelection('','',function(str) {
143 str = str.replace(/\r/g,'');
144 return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2");
145 });
146 }
147 }
148 }
149
150 // unbq
151 jsToolBar.prototype.elements.unbq = {
152 type: 'button',
153 title: 'Unquote',
154 fn: {
155 wiki: function() {
156 this.encloseLineSelection('','',function(str) {
157 str = str.replace(/\r/g,'');
158 return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2");
159 });
160 }
161 }
162 }
163
164 // pre
165 jsToolBar.prototype.elements.pre = {
166 type: 'button',
167 title: 'Preformatted text',
168 fn: {
169 wiki: function() { this.encloseLineSelection('~~~\n', '\n~~~') }
170 }
171 }
172
173 // spacer
174 jsToolBar.prototype.elements.space4 = {type: 'space'}
175
176 // wiki page
177 jsToolBar.prototype.elements.link = {
178 type: 'button',
179 title: 'Wiki link',
180 fn: {
181 wiki: function() { this.encloseSelection("[[", "]]") }
182 }
183 }
184 // image
185 jsToolBar.prototype.elements.img = {
186 type: 'button',
187 title: 'Image',
188 fn: {
189 wiki: function() { this.encloseSelection("![](", ")") }
190 }
191 }
192
193 // spacer
194 jsToolBar.prototype.elements.space5 = {type: 'space'}
@@ -0,0 +1,62
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.expand_path('../../../../../test_helper', __FILE__)
19
20 class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase
21 include ApplicationHelper
22
23 def setup
24 @formatter = Redmine::WikiFormatting::Markdown::Formatter
25 end
26
27 def test_inline_style
28 assert_equal "<p><strong>foo</strong></p>", @formatter.new("**foo**").to_html.strip
29 end
30
31 def test_wiki_links_should_be_preserved
32 text = 'This is a wiki link: [[Foo]]'
33 assert_include '[[Foo]]', @formatter.new(text).to_html
34 end
35
36 def test_redmine_links_with_double_quotes_should_be_preserved
37 text = 'This is a redmine link: version:"1.0"'
38 assert_include 'version:"1.0"', @formatter.new(text).to_html
39 end
40
41 def test_should_support_syntax_highligth
42 text = <<-STR
43 ~~~ruby
44 def foo
45 end
46 ~~~
47 STR
48 assert_select_in @formatter.new(text).to_html, 'pre code.ruby.syntaxhl' do
49 assert_select 'span.keyword', :text => 'def'
50 end
51 end
52
53 def test_external_links_should_have_external_css_class
54 text = 'This is a [link](http://example.net/)'
55 assert_equal '<p>This is a <a class="external" href="http://example.net/">link</a></p>', @formatter.new(text).to_html.strip
56 end
57
58 def test_locals_links_should_not_have_external_css_class
59 text = 'This is a [link](/issues)'
60 assert_equal '<p>This is a <a href="/issues">link</a></p>', @formatter.new(text).to_html.strip
61 end
62 end
@@ -1,98 +1,100
1 source 'https://rubygems.org'
1 source 'https://rubygems.org'
2
2
3 gem "rails", "3.2.16"
3 gem "rails", "3.2.16"
4 gem "jquery-rails", "~> 2.0.2"
4 gem "jquery-rails", "~> 2.0.2"
5 gem "coderay", "~> 1.1.0"
5 gem "coderay", "~> 1.1.0"
6 gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
6 gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
7 gem "builder", "3.0.0"
7 gem "builder", "3.0.0"
8 # TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped
9 gem "redcarpet", "~> 2.3.0"
8
10
9 # Optional gem for LDAP authentication
11 # Optional gem for LDAP authentication
10 group :ldap do
12 group :ldap do
11 gem "net-ldap", "~> 0.3.1"
13 gem "net-ldap", "~> 0.3.1"
12 end
14 end
13
15
14 # Optional gem for OpenID authentication
16 # Optional gem for OpenID authentication
15 group :openid do
17 group :openid do
16 gem "ruby-openid", "~> 2.3.0", :require => "openid"
18 gem "ruby-openid", "~> 2.3.0", :require => "openid"
17 gem "rack-openid"
19 gem "rack-openid"
18 end
20 end
19
21
20 # Optional gem for exporting the gantt to a PNG file, not supported with jruby
22 # Optional gem for exporting the gantt to a PNG file, not supported with jruby
21 platforms :mri, :mingw do
23 platforms :mri, :mingw do
22 group :rmagick do
24 group :rmagick do
23 # RMagick 2 supports ruby 1.9
25 # RMagick 2 supports ruby 1.9
24 # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
26 # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
25 # different requirements for the same gem on different platforms
27 # different requirements for the same gem on different platforms
26 gem "rmagick", ">= 2.0.0"
28 gem "rmagick", ">= 2.0.0"
27 end
29 end
28 end
30 end
29
31
30 platforms :jruby do
32 platforms :jruby do
31 # jruby-openssl is bundled with JRuby 1.7.0
33 # jruby-openssl is bundled with JRuby 1.7.0
32 gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
34 gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
33 gem "activerecord-jdbc-adapter", "~> 1.3.2"
35 gem "activerecord-jdbc-adapter", "~> 1.3.2"
34 end
36 end
35
37
36 # Include database gems for the adapters found in the database
38 # Include database gems for the adapters found in the database
37 # configuration file
39 # configuration file
38 require 'erb'
40 require 'erb'
39 require 'yaml'
41 require 'yaml'
40 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
42 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
41 if File.exist?(database_file)
43 if File.exist?(database_file)
42 database_config = YAML::load(ERB.new(IO.read(database_file)).result)
44 database_config = YAML::load(ERB.new(IO.read(database_file)).result)
43 adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
45 adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
44 if adapters.any?
46 if adapters.any?
45 adapters.each do |adapter|
47 adapters.each do |adapter|
46 case adapter
48 case adapter
47 when 'mysql2'
49 when 'mysql2'
48 gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
50 gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
49 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
51 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
50 when 'mysql'
52 when 'mysql'
51 gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
53 gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
52 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
54 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
53 when /postgresql/
55 when /postgresql/
54 gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
56 gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
55 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
57 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
56 when /sqlite3/
58 when /sqlite3/
57 gem "sqlite3", :platforms => [:mri, :mingw]
59 gem "sqlite3", :platforms => [:mri, :mingw]
58 gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
60 gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
59 when /sqlserver/
61 when /sqlserver/
60 gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw]
62 gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw]
61 gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
63 gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
62 else
64 else
63 warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
65 warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
64 end
66 end
65 end
67 end
66 else
68 else
67 warn("No adapter found in config/database.yml, please configure it first")
69 warn("No adapter found in config/database.yml, please configure it first")
68 end
70 end
69 else
71 else
70 warn("Please configure your config/database.yml first")
72 warn("Please configure your config/database.yml first")
71 end
73 end
72
74
73 group :development do
75 group :development do
74 gem "rdoc", ">= 2.4.2"
76 gem "rdoc", ">= 2.4.2"
75 gem "yard"
77 gem "yard"
76 end
78 end
77
79
78 group :test do
80 group :test do
79 gem "shoulda", "~> 3.3.2"
81 gem "shoulda", "~> 3.3.2"
80 gem "mocha", ">= 0.14", :require => 'mocha/api'
82 gem "mocha", ">= 0.14", :require => 'mocha/api'
81 if RUBY_VERSION >= '1.9.3'
83 if RUBY_VERSION >= '1.9.3'
82 gem "capybara", "~> 2.1.0"
84 gem "capybara", "~> 2.1.0"
83 gem "selenium-webdriver"
85 gem "selenium-webdriver"
84 end
86 end
85 end
87 end
86
88
87 local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
89 local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
88 if File.exists?(local_gemfile)
90 if File.exists?(local_gemfile)
89 puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
91 puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
90 instance_eval File.read(local_gemfile)
92 instance_eval File.read(local_gemfile)
91 end
93 end
92
94
93 # Load plugins' Gemfiles
95 # Load plugins' Gemfiles
94 Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
96 Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
95 puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
97 puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
96 #TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
98 #TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
97 instance_eval File.read(file), file
99 instance_eval File.read(file), file
98 end
100 end
@@ -1,272 +1,274
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'redmine/core_ext'
18 require 'redmine/core_ext'
19
19
20 begin
20 begin
21 require 'RMagick' unless Object.const_defined?(:Magick)
21 require 'RMagick' unless Object.const_defined?(:Magick)
22 rescue LoadError
22 rescue LoadError
23 # RMagick is not available
23 # RMagick is not available
24 end
24 end
25
25
26 require 'redmine/scm/base'
26 require 'redmine/scm/base'
27 require 'redmine/access_control'
27 require 'redmine/access_control'
28 require 'redmine/access_keys'
28 require 'redmine/access_keys'
29 require 'redmine/activity'
29 require 'redmine/activity'
30 require 'redmine/activity/fetcher'
30 require 'redmine/activity/fetcher'
31 require 'redmine/ciphering'
31 require 'redmine/ciphering'
32 require 'redmine/codeset_util'
32 require 'redmine/codeset_util'
33 require 'redmine/field_format'
33 require 'redmine/field_format'
34 require 'redmine/i18n'
34 require 'redmine/i18n'
35 require 'redmine/menu_manager'
35 require 'redmine/menu_manager'
36 require 'redmine/notifiable'
36 require 'redmine/notifiable'
37 require 'redmine/platform'
37 require 'redmine/platform'
38 require 'redmine/mime_type'
38 require 'redmine/mime_type'
39 require 'redmine/notifiable'
39 require 'redmine/notifiable'
40 require 'redmine/search'
40 require 'redmine/search'
41 require 'redmine/syntax_highlighting'
41 require 'redmine/syntax_highlighting'
42 require 'redmine/thumbnail'
42 require 'redmine/thumbnail'
43 require 'redmine/unified_diff'
43 require 'redmine/unified_diff'
44 require 'redmine/utils'
44 require 'redmine/utils'
45 require 'redmine/version'
45 require 'redmine/version'
46 require 'redmine/wiki_formatting'
46 require 'redmine/wiki_formatting'
47
47
48 require 'redmine/default_data/loader'
48 require 'redmine/default_data/loader'
49 require 'redmine/helpers/calendar'
49 require 'redmine/helpers/calendar'
50 require 'redmine/helpers/diff'
50 require 'redmine/helpers/diff'
51 require 'redmine/helpers/gantt'
51 require 'redmine/helpers/gantt'
52 require 'redmine/helpers/time_report'
52 require 'redmine/helpers/time_report'
53 require 'redmine/views/other_formats_builder'
53 require 'redmine/views/other_formats_builder'
54 require 'redmine/views/labelled_form_builder'
54 require 'redmine/views/labelled_form_builder'
55 require 'redmine/views/builders'
55 require 'redmine/views/builders'
56
56
57 require 'redmine/themes'
57 require 'redmine/themes'
58 require 'redmine/hook'
58 require 'redmine/hook'
59 require 'redmine/plugin'
59 require 'redmine/plugin'
60
60
61 if RUBY_VERSION < '1.9'
61 if RUBY_VERSION < '1.9'
62 require 'fastercsv'
62 require 'fastercsv'
63 else
63 else
64 require 'csv'
64 require 'csv'
65 FCSV = CSV
65 FCSV = CSV
66 end
66 end
67
67
68 Redmine::Scm::Base.add "Subversion"
68 Redmine::Scm::Base.add "Subversion"
69 Redmine::Scm::Base.add "Darcs"
69 Redmine::Scm::Base.add "Darcs"
70 Redmine::Scm::Base.add "Mercurial"
70 Redmine::Scm::Base.add "Mercurial"
71 Redmine::Scm::Base.add "Cvs"
71 Redmine::Scm::Base.add "Cvs"
72 Redmine::Scm::Base.add "Bazaar"
72 Redmine::Scm::Base.add "Bazaar"
73 Redmine::Scm::Base.add "Git"
73 Redmine::Scm::Base.add "Git"
74 Redmine::Scm::Base.add "Filesystem"
74 Redmine::Scm::Base.add "Filesystem"
75
75
76 # Permissions
76 # Permissions
77 Redmine::AccessControl.map do |map|
77 Redmine::AccessControl.map do |map|
78 map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true
78 map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true
79 map.permission :search_project, {:search => :index}, :public => true, :read => true
79 map.permission :search_project, {:search => :index}, :public => true, :read => true
80 map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
80 map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
81 map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
81 map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
82 map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true
82 map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true
83 map.permission :select_project_modules, {:projects => :modules}, :require => :member
83 map.permission :select_project_modules, {:projects => :modules}, :require => :member
84 map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member
84 map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member
85 map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
85 map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
86 map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
86 map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
87
87
88 map.project_module :issue_tracking do |map|
88 map.project_module :issue_tracking do |map|
89 # Issue categories
89 # Issue categories
90 map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member
90 map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member
91 # Issues
91 # Issues
92 map.permission :view_issues, {:issues => [:index, :show],
92 map.permission :view_issues, {:issues => [:index, :show],
93 :auto_complete => [:issues],
93 :auto_complete => [:issues],
94 :context_menus => [:issues],
94 :context_menus => [:issues],
95 :versions => [:index, :show, :status_by],
95 :versions => [:index, :show, :status_by],
96 :journals => [:index, :diff],
96 :journals => [:index, :diff],
97 :queries => :index,
97 :queries => :index,
98 :reports => [:issue_report, :issue_report_details]},
98 :reports => [:issue_report, :issue_report_details]},
99 :read => true
99 :read => true
100 map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload}
100 map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload}
101 map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload}
101 map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload}
102 map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
102 map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
103 map.permission :manage_subtasks, {}
103 map.permission :manage_subtasks, {}
104 map.permission :set_issues_private, {}
104 map.permission :set_issues_private, {}
105 map.permission :set_own_issues_private, {}, :require => :loggedin
105 map.permission :set_own_issues_private, {}, :require => :loggedin
106 map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
106 map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
107 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
107 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
108 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
108 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
109 map.permission :view_private_notes, {}, :read => true, :require => :member
109 map.permission :view_private_notes, {}, :read => true, :require => :member
110 map.permission :set_notes_private, {}, :require => :member
110 map.permission :set_notes_private, {}, :require => :member
111 map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin
111 map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin
112 map.permission :delete_issues, {:issues => :destroy}, :require => :member
112 map.permission :delete_issues, {:issues => :destroy}, :require => :member
113 # Queries
113 # Queries
114 map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member
114 map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member
115 map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
115 map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
116 # Watchers
116 # Watchers
117 map.permission :view_issue_watchers, {}, :read => true
117 map.permission :view_issue_watchers, {}, :read => true
118 map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]}
118 map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]}
119 map.permission :delete_issue_watchers, {:watchers => :destroy}
119 map.permission :delete_issue_watchers, {:watchers => :destroy}
120 end
120 end
121
121
122 map.project_module :time_tracking do |map|
122 map.project_module :time_tracking do |map|
123 map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
123 map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
124 map.permission :view_time_entries, {:timelog => [:index, :report, :show]}, :read => true
124 map.permission :view_time_entries, {:timelog => [:index, :report, :show]}, :read => true
125 map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member
125 map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member
126 map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
126 map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
127 map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
127 map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
128 end
128 end
129
129
130 map.project_module :news do |map|
130 map.project_module :news do |map|
131 map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
131 map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
132 map.permission :view_news, {:news => [:index, :show]}, :public => true, :read => true
132 map.permission :view_news, {:news => [:index, :show]}, :public => true, :read => true
133 map.permission :comment_news, {:comments => :create}
133 map.permission :comment_news, {:comments => :create}
134 end
134 end
135
135
136 map.project_module :documents do |map|
136 map.project_module :documents do |map|
137 map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin
137 map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin
138 map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin
138 map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin
139 map.permission :delete_documents, {:documents => [:destroy]}, :require => :loggedin
139 map.permission :delete_documents, {:documents => [:destroy]}, :require => :loggedin
140 map.permission :view_documents, {:documents => [:index, :show, :download]}, :read => true
140 map.permission :view_documents, {:documents => [:index, :show, :download]}, :read => true
141 end
141 end
142
142
143 map.project_module :files do |map|
143 map.project_module :files do |map|
144 map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
144 map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
145 map.permission :view_files, {:files => :index, :versions => :download}, :read => true
145 map.permission :view_files, {:files => :index, :versions => :download}, :read => true
146 end
146 end
147
147
148 map.project_module :wiki do |map|
148 map.project_module :wiki do |map|
149 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
149 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
150 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
150 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
151 map.permission :delete_wiki_pages, {:wiki => [:destroy, :destroy_version]}, :require => :member
151 map.permission :delete_wiki_pages, {:wiki => [:destroy, :destroy_version]}, :require => :member
152 map.permission :view_wiki_pages, {:wiki => [:index, :show, :special, :date_index]}, :read => true
152 map.permission :view_wiki_pages, {:wiki => [:index, :show, :special, :date_index]}, :read => true
153 map.permission :export_wiki_pages, {:wiki => [:export]}, :read => true
153 map.permission :export_wiki_pages, {:wiki => [:export]}, :read => true
154 map.permission :view_wiki_edits, {:wiki => [:history, :diff, :annotate]}, :read => true
154 map.permission :view_wiki_edits, {:wiki => [:history, :diff, :annotate]}, :read => true
155 map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment]
155 map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment]
156 map.permission :delete_wiki_pages_attachments, {}
156 map.permission :delete_wiki_pages_attachments, {}
157 map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
157 map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
158 end
158 end
159
159
160 map.project_module :repository do |map|
160 map.project_module :repository do |map|
161 map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
161 map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
162 map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
162 map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
163 map.permission :view_changesets, {:repositories => [:show, :revisions, :revision]}, :read => true
163 map.permission :view_changesets, {:repositories => [:show, :revisions, :revision]}, :read => true
164 map.permission :commit_access, {}
164 map.permission :commit_access, {}
165 map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
165 map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
166 end
166 end
167
167
168 map.project_module :boards do |map|
168 map.project_module :boards do |map|
169 map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
169 map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
170 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true
170 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true
171 map.permission :add_messages, {:messages => [:new, :reply, :quote]}
171 map.permission :add_messages, {:messages => [:new, :reply, :quote]}
172 map.permission :edit_messages, {:messages => :edit}, :require => :member
172 map.permission :edit_messages, {:messages => :edit}, :require => :member
173 map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
173 map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
174 map.permission :delete_messages, {:messages => :destroy}, :require => :member
174 map.permission :delete_messages, {:messages => :destroy}, :require => :member
175 map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
175 map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
176 end
176 end
177
177
178 map.project_module :calendar do |map|
178 map.project_module :calendar do |map|
179 map.permission :view_calendar, {:calendars => [:show, :update]}, :read => true
179 map.permission :view_calendar, {:calendars => [:show, :update]}, :read => true
180 end
180 end
181
181
182 map.project_module :gantt do |map|
182 map.project_module :gantt do |map|
183 map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true
183 map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true
184 end
184 end
185 end
185 end
186
186
187 Redmine::MenuManager.map :top_menu do |menu|
187 Redmine::MenuManager.map :top_menu do |menu|
188 menu.push :home, :home_path
188 menu.push :home, :home_path
189 menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
189 menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
190 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
190 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
191 menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
191 menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
192 menu.push :help, Redmine::Info.help_url, :last => true
192 menu.push :help, Redmine::Info.help_url, :last => true
193 end
193 end
194
194
195 Redmine::MenuManager.map :account_menu do |menu|
195 Redmine::MenuManager.map :account_menu do |menu|
196 menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? }
196 menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? }
197 menu.push :register, :register_path, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
197 menu.push :register, :register_path, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
198 menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
198 menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
199 menu.push :logout, :signout_path, :html => {:method => 'post'}, :if => Proc.new { User.current.logged? }
199 menu.push :logout, :signout_path, :html => {:method => 'post'}, :if => Proc.new { User.current.logged? }
200 end
200 end
201
201
202 Redmine::MenuManager.map :application_menu do |menu|
202 Redmine::MenuManager.map :application_menu do |menu|
203 # Empty
203 # Empty
204 end
204 end
205
205
206 Redmine::MenuManager.map :admin_menu do |menu|
206 Redmine::MenuManager.map :admin_menu do |menu|
207 menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
207 menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
208 menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
208 menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
209 menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
209 menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
210 menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
210 menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
211 menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
211 menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
212 menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
212 menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
213 :html => {:class => 'issue_statuses'}
213 :html => {:class => 'issue_statuses'}
214 menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
214 menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
215 menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural,
215 menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural,
216 :html => {:class => 'custom_fields'}
216 :html => {:class => 'custom_fields'}
217 menu.push :enumerations, {:controller => 'enumerations'}
217 menu.push :enumerations, {:controller => 'enumerations'}
218 menu.push :settings, {:controller => 'settings'}
218 menu.push :settings, {:controller => 'settings'}
219 menu.push :ldap_authentication, {:controller => 'auth_sources', :action => 'index'},
219 menu.push :ldap_authentication, {:controller => 'auth_sources', :action => 'index'},
220 :html => {:class => 'server_authentication'}
220 :html => {:class => 'server_authentication'}
221 menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
221 menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
222 menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
222 menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
223 end
223 end
224
224
225 Redmine::MenuManager.map :project_menu do |menu|
225 Redmine::MenuManager.map :project_menu do |menu|
226 menu.push :overview, { :controller => 'projects', :action => 'show' }
226 menu.push :overview, { :controller => 'projects', :action => 'show' }
227 menu.push :activity, { :controller => 'activities', :action => 'index' }
227 menu.push :activity, { :controller => 'activities', :action => 'index' }
228 menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
228 menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
229 :if => Proc.new { |p| p.shared_versions.any? }
229 :if => Proc.new { |p| p.shared_versions.any? }
230 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
230 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
231 menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
231 menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
232 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
232 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
233 menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
233 menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
234 menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
234 menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
235 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
235 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
236 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
236 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
237 menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
237 menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
238 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
238 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
239 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
239 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
240 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
240 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
241 menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
241 menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
242 menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
242 menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
243 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
243 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
244 menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
244 menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
245 end
245 end
246
246
247 Redmine::Activity.map do |activity|
247 Redmine::Activity.map do |activity|
248 activity.register :issues, :class_name => %w(Issue Journal)
248 activity.register :issues, :class_name => %w(Issue Journal)
249 activity.register :changesets
249 activity.register :changesets
250 activity.register :news
250 activity.register :news
251 activity.register :documents, :class_name => %w(Document Attachment)
251 activity.register :documents, :class_name => %w(Document Attachment)
252 activity.register :files, :class_name => 'Attachment'
252 activity.register :files, :class_name => 'Attachment'
253 activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
253 activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
254 activity.register :messages, :default => false
254 activity.register :messages, :default => false
255 activity.register :time_entries, :default => false
255 activity.register :time_entries, :default => false
256 end
256 end
257
257
258 Redmine::Search.map do |search|
258 Redmine::Search.map do |search|
259 search.register :issues
259 search.register :issues
260 search.register :news
260 search.register :news
261 search.register :documents
261 search.register :documents
262 search.register :changesets
262 search.register :changesets
263 search.register :wiki_pages
263 search.register :wiki_pages
264 search.register :messages
264 search.register :messages
265 search.register :projects
265 search.register :projects
266 end
266 end
267
267
268 Redmine::WikiFormatting.map do |format|
268 Redmine::WikiFormatting.map do |format|
269 format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
269 format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
270 format.register :markdown, Redmine::WikiFormatting::Markdown::Formatter, Redmine::WikiFormatting::Markdown::Helper,
271 :label => 'Markdown (experimental)'
270 end
272 end
271
273
272 ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler
274 ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler
General Comments 0
You need to be logged in to leave comments. Login now