diff options
author | Go MAEDA <maeda@farend.jp> | 2018-10-04 13:24:06 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-10-04 13:24:06 +0000 |
commit | 7d615fd516c60c0c448d3a35f56641e14b463c61 (patch) | |
tree | 7d788ac9b72c7c729f5c14b43e619a8360e05a67 /app | |
parent | dcc7ecb34a61d55193572ca8bc66c9859f3d6e49 (diff) | |
download | redmine-7d615fd516c60c0c448d3a35f56641e14b463c61.tar.gz redmine-7d615fd516c60c0c448d3a35f56641e14b463c61.zip |
Repository entry pagination (#29395).
Patch by Jens Krämer.
git-svn-id: http://svn.redmine.org/redmine/trunk@17568 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/repositories_controller.rb | 7 | ||||
-rw-r--r-- | app/helpers/repositories_helper.rb | 9 | ||||
-rw-r--r-- | app/views/repositories/entry.html.erb | 4 |
3 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0c6070b80..346ecf5c7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -146,6 +146,13 @@ class RepositoriesController < ApplicationController send_opt[:disposition] = disposition(@path) send_data @repository.cat(@path, @rev), send_opt 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 content = @repository.cat(@path, @rev) (show_error_not_found; return) unless content diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 59c97cdc5..f64ed1dc0 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -32,6 +32,15 @@ module RepositoriesHelper 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) unless properties.nil? || properties.empty? content = '' diff --git a/app/views/repositories/entry.html.erb b/app/views/repositories/entry.html.erb index eb2e1d5e4..ca52e2873 100644 --- a/app/views/repositories/entry.html.erb +++ b/app/views/repositories/entry.html.erb @@ -35,6 +35,10 @@ :class => 'icon icon-download') : nil } %> <% end %> +<span class="pagination"> + <%= render_pagination %> +</span> + <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> <% end %> |