Project

General

Profile

Patch #3357 ยป repo_browser_path_versions.diff

Lance Sanchez, 2009-05-13 22:18

View differences:

app/helpers/application_helper.rb (working copy)
path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
end
def pagination_links_full(paginator, count=nil, options={})
def pagination_links_full(paginator, count=nil, options={:update => 'content'})
page_param = options.delete(:page_param) || :page
url_param = params.dup
# don't reuse params if filters are present
......
html = ''
html << link_to_remote(('&#171; ' + l(:label_previous)),
{:update => 'content',
{:update => options[:update],
:url => url_param.merge(page_param => paginator.current.previous),
:complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
......
html << (pagination_links_each(paginator, options) do |n|
link_to_remote(n.to_s,
{:url => {:params => url_param.merge(page_param => n)},
:update => 'content',
:update => options[:update],
:complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_param.merge(page_param => n))})
end || '')
html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
{:update => 'content',
{:update => options[:update],
:url => url_param.merge(page_param => paginator.current.next),
:complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
unless count.nil?
html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page, options[:update])].compact.join(' | ')
end
html
end
def per_page_links(selected=nil)
def per_page_links(selected=nil, update = "content")
url_param = params.dup
url_param.clear if url_param.has_key?(:set_filter)
links = Setting.per_page_options_array.collect do |n|
n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)},
n == selected ? n : link_to_remote(n, {:update => update, :url => params.dup.merge(:per_page => n)},
{:href => url_for(url_param.merge(:per_page => n))})
end
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
app/controllers/repositories_controller.rb (working copy)
end
def browse
@changeset_count = @repository.changesets.count
@changeset_pages = Paginator.new self, @changeset_count,
per_page_option,
params['revisions_page']
@entries = @repository.entries(@path, @rev)
path = @repository.url[/#{@repository.root_url}(.*)/,1] + (@path.starts_with?('/') ? @path : "/#{@path}") + "%"
@changesets = @repository.changesets.find(:all,
:joins => "INNER JOIN changes on changes.changeset_id = changesets.id",
:group => "changesets.id",
:conditions => ["changes.path like ?", path],
:limit => @changeset_pages.items_per_page,
:offset => @changeset_pages.current.offset,
:order => "changesets.committed_on DESC")
if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
if params['revisions_page'] or params['per_page']
render(:partial => 'path_revisions')
else
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
end
else
show_error_not_found and return unless @entries
@properties = @repository.properties(@path, @rev)
app/views/repositories/_path_revisions.rhtml (revision 0)
<% if !@changesets.empty? && authorize_for('repositories', 'revisions') %>
<h3><%= l(:label_latest_revision_plural) %></h3>
<%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%>
<p class="pagination"><%= pagination_links_full @changeset_pages,@changeset_count, {:page_param => 'revisions_page' ,:update => 'revisions'} %></p>
<p><%= link_to l(:label_view_revisions), :action => 'revisions', :id => @project %></p>
<% end %>
app/views/repositories/browse.rhtml (working copy)
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
<% end %>
<div id="revisions">
<%= render :partial => 'path_revisions' %>
</div>
    (1-1/1)