##// 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 1 source 'https://rubygems.org'
2 2
3 3 gem "rails", "3.2.16"
4 4 gem "jquery-rails", "~> 2.0.2"
5 5 gem "coderay", "~> 1.1.0"
6 6 gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
7 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 11 # Optional gem for LDAP authentication
10 12 group :ldap do
11 13 gem "net-ldap", "~> 0.3.1"
12 14 end
13 15
14 16 # Optional gem for OpenID authentication
15 17 group :openid do
16 18 gem "ruby-openid", "~> 2.3.0", :require => "openid"
17 19 gem "rack-openid"
18 20 end
19 21
20 22 # Optional gem for exporting the gantt to a PNG file, not supported with jruby
21 23 platforms :mri, :mingw do
22 24 group :rmagick do
23 25 # RMagick 2 supports ruby 1.9
24 26 # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
25 27 # different requirements for the same gem on different platforms
26 28 gem "rmagick", ">= 2.0.0"
27 29 end
28 30 end
29 31
30 32 platforms :jruby do
31 33 # jruby-openssl is bundled with JRuby 1.7.0
32 34 gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
33 35 gem "activerecord-jdbc-adapter", "~> 1.3.2"
34 36 end
35 37
36 38 # Include database gems for the adapters found in the database
37 39 # configuration file
38 40 require 'erb'
39 41 require 'yaml'
40 42 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
41 43 if File.exist?(database_file)
42 44 database_config = YAML::load(ERB.new(IO.read(database_file)).result)
43 45 adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
44 46 if adapters.any?
45 47 adapters.each do |adapter|
46 48 case adapter
47 49 when 'mysql2'
48 50 gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
49 51 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
50 52 when 'mysql'
51 53 gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
52 54 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
53 55 when /postgresql/
54 56 gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
55 57 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
56 58 when /sqlite3/
57 59 gem "sqlite3", :platforms => [:mri, :mingw]
58 60 gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
59 61 when /sqlserver/
60 62 gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw]
61 63 gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
62 64 else
63 65 warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
64 66 end
65 67 end
66 68 else
67 69 warn("No adapter found in config/database.yml, please configure it first")
68 70 end
69 71 else
70 72 warn("Please configure your config/database.yml first")
71 73 end
72 74
73 75 group :development do
74 76 gem "rdoc", ">= 2.4.2"
75 77 gem "yard"
76 78 end
77 79
78 80 group :test do
79 81 gem "shoulda", "~> 3.3.2"
80 82 gem "mocha", ">= 0.14", :require => 'mocha/api'
81 83 if RUBY_VERSION >= '1.9.3'
82 84 gem "capybara", "~> 2.1.0"
83 85 gem "selenium-webdriver"
84 86 end
85 87 end
86 88
87 89 local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
88 90 if File.exists?(local_gemfile)
89 91 puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
90 92 instance_eval File.read(local_gemfile)
91 93 end
92 94
93 95 # Load plugins' Gemfiles
94 96 Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
95 97 puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
96 98 #TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
97 99 instance_eval File.read(file), file
98 100 end
@@ -1,272 +1,274
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'redmine/core_ext'
19 19
20 20 begin
21 21 require 'RMagick' unless Object.const_defined?(:Magick)
22 22 rescue LoadError
23 23 # RMagick is not available
24 24 end
25 25
26 26 require 'redmine/scm/base'
27 27 require 'redmine/access_control'
28 28 require 'redmine/access_keys'
29 29 require 'redmine/activity'
30 30 require 'redmine/activity/fetcher'
31 31 require 'redmine/ciphering'
32 32 require 'redmine/codeset_util'
33 33 require 'redmine/field_format'
34 34 require 'redmine/i18n'
35 35 require 'redmine/menu_manager'
36 36 require 'redmine/notifiable'
37 37 require 'redmine/platform'
38 38 require 'redmine/mime_type'
39 39 require 'redmine/notifiable'
40 40 require 'redmine/search'
41 41 require 'redmine/syntax_highlighting'
42 42 require 'redmine/thumbnail'
43 43 require 'redmine/unified_diff'
44 44 require 'redmine/utils'
45 45 require 'redmine/version'
46 46 require 'redmine/wiki_formatting'
47 47
48 48 require 'redmine/default_data/loader'
49 49 require 'redmine/helpers/calendar'
50 50 require 'redmine/helpers/diff'
51 51 require 'redmine/helpers/gantt'
52 52 require 'redmine/helpers/time_report'
53 53 require 'redmine/views/other_formats_builder'
54 54 require 'redmine/views/labelled_form_builder'
55 55 require 'redmine/views/builders'
56 56
57 57 require 'redmine/themes'
58 58 require 'redmine/hook'
59 59 require 'redmine/plugin'
60 60
61 61 if RUBY_VERSION < '1.9'
62 62 require 'fastercsv'
63 63 else
64 64 require 'csv'
65 65 FCSV = CSV
66 66 end
67 67
68 68 Redmine::Scm::Base.add "Subversion"
69 69 Redmine::Scm::Base.add "Darcs"
70 70 Redmine::Scm::Base.add "Mercurial"
71 71 Redmine::Scm::Base.add "Cvs"
72 72 Redmine::Scm::Base.add "Bazaar"
73 73 Redmine::Scm::Base.add "Git"
74 74 Redmine::Scm::Base.add "Filesystem"
75 75
76 76 # Permissions
77 77 Redmine::AccessControl.map do |map|
78 78 map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true
79 79 map.permission :search_project, {:search => :index}, :public => true, :read => true
80 80 map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
81 81 map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
82 82 map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true
83 83 map.permission :select_project_modules, {:projects => :modules}, :require => :member
84 84 map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member
85 85 map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
86 86 map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
87 87
88 88 map.project_module :issue_tracking do |map|
89 89 # Issue categories
90 90 map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member
91 91 # Issues
92 92 map.permission :view_issues, {:issues => [:index, :show],
93 93 :auto_complete => [:issues],
94 94 :context_menus => [:issues],
95 95 :versions => [:index, :show, :status_by],
96 96 :journals => [:index, :diff],
97 97 :queries => :index,
98 98 :reports => [:issue_report, :issue_report_details]},
99 99 :read => true
100 100 map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload}
101 101 map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload}
102 102 map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
103 103 map.permission :manage_subtasks, {}
104 104 map.permission :set_issues_private, {}
105 105 map.permission :set_own_issues_private, {}, :require => :loggedin
106 106 map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
107 107 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
108 108 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
109 109 map.permission :view_private_notes, {}, :read => true, :require => :member
110 110 map.permission :set_notes_private, {}, :require => :member
111 111 map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin
112 112 map.permission :delete_issues, {:issues => :destroy}, :require => :member
113 113 # Queries
114 114 map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member
115 115 map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
116 116 # Watchers
117 117 map.permission :view_issue_watchers, {}, :read => true
118 118 map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]}
119 119 map.permission :delete_issue_watchers, {:watchers => :destroy}
120 120 end
121 121
122 122 map.project_module :time_tracking do |map|
123 123 map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
124 124 map.permission :view_time_entries, {:timelog => [:index, :report, :show]}, :read => true
125 125 map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member
126 126 map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
127 127 map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
128 128 end
129 129
130 130 map.project_module :news do |map|
131 131 map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
132 132 map.permission :view_news, {:news => [:index, :show]}, :public => true, :read => true
133 133 map.permission :comment_news, {:comments => :create}
134 134 end
135 135
136 136 map.project_module :documents do |map|
137 137 map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin
138 138 map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin
139 139 map.permission :delete_documents, {:documents => [:destroy]}, :require => :loggedin
140 140 map.permission :view_documents, {:documents => [:index, :show, :download]}, :read => true
141 141 end
142 142
143 143 map.project_module :files do |map|
144 144 map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
145 145 map.permission :view_files, {:files => :index, :versions => :download}, :read => true
146 146 end
147 147
148 148 map.project_module :wiki do |map|
149 149 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
150 150 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
151 151 map.permission :delete_wiki_pages, {:wiki => [:destroy, :destroy_version]}, :require => :member
152 152 map.permission :view_wiki_pages, {:wiki => [:index, :show, :special, :date_index]}, :read => true
153 153 map.permission :export_wiki_pages, {:wiki => [:export]}, :read => true
154 154 map.permission :view_wiki_edits, {:wiki => [:history, :diff, :annotate]}, :read => true
155 155 map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment]
156 156 map.permission :delete_wiki_pages_attachments, {}
157 157 map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
158 158 end
159 159
160 160 map.project_module :repository do |map|
161 161 map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
162 162 map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
163 163 map.permission :view_changesets, {:repositories => [:show, :revisions, :revision]}, :read => true
164 164 map.permission :commit_access, {}
165 165 map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
166 166 end
167 167
168 168 map.project_module :boards do |map|
169 169 map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
170 170 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true
171 171 map.permission :add_messages, {:messages => [:new, :reply, :quote]}
172 172 map.permission :edit_messages, {:messages => :edit}, :require => :member
173 173 map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
174 174 map.permission :delete_messages, {:messages => :destroy}, :require => :member
175 175 map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
176 176 end
177 177
178 178 map.project_module :calendar do |map|
179 179 map.permission :view_calendar, {:calendars => [:show, :update]}, :read => true
180 180 end
181 181
182 182 map.project_module :gantt do |map|
183 183 map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true
184 184 end
185 185 end
186 186
187 187 Redmine::MenuManager.map :top_menu do |menu|
188 188 menu.push :home, :home_path
189 189 menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
190 190 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
191 191 menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
192 192 menu.push :help, Redmine::Info.help_url, :last => true
193 193 end
194 194
195 195 Redmine::MenuManager.map :account_menu do |menu|
196 196 menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? }
197 197 menu.push :register, :register_path, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
198 198 menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
199 199 menu.push :logout, :signout_path, :html => {:method => 'post'}, :if => Proc.new { User.current.logged? }
200 200 end
201 201
202 202 Redmine::MenuManager.map :application_menu do |menu|
203 203 # Empty
204 204 end
205 205
206 206 Redmine::MenuManager.map :admin_menu do |menu|
207 207 menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
208 208 menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
209 209 menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
210 210 menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
211 211 menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
212 212 menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
213 213 :html => {:class => 'issue_statuses'}
214 214 menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
215 215 menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural,
216 216 :html => {:class => 'custom_fields'}
217 217 menu.push :enumerations, {:controller => 'enumerations'}
218 218 menu.push :settings, {:controller => 'settings'}
219 219 menu.push :ldap_authentication, {:controller => 'auth_sources', :action => 'index'},
220 220 :html => {:class => 'server_authentication'}
221 221 menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
222 222 menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
223 223 end
224 224
225 225 Redmine::MenuManager.map :project_menu do |menu|
226 226 menu.push :overview, { :controller => 'projects', :action => 'show' }
227 227 menu.push :activity, { :controller => 'activities', :action => 'index' }
228 228 menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
229 229 :if => Proc.new { |p| p.shared_versions.any? }
230 230 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
231 231 menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
232 232 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
233 233 menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
234 234 menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
235 235 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
236 236 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
237 237 menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
238 238 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
239 239 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
240 240 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
241 241 menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
242 242 menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
243 243 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
244 244 menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
245 245 end
246 246
247 247 Redmine::Activity.map do |activity|
248 248 activity.register :issues, :class_name => %w(Issue Journal)
249 249 activity.register :changesets
250 250 activity.register :news
251 251 activity.register :documents, :class_name => %w(Document Attachment)
252 252 activity.register :files, :class_name => 'Attachment'
253 253 activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
254 254 activity.register :messages, :default => false
255 255 activity.register :time_entries, :default => false
256 256 end
257 257
258 258 Redmine::Search.map do |search|
259 259 search.register :issues
260 260 search.register :news
261 261 search.register :documents
262 262 search.register :changesets
263 263 search.register :wiki_pages
264 264 search.register :messages
265 265 search.register :projects
266 266 end
267 267
268 268 Redmine::WikiFormatting.map do |format|
269 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 272 end
271 273
272 274 ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler
General Comments 0
You need to be logged in to leave comments. Login now