mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-23 08:51:13 +00:00
Repository entry pagination (#29395).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17568 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
dcc7ecb34a
commit
7d615fd516
@ -146,6 +146,13 @@ class RepositoriesController < ApplicationController
|
|||||||
send_opt[:disposition] = disposition(@path)
|
send_opt[:disposition] = disposition(@path)
|
||||||
send_data @repository.cat(@path, @rev), send_opt
|
send_data @repository.cat(@path, @rev), send_opt
|
||||||
else
|
else
|
||||||
|
# set up pagination from entry to entry
|
||||||
|
parent_path = @path.split('/')[0...-1].join('/')
|
||||||
|
@entries = @repository.entries(parent_path, @rev).reject(&:is_dir?)
|
||||||
|
if index = @entries.index{|e| e.name == @entry.name}
|
||||||
|
@paginator = Redmine::Pagination::Paginator.new(@entries.size, 1, index+1)
|
||||||
|
end
|
||||||
|
|
||||||
if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte
|
if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte
|
||||||
content = @repository.cat(@path, @rev)
|
content = @repository.cat(@path, @rev)
|
||||||
(show_error_not_found; return) unless content
|
(show_error_not_found; return) unless content
|
||||||
|
|||||||
@ -32,6 +32,15 @@ module RepositoriesHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_pagination
|
||||||
|
pagination_links_each @paginator do |text, parameters, options|
|
||||||
|
if entry = @entries[parameters[:page] - 1]
|
||||||
|
ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path)
|
||||||
|
link_to text, {action: 'entry', id: @project, repository_id: @repository.identifier_param, path: to_path_param(ent_path), rev: @rev}
|
||||||
|
end
|
||||||
|
end if @paginator
|
||||||
|
end
|
||||||
|
|
||||||
def render_properties(properties)
|
def render_properties(properties)
|
||||||
unless properties.nil? || properties.empty?
|
unless properties.nil? || properties.empty?
|
||||||
content = ''
|
content = ''
|
||||||
|
|||||||
@ -35,6 +35,10 @@
|
|||||||
:class => 'icon icon-download') : nil } %>
|
:class => 'icon icon-download') : nil } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<span class="pagination">
|
||||||
|
<%= render_pagination %>
|
||||||
|
</span>
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= stylesheet_link_tag "scm" %>
|
<%= stylesheet_link_tag "scm" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -243,6 +243,17 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
|||||||
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_entry_show_should_render_pagination
|
||||||
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:repository_id => @repository.id,
|
||||||
|
:path => repository_path_hash(['README'])[:param]
|
||||||
|
}
|
||||||
|
assert_response :success
|
||||||
|
assert_select 'ul.pages li.next', :text => /next/i
|
||||||
|
assert_select 'ul.pages li.previous', :text => /previous/i
|
||||||
|
end
|
||||||
|
|
||||||
def test_entry_show_latin_1
|
def test_entry_show_latin_1
|
||||||
if @ruby19_non_utf8_pass
|
if @ruby19_non_utf8_pass
|
||||||
puts_ruby19_non_utf8_pass()
|
puts_ruby19_non_utf8_pass()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user