@@ -1,618 +1,619 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 'coderay' |
|
19 | 19 | require 'coderay/helpers/file_type' |
|
20 | 20 | require 'forwardable' |
|
21 | 21 | require 'cgi' |
|
22 | 22 | |
|
23 | 23 | module ApplicationHelper |
|
24 | 24 | include Redmine::WikiFormatting::Macros::Definitions |
|
25 | 25 | include GravatarHelper::PublicMethods |
|
26 | 26 | |
|
27 | 27 | extend Forwardable |
|
28 | 28 | def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter |
|
29 | 29 | |
|
30 | 30 | def current_role |
|
31 | 31 | @current_role ||= User.current.role_for_project(@project) |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | # Return true if user is authorized for controller/action, otherwise false |
|
35 | 35 | def authorize_for(controller, action) |
|
36 | 36 | User.current.allowed_to?({:controller => controller, :action => action}, @project) |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | # Display a link if user is authorized |
|
40 | 40 | def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference) |
|
41 | 41 | link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | # Display a link to remote if user is authorized |
|
45 | 45 | def link_to_remote_if_authorized(name, options = {}, html_options = nil) |
|
46 | 46 | url = options[:url] || {} |
|
47 | 47 | link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action]) |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | # Display a link to user's account page |
|
51 | 51 | def link_to_user(user, options={}) |
|
52 | 52 | (user && !user.anonymous?) ? link_to(user.name(options[:format]), :controller => 'account', :action => 'show', :id => user) : 'Anonymous' |
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | def link_to_issue(issue, options={}) |
|
56 | 56 | options[:class] ||= '' |
|
57 | 57 | options[:class] << ' issue' |
|
58 | 58 | options[:class] << ' closed' if issue.closed? |
|
59 | 59 | link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | # Generates a link to an attachment. |
|
63 | 63 | # Options: |
|
64 | 64 | # * :text - Link text (default to attachment filename) |
|
65 | 65 | # * :download - Force download (default: false) |
|
66 | 66 | def link_to_attachment(attachment, options={}) |
|
67 | 67 | text = options.delete(:text) || attachment.filename |
|
68 | 68 | action = options.delete(:download) ? 'download' : 'show' |
|
69 | 69 | |
|
70 | 70 | link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options) |
|
71 | 71 | end |
|
72 | 72 | |
|
73 | 73 | def toggle_link(name, id, options={}) |
|
74 | 74 | onclick = "Element.toggle('#{id}'); " |
|
75 | 75 | onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") |
|
76 | 76 | onclick << "return false;" |
|
77 | 77 | link_to(name, "#", :onclick => onclick) |
|
78 | 78 | end |
|
79 | 79 | |
|
80 | 80 | def image_to_function(name, function, html_options = {}) |
|
81 | 81 | html_options.symbolize_keys! |
|
82 | 82 | tag(:input, html_options.merge({ |
|
83 | 83 | :type => "image", :src => image_path(name), |
|
84 | 84 | :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" |
|
85 | 85 | })) |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | def prompt_to_remote(name, text, param, url, html_options = {}) |
|
89 | 89 | html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;" |
|
90 | 90 | link_to name, {}, html_options |
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | def format_date(date) |
|
94 | 94 | return nil unless date |
|
95 | 95 | # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed) |
|
96 | 96 | @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) |
|
97 | 97 | date.strftime(@date_format) |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def format_time(time, include_date = true) |
|
101 | 101 | return nil unless time |
|
102 | 102 | time = time.to_time if time.is_a?(String) |
|
103 | 103 | zone = User.current.time_zone |
|
104 | 104 | local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time) |
|
105 | 105 | @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) |
|
106 | 106 | @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format) |
|
107 | 107 | include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) |
|
108 | 108 | end |
|
109 | 109 | |
|
110 | 110 | def format_activity_title(text) |
|
111 | 111 | h(truncate_single_line(text, 100)) |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | def format_activity_day(date) |
|
115 | 115 | date == Date.today ? l(:label_today).titleize : format_date(date) |
|
116 | 116 | end |
|
117 | 117 | |
|
118 | 118 | def format_activity_description(text) |
|
119 | 119 | h(truncate(text.to_s, 250).gsub(%r{<(pre|code)>.*$}m, '...')) |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | def distance_of_date_in_words(from_date, to_date = 0) |
|
123 | 123 | from_date = from_date.to_date if from_date.respond_to?(:to_date) |
|
124 | 124 | to_date = to_date.to_date if to_date.respond_to?(:to_date) |
|
125 | 125 | distance_in_days = (to_date - from_date).abs |
|
126 | 126 | lwr(:actionview_datehelper_time_in_words_day, distance_in_days) |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | def due_date_distance_in_words(date) |
|
130 | 130 | if date |
|
131 | 131 | l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date)) |
|
132 | 132 | end |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | 135 | def render_page_hierarchy(pages, node=nil) |
|
136 | 136 | content = '' |
|
137 | 137 | if pages[node] |
|
138 | 138 | content << "<ul class=\"pages-hierarchy\">\n" |
|
139 | 139 | pages[node].each do |page| |
|
140 | 140 | content << "<li>" |
|
141 | 141 | content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :id => page.project, :page => page.title}, |
|
142 | 142 | :title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) |
|
143 | 143 | content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id] |
|
144 | 144 | content << "</li>\n" |
|
145 | 145 | end |
|
146 | 146 | content << "</ul>\n" |
|
147 | 147 | end |
|
148 | 148 | content |
|
149 | 149 | end |
|
150 | 150 | |
|
151 | 151 | # Truncates and returns the string as a single line |
|
152 | 152 | def truncate_single_line(string, *args) |
|
153 | 153 | truncate(string, *args).gsub(%r{[\r\n]+}m, ' ') |
|
154 | 154 | end |
|
155 | 155 | |
|
156 | 156 | def html_hours(text) |
|
157 | 157 | text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>') |
|
158 | 158 | end |
|
159 | 159 | |
|
160 | 160 | def authoring(created, author, options={}) |
|
161 | 161 | time_tag = @project.nil? ? content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created)) : |
|
162 | 162 | link_to(distance_of_time_in_words(Time.now, created), |
|
163 | 163 | {:controller => 'projects', :action => 'activity', :id => @project, :from => created.to_date}, |
|
164 | 164 | :title => format_time(created)) |
|
165 | 165 | author_tag = (author.is_a?(User) && !author.anonymous?) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous') |
|
166 | 166 | l(options[:label] || :label_added_time_by, author_tag, time_tag) |
|
167 | 167 | end |
|
168 | 168 | |
|
169 | 169 | def l_or_humanize(s, options={}) |
|
170 | 170 | k = "#{options[:prefix]}#{s}".to_sym |
|
171 | 171 | l_has_string?(k) ? l(k) : s.to_s.humanize |
|
172 | 172 | end |
|
173 | 173 | |
|
174 | 174 | def day_name(day) |
|
175 | 175 | l(:general_day_names).split(',')[day-1] |
|
176 | 176 | end |
|
177 | 177 | |
|
178 | 178 | def month_name(month) |
|
179 | 179 | l(:actionview_datehelper_select_month_names).split(',')[month-1] |
|
180 | 180 | end |
|
181 | 181 | |
|
182 | 182 | def syntax_highlight(name, content) |
|
183 | 183 | type = CodeRay::FileType[name] |
|
184 | 184 | type ? CodeRay.scan(content, type).html : h(content) |
|
185 | 185 | end |
|
186 | 186 | |
|
187 | 187 | def to_path_param(path) |
|
188 | 188 | path.to_s.split(%r{[/\\]}).select {|p| !p.blank?} |
|
189 | 189 | end |
|
190 | 190 | |
|
191 | 191 | def pagination_links_full(paginator, count=nil, options={}) |
|
192 | 192 | page_param = options.delete(:page_param) || :page |
|
193 | 193 | url_param = params.dup |
|
194 | 194 | # don't reuse params if filters are present |
|
195 | 195 | url_param.clear if url_param.has_key?(:set_filter) |
|
196 | 196 | |
|
197 | 197 | html = '' |
|
198 | 198 | html << link_to_remote(('« ' + l(:label_previous)), |
|
199 | 199 | {:update => 'content', |
|
200 | 200 | :url => url_param.merge(page_param => paginator.current.previous), |
|
201 | 201 | :complete => 'window.scrollTo(0,0)'}, |
|
202 | 202 | {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous |
|
203 | 203 | |
|
204 | 204 | html << (pagination_links_each(paginator, options) do |n| |
|
205 | 205 | link_to_remote(n.to_s, |
|
206 | 206 | {:url => {:params => url_param.merge(page_param => n)}, |
|
207 | 207 | :update => 'content', |
|
208 | 208 | :complete => 'window.scrollTo(0,0)'}, |
|
209 | 209 | {:href => url_for(:params => url_param.merge(page_param => n))}) |
|
210 | 210 | end || '') |
|
211 | 211 | |
|
212 | 212 | html << ' ' + link_to_remote((l(:label_next) + ' »'), |
|
213 | 213 | {:update => 'content', |
|
214 | 214 | :url => url_param.merge(page_param => paginator.current.next), |
|
215 | 215 | :complete => 'window.scrollTo(0,0)'}, |
|
216 | 216 | {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next |
|
217 | 217 | |
|
218 | 218 | unless count.nil? |
|
219 | 219 | html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ') |
|
220 | 220 | end |
|
221 | 221 | |
|
222 | 222 | html |
|
223 | 223 | end |
|
224 | 224 | |
|
225 | 225 | def per_page_links(selected=nil) |
|
226 | 226 | url_param = params.dup |
|
227 | 227 | url_param.clear if url_param.has_key?(:set_filter) |
|
228 | 228 | |
|
229 | 229 | links = Setting.per_page_options_array.collect do |n| |
|
230 | 230 | n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)}, |
|
231 | 231 | {:href => url_for(url_param.merge(:per_page => n))}) |
|
232 | 232 | end |
|
233 | 233 | links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil |
|
234 | 234 | end |
|
235 | 235 | |
|
236 | 236 | def breadcrumb(*args) |
|
237 | 237 | elements = args.flatten |
|
238 | 238 | elements.any? ? content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb') : nil |
|
239 | 239 | end |
|
240 | 240 | |
|
241 | 241 | def html_title(*args) |
|
242 | 242 | if args.empty? |
|
243 | 243 | title = [] |
|
244 | 244 | title << @project.name if @project |
|
245 | 245 | title += @html_title if @html_title |
|
246 | 246 | title << Setting.app_title |
|
247 | 247 | title.compact.join(' - ') |
|
248 | 248 | else |
|
249 | 249 | @html_title ||= [] |
|
250 | 250 | @html_title += args |
|
251 | 251 | end |
|
252 | 252 | end |
|
253 | 253 | |
|
254 | 254 | def accesskey(s) |
|
255 | 255 | Redmine::AccessKeys.key_for s |
|
256 | 256 | end |
|
257 | 257 | |
|
258 | 258 | # Formats text according to system settings. |
|
259 | 259 | # 2 ways to call this method: |
|
260 | 260 | # * with a String: textilizable(text, options) |
|
261 | 261 | # * with an object and one of its attribute: textilizable(issue, :description, options) |
|
262 | 262 | def textilizable(*args) |
|
263 | 263 | options = args.last.is_a?(Hash) ? args.pop : {} |
|
264 | 264 | case args.size |
|
265 | 265 | when 1 |
|
266 | 266 | obj = options[:object] |
|
267 | 267 | text = args.shift |
|
268 | 268 | when 2 |
|
269 | 269 | obj = args.shift |
|
270 | 270 | text = obj.send(args.shift).to_s |
|
271 | 271 | else |
|
272 | 272 | raise ArgumentError, 'invalid arguments to textilizable' |
|
273 | 273 | end |
|
274 | 274 | return '' if text.blank? |
|
275 | 275 | |
|
276 | 276 | only_path = options.delete(:only_path) == false ? false : true |
|
277 | 277 | |
|
278 | 278 | # when using an image link, try to use an attachment, if possible |
|
279 | 279 | attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) |
|
280 | 280 | |
|
281 | 281 | if attachments |
|
282 | 282 | attachments = attachments.sort_by(&:created_on).reverse |
|
283 | 283 | text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m| |
|
284 | 284 | style = $1 |
|
285 | 285 | filename = $6 |
|
286 | 286 | rf = Regexp.new(Regexp.escape(filename), Regexp::IGNORECASE) |
|
287 | 287 | # search for the picture in attachments |
|
288 | 288 | if found = attachments.detect { |att| att.filename =~ rf } |
|
289 | 289 | image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found |
|
290 | 290 | desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1") |
|
291 | 291 | alt = desc.blank? ? nil : "(#{desc})" |
|
292 | 292 | "!#{style}#{image_url}#{alt}!" |
|
293 | 293 | else |
|
294 | 294 | "!#{style}#{filename}!" |
|
295 | 295 | end |
|
296 | 296 | end |
|
297 | 297 | end |
|
298 | 298 | |
|
299 | 299 | text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) } |
|
300 | 300 | |
|
301 | 301 | # different methods for formatting wiki links |
|
302 | 302 | case options[:wiki_links] |
|
303 | 303 | when :local |
|
304 | 304 | # used for local links to html files |
|
305 | 305 | format_wiki_link = Proc.new {|project, title, anchor| "#{title}.html" } |
|
306 | 306 | when :anchor |
|
307 | 307 | # used for single-file wiki export |
|
308 | 308 | format_wiki_link = Proc.new {|project, title, anchor| "##{title}" } |
|
309 | 309 | else |
|
310 | 310 | format_wiki_link = Proc.new {|project, title, anchor| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title, :anchor => anchor) } |
|
311 | 311 | end |
|
312 | 312 | |
|
313 | 313 | project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) |
|
314 | 314 | |
|
315 | 315 | # Wiki links |
|
316 | 316 | # |
|
317 | 317 | # Examples: |
|
318 | 318 | # [[mypage]] |
|
319 | 319 | # [[mypage|mytext]] |
|
320 | 320 | # wiki links can refer other project wikis, using project name or identifier: |
|
321 | 321 | # [[project:]] -> wiki starting page |
|
322 | 322 | # [[project:|mytext]] |
|
323 | 323 | # [[project:mypage]] |
|
324 | 324 | # [[project:mypage|mytext]] |
|
325 | 325 | text = text.gsub(/(!)?(\[\[([^\]\n\|]+)(\|([^\]\n\|]+))?\]\])/) do |m| |
|
326 | 326 | link_project = project |
|
327 | 327 | esc, all, page, title = $1, $2, $3, $5 |
|
328 | 328 | if esc.nil? |
|
329 | 329 | if page =~ /^([^\:]+)\:(.*)$/ |
|
330 | 330 | link_project = Project.find_by_name($1) || Project.find_by_identifier($1) |
|
331 | 331 | page = $2 |
|
332 | 332 | title ||= $1 if page.blank? |
|
333 | 333 | end |
|
334 | 334 | |
|
335 | 335 | if link_project && link_project.wiki |
|
336 | 336 | # extract anchor |
|
337 | 337 | anchor = nil |
|
338 | 338 | if page =~ /^(.+?)\#(.+)$/ |
|
339 | 339 | page, anchor = $1, $2 |
|
340 | 340 | end |
|
341 | 341 | # check if page exists |
|
342 | 342 | wiki_page = link_project.wiki.find_page(page) |
|
343 | 343 | link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page), anchor), |
|
344 | 344 | :class => ('wiki-page' + (wiki_page ? '' : ' new'))) |
|
345 | 345 | else |
|
346 | 346 | # project or wiki doesn't exist |
|
347 | 347 | title || page |
|
348 | 348 | end |
|
349 | 349 | else |
|
350 | 350 | all |
|
351 | 351 | end |
|
352 | 352 | end |
|
353 | 353 | |
|
354 | 354 | # Redmine links |
|
355 | 355 | # |
|
356 | 356 | # Examples: |
|
357 | 357 | # Issues: |
|
358 | 358 | # #52 -> Link to issue #52 |
|
359 | 359 | # Changesets: |
|
360 | 360 | # r52 -> Link to revision 52 |
|
361 | 361 | # commit:a85130f -> Link to scmid starting with a85130f |
|
362 | 362 | # Documents: |
|
363 | 363 | # document#17 -> Link to document with id 17 |
|
364 | 364 | # document:Greetings -> Link to the document with title "Greetings" |
|
365 | 365 | # document:"Some document" -> Link to the document with title "Some document" |
|
366 | 366 | # Versions: |
|
367 | 367 | # version#3 -> Link to version with id 3 |
|
368 | 368 | # version:1.0.0 -> Link to version named "1.0.0" |
|
369 | 369 | # version:"1.0 beta 2" -> Link to version named "1.0 beta 2" |
|
370 | 370 | # Attachments: |
|
371 | 371 | # attachment:file.zip -> Link to the attachment of the current object named file.zip |
|
372 | 372 | # Source files: |
|
373 | 373 | # source:some/file -> Link to the file located at /some/file in the project's repository |
|
374 | 374 | # source:some/file@52 -> Link to the file's revision 52 |
|
375 | 375 | # source:some/file#L120 -> Link to line 120 of the file |
|
376 | 376 | # source:some/file@52#L120 -> Link to line 120 of the file's revision 52 |
|
377 | 377 | # export:some/file -> Force the download of the file |
|
378 | 378 | # Forum messages: |
|
379 | 379 | # message#1218 -> Link to message with id 1218 |
|
380 | 380 | text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|\s|<|$)}) do |m| |
|
381 | 381 | leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8 |
|
382 | 382 | link = nil |
|
383 | 383 | if esc.nil? |
|
384 | 384 | if prefix.nil? && sep == 'r' |
|
385 | 385 | if project && (changeset = project.changesets.find_by_revision(oid)) |
|
386 | 386 | link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid}, |
|
387 | 387 | :class => 'changeset', |
|
388 | 388 | :title => truncate_single_line(changeset.comments, 100)) |
|
389 | 389 | end |
|
390 | 390 | elsif sep == '#' |
|
391 | 391 | oid = oid.to_i |
|
392 | 392 | case prefix |
|
393 | 393 | when nil |
|
394 | 394 | if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current)) |
|
395 | 395 | link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid}, |
|
396 | 396 | :class => (issue.closed? ? 'issue closed' : 'issue'), |
|
397 | 397 | :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})") |
|
398 | 398 | link = content_tag('del', link) if issue.closed? |
|
399 | 399 | end |
|
400 | 400 | when 'document' |
|
401 | 401 | if document = Document.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current)) |
|
402 | 402 | link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document}, |
|
403 | 403 | :class => 'document' |
|
404 | 404 | end |
|
405 | 405 | when 'version' |
|
406 | 406 | if version = Version.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current)) |
|
407 | 407 | link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version}, |
|
408 | 408 | :class => 'version' |
|
409 | 409 | end |
|
410 | 410 | when 'message' |
|
411 | 411 | if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current)) |
|
412 | 412 | link = link_to h(truncate(message.subject, 60)), {:only_path => only_path, |
|
413 | 413 | :controller => 'messages', |
|
414 | 414 | :action => 'show', |
|
415 | 415 | :board_id => message.board, |
|
416 | 416 | :id => message.root, |
|
417 | 417 | :anchor => (message.parent ? "message-#{message.id}" : nil)}, |
|
418 | 418 | :class => 'message' |
|
419 | 419 | end |
|
420 | 420 | end |
|
421 | 421 | elsif sep == ':' |
|
422 | 422 | # removes the double quotes if any |
|
423 | 423 | name = oid.gsub(%r{^"(.*)"$}, "\\1") |
|
424 | 424 | case prefix |
|
425 | 425 | when 'document' |
|
426 | 426 | if project && document = project.documents.find_by_title(name) |
|
427 | 427 | link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document}, |
|
428 | 428 | :class => 'document' |
|
429 | 429 | end |
|
430 | 430 | when 'version' |
|
431 | 431 | if project && version = project.versions.find_by_name(name) |
|
432 | 432 | link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version}, |
|
433 | 433 | :class => 'version' |
|
434 | 434 | end |
|
435 | 435 | when 'commit' |
|
436 | 436 | if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) |
|
437 | 437 | link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision}, |
|
438 | 438 | :class => 'changeset', |
|
439 | 439 | :title => truncate_single_line(changeset.comments, 100) |
|
440 | 440 | end |
|
441 | 441 | when 'source', 'export' |
|
442 | 442 | if project && project.repository |
|
443 | 443 | name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$} |
|
444 | 444 | path, rev, anchor = $1, $3, $5 |
|
445 | 445 | link = link_to h("#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project, |
|
446 | 446 | :path => to_path_param(path), |
|
447 | 447 | :rev => rev, |
|
448 | 448 | :anchor => anchor, |
|
449 | 449 | :format => (prefix == 'export' ? 'raw' : nil)}, |
|
450 | 450 | :class => (prefix == 'export' ? 'source download' : 'source') |
|
451 | 451 | end |
|
452 | 452 | when 'attachment' |
|
453 | 453 | if attachments && attachment = attachments.detect {|a| a.filename == name } |
|
454 | 454 | link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, |
|
455 | 455 | :class => 'attachment' |
|
456 | 456 | end |
|
457 | 457 | end |
|
458 | 458 | end |
|
459 | 459 | end |
|
460 | 460 | leading + (link || "#{prefix}#{sep}#{oid}") |
|
461 | 461 | end |
|
462 | 462 | |
|
463 | 463 | text |
|
464 | 464 | end |
|
465 | 465 | |
|
466 | 466 | # Same as Rails' simple_format helper without using paragraphs |
|
467 | 467 | def simple_format_without_paragraph(text) |
|
468 | 468 | text.to_s. |
|
469 | 469 | gsub(/\r\n?/, "\n"). # \r\n and \r -> \n |
|
470 | 470 | gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br |
|
471 | 471 | gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br |
|
472 | 472 | end |
|
473 | 473 | |
|
474 | 474 | def error_messages_for(object_name, options = {}) |
|
475 | 475 | options = options.symbolize_keys |
|
476 | 476 | object = instance_variable_get("@#{object_name}") |
|
477 | 477 | if object && !object.errors.empty? |
|
478 | 478 | # build full_messages here with controller current language |
|
479 | 479 | full_messages = [] |
|
480 | 480 | object.errors.each do |attr, msg| |
|
481 | 481 | next if msg.nil? |
|
482 | 482 | msg = msg.first if msg.is_a? Array |
|
483 | 483 | if attr == "base" |
|
484 | 484 | full_messages << l(msg) |
|
485 | 485 | else |
|
486 | 486 | full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values" |
|
487 | 487 | end |
|
488 | 488 | end |
|
489 | 489 | # retrieve custom values error messages |
|
490 | 490 | if object.errors[:custom_values] |
|
491 | 491 | object.custom_values.each do |v| |
|
492 | 492 | v.errors.each do |attr, msg| |
|
493 | 493 | next if msg.nil? |
|
494 | 494 | msg = msg.first if msg.is_a? Array |
|
495 | 495 | full_messages << "« " + v.custom_field.name + " » " + l(msg) |
|
496 | 496 | end |
|
497 | 497 | end |
|
498 | 498 | end |
|
499 | 499 | content_tag("div", |
|
500 | 500 | content_tag( |
|
501 | 501 | options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":" |
|
502 | 502 | ) + |
|
503 | 503 | content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }), |
|
504 | 504 | "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" |
|
505 | 505 | ) |
|
506 | 506 | else |
|
507 | 507 | "" |
|
508 | 508 | end |
|
509 | 509 | end |
|
510 | 510 | |
|
511 | 511 | def lang_options_for_select(blank=true) |
|
512 | 512 | (blank ? [["(auto)", ""]] : []) + |
|
513 | 513 | GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last } |
|
514 | 514 | end |
|
515 | 515 | |
|
516 | 516 | def label_tag_for(name, option_tags = nil, options = {}) |
|
517 | 517 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") |
|
518 | 518 | content_tag("label", label_text) |
|
519 | 519 | end |
|
520 | 520 | |
|
521 | 521 | def labelled_tabular_form_for(name, object, options, &proc) |
|
522 | 522 | options[:html] ||= {} |
|
523 | 523 | options[:html][:class] = 'tabular' unless options[:html].has_key?(:class) |
|
524 | 524 | form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc) |
|
525 | 525 | end |
|
526 | 526 | |
|
527 | 527 | def back_url_hidden_field_tag |
|
528 | 528 | back_url = params[:back_url] || request.env['HTTP_REFERER'] |
|
529 | back_url = CGI.unescape(back_url.to_s) | |
|
529 | 530 | hidden_field_tag('back_url', CGI.escape(back_url)) unless back_url.blank? |
|
530 | 531 | end |
|
531 | 532 | |
|
532 | 533 | def check_all_links(form_name) |
|
533 | 534 | link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + |
|
534 | 535 | " | " + |
|
535 | 536 | link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") |
|
536 | 537 | end |
|
537 | 538 | |
|
538 | 539 | def progress_bar(pcts, options={}) |
|
539 | 540 | pcts = [pcts, pcts] unless pcts.is_a?(Array) |
|
540 | 541 | pcts[1] = pcts[1] - pcts[0] |
|
541 | 542 | pcts << (100 - pcts[1] - pcts[0]) |
|
542 | 543 | width = options[:width] || '100px;' |
|
543 | 544 | legend = options[:legend] || '' |
|
544 | 545 | content_tag('table', |
|
545 | 546 | content_tag('tr', |
|
546 | 547 | (pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0].floor}%;", :class => 'closed') : '') + |
|
547 | 548 | (pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1].floor}%;", :class => 'done') : '') + |
|
548 | 549 | (pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2].floor}%;", :class => 'todo') : '') |
|
549 | 550 | ), :class => 'progress', :style => "width: #{width};") + |
|
550 | 551 | content_tag('p', legend, :class => 'pourcent') |
|
551 | 552 | end |
|
552 | 553 | |
|
553 | 554 | def context_menu_link(name, url, options={}) |
|
554 | 555 | options[:class] ||= '' |
|
555 | 556 | if options.delete(:selected) |
|
556 | 557 | options[:class] << ' icon-checked disabled' |
|
557 | 558 | options[:disabled] = true |
|
558 | 559 | end |
|
559 | 560 | if options.delete(:disabled) |
|
560 | 561 | options.delete(:method) |
|
561 | 562 | options.delete(:confirm) |
|
562 | 563 | options.delete(:onclick) |
|
563 | 564 | options[:class] << ' disabled' |
|
564 | 565 | url = '#' |
|
565 | 566 | end |
|
566 | 567 | link_to name, url, options |
|
567 | 568 | end |
|
568 | 569 | |
|
569 | 570 | def calendar_for(field_id) |
|
570 | 571 | include_calendar_headers_tags |
|
571 | 572 | image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) + |
|
572 | 573 | javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });") |
|
573 | 574 | end |
|
574 | 575 | |
|
575 | 576 | def include_calendar_headers_tags |
|
576 | 577 | unless @calendar_headers_tags_included |
|
577 | 578 | @calendar_headers_tags_included = true |
|
578 | 579 | content_for :header_tags do |
|
579 | 580 | javascript_include_tag('calendar/calendar') + |
|
580 | 581 | javascript_include_tag("calendar/lang/calendar-#{current_language}.js") + |
|
581 | 582 | javascript_include_tag('calendar/calendar-setup') + |
|
582 | 583 | stylesheet_link_tag('calendar') |
|
583 | 584 | end |
|
584 | 585 | end |
|
585 | 586 | end |
|
586 | 587 | |
|
587 | 588 | def content_for(name, content = nil, &block) |
|
588 | 589 | @has_content ||= {} |
|
589 | 590 | @has_content[name] = true |
|
590 | 591 | super(name, content, &block) |
|
591 | 592 | end |
|
592 | 593 | |
|
593 | 594 | def has_content?(name) |
|
594 | 595 | (@has_content && @has_content[name]) || false |
|
595 | 596 | end |
|
596 | 597 | |
|
597 | 598 | # Returns the avatar image tag for the given +user+ if avatars are enabled |
|
598 | 599 | # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>') |
|
599 | 600 | def avatar(user, options = { }) |
|
600 | 601 | if Setting.gravatar_enabled? |
|
601 | 602 | email = nil |
|
602 | 603 | if user.respond_to?(:mail) |
|
603 | 604 | email = user.mail |
|
604 | 605 | elsif user.to_s =~ %r{<(.+?)>} |
|
605 | 606 | email = $1 |
|
606 | 607 | end |
|
607 | 608 | return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil |
|
608 | 609 | end |
|
609 | 610 | end |
|
610 | 611 | |
|
611 | 612 | private |
|
612 | 613 | |
|
613 | 614 | def wiki_helper |
|
614 | 615 | helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting) |
|
615 | 616 | extend helper |
|
616 | 617 | return self |
|
617 | 618 | end |
|
618 | 619 | end |
@@ -1,699 +1,699 | |||
|
1 | 1 | _gloc_rule_default: '|n| n==1 ? "" : "_plural" ' |
|
2 | 2 | |
|
3 | 3 | actionview_datehelper_select_day_prefix: |
|
4 | 4 | actionview_datehelper_select_month_names: Janeiro,Fevereiro,MarΓ§o,Abril,Maio,Junho,Julho,Agosto,Setembro,Outubro,Novembro,Dezembro |
|
5 | 5 | actionview_datehelper_select_month_names_abbr: Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ago,Set,Out,Nov,Dez |
|
6 | 6 | actionview_datehelper_select_month_prefix: |
|
7 | 7 | actionview_datehelper_select_year_prefix: |
|
8 | 8 | actionview_datehelper_time_in_words_day: 1 dia |
|
9 | 9 | actionview_datehelper_time_in_words_day_plural: %d dias |
|
10 | 10 | actionview_datehelper_time_in_words_hour_about: aproximadamente uma hora |
|
11 | 11 | actionview_datehelper_time_in_words_hour_about_plural: aproximadamente %d horas |
|
12 | 12 | actionview_datehelper_time_in_words_hour_about_single: aproximadamente uma hora |
|
13 | 13 | actionview_datehelper_time_in_words_minute: 1 minuto |
|
14 | 14 | actionview_datehelper_time_in_words_minute_half: meio minuto |
|
15 | 15 | actionview_datehelper_time_in_words_minute_less_than: menos de um minuto |
|
16 | 16 | actionview_datehelper_time_in_words_minute_plural: %d minutos |
|
17 | 17 | actionview_datehelper_time_in_words_minute_single: 1 minuto |
|
18 | 18 | actionview_datehelper_time_in_words_second_less_than: menos de um segundo |
|
19 | 19 | actionview_datehelper_time_in_words_second_less_than_plural: menos de %d segundos |
|
20 | 20 | actionview_instancetag_blank_option: Selecione |
|
21 | 21 | |
|
22 | 22 | activerecord_error_inclusion: nΓ£o estΓ‘ incluso na lista |
|
23 | 23 | activerecord_error_exclusion: estΓ‘ reservado |
|
24 | 24 | activerecord_error_invalid: Γ© invΓ‘lido |
|
25 | 25 | activerecord_error_confirmation: confirmaΓ§Γ£o nΓ£o confere |
|
26 | 26 | activerecord_error_accepted: deve ser aceito |
|
27 | 27 | activerecord_error_empty: nΓ£o pode ficar vazio |
|
28 | 28 | activerecord_error_blank: nΓ£o pode ficar em branco |
|
29 | 29 | activerecord_error_too_long: Γ© muito longo |
|
30 | 30 | activerecord_error_too_short: Γ© muito curto |
|
31 | 31 | activerecord_error_wrong_length: esta com o tamanho errado |
|
32 | 32 | activerecord_error_taken: jΓ‘ estΓ‘ em uso |
|
33 | 33 | activerecord_error_not_a_number: nΓ£o Γ© um nΓΊmero |
|
34 | 34 | activerecord_error_not_a_date: nΓ£o Γ© uma data vΓ‘lida |
|
35 | 35 | activerecord_error_greater_than_start_date: deve ser maior que a data inicial |
|
36 | 36 | activerecord_error_not_same_project: nΓ£o pertence ao mesmo projeto |
|
37 | 37 | activerecord_error_circular_dependency: Esta relaΓ§Γ£o geraria uma dependΓͺncia circular |
|
38 | 38 | |
|
39 | 39 | general_fmt_age: %d ano |
|
40 | 40 | general_fmt_age_plural: %d anos |
|
41 | 41 | general_fmt_date: %%d/%%m/%%Y |
|
42 | 42 | general_fmt_datetime: %%d/%%m/%%Y %%I:%%M %%p |
|
43 | 43 | general_fmt_datetime_short: %%b %%d, %%I:%%M %%p |
|
44 | 44 | general_fmt_time: %%I:%%M %%p |
|
45 | 45 | general_text_No: 'NΓ£o' |
|
46 | 46 | general_text_Yes: 'Sim' |
|
47 | 47 | general_text_no: 'nΓ£o' |
|
48 | 48 | general_text_yes: 'sim' |
|
49 | 49 | general_lang_name: 'PortuguΓͺs(Brasil)' |
|
50 |
general_csv_separator: ' |
|
|
51 |
general_csv_decimal_separator: ' |
|
|
50 | general_csv_separator: ';' | |
|
51 | general_csv_decimal_separator: ',' | |
|
52 | 52 | general_csv_encoding: ISO-8859-1 |
|
53 | 53 | general_pdf_encoding: ISO-8859-1 |
|
54 | 54 | general_day_names: Segunda,TerΓ§a,Quarta,Quinta,Sexta,SΓ‘bado,Domingo |
|
55 | 55 | general_first_day_of_week: '1' |
|
56 | 56 | |
|
57 | 57 | notice_account_updated: Conta atualizada com sucesso. |
|
58 | 58 | notice_account_invalid_creditentials: UsuΓ‘rio ou senha invΓ‘lido. |
|
59 | 59 | notice_account_password_updated: Senha alterada com sucesso. |
|
60 | 60 | notice_account_wrong_password: Senha invΓ‘lida. |
|
61 | 61 | notice_account_register_done: Conta criada com sucesso. Para ativar sua conta, clique no link que lhe foi enviado por e-mail. |
|
62 | 62 | notice_account_unknown_email: UsuΓ‘rio desconhecido. |
|
63 | 63 | notice_can_t_change_password: Esta conta utiliza autenticaΓ§Γ£o externa. NΓ£o Γ© possΓvel alterar a senha. |
|
64 | 64 | notice_account_lost_email_sent: Um email com instruΓ§Γ΅es para escolher uma nova senha foi enviado para vocΓͺ. |
|
65 | 65 | notice_account_activated: Sua conta foi ativada. VocΓͺ pode acessΓ‘-la agora. |
|
66 | 66 | notice_successful_create: Criado com sucesso. |
|
67 | 67 | notice_successful_update: Alterado com sucesso. |
|
68 | 68 | notice_successful_delete: ExcluΓdo com sucesso. |
|
69 | 69 | notice_successful_connection: Conectado com sucesso. |
|
70 | 70 | notice_file_not_found: A pΓ‘gina que vocΓͺ estΓ‘ tentando acessar nΓ£o existe ou foi excluΓda. |
|
71 | 71 | notice_locking_conflict: Os dados foram atualizados por outro usuΓ‘rio. |
|
72 | 72 | notice_not_authorized: VocΓͺ nΓ£o estΓ‘ autorizado a acessar esta pΓ‘gina. |
|
73 | 73 | notice_email_sent: Um email foi enviado para %s |
|
74 | 74 | notice_email_error: Ocorreu um erro ao enviar o e-mail (%s) |
|
75 | 75 | notice_feeds_access_key_reseted: Sua chave RSS foi reconfigurada. |
|
76 | 76 | notice_failed_to_save_issues: "Problema ao salvar %d ticket(s) de %d selecionados: %s." |
|
77 | 77 | notice_no_issue_selected: "Nenhum ticket selecionado! Por favor, marque os tickets que vocΓͺ deseja editar." |
|
78 | 78 | notice_account_pending: "Sua conta foi criada e estΓ‘ aguardando aprovaΓ§Γ£o do administrador." |
|
79 | 79 | notice_default_data_loaded: ConfiguraΓ§Γ£o padrΓ£o carregada com sucesso. |
|
80 | 80 | |
|
81 | 81 | error_can_t_load_default_data: "ConfiguraΓ§Γ£o padrΓ£o nΓ£o pΓ΄de ser carregada: %s" |
|
82 | 82 | error_scm_not_found: "A entrada e/ou a revisΓ£o nΓ£o existe no repositΓ³rio." |
|
83 | 83 | error_scm_command_failed: "Ocorreu um erro ao tentar acessar o repositΓ³rio: %s" |
|
84 | 84 | error_scm_annotate: "Esta entrada nΓ£o existe ou nΓ£o pode ser anotada." |
|
85 | 85 | error_issue_not_found_in_project: 'O ticket nΓ£o foi encontrado ou nΓ£o pertence a este projeto' |
|
86 | 86 | |
|
87 | 87 | mail_subject_lost_password: Sua senha do %s. |
|
88 | 88 | mail_body_lost_password: 'Para mudar sua senha, clique no link abaixo:' |
|
89 | 89 | mail_subject_register: AtivaΓ§Γ£o de conta do %s. |
|
90 | 90 | mail_body_register: 'Para ativar sua conta, clique no link abaixo:' |
|
91 | 91 | mail_body_account_information_external: VocΓͺ pode usar sua conta do "%s" para entrar. |
|
92 | 92 | mail_body_account_information: InformaΓ§Γ΅es sobre sua conta |
|
93 | 93 | mail_subject_account_activation_request: %s - RequisiΓ§Γ£o de ativaΓ§Γ£o de conta |
|
94 | 94 | mail_body_account_activation_request: 'Um novo usuΓ‘rio (%s) se registrou. A conta estΓ‘ aguardando sua aprovaΓ§Γ£o:' |
|
95 | 95 | mail_subject_reminder: "%d ticket(s) com data prevista para os prΓ³ximos dias" |
|
96 | 96 | mail_body_reminder: "%d tickets(s) para vocΓͺ com data prevista para os prΓ³ximos %d dias:" |
|
97 | 97 | |
|
98 | 98 | gui_validation_error: 1 erro |
|
99 | 99 | gui_validation_error_plural: %d erros |
|
100 | 100 | |
|
101 | 101 | field_name: Nome |
|
102 | 102 | field_description: DescriΓ§Γ£o |
|
103 | 103 | field_summary: Resumo |
|
104 | 104 | field_is_required: ObrigatΓ³rio |
|
105 | 105 | field_firstname: Nome |
|
106 | 106 | field_lastname: Sobrenome |
|
107 | 107 | field_mail: Email |
|
108 | 108 | field_filename: Arquivo |
|
109 | 109 | field_filesize: Tamanho |
|
110 | 110 | field_downloads: Downloads |
|
111 | 111 | field_author: Autor |
|
112 | 112 | field_created_on: Criado em |
|
113 | 113 | field_updated_on: Alterado em |
|
114 | 114 | field_field_format: Formato |
|
115 | 115 | field_is_for_all: Para todos os projetos |
|
116 | 116 | field_possible_values: PossΓveis valores |
|
117 | 117 | field_regexp: ExpressΓ£o regular |
|
118 | 118 | field_min_length: Tamanho mΓnimo |
|
119 | 119 | field_max_length: Tamanho mΓ‘ximo |
|
120 | 120 | field_value: Valor |
|
121 | 121 | field_category: Categoria |
|
122 | 122 | field_title: TΓtulo |
|
123 | 123 | field_project: Projeto |
|
124 | 124 | field_issue: Ticket |
|
125 | 125 | field_status: Status |
|
126 | 126 | field_notes: Notas |
|
127 | 127 | field_is_closed: Ticket fechado |
|
128 | 128 | field_is_default: Status padrΓ£o |
|
129 | 129 | field_tracker: Tipo |
|
130 | 130 | field_subject: TΓtulo |
|
131 | 131 | field_due_date: Data prevista |
|
132 | 132 | field_assigned_to: AtribuΓdo para |
|
133 | 133 | field_priority: Prioridade |
|
134 | 134 | field_fixed_version: VersΓ£o |
|
135 | 135 | field_user: UsuΓ‘rio |
|
136 | 136 | field_role: Papel |
|
137 | 137 | field_homepage: PΓ‘gina inicial |
|
138 | 138 | field_is_public: PΓΊblico |
|
139 | 139 | field_parent: Sub-projeto de |
|
140 | 140 | field_is_in_chlog: Exibir na lista de alteraΓ§Γ΅es |
|
141 | 141 | field_is_in_roadmap: Exibir no planejamento |
|
142 | 142 | field_login: UsuΓ‘rio |
|
143 | 143 | field_mail_notification: NotificaΓ§Γ΅es por email |
|
144 | 144 | field_admin: Administrador |
|
145 | 145 | field_last_login_on: Γltima conexΓ£o |
|
146 | 146 | field_language: Idioma |
|
147 | 147 | field_effective_date: Data |
|
148 | 148 | field_password: Senha |
|
149 | 149 | field_new_password: Nova senha |
|
150 | 150 | field_password_confirmation: ConfirmaΓ§Γ£o |
|
151 | 151 | field_version: VersΓ£o |
|
152 | 152 | field_type: Tipo |
|
153 | 153 | field_host: Servidor |
|
154 | 154 | field_port: Porta |
|
155 | 155 | field_account: Conta |
|
156 | 156 | field_base_dn: DN Base |
|
157 | 157 | field_attr_login: Atributo para nome de usuΓ‘rio |
|
158 | 158 | field_attr_firstname: Atributo para nome |
|
159 | 159 | field_attr_lastname: Atributo para sobrenome |
|
160 | 160 | field_attr_mail: Atributo para email |
|
161 | 161 | field_onthefly: Criar usuΓ‘rios dinamicamente ("on-the-fly") |
|
162 | 162 | field_start_date: InΓcio |
|
163 | 163 | field_done_ratio: %% Terminado |
|
164 | 164 | field_auth_source: Modo de autenticaΓ§Γ£o |
|
165 | 165 | field_hide_mail: Ocultar meu email |
|
166 | 166 | field_comments: ComentΓ‘rio |
|
167 | 167 | field_url: URL |
|
168 | 168 | field_start_page: PΓ‘gina inicial |
|
169 | 169 | field_subproject: Sub-projeto |
|
170 | 170 | field_hours: Horas |
|
171 | 171 | field_activity: Atividade |
|
172 | 172 | field_spent_on: Data |
|
173 | 173 | field_identifier: Identificador |
|
174 | 174 | field_is_filter: Γ um filtro |
|
175 | 175 | field_issue_to_id: Ticket relacionado |
|
176 | 176 | field_delay: Atraso |
|
177 | 177 | field_assignable: Tickets podem ser atribuΓdos para este papel |
|
178 | 178 | field_redirect_existing_links: Redirecionar links existentes |
|
179 | 179 | field_estimated_hours: Tempo estimado |
|
180 | 180 | field_column_names: Colunas |
|
181 | 181 | field_time_zone: Fuso-horΓ‘rio |
|
182 | 182 | field_searchable: PesquisΓ‘vel |
|
183 | 183 | field_default_value: PadrΓ£o |
|
184 | 184 | field_comments_sorting: Visualizar comentΓ‘rios |
|
185 | 185 | field_parent_title: PΓ‘gina pai |
|
186 | 186 | |
|
187 | 187 | setting_app_title: TΓtulo da aplicaΓ§Γ£o |
|
188 | 188 | setting_app_subtitle: Sub-tΓtulo da aplicaΓ§Γ£o |
|
189 | 189 | setting_welcome_text: Texto de boas-vindas |
|
190 | 190 | setting_default_language: Idioma padrΓ£o |
|
191 | 191 | setting_login_required: Exigir autenticaΓ§Γ£o |
|
192 | 192 | setting_self_registration: Permitido Auto-registro |
|
193 | 193 | setting_attachment_max_size: Tamanho mΓ‘ximo do anexo |
|
194 | 194 | setting_issues_export_limit: Limite de exportaΓ§Γ£o das tarefas |
|
195 | 195 | setting_mail_from: Email enviado de |
|
196 | 196 | setting_bcc_recipients: DestinatΓ‘rios com cΓ³pia oculta (cco) |
|
197 | 197 | setting_host_name: Servidor |
|
198 | 198 | setting_text_formatting: Formato do texto |
|
199 | 199 | setting_wiki_compression: CompactaΓ§Γ£o de histΓ³rico do Wiki |
|
200 | 200 | setting_feeds_limit: Limite do Feed |
|
201 | 201 | setting_default_projects_public: Novos projetos sΓ£o pΓΊblicos por padrΓ£o |
|
202 | 202 | setting_autofetch_changesets: Auto-obter commits |
|
203 | 203 | setting_sys_api_enabled: Ativa WS para gerenciamento do repositΓ³rio |
|
204 | 204 | setting_commit_ref_keywords: Palavras de referΓͺncia |
|
205 | 205 | setting_commit_fix_keywords: Palavras de fechamento |
|
206 | 206 | setting_autologin: Auto-login |
|
207 | 207 | setting_date_format: Formato da data |
|
208 | 208 | setting_time_format: Formato de data |
|
209 | 209 | setting_cross_project_issue_relations: Permitir relacionar tickets entre projetos |
|
210 | 210 | setting_issue_list_default_columns: Colunas padrΓ£o visΓveis na lista de tickets |
|
211 | 211 | setting_repositories_encodings: CodificaΓ§Γ£o dos repositΓ³rios |
|
212 | 212 | setting_commit_logs_encoding: CodificaΓ§Γ£o das mensagens de commit |
|
213 | 213 | setting_emails_footer: RodapΓ© dos emails |
|
214 | 214 | setting_protocol: Protocolo |
|
215 | 215 | setting_per_page_options: OpΓ§Γ΅es de itens por pΓ‘gina |
|
216 | 216 | setting_user_format: Formato de visualizaΓ§Γ£o dos usuΓ‘rios |
|
217 | 217 | setting_activity_days_default: Dias visualizados na atividade do projeto |
|
218 | 218 | setting_display_subprojects_issues: Visualizar tickets dos subprojetos nos projetos principais por padrΓ£o |
|
219 | 219 | setting_enabled_scm: Habilitar SCM |
|
220 | 220 | setting_mail_handler_api_enabled: Habilitar WS para emails de entrada |
|
221 | 221 | setting_mail_handler_api_key: Chave de API |
|
222 | 222 | setting_sequential_project_identifiers: Gerar identificadores de projeto sequenciais |
|
223 | 223 | |
|
224 | 224 | project_module_issue_tracking: Gerenciamento de Tickets |
|
225 | 225 | project_module_time_tracking: Gerenciamento de tempo |
|
226 | 226 | project_module_news: NotΓcias |
|
227 | 227 | project_module_documents: Documentos |
|
228 | 228 | project_module_files: Arquivos |
|
229 | 229 | project_module_wiki: Wiki |
|
230 | 230 | project_module_repository: RepositΓ³rio |
|
231 | 231 | project_module_boards: FΓ³runs |
|
232 | 232 | |
|
233 | 233 | label_user: UsuΓ‘rio |
|
234 | 234 | label_user_plural: UsuΓ‘rios |
|
235 | 235 | label_user_new: Novo usuΓ‘rio |
|
236 | 236 | label_project: Projeto |
|
237 | 237 | label_project_new: Novo projeto |
|
238 | 238 | label_project_plural: Projetos |
|
239 | 239 | label_project_all: Todos os projetos |
|
240 | 240 | label_project_latest: Γltimos projetos |
|
241 | 241 | label_issue: Ticket |
|
242 | 242 | label_issue_new: Novo ticket |
|
243 | 243 | label_issue_plural: Tickets |
|
244 | 244 | label_issue_view_all: Ver todos os tickets |
|
245 | 245 | label_issues_by: Tickets por %s |
|
246 | 246 | label_issue_added: Ticket adicionado |
|
247 | 247 | label_issue_updated: Ticket atualizado |
|
248 | 248 | label_document: Documento |
|
249 | 249 | label_document_new: Novo documento |
|
250 | 250 | label_document_plural: Documentos |
|
251 | 251 | label_document_added: Documento adicionado |
|
252 | 252 | label_role: Papel |
|
253 | 253 | label_role_plural: PapΓ©is |
|
254 | 254 | label_role_new: Novo papel |
|
255 | 255 | label_role_and_permissions: PapΓ©is e permissΓ΅es |
|
256 | 256 | label_member: Membro |
|
257 | 257 | label_member_new: Novo membro |
|
258 | 258 | label_member_plural: Membros |
|
259 | 259 | label_tracker: Tipo de ticket |
|
260 | 260 | label_tracker_plural: Tipos de ticket |
|
261 | 261 | label_tracker_new: Novo tipo |
|
262 | 262 | label_workflow: Workflow |
|
263 | 263 | label_issue_status: Status do ticket |
|
264 | 264 | label_issue_status_plural: Status dos tickets |
|
265 | 265 | label_issue_status_new: Novo status |
|
266 | 266 | label_issue_category: Categoria de ticket |
|
267 | 267 | label_issue_category_plural: Categorias de tickets |
|
268 | 268 | label_issue_category_new: Nova categoria |
|
269 | 269 | label_custom_field: Campo personalizado |
|
270 | 270 | label_custom_field_plural: Campos personalizados |
|
271 | 271 | label_custom_field_new: Novo campo personalizado |
|
272 | 272 | label_enumerations: 'Tipos & Categorias' |
|
273 | 273 | label_enumeration_new: Novo |
|
274 | 274 | label_information: InformaΓ§Γ£o |
|
275 | 275 | label_information_plural: InformaΓ§Γ΅es |
|
276 | 276 | label_please_login: Efetue o login |
|
277 | 277 | label_register: Cadastre-se |
|
278 | 278 | label_password_lost: Perdi minha senha |
|
279 | 279 | label_home: PΓ‘gina inicial |
|
280 | 280 | label_my_page: Minha pΓ‘gina |
|
281 | 281 | label_my_account: Minha conta |
|
282 | 282 | label_my_projects: Meus projetos |
|
283 | 283 | label_administration: AdministraΓ§Γ£o |
|
284 | 284 | label_login: Entrar |
|
285 | 285 | label_logout: Sair |
|
286 | 286 | label_help: Ajuda |
|
287 | 287 | label_reported_issues: Tickets reportados |
|
288 | 288 | label_assigned_to_me_issues: Meus tickets |
|
289 | 289 | label_last_login: Γltima conexΓ£o |
|
290 | 290 | label_last_updates: Γltima alteraΓ§Γ£o |
|
291 | 291 | label_last_updates_plural: %d Γltimas alteraΓ§Γ΅es |
|
292 | 292 | label_registered_on: Registrado em |
|
293 | 293 | label_activity: Atividade |
|
294 | 294 | label_overall_activity: Atividades gerais |
|
295 | 295 | label_new: Novo |
|
296 | 296 | label_logged_as: "Acessando como:" |
|
297 | 297 | label_environment: Ambiente |
|
298 | 298 | label_authentication: AutenticaΓ§Γ£o |
|
299 | 299 | label_auth_source: Modo de autenticaΓ§Γ£o |
|
300 | 300 | label_auth_source_new: Novo modo de autenticaΓ§Γ£o |
|
301 | 301 | label_auth_source_plural: Modos de autenticaΓ§Γ£o |
|
302 | 302 | label_subproject_plural: Sub-projetos |
|
303 | 303 | label_and_its_subprojects: %s e seus sub-projetos |
|
304 | 304 | label_min_max_length: Tamanho mΓn-mΓ‘x |
|
305 | 305 | label_list: Lista |
|
306 | 306 | label_date: Data |
|
307 | 307 | label_integer: Inteiro |
|
308 | 308 | label_float: Decimal |
|
309 | 309 | label_boolean: Boleano |
|
310 | 310 | label_string: Texto |
|
311 | 311 | label_text: Texto longo |
|
312 | 312 | label_attribute: Atributo |
|
313 | 313 | label_attribute_plural: Atributos |
|
314 | 314 | label_download: %d Download |
|
315 | 315 | label_download_plural: %d Downloads |
|
316 | 316 | label_no_data: Nenhuma informaΓ§Γ£o disponΓvel |
|
317 | 317 | label_change_status: Alterar status |
|
318 | 318 | label_history: HistΓ³rico |
|
319 | 319 | label_attachment: Arquivo |
|
320 | 320 | label_attachment_new: Novo arquivo |
|
321 | 321 | label_attachment_delete: Excluir arquivo |
|
322 | 322 | label_attachment_plural: Arquivos |
|
323 | 323 | label_file_added: Arquivo adicionado |
|
324 | 324 | label_report: RelatΓ³rio |
|
325 | 325 | label_report_plural: RelatΓ³rio |
|
326 | 326 | label_news: NotΓcia |
|
327 | 327 | label_news_new: Adicionar notΓcia |
|
328 | 328 | label_news_plural: NotΓcias |
|
329 | 329 | label_news_latest: Γltimas notΓcias |
|
330 | 330 | label_news_view_all: Ver todas as notΓcias |
|
331 | 331 | label_news_added: NotΓcia adicionada |
|
332 | 332 | label_change_log: Registro de alteraΓ§Γ΅es |
|
333 | 333 | label_settings: ConfiguraΓ§Γ΅es |
|
334 | 334 | label_overview: VisΓ£o geral |
|
335 | 335 | label_version: VersΓ£o |
|
336 | 336 | label_version_new: Nova versΓ£o |
|
337 | 337 | label_version_plural: VersΓ΅es |
|
338 | 338 | label_confirmation: ConfirmaΓ§Γ£o |
|
339 | 339 | label_export_to: Exportar para |
|
340 | 340 | label_read: Ler... |
|
341 | 341 | label_public_projects: Projetos pΓΊblicos |
|
342 | 342 | label_open_issues: Aberto |
|
343 | 343 | label_open_issues_plural: Abertos |
|
344 | 344 | label_closed_issues: Fechado |
|
345 | 345 | label_closed_issues_plural: Fechados |
|
346 | 346 | label_total: Total |
|
347 | 347 | label_permissions: PermissΓ΅es |
|
348 | 348 | label_current_status: Status atual |
|
349 | 349 | label_new_statuses_allowed: Novo status permitido |
|
350 | 350 | label_all: todos |
|
351 | 351 | label_none: nenhum |
|
352 | 352 | label_nobody: ninguΓ©m |
|
353 | 353 | label_next: PrΓ³ximo |
|
354 | 354 | label_previous: Anterior |
|
355 | 355 | label_used_by: Usado por |
|
356 | 356 | label_details: Detalhes |
|
357 | 357 | label_add_note: Adicionar nota |
|
358 | 358 | label_per_page: Por pΓ‘gina |
|
359 | 359 | label_calendar: CalendΓ‘rio |
|
360 | 360 | label_months_from: meses a partir de |
|
361 | 361 | label_gantt: Gantt |
|
362 | 362 | label_internal: Interno |
|
363 | 363 | label_last_changes: ΓΊltimas %d alteraΓ§Γ΅es |
|
364 | 364 | label_change_view_all: Mostrar todas as alteraΓ§Γ΅es |
|
365 | 365 | label_personalize_page: Personalizar esta pΓ‘gina |
|
366 | 366 | label_comment: ComentΓ‘rio |
|
367 | 367 | label_comment_plural: ComentΓ‘rios |
|
368 | 368 | label_comment_add: Adicionar comentΓ‘rio |
|
369 | 369 | label_comment_added: ComentΓ‘rio adicionado |
|
370 | 370 | label_comment_delete: Excluir comentΓ‘rio |
|
371 | 371 | label_query: Consulta personalizada |
|
372 | 372 | label_query_plural: Consultas personalizadas |
|
373 | 373 | label_query_new: Nova consulta |
|
374 | 374 | label_filter_add: Adicionar filtro |
|
375 | 375 | label_filter_plural: Filtros |
|
376 | 376 | label_equals: igual a |
|
377 | 377 | label_not_equals: diferente de |
|
378 | 378 | label_in_less_than: maior que |
|
379 | 379 | label_in_more_than: menor que |
|
380 | 380 | label_in: em |
|
381 | 381 | label_today: hoje |
|
382 | 382 | label_all_time: tudo |
|
383 | 383 | label_yesterday: ontem |
|
384 | 384 | label_this_week: esta semana |
|
385 | 385 | label_last_week: ΓΊltima semana |
|
386 | 386 | label_last_n_days: ΓΊltimos %d dias |
|
387 | 387 | label_this_month: este mΓͺs |
|
388 | 388 | label_last_month: ΓΊltimo mΓͺs |
|
389 | 389 | label_this_year: este ano |
|
390 | 390 | label_date_range: PerΓodo |
|
391 | 391 | label_less_than_ago: menos de |
|
392 | 392 | label_more_than_ago: mais de |
|
393 | 393 | label_ago: dias atrΓ‘s |
|
394 | 394 | label_contains: contΓ©m |
|
395 | 395 | label_not_contains: nΓ£o contΓ©m |
|
396 | 396 | label_day_plural: dias |
|
397 | 397 | label_repository: RepositΓ³rio |
|
398 | 398 | label_repository_plural: RepositΓ³rios |
|
399 | 399 | label_browse: Procurar |
|
400 | 400 | label_modification: %d alteraΓ§Γ£o |
|
401 | 401 | label_modification_plural: %d alteraΓ§Γ΅es |
|
402 | 402 | label_revision: RevisΓ£o |
|
403 | 403 | label_revision_plural: RevisΓ΅es |
|
404 | 404 | label_associated_revisions: RevisΓ΅es associadas |
|
405 | 405 | label_added: adicionada |
|
406 | 406 | label_modified: alterada |
|
407 | 407 | label_deleted: excluΓda |
|
408 | 408 | label_latest_revision: Γltima revisΓ£o |
|
409 | 409 | label_latest_revision_plural: Γltimas revisΓ΅es |
|
410 | 410 | label_view_revisions: Ver revisΓ΅es |
|
411 | 411 | label_max_size: Tamanho mΓ‘ximo |
|
412 | 412 | label_on: 'de' |
|
413 | 413 | label_sort_highest: Mover para o inΓcio |
|
414 | 414 | label_sort_higher: Mover para cima |
|
415 | 415 | label_sort_lower: Mover para baixo |
|
416 | 416 | label_sort_lowest: Mover para o fim |
|
417 | 417 | label_roadmap: Planejamento |
|
418 | 418 | label_roadmap_due_in: Previsto para %s |
|
419 | 419 | label_roadmap_overdue: %s atrasado |
|
420 | 420 | label_roadmap_no_issues: Sem tickets para esta versΓ£o |
|
421 | 421 | label_search: Busca |
|
422 | 422 | label_result_plural: Resultados |
|
423 | 423 | label_all_words: Todas as palavras |
|
424 | 424 | label_wiki: Wiki |
|
425 | 425 | label_wiki_edit: Editar Wiki |
|
426 | 426 | label_wiki_edit_plural: EdiΓ§Γ΅es Wiki |
|
427 | 427 | label_wiki_page: PΓ‘gina Wiki |
|
428 | 428 | label_wiki_page_plural: pΓ‘ginas Wiki |
|
429 | 429 | label_index_by_title: Γndice por tΓtulo |
|
430 | 430 | label_index_by_date: Γndice por data |
|
431 | 431 | label_current_version: VersΓ£o atual |
|
432 | 432 | label_preview: PrΓ©-visualizar |
|
433 | 433 | label_feed_plural: Feeds |
|
434 | 434 | label_changes_details: Detalhes de todas as alteraΓ§Γ΅es |
|
435 | 435 | label_issue_tracking: Tickets |
|
436 | 436 | label_spent_time: Tempo gasto |
|
437 | 437 | label_f_hour: %.2f hora |
|
438 | 438 | label_f_hour_plural: %.2f horas |
|
439 | 439 | label_time_tracking: Controle de horas |
|
440 | 440 | label_change_plural: AlteraΓ§Γ΅es |
|
441 | 441 | label_statistics: EstatΓsticas |
|
442 | 442 | label_commits_per_month: Commits por mΓͺs |
|
443 | 443 | label_commits_per_author: Commits por autor |
|
444 | 444 | label_view_diff: Ver diferenΓ§as |
|
445 | 445 | label_diff_inline: inline |
|
446 | 446 | label_diff_side_by_side: lado a lado |
|
447 | 447 | label_options: OpΓ§Γ΅es |
|
448 | 448 | label_copy_workflow_from: Copiar workflow de |
|
449 | 449 | label_permissions_report: RelatΓ³rio de permissΓ΅es |
|
450 | 450 | label_watched_issues: Tickes monitorados |
|
451 | 451 | label_related_issues: Tickets relacionados |
|
452 | 452 | label_applied_status: Status aplicado |
|
453 | 453 | label_loading: Carregando... |
|
454 | 454 | label_relation_new: Nova relaΓ§Γ£o |
|
455 | 455 | label_relation_delete: Excluir relaΓ§Γ£o |
|
456 | 456 | label_relates_to: relacionado a |
|
457 | 457 | label_duplicates: duplica |
|
458 | 458 | label_duplicated_by: duplicado por |
|
459 | 459 | label_blocks: bloqueia |
|
460 | 460 | label_blocked_by: bloqueado por |
|
461 | 461 | label_precedes: precede |
|
462 | 462 | label_follows: segue |
|
463 | 463 | label_end_to_start: fim para o inΓcio |
|
464 | 464 | label_end_to_end: fim para fim |
|
465 | 465 | label_start_to_start: inΓcio para inΓcio |
|
466 | 466 | label_start_to_end: inΓcio para fim |
|
467 | 467 | label_stay_logged_in: Permanecer logado |
|
468 | 468 | label_disabled: desabilitado |
|
469 | 469 | label_show_completed_versions: Exibir versΓ΅es completas |
|
470 | 470 | label_me: mim |
|
471 | 471 | label_board: FΓ³rum |
|
472 | 472 | label_board_new: Novo fΓ³rum |
|
473 | 473 | label_board_plural: FΓ³runs |
|
474 | 474 | label_topic_plural: TΓ³picos |
|
475 | 475 | label_message_plural: Mensagens |
|
476 | 476 | label_message_last: Γltima mensagem |
|
477 | 477 | label_message_new: Nova mensagem |
|
478 | 478 | label_message_posted: Mensagem enviada |
|
479 | 479 | label_reply_plural: Respostas |
|
480 | 480 | label_send_information: Enviar informaΓ§Γ£o da nova conta para o usuΓ‘rio |
|
481 | 481 | label_year: Ano |
|
482 | 482 | label_month: MΓͺs |
|
483 | 483 | label_week: Semana |
|
484 | 484 | label_date_from: De |
|
485 | 485 | label_date_to: Para |
|
486 | 486 | label_language_based: Com base no idioma do usuΓ‘rio |
|
487 | 487 | label_sort_by: Ordenar por %s |
|
488 | 488 | label_send_test_email: Enviar um email de teste |
|
489 | 489 | label_feeds_access_key_created_on: chave de acesso RSS criada %s atrΓ‘s |
|
490 | 490 | label_module_plural: MΓ³dulos |
|
491 | 491 | label_added_time_by: Adicionado por %s %s atrΓ‘s |
|
492 | 492 | label_updated_time: Atualizado %s atrΓ‘s |
|
493 | 493 | label_jump_to_a_project: Ir para o projeto... |
|
494 | 494 | label_file_plural: Arquivos |
|
495 | 495 | label_changeset_plural: Changesets |
|
496 | 496 | label_default_columns: Colunas padrΓ£o |
|
497 | 497 | label_no_change_option: (Sem alteraΓ§Γ£o) |
|
498 | 498 | label_bulk_edit_selected_issues: EdiΓ§Γ£o em massa dos tickets selecionados. |
|
499 | 499 | label_theme: Tema |
|
500 | 500 | label_default: PadrΓ£o |
|
501 | 501 | label_search_titles_only: Pesquisar somente tΓtulos |
|
502 | 502 | label_user_mail_option_all: "Para qualquer evento em todos os meus projetos" |
|
503 | 503 | label_user_mail_option_selected: "Para qualquer evento somente no(s) projeto(s) selecionado(s)..." |
|
504 | 504 | label_user_mail_option_none: "Somente tickets que eu acompanho ou estou envolvido" |
|
505 | 505 | label_user_mail_no_self_notified: "Eu nΓ£o quero ser notificado de minhas prΓ³prias modificaΓ§Γ΅es" |
|
506 | 506 | label_registration_activation_by_email: ativaΓ§Γ£o de conta por e-mail |
|
507 | 507 | label_registration_manual_activation: ativaΓ§Γ£o manual de conta |
|
508 | 508 | label_registration_automatic_activation: ativaΓ§Γ£o automΓ‘tica de conta |
|
509 | 509 | label_display_per_page: 'Por pΓ‘gina: %s' |
|
510 | 510 | label_age: Idade |
|
511 | 511 | label_change_properties: Alterar propriedades |
|
512 | 512 | label_general: Geral |
|
513 | 513 | label_more: Mais |
|
514 | 514 | label_scm: 'Controle de versΓ£o:' |
|
515 | 515 | label_plugins: Plugins |
|
516 | 516 | label_ldap_authentication: AutenticaΓ§Γ£o LDAP |
|
517 | 517 | label_downloads_abbr: D/L |
|
518 | 518 | label_optional_description: DescriΓ§Γ£o opcional |
|
519 | 519 | label_add_another_file: Adicionar outro arquivo |
|
520 | 520 | label_preferences: PreferΓͺncias |
|
521 | 521 | label_chronological_order: Em ordem cronolΓ³gica |
|
522 | 522 | label_reverse_chronological_order: Em ordem cronolΓ³gica inversa |
|
523 | 523 | label_planning: Planejamento |
|
524 | 524 | label_incoming_emails: Emails de entrada |
|
525 | 525 | label_generate_key: Gerar uma chave |
|
526 | 526 | label_issue_watchers: Monitorando |
|
527 | 527 | |
|
528 | 528 | button_login: Entrar |
|
529 | 529 | button_submit: Enviar |
|
530 | 530 | button_save: Salvar |
|
531 | 531 | button_check_all: Marcar todos |
|
532 | 532 | button_uncheck_all: Desmarcar todos |
|
533 | 533 | button_delete: Excluir |
|
534 | 534 | button_create: Criar |
|
535 | 535 | button_test: Testar |
|
536 | 536 | button_edit: Editar |
|
537 | 537 | button_add: Adicionar |
|
538 | 538 | button_change: Alterar |
|
539 | 539 | button_apply: Aplicar |
|
540 | 540 | button_clear: Limpar |
|
541 | 541 | button_lock: Bloquear |
|
542 | 542 | button_unlock: Desbloquear |
|
543 | 543 | button_download: Download |
|
544 | 544 | button_list: Listar |
|
545 | 545 | button_view: Ver |
|
546 | 546 | button_move: Mover |
|
547 | 547 | button_back: Voltar |
|
548 | 548 | button_cancel: Cancelar |
|
549 | 549 | button_activate: Ativar |
|
550 | 550 | button_sort: Ordenar |
|
551 | 551 | button_log_time: Tempo de trabalho |
|
552 | 552 | button_rollback: Voltar para esta versΓ£o |
|
553 | 553 | button_watch: Monitorar |
|
554 | 554 | button_unwatch: Parar de Monitorar |
|
555 | 555 | button_reply: Responder |
|
556 | 556 | button_archive: Arquivar |
|
557 | 557 | button_unarchive: Desarquivar |
|
558 | 558 | button_reset: Redefinir |
|
559 | 559 | button_rename: Renomear |
|
560 | 560 | button_change_password: Alterar senha |
|
561 | 561 | button_copy: Copiar |
|
562 | 562 | button_annotate: Anotar |
|
563 | 563 | button_update: Atualizar |
|
564 | 564 | button_configure: Configurar |
|
565 | 565 | button_quote: Responder |
|
566 | 566 | |
|
567 | 567 | status_active: ativo |
|
568 | 568 | status_registered: registrado |
|
569 | 569 | status_locked: bloqueado |
|
570 | 570 | |
|
571 | 571 | text_select_mail_notifications: Selecionar aΓ§Γ΅es para ser enviado uma notificaΓ§Γ£o por email |
|
572 | 572 | text_regexp_info: ex. ^[A-Z0-9]+$ |
|
573 | 573 | text_min_max_length_info: 0 = sem restriΓ§Γ£o |
|
574 | 574 | text_project_destroy_confirmation: VocΓͺ tem certeza que deseja excluir este projeto e todos os dados relacionados? |
|
575 | 575 | text_subprojects_destroy_warning: 'Seu(s) subprojeto(s): %s tambΓ©m serΓ£o excluΓdos.' |
|
576 | 576 | text_workflow_edit: Selecione um papel e um tipo de tarefa para editar o workflow |
|
577 | 577 | text_are_you_sure: VocΓͺ tem certeza? |
|
578 | 578 | text_journal_changed: alterado(a) de %s para %s |
|
579 | 579 | text_journal_set_to: alterado(a) para %s |
|
580 | 580 | text_journal_deleted: excluΓdo |
|
581 | 581 | text_tip_task_begin_day: tarefa inicia neste dia |
|
582 | 582 | text_tip_task_end_day: tarefa termina neste dia |
|
583 | 583 | text_tip_task_begin_end_day: tarefa inicia e termina neste dia |
|
584 | 584 | text_project_identifier_info: 'Letras minΓΊsculas (a-z), nΓΊmeros e hΓfens permitidos.<br />Uma vez salvo, o identificador nΓ£o poderΓ‘ ser alterado.' |
|
585 | 585 | text_caracters_maximum: mΓ‘ximo %d caracteres |
|
586 | 586 | text_caracters_minimum: deve ter ao menos %d caracteres. |
|
587 | 587 | text_length_between: deve ter entre %d e %d caracteres. |
|
588 | 588 | text_tracker_no_workflow: Sem workflow definido para este tipo. |
|
589 | 589 | text_unallowed_characters: Caracteres nΓ£o permitidos |
|
590 | 590 | text_comma_separated: MΓΊltiplos valores sΓ£o permitidos (separados por vΓrgula). |
|
591 | 591 | text_issues_ref_in_commit_messages: Referenciando tickets nas mensagens de commit |
|
592 | 592 | text_issue_added: Ticket %s incluΓdo (por %s). |
|
593 | 593 | text_issue_updated: Ticket %s alterado (por %s). |
|
594 | 594 | text_wiki_destroy_confirmation: VocΓͺ tem certeza que deseja excluir este wiki e TODO o seu conteΓΊdo? |
|
595 | 595 | text_issue_category_destroy_question: Alguns tickets (%d) estΓ£o atribuΓdos a esta categoria. O que vocΓͺ deseja fazer? |
|
596 | 596 | text_issue_category_destroy_assignments: Remover atribuiΓ§Γ΅es da categoria |
|
597 | 597 | text_issue_category_reassign_to: Redefinir tickets para esta categoria |
|
598 | 598 | text_user_mail_option: "Para projetos (nΓ£o selecionados), vocΓͺ somente receberΓ‘ notificaΓ§Γ΅es sobre o que vocΓͺ monitora ou estΓ‘ envolvido (ex. tickets nos quais vocΓͺ Γ© o autor ou estΓ£o atribuΓdos a vocΓͺ)" |
|
599 | 599 | text_no_configuration_data: "Os PapΓ©is, tipos de tickets, status de tickets e workflows nΓ£o foram configurados ainda.\nΓ altamente recomendado carregar as configuraΓ§Γ΅es padrΓ£o. VocΓͺ poderΓ‘ modificar estas configuraΓ§Γ΅es assim que carregadas." |
|
600 | 600 | text_load_default_configuration: Carregar a configuraΓ§Γ£o padrΓ£o |
|
601 | 601 | text_status_changed_by_changeset: Aplicado no changeset %s. |
|
602 | 602 | text_issues_destroy_confirmation: 'VocΓͺ tem certeza que deseja excluir o(s) ticket(s) selecionado(s)?' |
|
603 | 603 | text_select_project_modules: 'Selecione mΓ³dulos para habilitar para este projeto:' |
|
604 | 604 | text_default_administrator_account_changed: Conta padrΓ£o do administrador alterada |
|
605 | 605 | text_file_repository_writable: RepositΓ³rio com permissΓ£o de escrita |
|
606 | 606 | text_rmagick_available: RMagick disponΓvel (opcional) |
|
607 | 607 | text_destroy_time_entries_question: %.02f horas de trabalho foram registradas nos tickets que vocΓͺ estΓ‘ excluindo. O que vocΓͺ deseja fazer? |
|
608 | 608 | text_destroy_time_entries: Excluir horas de trabalho |
|
609 | 609 | text_assign_time_entries_to_project: Atribuir estas horas de trabalho para outro projeto |
|
610 | 610 | text_reassign_time_entries: 'Atribuir horas reportadas para este ticket:' |
|
611 | 611 | text_user_wrote: '%s escreveu:' |
|
612 | 612 | text_enumeration_destroy_question: '%d objetos estΓ£o atribuΓdos a este valor.' |
|
613 | 613 | text_enumeration_category_reassign_to: 'ReatribuΓ-los ao valor:' |
|
614 | 614 | text_email_delivery_not_configured: "O envio de email nΓ£o estΓ‘ configurado, e as notificaΓ§Γ΅es estΓ£o inativas.\nConfigure seu servidor SMTP no arquivo config/email.yml e reinicie a aplicaΓ§Γ£o para ativΓ‘-las." |
|
615 | 615 | |
|
616 | 616 | default_role_manager: Gerente |
|
617 | 617 | default_role_developper: Desenvolvedor |
|
618 | 618 | default_role_reporter: Informante |
|
619 | 619 | default_tracker_bug: Problema |
|
620 | 620 | default_tracker_feature: Funcionalidade |
|
621 | 621 | default_tracker_support: Suporte |
|
622 | 622 | default_issue_status_new: Novo |
|
623 | 623 | default_issue_status_assigned: AtribuΓdo |
|
624 | 624 | default_issue_status_resolved: Resolvido |
|
625 | 625 | default_issue_status_feedback: Feedback |
|
626 | 626 | default_issue_status_closed: Fechado |
|
627 | 627 | default_issue_status_rejected: Rejeitado |
|
628 | 628 | default_doc_category_user: DocumentaΓ§Γ£o do usuΓ‘rio |
|
629 | 629 | default_doc_category_tech: DocumentaΓ§Γ£o tΓ©cnica |
|
630 | 630 | default_priority_low: Baixo |
|
631 | 631 | default_priority_normal: Normal |
|
632 | 632 | default_priority_high: Alto |
|
633 | 633 | default_priority_urgent: Urgente |
|
634 | 634 | default_priority_immediate: Imediato |
|
635 | 635 | default_activity_design: Design |
|
636 | 636 | default_activity_development: Desenvolvimento |
|
637 | 637 | |
|
638 | 638 | enumeration_issue_priorities: Prioridade das tarefas |
|
639 | 639 | enumeration_doc_categories: Categorias de documento |
|
640 | 640 | enumeration_activities: Atividades (time tracking) |
|
641 | 641 | notice_unable_delete_version: NΓ£o foi possΓvel excluir a versΓ£o |
|
642 | 642 | label_renamed: renomeado |
|
643 | 643 | label_copied: copiado |
|
644 | 644 | setting_plain_text_mail: texto plano apenas (sem HTML) |
|
645 | 645 | permission_view_files: Ver Arquivos |
|
646 | 646 | permission_edit_issues: Editar tickets |
|
647 | 647 | permission_edit_own_time_entries: Editar o prΓ³prio tempo de trabalho |
|
648 | 648 | permission_manage_public_queries: Gerenciar consultas publicas |
|
649 | 649 | permission_add_issues: Adicionar Tickets |
|
650 | 650 | permission_log_time: Adicionar tempo gasto |
|
651 | 651 | permission_view_changesets: Ver changesets |
|
652 | 652 | permission_view_time_entries: Ver tempo gasto |
|
653 | 653 | permission_manage_versions: Gerenciar versΓ΅es |
|
654 | 654 | permission_manage_wiki: Gerenciar wiki |
|
655 | 655 | permission_manage_categories: Gerenciar categorias de tickets |
|
656 | 656 | permission_protect_wiki_pages: Proteger pΓ‘ginas wiki |
|
657 | 657 | permission_comment_news: Comentar notΓcias |
|
658 | 658 | permission_delete_messages: Excluir mensagens |
|
659 | 659 | permission_select_project_modules: Selecionar mΓ³dulos de projeto |
|
660 | 660 | permission_manage_documents: Gerenciar documentos |
|
661 | 661 | permission_edit_wiki_pages: Editar pΓ‘ginas wiki |
|
662 | 662 | permission_add_issue_watchers: Adicionar monitores |
|
663 | 663 | permission_view_gantt: Ver grΓ‘fico gantt |
|
664 | 664 | permission_move_issues: Mover tickets |
|
665 | 665 | permission_manage_issue_relations: Gerenciar relacionamentos de tickets |
|
666 | 666 | permission_delete_wiki_pages: Excluir pΓ‘ginas wiki |
|
667 | 667 | permission_manage_boards: Gerenciar fΓ³runs |
|
668 | 668 | permission_delete_wiki_pages_attachments: Excluir anexos |
|
669 | 669 | permission_view_wiki_edits: Ver histΓ³rico do wiki |
|
670 | 670 | permission_add_messages: Postar mensagens |
|
671 | 671 | permission_view_messages: Ver mensagens |
|
672 | 672 | permission_manage_files: Gerenciar arquivos |
|
673 | 673 | permission_edit_issue_notes: Editar notas |
|
674 | 674 | permission_manage_news: Gerenciar notΓcias |
|
675 | 675 | permission_view_calendar: Ver caneldΓ‘rio |
|
676 | 676 | permission_manage_members: Gerenciar membros |
|
677 | 677 | permission_edit_messages: Editar mensagens |
|
678 | 678 | permission_delete_issues: Excluir tickets |
|
679 | 679 | permission_view_issue_watchers: Ver lista de monitores |
|
680 | 680 | permission_manage_repository: Gerenciar repositΓ³rio |
|
681 | 681 | permission_commit_access: Acesso de commit |
|
682 | 682 | permission_browse_repository: Pesquisar repositorio |
|
683 | 683 | permission_view_documents: Ver documentos |
|
684 | 684 | permission_edit_project: Editar projeto |
|
685 | 685 | permission_add_issue_notes: Adicionar notas |
|
686 | 686 | permission_save_queries: Salvar consultas |
|
687 | 687 | permission_view_wiki_pages: Ver wiki |
|
688 | 688 | permission_rename_wiki_pages: Renomear pΓ‘ginas wiki |
|
689 | 689 | permission_edit_time_entries: Editar tempo gasto |
|
690 | 690 | permission_edit_own_issue_notes: Editar prΓ³prias notas |
|
691 | 691 | setting_gravatar_enabled: Usar Γcones do Gravatar |
|
692 | 692 | label_example: Exemplo |
|
693 | 693 | text_repository_usernames_mapping: "Seleciona ou atualiza os usuΓ‘rios do Redmine mapeando para cada usuΓ‘rio encontrado no log do repositΓ³rio.\nUsuΓ‘rios com o mesmo login ou email no Redmine e no repositΓ³rio serΓ£o mapeados automaticamente." |
|
694 | 694 | permission_edit_own_messages: Editar prΓ³prias mensagens |
|
695 | 695 | permission_delete_own_messages: Excluir prΓ³prias mensagens |
|
696 | 696 | label_user_activity: "Atividade de %s" |
|
697 | 697 | label_updated_time_by: Updated by %s %s ago |
|
698 | 698 | text_diff_truncated: '... This diff was truncated because it exceeds the maximum size that can be displayed.' |
|
699 | 699 | setting_diff_max_lines_displayed: Max number of diff lines displayed |
@@ -1,1174 +1,1177 | |||
|
1 | 1 | # vim:ts=4:sw=4: |
|
2 | 2 | # = RedCloth - Textile and Markdown Hybrid for Ruby |
|
3 | 3 | # |
|
4 | 4 | # Homepage:: http://whytheluckystiff.net/ruby/redcloth/ |
|
5 | 5 | # Author:: why the lucky stiff (http://whytheluckystiff.net/) |
|
6 | 6 | # Copyright:: (cc) 2004 why the lucky stiff (and his puppet organizations.) |
|
7 | 7 | # License:: BSD |
|
8 | 8 | # |
|
9 | 9 | # (see http://hobix.com/textile/ for a Textile Reference.) |
|
10 | 10 | # |
|
11 | 11 | # Based on (and also inspired by) both: |
|
12 | 12 | # |
|
13 | 13 | # PyTextile: http://diveintomark.org/projects/textile/textile.py.txt |
|
14 | 14 | # Textism for PHP: http://www.textism.com/tools/textile/ |
|
15 | 15 | # |
|
16 | 16 | # |
|
17 | 17 | |
|
18 | 18 | # = RedCloth |
|
19 | 19 | # |
|
20 | 20 | # RedCloth is a Ruby library for converting Textile and/or Markdown |
|
21 | 21 | # into HTML. You can use either format, intermingled or separately. |
|
22 | 22 | # You can also extend RedCloth to honor your own custom text stylings. |
|
23 | 23 | # |
|
24 | 24 | # RedCloth users are encouraged to use Textile if they are generating |
|
25 | 25 | # HTML and to use Markdown if others will be viewing the plain text. |
|
26 | 26 | # |
|
27 | 27 | # == What is Textile? |
|
28 | 28 | # |
|
29 | 29 | # Textile is a simple formatting style for text |
|
30 | 30 | # documents, loosely based on some HTML conventions. |
|
31 | 31 | # |
|
32 | 32 | # == Sample Textile Text |
|
33 | 33 | # |
|
34 | 34 | # h2. This is a title |
|
35 | 35 | # |
|
36 | 36 | # h3. This is a subhead |
|
37 | 37 | # |
|
38 | 38 | # This is a bit of paragraph. |
|
39 | 39 | # |
|
40 | 40 | # bq. This is a blockquote. |
|
41 | 41 | # |
|
42 | 42 | # = Writing Textile |
|
43 | 43 | # |
|
44 | 44 | # A Textile document consists of paragraphs. Paragraphs |
|
45 | 45 | # can be specially formatted by adding a small instruction |
|
46 | 46 | # to the beginning of the paragraph. |
|
47 | 47 | # |
|
48 | 48 | # h[n]. Header of size [n]. |
|
49 | 49 | # bq. Blockquote. |
|
50 | 50 | # # Numeric list. |
|
51 | 51 | # * Bulleted list. |
|
52 | 52 | # |
|
53 | 53 | # == Quick Phrase Modifiers |
|
54 | 54 | # |
|
55 | 55 | # Quick phrase modifiers are also included, to allow formatting |
|
56 | 56 | # of small portions of text within a paragraph. |
|
57 | 57 | # |
|
58 | 58 | # \_emphasis\_ |
|
59 | 59 | # \_\_italicized\_\_ |
|
60 | 60 | # \*strong\* |
|
61 | 61 | # \*\*bold\*\* |
|
62 | 62 | # ??citation?? |
|
63 | 63 | # -deleted text- |
|
64 | 64 | # +inserted text+ |
|
65 | 65 | # ^superscript^ |
|
66 | 66 | # ~subscript~ |
|
67 | 67 | # @code@ |
|
68 | 68 | # %(classname)span% |
|
69 | 69 | # |
|
70 | 70 | # ==notextile== (leave text alone) |
|
71 | 71 | # |
|
72 | 72 | # == Links |
|
73 | 73 | # |
|
74 | 74 | # To make a hypertext link, put the link text in "quotation |
|
75 | 75 | # marks" followed immediately by a colon and the URL of the link. |
|
76 | 76 | # |
|
77 | 77 | # Optional: text in (parentheses) following the link text, |
|
78 | 78 | # but before the closing quotation mark, will become a Title |
|
79 | 79 | # attribute for the link, visible as a tool tip when a cursor is above it. |
|
80 | 80 | # |
|
81 | 81 | # Example: |
|
82 | 82 | # |
|
83 | 83 | # "This is a link (This is a title) ":http://www.textism.com |
|
84 | 84 | # |
|
85 | 85 | # Will become: |
|
86 | 86 | # |
|
87 | 87 | # <a href="http://www.textism.com" title="This is a title">This is a link</a> |
|
88 | 88 | # |
|
89 | 89 | # == Images |
|
90 | 90 | # |
|
91 | 91 | # To insert an image, put the URL for the image inside exclamation marks. |
|
92 | 92 | # |
|
93 | 93 | # Optional: text that immediately follows the URL in (parentheses) will |
|
94 | 94 | # be used as the Alt text for the image. Images on the web should always |
|
95 | 95 | # have descriptive Alt text for the benefit of readers using non-graphical |
|
96 | 96 | # browsers. |
|
97 | 97 | # |
|
98 | 98 | # Optional: place a colon followed by a URL immediately after the |
|
99 | 99 | # closing ! to make the image into a link. |
|
100 | 100 | # |
|
101 | 101 | # Example: |
|
102 | 102 | # |
|
103 | 103 | # !http://www.textism.com/common/textist.gif(Textist)! |
|
104 | 104 | # |
|
105 | 105 | # Will become: |
|
106 | 106 | # |
|
107 | 107 | # <img src="http://www.textism.com/common/textist.gif" alt="Textist" /> |
|
108 | 108 | # |
|
109 | 109 | # With a link: |
|
110 | 110 | # |
|
111 | 111 | # !/common/textist.gif(Textist)!:http://textism.com |
|
112 | 112 | # |
|
113 | 113 | # Will become: |
|
114 | 114 | # |
|
115 | 115 | # <a href="http://textism.com"><img src="/common/textist.gif" alt="Textist" /></a> |
|
116 | 116 | # |
|
117 | 117 | # == Defining Acronyms |
|
118 | 118 | # |
|
119 | 119 | # HTML allows authors to define acronyms via the tag. The definition appears as a |
|
120 | 120 | # tool tip when a cursor hovers over the acronym. A crucial aid to clear writing, |
|
121 | 121 | # this should be used at least once for each acronym in documents where they appear. |
|
122 | 122 | # |
|
123 | 123 | # To quickly define an acronym in Textile, place the full text in (parentheses) |
|
124 | 124 | # immediately following the acronym. |
|
125 | 125 | # |
|
126 | 126 | # Example: |
|
127 | 127 | # |
|
128 | 128 | # ACLU(American Civil Liberties Union) |
|
129 | 129 | # |
|
130 | 130 | # Will become: |
|
131 | 131 | # |
|
132 | 132 | # <acronym title="American Civil Liberties Union">ACLU</acronym> |
|
133 | 133 | # |
|
134 | 134 | # == Adding Tables |
|
135 | 135 | # |
|
136 | 136 | # In Textile, simple tables can be added by seperating each column by |
|
137 | 137 | # a pipe. |
|
138 | 138 | # |
|
139 | 139 | # |a|simple|table|row| |
|
140 | 140 | # |And|Another|table|row| |
|
141 | 141 | # |
|
142 | 142 | # Attributes are defined by style definitions in parentheses. |
|
143 | 143 | # |
|
144 | 144 | # table(border:1px solid black). |
|
145 | 145 | # (background:#ddd;color:red). |{}| | | | |
|
146 | 146 | # |
|
147 | 147 | # == Using RedCloth |
|
148 | 148 | # |
|
149 | 149 | # RedCloth is simply an extension of the String class, which can handle |
|
150 | 150 | # Textile formatting. Use it like a String and output HTML with its |
|
151 | 151 | # RedCloth#to_html method. |
|
152 | 152 | # |
|
153 | 153 | # doc = RedCloth.new " |
|
154 | 154 | # |
|
155 | 155 | # h2. Test document |
|
156 | 156 | # |
|
157 | 157 | # Just a simple test." |
|
158 | 158 | # |
|
159 | 159 | # puts doc.to_html |
|
160 | 160 | # |
|
161 | 161 | # By default, RedCloth uses both Textile and Markdown formatting, with |
|
162 | 162 | # Textile formatting taking precedence. If you want to turn off Markdown |
|
163 | 163 | # formatting, to boost speed and limit the processor: |
|
164 | 164 | # |
|
165 | 165 | # class RedCloth::Textile.new( str ) |
|
166 | 166 | |
|
167 | 167 | class RedCloth3 < String |
|
168 | 168 | |
|
169 | 169 | VERSION = '3.0.4' |
|
170 | 170 | DEFAULT_RULES = [:textile, :markdown] |
|
171 | 171 | |
|
172 | 172 | # |
|
173 | 173 | # Two accessor for setting security restrictions. |
|
174 | 174 | # |
|
175 | 175 | # This is a nice thing if you're using RedCloth for |
|
176 | 176 | # formatting in public places (e.g. Wikis) where you |
|
177 | 177 | # don't want users to abuse HTML for bad things. |
|
178 | 178 | # |
|
179 | 179 | # If +:filter_html+ is set, HTML which wasn't |
|
180 | 180 | # created by the Textile processor will be escaped. |
|
181 | 181 | # |
|
182 | 182 | # If +:filter_styles+ is set, it will also disable |
|
183 | 183 | # the style markup specifier. ('{color: red}') |
|
184 | 184 | # |
|
185 | 185 | attr_accessor :filter_html, :filter_styles |
|
186 | 186 | |
|
187 | 187 | # |
|
188 | 188 | # Accessor for toggling hard breaks. |
|
189 | 189 | # |
|
190 | 190 | # If +:hard_breaks+ is set, single newlines will |
|
191 | 191 | # be converted to HTML break tags. This is the |
|
192 | 192 | # default behavior for traditional RedCloth. |
|
193 | 193 | # |
|
194 | 194 | attr_accessor :hard_breaks |
|
195 | 195 | |
|
196 | 196 | # Accessor for toggling lite mode. |
|
197 | 197 | # |
|
198 | 198 | # In lite mode, block-level rules are ignored. This means |
|
199 | 199 | # that tables, paragraphs, lists, and such aren't available. |
|
200 | 200 | # Only the inline markup for bold, italics, entities and so on. |
|
201 | 201 | # |
|
202 | 202 | # r = RedCloth.new( "And then? She *fell*!", [:lite_mode] ) |
|
203 | 203 | # r.to_html |
|
204 | 204 | # #=> "And then? She <strong>fell</strong>!" |
|
205 | 205 | # |
|
206 | 206 | attr_accessor :lite_mode |
|
207 | 207 | |
|
208 | 208 | # |
|
209 | 209 | # Accessor for toggling span caps. |
|
210 | 210 | # |
|
211 | 211 | # Textile places `span' tags around capitalized |
|
212 | 212 | # words by default, but this wreaks havoc on Wikis. |
|
213 | 213 | # If +:no_span_caps+ is set, this will be |
|
214 | 214 | # suppressed. |
|
215 | 215 | # |
|
216 | 216 | attr_accessor :no_span_caps |
|
217 | 217 | |
|
218 | 218 | # |
|
219 | 219 | # Establishes the markup predence. Available rules include: |
|
220 | 220 | # |
|
221 | 221 | # == Textile Rules |
|
222 | 222 | # |
|
223 | 223 | # The following textile rules can be set individually. Or add the complete |
|
224 | 224 | # set of rules with the single :textile rule, which supplies the rule set in |
|
225 | 225 | # the following precedence: |
|
226 | 226 | # |
|
227 | 227 | # refs_textile:: Textile references (i.e. [hobix]http://hobix.com/) |
|
228 | 228 | # block_textile_table:: Textile table block structures |
|
229 | 229 | # block_textile_lists:: Textile list structures |
|
230 | 230 | # block_textile_prefix:: Textile blocks with prefixes (i.e. bq., h2., etc.) |
|
231 | 231 | # inline_textile_image:: Textile inline images |
|
232 | 232 | # inline_textile_link:: Textile inline links |
|
233 | 233 | # inline_textile_span:: Textile inline spans |
|
234 | 234 | # glyphs_textile:: Textile entities (such as em-dashes and smart quotes) |
|
235 | 235 | # |
|
236 | 236 | # == Markdown |
|
237 | 237 | # |
|
238 | 238 | # refs_markdown:: Markdown references (for example: [hobix]: http://hobix.com/) |
|
239 | 239 | # block_markdown_setext:: Markdown setext headers |
|
240 | 240 | # block_markdown_atx:: Markdown atx headers |
|
241 | 241 | # block_markdown_rule:: Markdown horizontal rules |
|
242 | 242 | # block_markdown_bq:: Markdown blockquotes |
|
243 | 243 | # block_markdown_lists:: Markdown lists |
|
244 | 244 | # inline_markdown_link:: Markdown links |
|
245 | 245 | attr_accessor :rules |
|
246 | 246 | |
|
247 | 247 | # Returns a new RedCloth object, based on _string_ and |
|
248 | 248 | # enforcing all the included _restrictions_. |
|
249 | 249 | # |
|
250 | 250 | # r = RedCloth.new( "h1. A <b>bold</b> man", [:filter_html] ) |
|
251 | 251 | # r.to_html |
|
252 | 252 | # #=>"<h1>A <b>bold</b> man</h1>" |
|
253 | 253 | # |
|
254 | 254 | def initialize( string, restrictions = [] ) |
|
255 | 255 | restrictions.each { |r| method( "#{ r }=" ).call( true ) } |
|
256 | 256 | super( string ) |
|
257 | 257 | end |
|
258 | 258 | |
|
259 | 259 | # |
|
260 | 260 | # Generates HTML from the Textile contents. |
|
261 | 261 | # |
|
262 | 262 | # r = RedCloth.new( "And then? She *fell*!" ) |
|
263 | 263 | # r.to_html( true ) |
|
264 | 264 | # #=>"And then? She <strong>fell</strong>!" |
|
265 | 265 | # |
|
266 | 266 | def to_html( *rules ) |
|
267 | 267 | rules = DEFAULT_RULES if rules.empty? |
|
268 | 268 | # make our working copy |
|
269 | 269 | text = self.dup |
|
270 | 270 | |
|
271 | 271 | @urlrefs = {} |
|
272 | 272 | @shelf = [] |
|
273 | 273 | textile_rules = [:refs_textile, :block_textile_table, :block_textile_lists, |
|
274 | 274 | :block_textile_prefix, :inline_textile_image, :inline_textile_link, |
|
275 | 275 | :inline_textile_code, :inline_textile_span, :glyphs_textile] |
|
276 | 276 | markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule, |
|
277 | 277 | :block_markdown_bq, :block_markdown_lists, |
|
278 | 278 | :inline_markdown_reflink, :inline_markdown_link] |
|
279 | 279 | @rules = rules.collect do |rule| |
|
280 | 280 | case rule |
|
281 | 281 | when :markdown |
|
282 | 282 | markdown_rules |
|
283 | 283 | when :textile |
|
284 | 284 | textile_rules |
|
285 | 285 | else |
|
286 | 286 | rule |
|
287 | 287 | end |
|
288 | 288 | end.flatten |
|
289 | 289 | |
|
290 | 290 | # standard clean up |
|
291 | 291 | incoming_entities text |
|
292 | 292 | clean_white_space text |
|
293 | 293 | |
|
294 | 294 | # start processor |
|
295 | 295 | @pre_list = [] |
|
296 | 296 | rip_offtags text |
|
297 | 297 | no_textile text |
|
298 | 298 | escape_html_tags text |
|
299 | 299 | hard_break text |
|
300 | 300 | unless @lite_mode |
|
301 | 301 | refs text |
|
302 | 302 | # need to do this before text is split by #blocks |
|
303 | 303 | block_textile_quotes text |
|
304 | 304 | blocks text |
|
305 | 305 | end |
|
306 | 306 | inline text |
|
307 | 307 | smooth_offtags text |
|
308 | 308 | |
|
309 | 309 | retrieve text |
|
310 | 310 | |
|
311 | 311 | text.gsub!( /<\/?notextile>/, '' ) |
|
312 | 312 | text.gsub!( /x%x%/, '&' ) |
|
313 | 313 | clean_html text if filter_html |
|
314 | 314 | text.strip! |
|
315 | 315 | text |
|
316 | 316 | |
|
317 | 317 | end |
|
318 | 318 | |
|
319 | 319 | ####### |
|
320 | 320 | private |
|
321 | 321 | ####### |
|
322 | 322 | # |
|
323 | 323 | # Mapping of 8-bit ASCII codes to HTML numerical entity equivalents. |
|
324 | 324 | # (from PyTextile) |
|
325 | 325 | # |
|
326 | 326 | TEXTILE_TAGS = |
|
327 | 327 | |
|
328 | 328 | [[128, 8364], [129, 0], [130, 8218], [131, 402], [132, 8222], [133, 8230], |
|
329 | 329 | [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], |
|
330 | 330 | [140, 338], [141, 0], [142, 0], [143, 0], [144, 0], [145, 8216], [146, 8217], |
|
331 | 331 | [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], |
|
332 | 332 | [153, 8482], [154, 353], [155, 8250], [156, 339], [157, 0], [158, 0], [159, 376]]. |
|
333 | 333 | |
|
334 | 334 | collect! do |a, b| |
|
335 | 335 | [a.chr, ( b.zero? and "" or "&#{ b };" )] |
|
336 | 336 | end |
|
337 | 337 | |
|
338 | 338 | # |
|
339 | 339 | # Regular expressions to convert to HTML. |
|
340 | 340 | # |
|
341 | 341 | A_HLGN = /(?:(?:<>|<|>|\=|[()]+)+)/ |
|
342 | 342 | A_VLGN = /[\-^~]/ |
|
343 | 343 | C_CLAS = '(?:\([^)]+\))' |
|
344 | 344 | C_LNGE = '(?:\[[^\[\]]+\])' |
|
345 | 345 | C_STYL = '(?:\{[^}]+\})' |
|
346 | 346 | S_CSPN = '(?:\\\\\d+)' |
|
347 | 347 | S_RSPN = '(?:/\d+)' |
|
348 | 348 | A = "(?:#{A_HLGN}?#{A_VLGN}?|#{A_VLGN}?#{A_HLGN}?)" |
|
349 | 349 | S = "(?:#{S_CSPN}?#{S_RSPN}|#{S_RSPN}?#{S_CSPN}?)" |
|
350 | 350 | C = "(?:#{C_CLAS}?#{C_STYL}?#{C_LNGE}?|#{C_STYL}?#{C_LNGE}?#{C_CLAS}?|#{C_LNGE}?#{C_STYL}?#{C_CLAS}?)" |
|
351 | 351 | # PUNCT = Regexp::quote( '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ) |
|
352 | 352 | PUNCT = Regexp::quote( '!"#$%&\'*+,-./:;=?@\\^_`|~' ) |
|
353 | 353 | PUNCT_NOQ = Regexp::quote( '!"#$&\',./:;=?@\\`|' ) |
|
354 | 354 | PUNCT_Q = Regexp::quote( '*-_+^~%' ) |
|
355 | 355 | HYPERLINK = '(\S+?)([^\w\s/;=\?]*?)(?=\s|<|$)' |
|
356 | 356 | |
|
357 | 357 | # Text markup tags, don't conflict with block tags |
|
358 | 358 | SIMPLE_HTML_TAGS = [ |
|
359 | 359 | 'tt', 'b', 'i', 'big', 'small', 'em', 'strong', 'dfn', 'code', |
|
360 | 360 | 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'a', 'img', 'br', |
|
361 | 361 | 'br', 'map', 'q', 'sub', 'sup', 'span', 'bdo' |
|
362 | 362 | ] |
|
363 | 363 | |
|
364 | 364 | QTAGS = [ |
|
365 | 365 | ['**', 'b', :limit], |
|
366 | 366 | ['*', 'strong', :limit], |
|
367 | 367 | ['??', 'cite', :limit], |
|
368 | 368 | ['-', 'del', :limit], |
|
369 | 369 | ['__', 'i', :limit], |
|
370 | 370 | ['_', 'em', :limit], |
|
371 | 371 | ['%', 'span', :limit], |
|
372 | 372 | ['+', 'ins', :limit], |
|
373 | 373 | ['^', 'sup', :limit], |
|
374 | 374 | ['~', 'sub', :limit] |
|
375 | 375 | ] |
|
376 | 376 | QTAGS.collect! do |rc, ht, rtype| |
|
377 | 377 | rcq = Regexp::quote rc |
|
378 | 378 | re = |
|
379 | 379 | case rtype |
|
380 | 380 | when :limit |
|
381 | 381 | /(^|[>\s\(]) |
|
382 | 382 | (#{rcq}) |
|
383 | 383 | (#{C}) |
|
384 | 384 | (?::(\S+?))? |
|
385 | 385 | (\w|[^\s\-].*?[^\s\-]) |
|
386 | 386 | #{rcq} |
|
387 | 387 | (?=[[:punct:]]|\s|\)|$)/x |
|
388 | 388 | else |
|
389 | 389 | /(#{rcq}) |
|
390 | 390 | (#{C}) |
|
391 | 391 | (?::(\S+))? |
|
392 | 392 | (\w|[^\s\-].*?[^\s\-]) |
|
393 | 393 | #{rcq}/xm |
|
394 | 394 | end |
|
395 | 395 | [rc, ht, re, rtype] |
|
396 | 396 | end |
|
397 | 397 | |
|
398 | 398 | # Elements to handle |
|
399 | 399 | GLYPHS = [ |
|
400 | 400 | # [ /([^\s\[{(>])?\'([dmst]\b|ll\b|ve\b|\s|:|$)/, '\1’\2' ], # single closing |
|
401 | 401 | # [ /([^\s\[{(>#{PUNCT_Q}][#{PUNCT_Q}]*)\'/, '\1’' ], # single closing |
|
402 | 402 | # [ /\'(?=[#{PUNCT_Q}]*(s\b|[\s#{PUNCT_NOQ}]))/, '’' ], # single closing |
|
403 | 403 | # [ /\'/, '‘' ], # single opening |
|
404 | 404 | # [ /</, '<' ], # less-than |
|
405 | 405 | # [ />/, '>' ], # greater-than |
|
406 | 406 | # [ /([^\s\[{(])?"(\s|:|$)/, '\1”\2' ], # double closing |
|
407 | 407 | # [ /([^\s\[{(>#{PUNCT_Q}][#{PUNCT_Q}]*)"/, '\1”' ], # double closing |
|
408 | 408 | # [ /"(?=[#{PUNCT_Q}]*[\s#{PUNCT_NOQ}])/, '”' ], # double closing |
|
409 | 409 | # [ /"/, '“' ], # double opening |
|
410 | 410 | # [ /\b( )?\.{3}/, '\1…' ], # ellipsis |
|
411 | 411 | # [ /\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/, '<acronym title="\2">\1</acronym>' ], # 3+ uppercase acronym |
|
412 | 412 | # [ /(^|[^"][>\s])([A-Z][A-Z0-9 ]+[A-Z0-9])([^<A-Za-z0-9]|$)/, '\1<span class="caps">\2</span>\3', :no_span_caps ], # 3+ uppercase caps |
|
413 | 413 | # [ /(\.\s)?\s?--\s?/, '\1—' ], # em dash |
|
414 | 414 | # [ /\s->\s/, ' → ' ], # right arrow |
|
415 | 415 | # [ /\s-\s/, ' – ' ], # en dash |
|
416 | 416 | # [ /(\d+) ?x ?(\d+)/, '\1×\2' ], # dimension sign |
|
417 | 417 | # [ /\b ?[(\[]TM[\])]/i, '™' ], # trademark |
|
418 | 418 | # [ /\b ?[(\[]R[\])]/i, '®' ], # registered |
|
419 | 419 | # [ /\b ?[(\[]C[\])]/i, '©' ] # copyright |
|
420 | 420 | ] |
|
421 | 421 | |
|
422 | 422 | H_ALGN_VALS = { |
|
423 | 423 | '<' => 'left', |
|
424 | 424 | '=' => 'center', |
|
425 | 425 | '>' => 'right', |
|
426 | 426 | '<>' => 'justify' |
|
427 | 427 | } |
|
428 | 428 | |
|
429 | 429 | V_ALGN_VALS = { |
|
430 | 430 | '^' => 'top', |
|
431 | 431 | '-' => 'middle', |
|
432 | 432 | '~' => 'bottom' |
|
433 | 433 | } |
|
434 | 434 | |
|
435 | 435 | # |
|
436 | 436 | # Flexible HTML escaping |
|
437 | 437 | # |
|
438 | 438 | def htmlesc( str, mode=:Quotes ) |
|
439 | 439 | if str |
|
440 | 440 | str.gsub!( '&', '&' ) |
|
441 | 441 | str.gsub!( '"', '"' ) if mode != :NoQuotes |
|
442 | 442 | str.gsub!( "'", ''' ) if mode == :Quotes |
|
443 | 443 | str.gsub!( '<', '<') |
|
444 | 444 | str.gsub!( '>', '>') |
|
445 | 445 | end |
|
446 | 446 | str |
|
447 | 447 | end |
|
448 | 448 | |
|
449 | 449 | # Search and replace for Textile glyphs (quotes, dashes, other symbols) |
|
450 | 450 | def pgl( text ) |
|
451 | 451 | #GLYPHS.each do |re, resub, tog| |
|
452 | 452 | # next if tog and method( tog ).call |
|
453 | 453 | # text.gsub! re, resub |
|
454 | 454 | #end |
|
455 | 455 | text.gsub!(/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/) do |m| |
|
456 | 456 | "<acronym title=\"#{htmlesc $2}\">#{$1}</acronym>" |
|
457 | 457 | end |
|
458 | 458 | end |
|
459 | 459 | |
|
460 | 460 | # Parses Textile attribute lists and builds an HTML attribute string |
|
461 | 461 | def pba( text_in, element = "" ) |
|
462 | 462 | |
|
463 | 463 | return '' unless text_in |
|
464 | 464 | |
|
465 | 465 | style = [] |
|
466 | 466 | text = text_in.dup |
|
467 | 467 | if element == 'td' |
|
468 | 468 | colspan = $1 if text =~ /\\(\d+)/ |
|
469 | 469 | rowspan = $1 if text =~ /\/(\d+)/ |
|
470 | 470 | style << "vertical-align:#{ v_align( $& ) };" if text =~ A_VLGN |
|
471 | 471 | end |
|
472 | 472 | |
|
473 | 473 | style << "#{ htmlesc $1 };" if text.sub!( /\{([^}]*)\}/, '' ) && !filter_styles |
|
474 | 474 | |
|
475 | 475 | lang = $1 if |
|
476 | 476 | text.sub!( /\[([^)]+?)\]/, '' ) |
|
477 | 477 | |
|
478 | 478 | cls = $1 if |
|
479 | 479 | text.sub!( /\(([^()]+?)\)/, '' ) |
|
480 | 480 | |
|
481 | 481 | style << "padding-left:#{ $1.length }em;" if |
|
482 | 482 | text.sub!( /([(]+)/, '' ) |
|
483 | 483 | |
|
484 | 484 | style << "padding-right:#{ $1.length }em;" if text.sub!( /([)]+)/, '' ) |
|
485 | 485 | |
|
486 | 486 | style << "text-align:#{ h_align( $& ) };" if text =~ A_HLGN |
|
487 | 487 | |
|
488 | 488 | cls, id = $1, $2 if cls =~ /^(.*?)#(.*)$/ |
|
489 | 489 | |
|
490 | 490 | atts = '' |
|
491 | 491 | atts << " style=\"#{ style.join }\"" unless style.empty? |
|
492 | 492 | atts << " class=\"#{ cls }\"" unless cls.to_s.empty? |
|
493 | 493 | atts << " lang=\"#{ lang }\"" if lang |
|
494 | 494 | atts << " id=\"#{ id }\"" if id |
|
495 | 495 | atts << " colspan=\"#{ colspan }\"" if colspan |
|
496 | 496 | atts << " rowspan=\"#{ rowspan }\"" if rowspan |
|
497 | 497 | |
|
498 | 498 | atts |
|
499 | 499 | end |
|
500 | 500 | |
|
501 | 501 | TABLE_RE = /^(?:table(_?#{S}#{A}#{C})\. ?\n)?^(#{A}#{C}\.? ?\|.*?\|)(\n\n|\Z)/m |
|
502 | 502 | |
|
503 | 503 | # Parses a Textile table block, building HTML from the result. |
|
504 | 504 | def block_textile_table( text ) |
|
505 | 505 | text.gsub!( TABLE_RE ) do |matches| |
|
506 | 506 | |
|
507 | 507 | tatts, fullrow = $~[1..2] |
|
508 | 508 | tatts = pba( tatts, 'table' ) |
|
509 | 509 | tatts = shelve( tatts ) if tatts |
|
510 | 510 | rows = [] |
|
511 | 511 | |
|
512 | 512 | fullrow.each_line do |row| |
|
513 | 513 | ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m |
|
514 | 514 | cells = [] |
|
515 | 515 | row.split( /(\|)(?![^\[\|]*\]\])/ )[1..-2].each do |cell| |
|
516 | 516 | next if cell == '|' |
|
517 | 517 | ctyp = 'd' |
|
518 | 518 | ctyp = 'h' if cell =~ /^_/ |
|
519 | 519 | |
|
520 | 520 | catts = '' |
|
521 | 521 | catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. ?)(.*)/ |
|
522 | 522 | |
|
523 | 523 | catts = shelve( catts ) if catts |
|
524 | 524 | cells << "\t\t\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>" |
|
525 | 525 | end |
|
526 | 526 | ratts = shelve( ratts ) if ratts |
|
527 | 527 | rows << "\t\t<tr#{ ratts }>\n#{ cells.join( "\n" ) }\n\t\t</tr>" |
|
528 | 528 | end |
|
529 | 529 | "\t<table#{ tatts }>\n#{ rows.join( "\n" ) }\n\t</table>\n\n" |
|
530 | 530 | end |
|
531 | 531 | end |
|
532 | 532 | |
|
533 | 533 | LISTS_RE = /^([#*]+?#{C} .*?)$(?![^#*])/m |
|
534 | 534 | LISTS_CONTENT_RE = /^([#*]+)(#{A}#{C}) (.*)$/m |
|
535 | 535 | |
|
536 | 536 | # Parses Textile lists and generates HTML |
|
537 | 537 | def block_textile_lists( text ) |
|
538 | 538 | text.gsub!( LISTS_RE ) do |match| |
|
539 | 539 | lines = match.split( /\n/ ) |
|
540 | 540 | last_line = -1 |
|
541 | 541 | depth = [] |
|
542 | 542 | lines.each_with_index do |line, line_id| |
|
543 | 543 | if line =~ LISTS_CONTENT_RE |
|
544 | 544 | tl,atts,content = $~[1..3] |
|
545 | 545 | if depth.last |
|
546 | 546 | if depth.last.length > tl.length |
|
547 | 547 | (depth.length - 1).downto(0) do |i| |
|
548 | 548 | break if depth[i].length == tl.length |
|
549 | 549 | lines[line_id - 1] << "</li>\n\t</#{ lT( depth[i] ) }l>\n\t" |
|
550 | 550 | depth.pop |
|
551 | 551 | end |
|
552 | 552 | end |
|
553 | 553 | if depth.last and depth.last.length == tl.length |
|
554 | 554 | lines[line_id - 1] << '</li>' |
|
555 | 555 | end |
|
556 | 556 | end |
|
557 | 557 | unless depth.last == tl |
|
558 | 558 | depth << tl |
|
559 | 559 | atts = pba( atts ) |
|
560 | 560 | atts = shelve( atts ) if atts |
|
561 | 561 | lines[line_id] = "\t<#{ lT(tl) }l#{ atts }>\n\t<li>#{ content }" |
|
562 | 562 | else |
|
563 | 563 | lines[line_id] = "\t\t<li>#{ content }" |
|
564 | 564 | end |
|
565 | 565 | last_line = line_id |
|
566 | 566 | |
|
567 | 567 | else |
|
568 | 568 | last_line = line_id |
|
569 | 569 | end |
|
570 | 570 | if line_id - last_line > 1 or line_id == lines.length - 1 |
|
571 | 571 | depth.delete_if do |v| |
|
572 | 572 | lines[last_line] << "</li>\n\t</#{ lT( v ) }l>" |
|
573 | 573 | end |
|
574 | 574 | end |
|
575 | 575 | end |
|
576 | 576 | lines.join( "\n" ) |
|
577 | 577 | end |
|
578 | 578 | end |
|
579 | 579 | |
|
580 | 580 | QUOTES_RE = /(^>+([^\n]*?)\n?)+/m |
|
581 | 581 | QUOTES_CONTENT_RE = /^([> ]+)(.*)$/m |
|
582 | 582 | |
|
583 | 583 | def block_textile_quotes( text ) |
|
584 | 584 | text.gsub!( QUOTES_RE ) do |match| |
|
585 | 585 | lines = match.split( /\n/ ) |
|
586 | 586 | quotes = '' |
|
587 | 587 | indent = 0 |
|
588 | 588 | lines.each do |line| |
|
589 | 589 | line =~ QUOTES_CONTENT_RE |
|
590 | 590 | bq,content = $1, $2 |
|
591 | 591 | l = bq.count('>') |
|
592 | 592 | if l != indent |
|
593 | 593 | quotes << ("\n\n" + (l>indent ? '<blockquote>' * (l-indent) : '</blockquote>' * (indent-l)) + "\n\n") |
|
594 | 594 | indent = l |
|
595 | 595 | end |
|
596 | 596 | quotes << (content + "\n") |
|
597 | 597 | end |
|
598 | 598 | quotes << ("\n" + '</blockquote>' * indent + "\n\n") |
|
599 | 599 | quotes |
|
600 | 600 | end |
|
601 | 601 | end |
|
602 | 602 | |
|
603 | 603 | CODE_RE = /(\W) |
|
604 | 604 | @ |
|
605 | 605 | (?:\|(\w+?)\|)? |
|
606 | 606 | (.+?) |
|
607 | 607 | @ |
|
608 | 608 | (?=\W)/x |
|
609 | 609 | |
|
610 | 610 | def inline_textile_code( text ) |
|
611 | 611 | text.gsub!( CODE_RE ) do |m| |
|
612 | 612 | before,lang,code,after = $~[1..4] |
|
613 | 613 | lang = " lang=\"#{ lang }\"" if lang |
|
614 | 614 | rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }" ) |
|
615 | 615 | end |
|
616 | 616 | end |
|
617 | 617 | |
|
618 | 618 | def lT( text ) |
|
619 | 619 | text =~ /\#$/ ? 'o' : 'u' |
|
620 | 620 | end |
|
621 | 621 | |
|
622 | 622 | def hard_break( text ) |
|
623 | 623 | text.gsub!( /(.)\n(?!\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks |
|
624 | 624 | end |
|
625 | 625 | |
|
626 | 626 | BLOCKS_GROUP_RE = /\n{2,}(?! )/m |
|
627 | 627 | |
|
628 | 628 | def blocks( text, deep_code = false ) |
|
629 | 629 | text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk| |
|
630 | 630 | plain = blk !~ /\A[#*> ]/ |
|
631 | 631 | |
|
632 | 632 | # skip blocks that are complex HTML |
|
633 | 633 | if blk =~ /^<\/?(\w+).*>/ and not SIMPLE_HTML_TAGS.include? $1 |
|
634 | 634 | blk |
|
635 | 635 | else |
|
636 | 636 | # search for indentation levels |
|
637 | 637 | blk.strip! |
|
638 | 638 | if blk.empty? |
|
639 | 639 | blk |
|
640 | 640 | else |
|
641 | 641 | code_blk = nil |
|
642 | 642 | blk.gsub!( /((?:\n(?:\n^ +[^\n]*)+)+)/m ) do |iblk| |
|
643 | 643 | flush_left iblk |
|
644 | 644 | blocks iblk, plain |
|
645 | 645 | iblk.gsub( /^(\S)/, "\t\\1" ) |
|
646 | 646 | if plain |
|
647 | 647 | code_blk = iblk; "" |
|
648 | 648 | else |
|
649 | 649 | iblk |
|
650 | 650 | end |
|
651 | 651 | end |
|
652 | 652 | |
|
653 | 653 | block_applied = 0 |
|
654 | 654 | @rules.each do |rule_name| |
|
655 | 655 | block_applied += 1 if ( rule_name.to_s.match /^block_/ and method( rule_name ).call( blk ) ) |
|
656 | 656 | end |
|
657 | 657 | if block_applied.zero? |
|
658 | 658 | if deep_code |
|
659 | 659 | blk = "\t<pre><code>#{ blk }</code></pre>" |
|
660 | 660 | else |
|
661 | 661 | blk = "\t<p>#{ blk }</p>" |
|
662 | 662 | end |
|
663 | 663 | end |
|
664 | 664 | # hard_break blk |
|
665 | 665 | blk + "\n#{ code_blk }" |
|
666 | 666 | end |
|
667 | 667 | end |
|
668 | 668 | |
|
669 | 669 | end.join( "\n\n" ) ) |
|
670 | 670 | end |
|
671 | 671 | |
|
672 | 672 | def textile_bq( tag, atts, cite, content ) |
|
673 | 673 | cite, cite_title = check_refs( cite ) |
|
674 | 674 | cite = " cite=\"#{ cite }\"" if cite |
|
675 | 675 | atts = shelve( atts ) if atts |
|
676 | 676 | "\t<blockquote#{ cite }>\n\t\t<p#{ atts }>#{ content }</p>\n\t</blockquote>" |
|
677 | 677 | end |
|
678 | 678 | |
|
679 | 679 | def textile_p( tag, atts, cite, content ) |
|
680 | 680 | atts = shelve( atts ) if atts |
|
681 | 681 | "\t<#{ tag }#{ atts }>#{ content }</#{ tag }>" |
|
682 | 682 | end |
|
683 | 683 | |
|
684 | 684 | alias textile_h1 textile_p |
|
685 | 685 | alias textile_h2 textile_p |
|
686 | 686 | alias textile_h3 textile_p |
|
687 | 687 | alias textile_h4 textile_p |
|
688 | 688 | alias textile_h5 textile_p |
|
689 | 689 | alias textile_h6 textile_p |
|
690 | 690 | |
|
691 | 691 | def textile_fn_( tag, num, atts, cite, content ) |
|
692 | 692 | atts << " id=\"fn#{ num }\" class=\"footnote\"" |
|
693 | 693 | content = "<sup>#{ num }</sup> #{ content }" |
|
694 | 694 | atts = shelve( atts ) if atts |
|
695 | 695 | "\t<p#{ atts }>#{ content }</p>" |
|
696 | 696 | end |
|
697 | 697 | |
|
698 | 698 | BLOCK_RE = /^(([a-z]+)(\d*))(#{A}#{C})\.(?::(\S+))? (.*)$/m |
|
699 | 699 | |
|
700 | 700 | def block_textile_prefix( text ) |
|
701 | 701 | if text =~ BLOCK_RE |
|
702 | 702 | tag,tagpre,num,atts,cite,content = $~[1..6] |
|
703 | 703 | atts = pba( atts ) |
|
704 | 704 | |
|
705 | 705 | # pass to prefix handler |
|
706 | 706 | if respond_to? "textile_#{ tag }", true |
|
707 | 707 | text.gsub!( $&, method( "textile_#{ tag }" ).call( tag, atts, cite, content ) ) |
|
708 | 708 | elsif respond_to? "textile_#{ tagpre }_", true |
|
709 | 709 | text.gsub!( $&, method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) ) |
|
710 | 710 | end |
|
711 | 711 | end |
|
712 | 712 | end |
|
713 | 713 | |
|
714 | 714 | SETEXT_RE = /\A(.+?)\n([=-])[=-]* *$/m |
|
715 | 715 | def block_markdown_setext( text ) |
|
716 | 716 | if text =~ SETEXT_RE |
|
717 | 717 | tag = if $2 == "="; "h1"; else; "h2"; end |
|
718 | 718 | blk, cont = "<#{ tag }>#{ $1 }</#{ tag }>", $' |
|
719 | 719 | blocks cont |
|
720 | 720 | text.replace( blk + cont ) |
|
721 | 721 | end |
|
722 | 722 | end |
|
723 | 723 | |
|
724 | 724 | ATX_RE = /\A(\#{1,6}) # $1 = string of #'s |
|
725 | 725 | [ ]* |
|
726 | 726 | (.+?) # $2 = Header text |
|
727 | 727 | [ ]* |
|
728 | 728 | \#* # optional closing #'s (not counted) |
|
729 | 729 | $/x |
|
730 | 730 | def block_markdown_atx( text ) |
|
731 | 731 | if text =~ ATX_RE |
|
732 | 732 | tag = "h#{ $1.length }" |
|
733 | 733 | blk, cont = "<#{ tag }>#{ $2 }</#{ tag }>\n\n", $' |
|
734 | 734 | blocks cont |
|
735 | 735 | text.replace( blk + cont ) |
|
736 | 736 | end |
|
737 | 737 | end |
|
738 | 738 | |
|
739 | 739 | MARKDOWN_BQ_RE = /\A(^ *> ?.+$(.+\n)*\n*)+/m |
|
740 | 740 | |
|
741 | 741 | def block_markdown_bq( text ) |
|
742 | 742 | text.gsub!( MARKDOWN_BQ_RE ) do |blk| |
|
743 | 743 | blk.gsub!( /^ *> ?/, '' ) |
|
744 | 744 | flush_left blk |
|
745 | 745 | blocks blk |
|
746 | 746 | blk.gsub!( /^(\S)/, "\t\\1" ) |
|
747 | 747 | "<blockquote>\n#{ blk }\n</blockquote>\n\n" |
|
748 | 748 | end |
|
749 | 749 | end |
|
750 | 750 | |
|
751 | 751 | MARKDOWN_RULE_RE = /^(#{ |
|
752 | 752 | ['*', '-', '_'].collect { |ch| ' ?(' + Regexp::quote( ch ) + ' ?){3,}' }.join( '|' ) |
|
753 | 753 | })$/ |
|
754 | 754 | |
|
755 | 755 | def block_markdown_rule( text ) |
|
756 | 756 | text.gsub!( MARKDOWN_RULE_RE ) do |blk| |
|
757 | 757 | "<hr />" |
|
758 | 758 | end |
|
759 | 759 | end |
|
760 | 760 | |
|
761 | 761 | # XXX TODO XXX |
|
762 | 762 | def block_markdown_lists( text ) |
|
763 | 763 | end |
|
764 | 764 | |
|
765 | 765 | def inline_textile_span( text ) |
|
766 | 766 | QTAGS.each do |qtag_rc, ht, qtag_re, rtype| |
|
767 | 767 | text.gsub!( qtag_re ) do |m| |
|
768 | 768 | |
|
769 | 769 | case rtype |
|
770 | 770 | when :limit |
|
771 | 771 | sta,qtag,atts,cite,content = $~[1..5] |
|
772 | 772 | else |
|
773 | 773 | qtag,atts,cite,content = $~[1..4] |
|
774 | 774 | sta = '' |
|
775 | 775 | end |
|
776 | 776 | atts = pba( atts ) |
|
777 | 777 | atts << " cite=\"#{ cite }\"" if cite |
|
778 | 778 | atts = shelve( atts ) if atts |
|
779 | 779 | |
|
780 | 780 | "#{ sta }<#{ ht }#{ atts }>#{ content }</#{ ht }>" |
|
781 | 781 | |
|
782 | 782 | end |
|
783 | 783 | end |
|
784 | 784 | end |
|
785 | 785 | |
|
786 | 786 | LINK_RE = / |
|
787 | 787 | ([\s\[{(]|[#{PUNCT}])? # $pre |
|
788 | 788 | " # start |
|
789 | 789 | (#{C}) # $atts |
|
790 | 790 | ([^"\n]+?) # $text |
|
791 | 791 | \s? |
|
792 | 792 | (?:\(([^)]+?)\)(?="))? # $title |
|
793 | 793 | ": |
|
794 |
( |
|
|
794 | ( # $url | |
|
795 | (\/|https?:\/\/|s?ftps?:\/\/|www\.) | |
|
796 | [\w\/]\S+? | |
|
797 | ) | |
|
795 | 798 | (\/)? # $slash |
|
796 | 799 | ([^\w\=\/;\(\)]*?) # $post |
|
797 | 800 | (?=<|\s|$) |
|
798 | 801 | /x |
|
799 | 802 | #" |
|
800 | 803 | def inline_textile_link( text ) |
|
801 | 804 | text.gsub!( LINK_RE ) do |m| |
|
802 |
pre,atts,text,title,url,slash,post = $~[1.. |
|
|
805 | pre,atts,text,title,url,proto,slash,post = $~[1..8] | |
|
803 | 806 | |
|
804 | 807 | url, url_title = check_refs( url ) |
|
805 | 808 | title ||= url_title |
|
806 | 809 | |
|
807 | 810 | # Idea below : an URL with unbalanced parethesis and |
|
808 | 811 | # ending by ')' is put into external parenthesis |
|
809 | 812 | if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) ) |
|
810 | 813 | url=url[0..-2] # discard closing parenth from url |
|
811 | 814 | post = ")"+post # add closing parenth to post |
|
812 | 815 | end |
|
813 | 816 | atts = pba( atts ) |
|
814 | 817 | atts = " href=\"#{ url }#{ slash }\"#{ atts }" |
|
815 | 818 | atts << " title=\"#{ htmlesc title }\"" if title |
|
816 | 819 | atts = shelve( atts ) if atts |
|
817 | 820 | |
|
818 | 821 | external = (url =~ /^https?:\/\//) ? ' class="external"' : '' |
|
819 | 822 | |
|
820 | 823 | "#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }" |
|
821 | 824 | end |
|
822 | 825 | end |
|
823 | 826 | |
|
824 | 827 | MARKDOWN_REFLINK_RE = / |
|
825 | 828 | \[([^\[\]]+)\] # $text |
|
826 | 829 | [ ]? # opt. space |
|
827 | 830 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
828 | 831 | \[(.*?)\] # $id |
|
829 | 832 | /x |
|
830 | 833 | |
|
831 | 834 | def inline_markdown_reflink( text ) |
|
832 | 835 | text.gsub!( MARKDOWN_REFLINK_RE ) do |m| |
|
833 | 836 | text, id = $~[1..2] |
|
834 | 837 | |
|
835 | 838 | if id.empty? |
|
836 | 839 | url, title = check_refs( text ) |
|
837 | 840 | else |
|
838 | 841 | url, title = check_refs( id ) |
|
839 | 842 | end |
|
840 | 843 | |
|
841 | 844 | atts = " href=\"#{ url }\"" |
|
842 | 845 | atts << " title=\"#{ title }\"" if title |
|
843 | 846 | atts = shelve( atts ) |
|
844 | 847 | |
|
845 | 848 | "<a#{ atts }>#{ text }</a>" |
|
846 | 849 | end |
|
847 | 850 | end |
|
848 | 851 | |
|
849 | 852 | MARKDOWN_LINK_RE = / |
|
850 | 853 | \[([^\[\]]+)\] # $text |
|
851 | 854 | \( # open paren |
|
852 | 855 | [ \t]* # opt space |
|
853 | 856 | <?(.+?)>? # $href |
|
854 | 857 | [ \t]* # opt space |
|
855 | 858 | (?: # whole title |
|
856 | 859 | (['"]) # $quote |
|
857 | 860 | (.*?) # $title |
|
858 | 861 | \3 # matching quote |
|
859 | 862 | )? # title is optional |
|
860 | 863 | \) |
|
861 | 864 | /x |
|
862 | 865 | |
|
863 | 866 | def inline_markdown_link( text ) |
|
864 | 867 | text.gsub!( MARKDOWN_LINK_RE ) do |m| |
|
865 | 868 | text, url, quote, title = $~[1..4] |
|
866 | 869 | |
|
867 | 870 | atts = " href=\"#{ url }\"" |
|
868 | 871 | atts << " title=\"#{ title }\"" if title |
|
869 | 872 | atts = shelve( atts ) |
|
870 | 873 | |
|
871 | 874 | "<a#{ atts }>#{ text }</a>" |
|
872 | 875 | end |
|
873 | 876 | end |
|
874 | 877 | |
|
875 | 878 | TEXTILE_REFS_RE = /(^ *)\[([^\[\n]+?)\](#{HYPERLINK})(?=\s|$)/ |
|
876 | 879 | MARKDOWN_REFS_RE = /(^ *)\[([^\n]+?)\]:\s+<?(#{HYPERLINK})>?(?:\s+"((?:[^"]|\\")+)")?(?=\s|$)/m |
|
877 | 880 | |
|
878 | 881 | def refs( text ) |
|
879 | 882 | @rules.each do |rule_name| |
|
880 | 883 | method( rule_name ).call( text ) if rule_name.to_s.match /^refs_/ |
|
881 | 884 | end |
|
882 | 885 | end |
|
883 | 886 | |
|
884 | 887 | def refs_textile( text ) |
|
885 | 888 | text.gsub!( TEXTILE_REFS_RE ) do |m| |
|
886 | 889 | flag, url = $~[2..3] |
|
887 | 890 | @urlrefs[flag.downcase] = [url, nil] |
|
888 | 891 | nil |
|
889 | 892 | end |
|
890 | 893 | end |
|
891 | 894 | |
|
892 | 895 | def refs_markdown( text ) |
|
893 | 896 | text.gsub!( MARKDOWN_REFS_RE ) do |m| |
|
894 | 897 | flag, url = $~[2..3] |
|
895 | 898 | title = $~[6] |
|
896 | 899 | @urlrefs[flag.downcase] = [url, title] |
|
897 | 900 | nil |
|
898 | 901 | end |
|
899 | 902 | end |
|
900 | 903 | |
|
901 | 904 | def check_refs( text ) |
|
902 | 905 | ret = @urlrefs[text.downcase] if text |
|
903 | 906 | ret || [text, nil] |
|
904 | 907 | end |
|
905 | 908 | |
|
906 | 909 | IMAGE_RE = / |
|
907 | 910 | (<p>|.|^) # start of line? |
|
908 | 911 | \! # opening |
|
909 | 912 | (\<|\=|\>)? # optional alignment atts |
|
910 | 913 | (#{C}) # optional style,class atts |
|
911 | 914 | (?:\. )? # optional dot-space |
|
912 | 915 | ([^\s(!]+?) # presume this is the src |
|
913 | 916 | \s? # optional space |
|
914 | 917 | (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title |
|
915 | 918 | \! # closing |
|
916 | 919 | (?::#{ HYPERLINK })? # optional href |
|
917 | 920 | /x |
|
918 | 921 | |
|
919 | 922 | def inline_textile_image( text ) |
|
920 | 923 | text.gsub!( IMAGE_RE ) do |m| |
|
921 | 924 | stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8] |
|
922 | 925 | htmlesc title |
|
923 | 926 | atts = pba( atts ) |
|
924 | 927 | atts = " src=\"#{ url }\"#{ atts }" |
|
925 | 928 | atts << " title=\"#{ title }\"" if title |
|
926 | 929 | atts << " alt=\"#{ title }\"" |
|
927 | 930 | # size = @getimagesize($url); |
|
928 | 931 | # if($size) $atts.= " $size[3]"; |
|
929 | 932 | |
|
930 | 933 | href, alt_title = check_refs( href ) if href |
|
931 | 934 | url, url_title = check_refs( url ) |
|
932 | 935 | |
|
933 | 936 | out = '' |
|
934 | 937 | out << "<a#{ shelve( " href=\"#{ href }\"" ) }>" if href |
|
935 | 938 | out << "<img#{ shelve( atts ) } />" |
|
936 | 939 | out << "</a>#{ href_a1 }#{ href_a2 }" if href |
|
937 | 940 | |
|
938 | 941 | if algn |
|
939 | 942 | algn = h_align( algn ) |
|
940 | 943 | if stln == "<p>" |
|
941 | 944 | out = "<p style=\"float:#{ algn }\">#{ out }" |
|
942 | 945 | else |
|
943 | 946 | out = "#{ stln }<div style=\"float:#{ algn }\">#{ out }</div>" |
|
944 | 947 | end |
|
945 | 948 | else |
|
946 | 949 | out = stln + out |
|
947 | 950 | end |
|
948 | 951 | |
|
949 | 952 | out |
|
950 | 953 | end |
|
951 | 954 | end |
|
952 | 955 | |
|
953 | 956 | def shelve( val ) |
|
954 | 957 | @shelf << val |
|
955 | 958 | " :redsh##{ @shelf.length }:" |
|
956 | 959 | end |
|
957 | 960 | |
|
958 | 961 | def retrieve( text ) |
|
959 | 962 | @shelf.each_with_index do |r, i| |
|
960 | 963 | text.gsub!( " :redsh##{ i + 1 }:", r ) |
|
961 | 964 | end |
|
962 | 965 | end |
|
963 | 966 | |
|
964 | 967 | def incoming_entities( text ) |
|
965 | 968 | ## turn any incoming ampersands into a dummy character for now. |
|
966 | 969 | ## This uses a negative lookahead for alphanumerics followed by a semicolon, |
|
967 | 970 | ## implying an incoming html entity, to be skipped |
|
968 | 971 | |
|
969 | 972 | text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" ) |
|
970 | 973 | end |
|
971 | 974 | |
|
972 | 975 | def no_textile( text ) |
|
973 | 976 | text.gsub!( /(^|\s)==([^=]+.*?)==(\s|$)?/, |
|
974 | 977 | '\1<notextile>\2</notextile>\3' ) |
|
975 | 978 | text.gsub!( /^ *==([^=]+.*?)==/m, |
|
976 | 979 | '\1<notextile>\2</notextile>\3' ) |
|
977 | 980 | end |
|
978 | 981 | |
|
979 | 982 | def clean_white_space( text ) |
|
980 | 983 | # normalize line breaks |
|
981 | 984 | text.gsub!( /\r\n/, "\n" ) |
|
982 | 985 | text.gsub!( /\r/, "\n" ) |
|
983 | 986 | text.gsub!( /\t/, ' ' ) |
|
984 | 987 | text.gsub!( /^ +$/, '' ) |
|
985 | 988 | text.gsub!( /\n{3,}/, "\n\n" ) |
|
986 | 989 | text.gsub!( /"$/, "\" " ) |
|
987 | 990 | |
|
988 | 991 | # if entire document is indented, flush |
|
989 | 992 | # to the left side |
|
990 | 993 | flush_left text |
|
991 | 994 | end |
|
992 | 995 | |
|
993 | 996 | def flush_left( text ) |
|
994 | 997 | indt = 0 |
|
995 | 998 | if text =~ /^ / |
|
996 | 999 | while text !~ /^ {#{indt}}\S/ |
|
997 | 1000 | indt += 1 |
|
998 | 1001 | end unless text.empty? |
|
999 | 1002 | if indt.nonzero? |
|
1000 | 1003 | text.gsub!( /^ {#{indt}}/, '' ) |
|
1001 | 1004 | end |
|
1002 | 1005 | end |
|
1003 | 1006 | end |
|
1004 | 1007 | |
|
1005 | 1008 | def footnote_ref( text ) |
|
1006 | 1009 | text.gsub!( /\b\[([0-9]+?)\](\s)?/, |
|
1007 | 1010 | '<sup><a href="#fn\1">\1</a></sup>\2' ) |
|
1008 | 1011 | end |
|
1009 | 1012 | |
|
1010 | 1013 | OFFTAGS = /(code|pre|kbd|notextile)/ |
|
1011 | 1014 | OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }|\Z)/mi |
|
1012 | 1015 | OFFTAG_OPEN = /<#{ OFFTAGS }/ |
|
1013 | 1016 | OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/ |
|
1014 | 1017 | HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m |
|
1015 | 1018 | ALLTAG_MATCH = /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m |
|
1016 | 1019 | |
|
1017 | 1020 | def glyphs_textile( text, level = 0 ) |
|
1018 | 1021 | if text !~ HASTAG_MATCH |
|
1019 | 1022 | pgl text |
|
1020 | 1023 | footnote_ref text |
|
1021 | 1024 | else |
|
1022 | 1025 | codepre = 0 |
|
1023 | 1026 | text.gsub!( ALLTAG_MATCH ) do |line| |
|
1024 | 1027 | ## matches are off if we're between <code>, <pre> etc. |
|
1025 | 1028 | if $1 |
|
1026 | 1029 | if line =~ OFFTAG_OPEN |
|
1027 | 1030 | codepre += 1 |
|
1028 | 1031 | elsif line =~ OFFTAG_CLOSE |
|
1029 | 1032 | codepre -= 1 |
|
1030 | 1033 | codepre = 0 if codepre < 0 |
|
1031 | 1034 | end |
|
1032 | 1035 | elsif codepre.zero? |
|
1033 | 1036 | glyphs_textile( line, level + 1 ) |
|
1034 | 1037 | else |
|
1035 | 1038 | htmlesc( line, :NoQuotes ) |
|
1036 | 1039 | end |
|
1037 | 1040 | # p [level, codepre, line] |
|
1038 | 1041 | |
|
1039 | 1042 | line |
|
1040 | 1043 | end |
|
1041 | 1044 | end |
|
1042 | 1045 | end |
|
1043 | 1046 | |
|
1044 | 1047 | def rip_offtags( text ) |
|
1045 | 1048 | if text =~ /<.*>/ |
|
1046 | 1049 | ## strip and encode <pre> content |
|
1047 | 1050 | codepre, used_offtags = 0, {} |
|
1048 | 1051 | text.gsub!( OFFTAG_MATCH ) do |line| |
|
1049 | 1052 | if $3 |
|
1050 | 1053 | offtag, aftertag = $4, $5 |
|
1051 | 1054 | codepre += 1 |
|
1052 | 1055 | used_offtags[offtag] = true |
|
1053 | 1056 | if codepre - used_offtags.length > 0 |
|
1054 | 1057 | htmlesc( line, :NoQuotes ) |
|
1055 | 1058 | @pre_list.last << line |
|
1056 | 1059 | line = "" |
|
1057 | 1060 | else |
|
1058 | 1061 | htmlesc( aftertag, :NoQuotes ) if aftertag |
|
1059 | 1062 | line = "<redpre##{ @pre_list.length }>" |
|
1060 | 1063 | $3.match(/<#{ OFFTAGS }([^>]*)>/) |
|
1061 | 1064 | tag = $1 |
|
1062 | 1065 | $2.to_s.match(/(class\=\S+)/i) |
|
1063 | 1066 | tag << " #{$1}" if $1 |
|
1064 | 1067 | @pre_list << "<#{ tag }>#{ aftertag }" |
|
1065 | 1068 | end |
|
1066 | 1069 | elsif $1 and codepre > 0 |
|
1067 | 1070 | if codepre - used_offtags.length > 0 |
|
1068 | 1071 | htmlesc( line, :NoQuotes ) |
|
1069 | 1072 | @pre_list.last << line |
|
1070 | 1073 | line = "" |
|
1071 | 1074 | end |
|
1072 | 1075 | codepre -= 1 unless codepre.zero? |
|
1073 | 1076 | used_offtags = {} if codepre.zero? |
|
1074 | 1077 | end |
|
1075 | 1078 | line |
|
1076 | 1079 | end |
|
1077 | 1080 | end |
|
1078 | 1081 | text |
|
1079 | 1082 | end |
|
1080 | 1083 | |
|
1081 | 1084 | def smooth_offtags( text ) |
|
1082 | 1085 | unless @pre_list.empty? |
|
1083 | 1086 | ## replace <pre> content |
|
1084 | 1087 | text.gsub!( /<redpre#(\d+)>/ ) { @pre_list[$1.to_i] } |
|
1085 | 1088 | end |
|
1086 | 1089 | end |
|
1087 | 1090 | |
|
1088 | 1091 | def inline( text ) |
|
1089 | 1092 | [/^inline_/, /^glyphs_/].each do |meth_re| |
|
1090 | 1093 | @rules.each do |rule_name| |
|
1091 | 1094 | method( rule_name ).call( text ) if rule_name.to_s.match( meth_re ) |
|
1092 | 1095 | end |
|
1093 | 1096 | end |
|
1094 | 1097 | end |
|
1095 | 1098 | |
|
1096 | 1099 | def h_align( text ) |
|
1097 | 1100 | H_ALGN_VALS[text] |
|
1098 | 1101 | end |
|
1099 | 1102 | |
|
1100 | 1103 | def v_align( text ) |
|
1101 | 1104 | V_ALGN_VALS[text] |
|
1102 | 1105 | end |
|
1103 | 1106 | |
|
1104 | 1107 | def textile_popup_help( name, windowW, windowH ) |
|
1105 | 1108 | ' <a target="_blank" href="http://hobix.com/textile/#' + helpvar + '" onclick="window.open(this.href, \'popupwindow\', \'width=' + windowW + ',height=' + windowH + ',scrollbars,resizable\'); return false;">' + name + '</a><br />' |
|
1106 | 1109 | end |
|
1107 | 1110 | |
|
1108 | 1111 | # HTML cleansing stuff |
|
1109 | 1112 | BASIC_TAGS = { |
|
1110 | 1113 | 'a' => ['href', 'title'], |
|
1111 | 1114 | 'img' => ['src', 'alt', 'title'], |
|
1112 | 1115 | 'br' => [], |
|
1113 | 1116 | 'i' => nil, |
|
1114 | 1117 | 'u' => nil, |
|
1115 | 1118 | 'b' => nil, |
|
1116 | 1119 | 'pre' => nil, |
|
1117 | 1120 | 'kbd' => nil, |
|
1118 | 1121 | 'code' => ['lang'], |
|
1119 | 1122 | 'cite' => nil, |
|
1120 | 1123 | 'strong' => nil, |
|
1121 | 1124 | 'em' => nil, |
|
1122 | 1125 | 'ins' => nil, |
|
1123 | 1126 | 'sup' => nil, |
|
1124 | 1127 | 'sub' => nil, |
|
1125 | 1128 | 'del' => nil, |
|
1126 | 1129 | 'table' => nil, |
|
1127 | 1130 | 'tr' => nil, |
|
1128 | 1131 | 'td' => ['colspan', 'rowspan'], |
|
1129 | 1132 | 'th' => nil, |
|
1130 | 1133 | 'ol' => nil, |
|
1131 | 1134 | 'ul' => nil, |
|
1132 | 1135 | 'li' => nil, |
|
1133 | 1136 | 'p' => nil, |
|
1134 | 1137 | 'h1' => nil, |
|
1135 | 1138 | 'h2' => nil, |
|
1136 | 1139 | 'h3' => nil, |
|
1137 | 1140 | 'h4' => nil, |
|
1138 | 1141 | 'h5' => nil, |
|
1139 | 1142 | 'h6' => nil, |
|
1140 | 1143 | 'blockquote' => ['cite'] |
|
1141 | 1144 | } |
|
1142 | 1145 | |
|
1143 | 1146 | def clean_html( text, tags = BASIC_TAGS ) |
|
1144 | 1147 | text.gsub!( /<!\[CDATA\[/, '' ) |
|
1145 | 1148 | text.gsub!( /<(\/*)(\w+)([^>]*)>/ ) do |
|
1146 | 1149 | raw = $~ |
|
1147 | 1150 | tag = raw[2].downcase |
|
1148 | 1151 | if tags.has_key? tag |
|
1149 | 1152 | pcs = [tag] |
|
1150 | 1153 | tags[tag].each do |prop| |
|
1151 | 1154 | ['"', "'", ''].each do |q| |
|
1152 | 1155 | q2 = ( q != '' ? q : '\s' ) |
|
1153 | 1156 | if raw[3] =~ /#{prop}\s*=\s*#{q}([^#{q2}]+)#{q}/i |
|
1154 | 1157 | attrv = $1 |
|
1155 | 1158 | next if prop == 'src' and attrv =~ %r{^(?!http)\w+:} |
|
1156 | 1159 | pcs << "#{prop}=\"#{$1.gsub('"', '\\"')}\"" |
|
1157 | 1160 | break |
|
1158 | 1161 | end |
|
1159 | 1162 | end |
|
1160 | 1163 | end if tags[tag] |
|
1161 | 1164 | "<#{raw[1]}#{pcs.join " "}>" |
|
1162 | 1165 | else |
|
1163 | 1166 | " " |
|
1164 | 1167 | end |
|
1165 | 1168 | end |
|
1166 | 1169 | end |
|
1167 | 1170 | |
|
1168 | 1171 | ALLOWED_TAGS = %w(redpre pre code notextile) |
|
1169 | 1172 | |
|
1170 | 1173 | def escape_html_tags(text) |
|
1171 | 1174 | text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' unless $3.blank?}" } |
|
1172 | 1175 | end |
|
1173 | 1176 | end |
|
1174 | 1177 |
General Comments 0
You need to be logged in to leave comments.
Login now