Render Textile and Markdown files in the repository browser (#16849).

Patch by Takenori TAKAKI.


git-svn-id: http://svn.redmine.org/redmine/trunk@21013 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2021-05-28 08:37:30 +00:00
parent 66fc9f463d
commit 5ac8f70d10
5 changed files with 38 additions and 7 deletions

View File

@@ -10,6 +10,10 @@
<% if Redmine::MimeType.is_type?('image', @path) %> <% if Redmine::MimeType.is_type?('image', @path) %>
<%= render :partial => 'common/image', :locals => {:path => @raw_url, :alt => @path} %> <%= render :partial => 'common/image', :locals => {:path => @raw_url, :alt => @path} %>
<% elsif Redmine::MimeType.of(@path) == 'text/x-textile' %>
<%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'textile', :markup_text => @content} %>
<% elsif Redmine::MimeType.of(@path) == 'text/markdown' %>
<%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'markdown', :markup_text => @content} %>
<% elsif @content %> <% elsif @content %>
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
<% else %> <% else %>

View File

@@ -789,7 +789,7 @@ span.pagination {margin-left:3px; color:#888; display:block;}
font-weight: bold; font-weight: bold;
} }
span.pagination>span {white-space:nowrap;} span.pagination>span {white-space:nowrap;}
.controller-attachments.action-show span.pagination{ .controller-attachments.action-show span.pagination, .controller-repositories.action-entry span.pagination {
display: block; display: block;
margin-top: 1.2em; margin-top: 1.2em;
} }
@@ -1804,7 +1804,7 @@ img {
max-width: 100%; max-width: 100%;
} }
.filecontent-container > .filecontent.wiki { .filecontent.wiki {
position: relative; position: relative;
padding: 1em; padding: 1em;
border: 1px solid #e4e4e4; border: 1px solid #e4e4e4;

View File

@@ -27,7 +27,7 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
PRJ_ID = 3 PRJ_ID = 3
NUM_REV = 12 NUM_REV = 13
def setup def setup
super super
@@ -204,7 +204,8 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest
) )
assert_response :success assert_response :success
assert_select 'table.changesets tbody' do assert_select 'table.changesets tbody' do
assert_select 'tr', 7 assert_select 'tr', 8
assert_select 'tr td.id a', :text => '13'
assert_select 'tr td.id a', :text => '12' assert_select 'tr td.id a', :text => '12'
assert_select 'tr td.id a', :text => '10' assert_select 'tr td.id a', :text => '10'
assert_select 'tr td.id a', :text => '9' assert_select 'tr td.id a', :text => '9'
@@ -280,6 +281,32 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest
assert_select 'audio[src=?]', "/projects/subproject1/repository/#{@repository.id}/raw/subversion_test/folder/subfolder/chords.mp3" assert_select 'audio[src=?]', "/projects/subproject1/repository/#{@repository.id}/raw/subversion_test/folder/subfolder/chords.mp3"
end end
def text_entry_should_preview_markdown
get(
:entry,
:params => {
:id => PRJ_ID,
:repository_id => @repository.id,
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'testfile.md'])[:param]
}
)
assert_response :success
assert_select 'div.wiki', :html => "<h1>Header 1</h1>\n\n<h2>Header 2</h2>\n\n<h3>Header 3</h3>"
end
def text_entry_should_preview_textile
get(
:entry,
:params => {
:id => PRJ_ID,
:repository_id => @repository.id,
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'testfile.textile'])[:param]
}
)
assert_response :success
assert_select 'div.wiki', :html => "<h1>Header 1</h1>\n\n\n\t<h2>Header 2</h2>\n\n\n\t<h3>Header 3</h3>"
end
def test_entry_at_given_revision def test_entry_at_given_revision
assert_equal 0, @repository.changesets.count assert_equal 0, @repository.changesets.count
@repository.fetch_changesets @repository.fetch_changesets

View File

@@ -24,7 +24,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
include Redmine::I18n include Redmine::I18n
NUM_REV = 12 NUM_REV = 13
def setup def setup
User.current = nil User.current = nil
@@ -100,7 +100,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
@project.reload @project.reload
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
assert_equal 21, @repository.filechanges.count assert_equal 23, @repository.filechanges.count
assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
end end
@@ -144,7 +144,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
# with path # with path
changesets = @repository.latest_changesets('subversion_test/folder', nil) changesets = @repository.latest_changesets('subversion_test/folder', nil)
assert_equal ["12", "10", "9", "7", "6", "5", "2"], changesets.collect(&:revision) assert_equal ["13", "12", "10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
# with path and revision # with path and revision
changesets = @repository.latest_changesets('subversion_test/folder', 8) changesets = @repository.latest_changesets('subversion_test/folder', 8)