@@ -1,45 +1,46 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2015 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 | module Redmine |
|
19 | 19 | module WikiFormatting |
|
20 | 20 | module Markdown |
|
21 | 21 | module Helper |
|
22 | 22 | def wikitoolbar_for(field_id) |
|
23 | 23 | heads_for_wiki_formatter |
|
24 | javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.draw();") | |
|
24 | url = "#{Redmine::Utils.relative_url_root}/help/#{current_language.to_s.downcase}/wiki_syntax_markdown.html" | |
|
25 | javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript url}'); wikiToolbar.draw();") | |
|
25 | 26 | end |
|
26 | 27 | |
|
27 | 28 | def initial_page_content(page) |
|
28 | 29 | "# #{@page.pretty_title}" |
|
29 | 30 | end |
|
30 | 31 | |
|
31 | 32 | def heads_for_wiki_formatter |
|
32 | 33 | unless @heads_for_wiki_formatter_included |
|
33 | 34 | content_for :header_tags do |
|
34 | 35 | javascript_include_tag('jstoolbar/jstoolbar') + |
|
35 | 36 | javascript_include_tag('jstoolbar/markdown') + |
|
36 | 37 | javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") + |
|
37 | 38 | stylesheet_link_tag('jstoolbar') |
|
38 | 39 | end |
|
39 | 40 | @heads_for_wiki_formatter_included = true |
|
40 | 41 | end |
|
41 | 42 | end |
|
42 | 43 | end |
|
43 | 44 | end |
|
44 | 45 | end |
|
45 | 46 | end |
@@ -1,194 +1,202 | |||
|
1 | 1 | /* ***** BEGIN LICENSE BLOCK ***** |
|
2 | 2 | * This file is part of DotClear. |
|
3 | 3 | * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All |
|
4 | 4 | * rights reserved. |
|
5 | 5 | * |
|
6 | 6 | * DotClear is free software; you can redistribute it and/or modify |
|
7 | 7 | * it under the terms of the GNU General Public License as published by |
|
8 | 8 | * the Free Software Foundation; either version 2 of the License, or |
|
9 | 9 | * (at your option) any later version. |
|
10 | 10 | * |
|
11 | 11 | * DotClear is distributed in the hope that it will be useful, |
|
12 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 | * GNU General Public License for more details. |
|
15 | 15 | * |
|
16 | 16 | * You should have received a copy of the GNU General Public License |
|
17 | 17 | * along with DotClear; if not, write to the Free Software |
|
18 | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
19 | 19 | * |
|
20 | 20 | * ***** END LICENSE BLOCK ***** |
|
21 | 21 | */ |
|
22 | 22 | |
|
23 | 23 | /* Modified by JP LANG for markdown formatting */ |
|
24 | 24 | |
|
25 | 25 | // strong |
|
26 | 26 | jsToolBar.prototype.elements.strong = { |
|
27 | 27 | type: 'button', |
|
28 | 28 | title: 'Strong', |
|
29 | 29 | fn: { |
|
30 | 30 | wiki: function() { this.singleTag('**') } |
|
31 | 31 | } |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | 34 | // em |
|
35 | 35 | jsToolBar.prototype.elements.em = { |
|
36 | 36 | type: 'button', |
|
37 | 37 | title: 'Italic', |
|
38 | 38 | fn: { |
|
39 | 39 | wiki: function() { this.singleTag("*") } |
|
40 | 40 | } |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | // del |
|
44 | 44 | jsToolBar.prototype.elements.del = { |
|
45 | 45 | type: 'button', |
|
46 | 46 | title: 'Deleted', |
|
47 | 47 | fn: { |
|
48 | 48 | wiki: function() { this.singleTag('~~') } |
|
49 | 49 | } |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | // code |
|
53 | 53 | jsToolBar.prototype.elements.code = { |
|
54 | 54 | type: 'button', |
|
55 | 55 | title: 'Code', |
|
56 | 56 | fn: { |
|
57 | 57 | wiki: function() { this.singleTag('`') } |
|
58 | 58 | } |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | // spacer |
|
62 | 62 | jsToolBar.prototype.elements.space1 = {type: 'space'} |
|
63 | 63 | |
|
64 | 64 | // headings |
|
65 | 65 | jsToolBar.prototype.elements.h1 = { |
|
66 | 66 | type: 'button', |
|
67 | 67 | title: 'Heading 1', |
|
68 | 68 | fn: { |
|
69 | 69 | wiki: function() { |
|
70 | 70 | this.encloseLineSelection('# ', '',function(str) { |
|
71 | 71 | str = str.replace(/^#+\s+/, '') |
|
72 | 72 | return str; |
|
73 | 73 | }); |
|
74 | 74 | } |
|
75 | 75 | } |
|
76 | 76 | } |
|
77 | 77 | jsToolBar.prototype.elements.h2 = { |
|
78 | 78 | type: 'button', |
|
79 | 79 | title: 'Heading 2', |
|
80 | 80 | fn: { |
|
81 | 81 | wiki: function() { |
|
82 | 82 | this.encloseLineSelection('## ', '',function(str) { |
|
83 | 83 | str = str.replace(/^#+\s+/, '') |
|
84 | 84 | return str; |
|
85 | 85 | }); |
|
86 | 86 | } |
|
87 | 87 | } |
|
88 | 88 | } |
|
89 | 89 | jsToolBar.prototype.elements.h3 = { |
|
90 | 90 | type: 'button', |
|
91 | 91 | title: 'Heading 3', |
|
92 | 92 | fn: { |
|
93 | 93 | wiki: function() { |
|
94 | 94 | this.encloseLineSelection('### ', '',function(str) { |
|
95 | 95 | str = str.replace(/^#+\s+/, '') |
|
96 | 96 | return str; |
|
97 | 97 | }); |
|
98 | 98 | } |
|
99 | 99 | } |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | // spacer |
|
103 | 103 | jsToolBar.prototype.elements.space2 = {type: 'space'} |
|
104 | 104 | |
|
105 | 105 | // ul |
|
106 | 106 | jsToolBar.prototype.elements.ul = { |
|
107 | 107 | type: 'button', |
|
108 | 108 | title: 'Unordered list', |
|
109 | 109 | fn: { |
|
110 | 110 | wiki: function() { |
|
111 | 111 | this.encloseLineSelection('','',function(str) { |
|
112 | 112 | str = str.replace(/\r/g,''); |
|
113 | 113 | return str.replace(/(\n|^)[#-]?\s*/g,"$1* "); |
|
114 | 114 | }); |
|
115 | 115 | } |
|
116 | 116 | } |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | // ol |
|
120 | 120 | jsToolBar.prototype.elements.ol = { |
|
121 | 121 | type: 'button', |
|
122 | 122 | title: 'Ordered list', |
|
123 | 123 | fn: { |
|
124 | 124 | wiki: function() { |
|
125 | 125 | this.encloseLineSelection('','',function(str) { |
|
126 | 126 | str = str.replace(/\r/g,''); |
|
127 | 127 | return str.replace(/(\n|^)[*-]?\s*/g,"$11. "); |
|
128 | 128 | }); |
|
129 | 129 | } |
|
130 | 130 | } |
|
131 | 131 | } |
|
132 | 132 | |
|
133 | 133 | // spacer |
|
134 | 134 | jsToolBar.prototype.elements.space3 = {type: 'space'} |
|
135 | 135 | |
|
136 | 136 | // bq |
|
137 | 137 | jsToolBar.prototype.elements.bq = { |
|
138 | 138 | type: 'button', |
|
139 | 139 | title: 'Quote', |
|
140 | 140 | fn: { |
|
141 | 141 | wiki: function() { |
|
142 | 142 | this.encloseLineSelection('','',function(str) { |
|
143 | 143 | str = str.replace(/\r/g,''); |
|
144 | 144 | return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2"); |
|
145 | 145 | }); |
|
146 | 146 | } |
|
147 | 147 | } |
|
148 | 148 | } |
|
149 | 149 | |
|
150 | 150 | // unbq |
|
151 | 151 | jsToolBar.prototype.elements.unbq = { |
|
152 | 152 | type: 'button', |
|
153 | 153 | title: 'Unquote', |
|
154 | 154 | fn: { |
|
155 | 155 | wiki: function() { |
|
156 | 156 | this.encloseLineSelection('','',function(str) { |
|
157 | 157 | str = str.replace(/\r/g,''); |
|
158 | 158 | return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2"); |
|
159 | 159 | }); |
|
160 | 160 | } |
|
161 | 161 | } |
|
162 | 162 | } |
|
163 | 163 | |
|
164 | 164 | // pre |
|
165 | 165 | jsToolBar.prototype.elements.pre = { |
|
166 | 166 | type: 'button', |
|
167 | 167 | title: 'Preformatted text', |
|
168 | 168 | fn: { |
|
169 | 169 | wiki: function() { this.encloseLineSelection('~~~\n', '\n~~~') } |
|
170 | 170 | } |
|
171 | 171 | } |
|
172 | 172 | |
|
173 | 173 | // spacer |
|
174 | 174 | jsToolBar.prototype.elements.space4 = {type: 'space'} |
|
175 | 175 | |
|
176 | 176 | // wiki page |
|
177 | 177 | jsToolBar.prototype.elements.link = { |
|
178 | 178 | type: 'button', |
|
179 | 179 | title: 'Wiki link', |
|
180 | 180 | fn: { |
|
181 | 181 | wiki: function() { this.encloseSelection("[[", "]]") } |
|
182 | 182 | } |
|
183 | 183 | } |
|
184 | 184 | // image |
|
185 | 185 | jsToolBar.prototype.elements.img = { |
|
186 | 186 | type: 'button', |
|
187 | 187 | title: 'Image', |
|
188 | 188 | fn: { |
|
189 | 189 | wiki: function() { this.encloseSelection("") } |
|
190 | 190 | } |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | // spacer |
|
194 | 194 | jsToolBar.prototype.elements.space5 = {type: 'space'} |
|
195 | // help | |
|
196 | jsToolBar.prototype.elements.help = { | |
|
197 | type: 'button', | |
|
198 | title: 'Help', | |
|
199 | fn: { | |
|
200 | wiki: function() { window.open(this.help_link, '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes') } | |
|
201 | } | |
|
202 | } |
General Comments 0
You need to be logged in to leave comments.
Login now