Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Redmine
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
Redmine
Commits
f5d619f5
Commit
f5d619f5
authored
Nov 18, 2011
by
jplang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wiki: allows single section edit (#2222).
git-svn-id:
https://svn.redmine.org/redmine/trunk@7829
e93f8b46-1217-0410-a6f0-8f06a7374b81
parent
5a8fd2f6
Changes
55
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
440 additions
and
41 deletions
+440
-41
app/controllers/wiki_controller.rb
app/controllers/wiki_controller.rb
+19
-2
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+47
-4
app/views/wiki/_content.html.erb
app/views/wiki/_content.html.erb
+3
-2
app/views/wiki/edit.html.erb
app/views/wiki/edit.html.erb
+5
-1
config/locales/bg.yml
config/locales/bg.yml
+1
-0
config/locales/bs.yml
config/locales/bs.yml
+1
-0
config/locales/ca.yml
config/locales/ca.yml
+1
-0
config/locales/cs.yml
config/locales/cs.yml
+1
-0
config/locales/da.yml
config/locales/da.yml
+1
-0
config/locales/de.yml
config/locales/de.yml
+1
-0
config/locales/el.yml
config/locales/el.yml
+1
-0
config/locales/en-GB.yml
config/locales/en-GB.yml
+1
-0
config/locales/en.yml
config/locales/en.yml
+1
-0
config/locales/es.yml
config/locales/es.yml
+1
-0
config/locales/eu.yml
config/locales/eu.yml
+1
-0
config/locales/fa.yml
config/locales/fa.yml
+1
-0
config/locales/fi.yml
config/locales/fi.yml
+1
-0
config/locales/fr.yml
config/locales/fr.yml
+1
-0
config/locales/gl.yml
config/locales/gl.yml
+1
-0
config/locales/he.yml
config/locales/he.yml
+1
-0
config/locales/hr.yml
config/locales/hr.yml
+1
-0
config/locales/hu.yml
config/locales/hu.yml
+1
-0
config/locales/id.yml
config/locales/id.yml
+1
-0
config/locales/it.yml
config/locales/it.yml
+1
-0
config/locales/ja.yml
config/locales/ja.yml
+1
-0
config/locales/ko.yml
config/locales/ko.yml
+1
-0
config/locales/lt.yml
config/locales/lt.yml
+1
-0
config/locales/lv.yml
config/locales/lv.yml
+1
-0
config/locales/mk.yml
config/locales/mk.yml
+1
-0
config/locales/mn.yml
config/locales/mn.yml
+1
-0
config/locales/nl.yml
config/locales/nl.yml
+1
-0
config/locales/no.yml
config/locales/no.yml
+1
-0
config/locales/pl.yml
config/locales/pl.yml
+1
-0
config/locales/pt-BR.yml
config/locales/pt-BR.yml
+1
-0
config/locales/pt.yml
config/locales/pt.yml
+1
-0
config/locales/ro.yml
config/locales/ro.yml
+1
-0
config/locales/ru.yml
config/locales/ru.yml
+1
-0
config/locales/sk.yml
config/locales/sk.yml
+1
-0
config/locales/sl.yml
config/locales/sl.yml
+1
-0
config/locales/sr-YU.yml
config/locales/sr-YU.yml
+1
-0
config/locales/sr.yml
config/locales/sr.yml
+1
-0
config/locales/sv.yml
config/locales/sv.yml
+1
-0
config/locales/th.yml
config/locales/th.yml
+1
-0
config/locales/tr.yml
config/locales/tr.yml
+1
-0
config/locales/uk.yml
config/locales/uk.yml
+1
-0
config/locales/vi.yml
config/locales/vi.yml
+1
-0
config/locales/zh-TW.yml
config/locales/zh-TW.yml
+1
-0
config/locales/zh.yml
config/locales/zh.yml
+1
-0
lib/redmine/wiki_formatting.rb
lib/redmine/wiki_formatting.rb
+7
-31
lib/redmine/wiki_formatting/textile/formatter.rb
lib/redmine/wiki_formatting/textile/formatter.rb
+63
-0
public/stylesheets/application.css
public/stylesheets/application.css
+3
-0
test/fixtures/wiki_contents.yml
test/fixtures/wiki_contents.yml
+22
-1
test/fixtures/wiki_pages.yml
test/fixtures/wiki_pages.yml
+7
-0
test/functional/wiki_controller_test.rb
test/functional/wiki_controller_test.rb
+115
-0
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
...nit/lib/redmine/wiki_formatting/textile_formatter_test.rb
+105
-0
No files found.
app/controllers/wiki_controller.rb
View file @
f5d619f5
...
...
@@ -100,6 +100,13 @@ class WikiController < ApplicationController
# To prevent StaleObjectError exception when reverting to a previous version
@content
.
version
=
@page
.
content
.
version
@text
=
@content
.
text
if
params
[
:section
].
present?
@section
=
params
[
:section
].
to_i
@text
,
@section_hash
=
Redmine
::
WikiFormatting
.
formatter
.
new
(
@text
).
get_section
(
@section
)
render_404
if
@text
.
blank?
end
end
verify
:method
=>
:put
,
:only
=>
:update
,
:render
=>
{
:nothing
=>
true
,
:status
=>
:method_not_allowed
}
...
...
@@ -120,7 +127,17 @@ class WikiController < ApplicationController
redirect_to
:action
=>
'show'
,
:project_id
=>
@project
,
:id
=>
@page
.
title
return
end
@content
.
attributes
=
params
[
:content
]
@content
.
comments
=
params
[
:content
][
:comments
]
@text
=
params
[
:content
][
:text
]
if
params
[
:section
].
present?
@section
=
params
[
:section
].
to_i
@section_hash
=
params
[
:section_hash
]
@content
.
text
=
Redmine
::
WikiFormatting
.
formatter
.
new
(
@content
.
text
).
update_section
(
params
[
:section
].
to_i
,
@text
,
@section_hash
)
else
@content
.
version
=
params
[
:content
][
:version
]
@content
.
text
=
@text
end
@content
.
author
=
User
.
current
# if page is new @page.save will also save content, but not if page isn't a new record
if
(
@page
.
new_record?
?
@page
.
save
:
@content
.
save
)
...
...
@@ -132,7 +149,7 @@ class WikiController < ApplicationController
render
:action
=>
'edit'
end
rescue
ActiveRecord
::
StaleObjectError
rescue
ActiveRecord
::
StaleObjectError
,
Redmine
::
WikiFormatting
::
StaleSectionError
# Optimistic locking exception
flash
.
now
[
:error
]
=
l
(
:notice_locking_conflict
)
render
:action
=>
'edit'
...
...
app/helpers/application_helper.rb
View file @
f5d619f5
...
...
@@ -486,11 +486,11 @@ module ApplicationHelper
project
=
options
[
:project
]
||
@project
||
(
obj
&&
obj
.
respond_to?
(
:project
)
?
obj
.
project
:
nil
)
only_path
=
options
.
delete
(
:only_path
)
==
false
?
false
:
true
text
=
Redmine
::
WikiFormatting
.
to_html
(
Setting
.
text_formatting
,
text
,
:object
=>
obj
,
:attribute
=>
attr
)
{
|
macro
,
args
|
exec_macro
(
macro
,
obj
,
args
)
}
text
=
Redmine
::
WikiFormatting
.
to_html
(
Setting
.
text_formatting
,
text
,
:object
=>
obj
,
:attribute
=>
attr
)
@parsed_headings
=
[]
text
=
parse_non_pre_blocks
(
text
)
do
|
text
|
[
:parse_
inline_attachments
,
:parse_wiki_links
,
:parse_redmine_link
s
,
:parse_headings
].
each
do
|
method_name
|
[
:parse_
sections
,
:parse_inline_attachments
,
:parse_wiki_links
,
:parse_redmine_links
,
:parse_macro
s
,
:parse_headings
].
each
do
|
method_name
|
send
method_name
,
text
,
project
,
obj
,
attr
,
only_path
,
options
end
end
...
...
@@ -728,7 +728,23 @@ module ApplicationHelper
end
end
HEADING_RE
=
/<h(1|2|3|4)( [^>]+)?>(.+?)<\/h(1|2|3|4)>/i
unless
const_defined?
(
:HEADING_RE
)
HEADING_RE
=
/(<h(1|2|3|4)( [^>]+)?>(.+?)<\/h(1|2|3|4)>)/i
unless
const_defined?
(
:HEADING_RE
)
def
parse_sections
(
text
,
project
,
obj
,
attr
,
only_path
,
options
)
return
unless
options
[
:edit_section_links
]
section
=
0
text
.
gsub!
(
HEADING_RE
)
do
section
+=
1
if
section
>
1
content_tag
(
'div'
,
link_to
(
image_tag
(
'edit.png'
),
options
[
:edit_section_links
].
merge
(
:section
=>
section
)),
:class
=>
'contextual'
,
:title
=>
l
(
:button_edit_section
))
+
$1
else
$1
end
end
end
# Headings and TOC
# Adds ids and links to headings unless options[:headings] is set to false
...
...
@@ -736,7 +752,7 @@ module ApplicationHelper
return
if
options
[
:headings
]
==
false
text
.
gsub!
(
HEADING_RE
)
do
level
,
attrs
,
content
=
$
1
.
to_i
,
$2
,
$3
level
,
attrs
,
content
=
$
2
.
to_i
,
$3
,
$4
item
=
strip_tags
(
content
).
strip
anchor
=
sanitize_anchor_name
(
item
)
# used for single-file wiki export
...
...
@@ -746,6 +762,33 @@ module ApplicationHelper
end
end
MACROS_RE
=
/
(!)? # escaping
(
\{\{ # opening tag
([\w]+) # macro name
(\(([^\}]*)\))? # optional arguments
\}\} # closing tag
)
/x
unless
const_defined?
(
:MACROS_RE
)
# Macros substitution
def
parse_macros
(
text
,
project
,
obj
,
attr
,
only_path
,
options
)
text
.
gsub!
(
MACROS_RE
)
do
esc
,
all
,
macro
=
$1
,
$2
,
$3
.
downcase
args
=
(
$5
||
''
).
split
(
','
).
each
(
&
:strip
)
if
esc
.
nil?
begin
exec_macro
(
macro
,
obj
,
args
)
rescue
=>
e
"<div class=
\"
flash error
\"
>Error executing the <strong>
#{
macro
}
</strong> macro (
#{
e
}
)</div>"
end
||
all
else
all
end
end
end
TOC_RE
=
/<p>\{\{([<>]?)toc\}\}<\/p>/i
unless
const_defined?
(
:TOC_RE
)
# Renders the TOC with given headings
...
...
app/views/wiki/_content.html.erb
View file @
f5d619f5
<div
class=
"wiki"
>
<%=
textilizable
content
,
:text
,
:attachments
=>
content
.
page
.
attachments
%>
<div
class=
"wiki wiki-page"
>
<%=
textilizable
content
,
:text
,
:attachments
=>
content
.
page
.
attachments
,
:edit_section_links
=>
(
content
.
is_a?
(
WikiContent
)
&&
@editable
&&
User
.
current
.
allowed_to?
(
:edit_wiki_pages
,
@page
.
project
)
&&
{
:controller
=>
'wiki'
,
:action
=>
'edit'
,
:project_id
=>
@page
.
project
,
:id
=>
@page
.
title
})
%>
</div>
app/views/wiki/edit.html.erb
View file @
f5d619f5
...
...
@@ -4,9 +4,13 @@
<%
form_for
:content
,
@content
,
:url
=>
{
:action
=>
'update'
,
:id
=>
@page
.
title
},
:html
=>
{
:method
=>
:put
,
:multipart
=>
true
,
:id
=>
'wiki_form'
}
do
|
f
|
%>
<%=
f
.
hidden_field
:version
%>
<%
if
@section
%>
<%=
hidden_field_tag
'section'
,
@section
%>
<%=
hidden_field_tag
'section_hash'
,
@section_hash
%>
<%
end
%>
<%=
error_messages_for
'content'
%>
<p>
<%=
f
.
text_area
:
text
,
:cols
=>
100
,
:rows
=>
25
,
:class
=>
'wiki-edit'
,
:accesskey
=>
accesskey
(
:edit
)
%>
</p>
<p>
<%=
text_area_tag
'content[text]'
,
@
text
,
:cols
=>
100
,
:rows
=>
25
,
:class
=>
'wiki-edit'
,
:accesskey
=>
accesskey
(
:edit
)
%>
</p>
<p><label>
<%=
l
(
:field_comments
)
%>
</label><br
/>
<%=
f
.
text_field
:comments
,
:size
=>
120
%>
</p>
<p><label>
<%=
l
(
:label_attachment_plural
)
%>
</label><br
/>
<%=
render
:partial
=>
'attachments/form'
%>
</p>
...
...
config/locales/bg.yml
View file @
f5d619f5
...
...
@@ -999,3 +999,4 @@ bg:
description_date_range_interval
:
Изберете диапазон чрез задаване на начална и крайна дати
description_date_from
:
Въведете начална дата
description_date_to
:
Въведете крайна дата
button_edit_section
:
Edit this section
config/locales/bs.yml
View file @
f5d619f5
...
...
@@ -1015,3 +1015,4 @@ bs:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/ca.yml
View file @
f5d619f5
...
...
@@ -1004,3 +1004,4 @@ ca:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/cs.yml
View file @
f5d619f5
...
...
@@ -1005,3 +1005,4 @@ cs:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/da.yml
View file @
f5d619f5
...
...
@@ -1018,3 +1018,4 @@ da:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/de.yml
View file @
f5d619f5
...
...
@@ -1022,3 +1022,4 @@ de:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/el.yml
View file @
f5d619f5
...
...
@@ -1001,3 +1001,4 @@ el:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/en-GB.yml
View file @
f5d619f5
...
...
@@ -1004,3 +1004,4 @@ en-GB:
description_selected_columns
:
Selected Columns
label_parent_revision
:
Parent
label_child_revision
:
Child
button_edit_section
:
Edit this section
config/locales/en.yml
View file @
f5d619f5
...
...
@@ -874,6 +874,7 @@ en:
button_quote
:
Quote
button_duplicate
:
Duplicate
button_show
:
Show
button_edit_section
:
Edit this section
status_active
:
active
status_registered
:
registered
...
...
config/locales/es.yml
View file @
f5d619f5
...
...
@@ -1038,3 +1038,4 @@ es:
label_parent_revision
:
Parent
label_child_revision
:
Child
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/eu.yml
View file @
f5d619f5
...
...
@@ -1005,3 +1005,4 @@ eu:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/fa.yml
View file @
f5d619f5
...
...
@@ -1004,3 +1004,4 @@ fa:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/fi.yml
View file @
f5d619f5
...
...
@@ -1022,3 +1022,4 @@ fi:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/fr.yml
View file @
f5d619f5
...
...
@@ -850,6 +850,7 @@ fr:
button_quote
:
Citer
button_duplicate
:
Dupliquer
button_show
:
Afficher
button_edit_section
:
Modifier cette section
status_active
:
actif
status_registered
:
enregistré
...
...
config/locales/gl.yml
View file @
f5d619f5
...
...
@@ -1013,3 +1013,4 @@ gl:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/he.yml
View file @
f5d619f5
...
...
@@ -1006,3 +1006,4 @@ he:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/hr.yml
View file @
f5d619f5
...
...
@@ -1008,3 +1008,4 @@ hr:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/hu.yml
View file @
f5d619f5
...
...
@@ -1020,3 +1020,4 @@
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/id.yml
View file @
f5d619f5
...
...
@@ -1009,3 +1009,4 @@ id:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/it.yml
View file @
f5d619f5
...
...
@@ -1002,3 +1002,4 @@ it:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/ja.yml
View file @
f5d619f5
...
...
@@ -1031,3 +1031,4 @@ ja:
description_selected_columns
:
Selected Columns
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/ko.yml
View file @
f5d619f5
...
...
@@ -1053,3 +1053,4 @@ ko:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/lt.yml
View file @
f5d619f5
...
...
@@ -1061,3 +1061,4 @@ lt:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/lv.yml
View file @
f5d619f5
...
...
@@ -996,3 +996,4 @@ lv:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/mk.yml
View file @
f5d619f5
...
...
@@ -1001,3 +1001,4 @@ mk:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/mn.yml
View file @
f5d619f5
...
...
@@ -1002,3 +1002,4 @@ mn:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/nl.yml
View file @
f5d619f5
...
...
@@ -983,3 +983,4 @@ nl:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/no.yml
View file @
f5d619f5
...
...
@@ -991,3 +991,4 @@
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/pl.yml
View file @
f5d619f5
...
...
@@ -1018,3 +1018,4 @@ pl:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/pt-BR.yml
View file @
f5d619f5
...
...
@@ -1022,3 +1022,4 @@ pt-BR:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/pt.yml
View file @
f5d619f5
...
...
@@ -1006,3 +1006,4 @@ pt:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/ro.yml
View file @
f5d619f5
...
...
@@ -994,3 +994,4 @@ ro:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/ru.yml
View file @
f5d619f5
...
...
@@ -1114,3 +1114,4 @@ ru:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/sk.yml
View file @
f5d619f5
...
...
@@ -996,3 +996,4 @@ sk:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/sl.yml
View file @
f5d619f5
...
...
@@ -1001,3 +1001,4 @@ sl:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/sr-YU.yml
View file @
f5d619f5
...
...
@@ -1001,3 +1001,4 @@ sr-YU:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/sr.yml
View file @
f5d619f5
...
...
@@ -1002,3 +1002,4 @@ sr:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/sv.yml
View file @
f5d619f5
...
...
@@ -1042,3 +1042,4 @@ sv:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/th.yml
View file @
f5d619f5
...
...
@@ -998,3 +998,4 @@ th:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/tr.yml
View file @
f5d619f5
...
...
@@ -1020,3 +1020,4 @@ tr:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/uk.yml
View file @
f5d619f5
...
...
@@ -997,3 +997,4 @@ uk:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/vi.yml
View file @
f5d619f5
...
...
@@ -1052,3 +1052,4 @@ vi:
label_child_revision
:
Child
error_scm_annotate_big_text_file
:
The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date
:
Use current date as start date for new issues
button_edit_section
:
Edit this section
config/locales/zh-TW.yml
View file @
f5d619f5
...
...
@@ -1081,3 +1081,4 @@
description_date_range_interval
:
選擇起始與結束日期以設定範圍區間
description_date_from
:
輸入起始日期
description_date_to
:
輸入結束日期
button_edit_section
:
Edit this section
config/locales/zh.yml
View file @
f5d619f5
...
...
@@ -1003,3 +1003,4 @@ zh:
label_child_revision
:
子修订
error_scm_annotate_big_text_file
:
输入文本内容超长,无法输入。
setting_default_issue_start_date_to_creation_date
:
使用当前日期作为新问题的开始日期
button_edit_section
:
Edit this section
lib/redmine/wiki_formatting.rb
View file @
f5d619f5
...
...
@@ -17,6 +17,8 @@
module
Redmine
module
WikiFormatting
class
StaleSectionError
<
Exception
;
end
@@formatters
=
{}
class
<<
self
...
...
@@ -29,6 +31,10 @@ module Redmine
@@formatters
[
name
.
to_s
]
=
{
:formatter
=>
formatter
,
:helper
=>
helper
}
end
def
formatter
formatter_for
(
Setting
.
text_formatting
)
end
def
formatter_for
(
name
)
entry
=
@@formatters
[
name
.
to_s
]
(
entry
&&
entry
[
:formatter
])
||
Redmine
::
WikiFormatting
::
NullFormatter
::
Formatter
...
...
@@ -43,7 +49,7 @@ module Redmine
@@formatters
.
keys
.
map
end
def
to_html
(
format
,
text
,
options
=
{}
,
&
block
)
def
to_html
(
format
,
text
,
options
=
{})
text
=
if
Setting
.
cache_formatted_text?
&&
text
.
size
>
2
.
kilobyte
&&
cache_store
&&
cache_key
=
cache_key_for
(
format
,
options
[
:object
],
options
[
:attribute
])
# Text retrieved from the cache store may be frozen
# We need to dup it so we can do in-place substitutions with gsub!
...
...
@@ -53,9 +59,6 @@ module Redmine
else
formatter_for
(
format
).
new
(
text
).
to_html
end
if
block_given?
execute_macros
(
text
,
block
)
end
text
end
...
...
@@ -70,33 +73,6 @@ module Redmine
def
cache_store
ActionController
::
Base
.
cache_store
end
MACROS_RE
=
/
(!)? # escaping
(
\{\{ # opening tag
([\w]+) # macro name
(\(([^\}]*)\))? # optional arguments
\}\} # closing tag
)
/x
unless
const_defined?
(
:MACROS_RE
)
# Macros substitution
def
execute_macros
(
text
,
macros_runner
)
text
.
gsub!
(
MACROS_RE
)
do
esc
,
all
,
macro
=
$1
,
$2
,
$3
.
downcase
args
=
(
$5
||
''
).
split
(
','
).
each
(
&
:strip
)
if
esc
.
nil?
begin
macros_runner
.
call
(
macro
,
args
)
rescue
=>
e
"<div class=
\"
flash error
\"
>Error executing the <strong>
#{
macro
}
</strong> macro (
#{
e
}
)</div>"
end
||
all
else
all
end
end
end
end
# Default formatter module
...
...
lib/redmine/wiki_formatting/textile/formatter.rb
View file @
f5d619f5
...
...
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require
'redcloth3'
require
'digest/md5'
module
Redmine
module
WikiFormatting
...
...
@@ -38,6 +39,68 @@ module Redmine
super
(
*
RULES
).
to_s
end
def
get_section
(
index
)
section
=
extract_sections
(
index
)[
1
]
hash
=
Digest
::
MD5
.
hexdigest
(
section
)
return
section
,
hash
end
def
update_section
(
index
,
update
,
hash
=
nil
)
t
=
extract_sections
(
index
)
if
hash
.
present?
&&
hash
!=
Digest
::
MD5
.
hexdigest
(
t
[
1
])
raise
Redmine
::
WikiFormatting
::
StaleSectionError
end
t
[
1
]
=
update
unless
t
[
1
].
blank?
t
.
reject
(
&
:blank?
).
join
"
\n\n
"
end
def
extract_sections
(
index
)
@pre_list
=
[]
text
=
self
.
dup
rip_offtags
text
before
=
''
s
=
''
after
=
''
i
=
0
l
=
1
started
=
false
ended
=
false
text
.
scan
(
/(((?:.*?)(\A|\r?\n\r?\n))(h(\d+)(
#{
A
}#{
C
}
)\.(?::(\S+))? (.*?)$)|.*)/m
).
each
do
|
all
,
content
,
lf
,
heading
,
level
|
if
heading
.
nil?
if
ended
after
<<
all
elsif
started
s
<<
all
else
before
<<
all
end
break
end
i
+=
1
if
ended
after
<<
all
elsif
i
==
index
l
=
level
.
to_i
before
<<
content
s
<<
heading
started
=
true
elsif
i
>
index
s
<<
content
if
level
.
to_i
>
l
s
<<
heading
else
after
<<
heading
ended
=
true
end
else
before
<<
all
end
end
sections
=
[
before
.
strip
,
s
.
strip
,
after
.
strip
]
sections
.
each
{
|
section
|
smooth_offtags
section
}
sections
end
private
# Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
...
...
public/stylesheets/application.css
View file @
f5d619f5
...
...
@@ -358,6 +358,9 @@ table#time-report tbody tr.last-level { font-style: normal; color: #555; }
table
#time-report
tbody
tr
.total
{
font-style
:
normal
;
font-weight
:
bold
;
color
:
#555
;
background-color
:
#EEEEEE
;
}
table
#time-report
.hours-dec
{
font-size
:
0.9em
;
}
div
.wiki-page
.contextual
a
{
opacity
:
0.4
}
div
.wiki-page
.contextual
a
:hover
{
opacity
:
1
}
form
.attributes
{
margin-bottom
:
8px
;
}
form
.attributes
p
{
padding-top
:
1px
;
padding-bottom
:
2px
;
}
form
.attributes
select
{
width
:
60%
;
}
...
...
test/fixtures/wiki_contents.yml
View file @
f5d619f5
...
...
@@ -103,4 +103,25 @@ wiki_contents_010:
version
:
1
author_id
:
1
comments
:
\ No newline at end of file
wiki_contents_011
:
text
:
|-
h1. Title
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
h2. Heading 1
Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
Cras ipsum felis, ultrices at porttitor vel, faucibus eu nunc.
h2. Heading 2
Morbi facilisis accumsan orci non pharetra.
updated_on
:
2007-03-08 00:18:07 +01:00
page_id
:
11
id
:
11
version
:
3
author_id
:
1
comments
:
test/fixtures/wiki_pages.yml
View file @
f5d619f5
...
...
@@ -69,3 +69,10 @@ wiki_pages_010:
wiki_id
:
1
protected
:
false
parent_id
:
wiki_pages_011
:
created_on
:
2007-03-08 00:18:07 +01:00
title
:
Page_with_sections
id
:
11
wiki_id
:
1
protected
:
false
parent_id
:
test/functional/wiki_controller_test.rb
View file @
f5d619f5
...
...
@@ -118,6 +118,44 @@ class WikiControllerTest < ActionController::TestCase
assert_equal
'testfile.txt'
,
page
.
attachments
.
first
.
filename
end
def
test_edit_page
@request
.
session
[
:user_id
]
=
2
get
:edit
,
:project_id
=>
'ecookbook'
,
:id
=>
'Another_page'
assert_response
:success
assert_template
'edit'