Patch #29395 » 0002-repository-entry-pagination.patch
app/controllers/repositories_controller.rb | ||
---|---|---|
146 | 146 |
send_opt[:disposition] = disposition(@path) |
147 | 147 |
send_data @repository.cat(@path, @rev), send_opt |
148 | 148 |
else |
149 |
# set up pagination from entry to entry |
|
150 |
parent_path = @path.split('/')[0...-1].join('/') |
|
151 |
@entries = @repository.entries(parent_path, @rev).reject(&:is_dir?) |
|
152 |
if index = @entries.index{|e| e.name == @entry.name} |
|
153 |
@paginator = Redmine::Pagination::Paginator.new(@entries.size, 1, index+1) |
|
154 |
end |
|
155 | ||
149 | 156 |
if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte |
150 | 157 |
content = @repository.cat(@path, @rev) |
151 | 158 |
(show_error_not_found; return) unless content |
app/helpers/repositories_helper.rb | ||
---|---|---|
32 | 32 |
end |
33 | 33 |
end |
34 | 34 | |
35 |
def render_pagination |
|
36 |
pagination_links_each @paginator do |text, parameters, options| |
|
37 |
if entry = @entries[parameters[:page] - 1] |
|
38 |
ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) |
|
39 |
link_to text, {action: 'entry', id: @project, repository_id: @repository.identifier_param, path: to_path_param(ent_path), rev: @rev} |
|
40 |
end |
|
41 |
end if @paginator |
|
42 |
end |
|
43 | ||
35 | 44 |
def render_properties(properties) |
36 | 45 |
unless properties.nil? || properties.empty? |
37 | 46 |
content = '' |
app/views/repositories/entry.html.erb | ||
---|---|---|
35 | 35 |
:class => 'icon icon-download') : nil } %> |
36 | 36 |
<% end %> |
37 | 37 | |
38 |
<span class="pagination"> |
|
39 |
<%= render_pagination %> |
|
40 |
</span> |
|
41 | ||
38 | 42 |
<% content_for :header_tags do %> |
39 | 43 |
<%= stylesheet_link_tag "scm" %> |
40 | 44 |
<% end %> |
test/functional/repositories_git_controller_test.rb | ||
---|---|---|
243 | 243 |
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/ |
244 | 244 |
end |
245 | 245 | |
246 |
def test_entry_show_should_render_pagination |
|
247 |
get :entry, :params => { |
|
248 |
:id => PRJ_ID, |
|
249 |
:repository_id => @repository.id, |
|
250 |
:path => repository_path_hash(['README'])[:param] |
|
251 |
} |
|
252 |
assert_response :success |
|
253 |
assert_select 'ul.pages li.next', :text => /next/i |
|
254 |
assert_select 'ul.pages li.previous', :text => /previous/i |
|
255 |
end |
|
256 | ||
246 | 257 |
def test_entry_show_latin_1 |
247 | 258 |
if @ruby19_non_utf8_pass |
248 | 259 |
puts_ruby19_non_utf8_pass() |