refactoring

This commit is contained in:
gitlabhq 2011-11-16 08:38:53 +03:00
parent f294b8d4c3
commit af08ed6b66
16 changed files with 96 additions and 79 deletions

View file

@ -9,7 +9,7 @@
%data.commit-button
= truncate(commit.id.to_s, :length => 16)
%i
%data.commit-browse{ :onclick => "location.href='#{tree_project_path(@project, :commit_id => commit.id)}';return false;"}
%data.commit-browse{ :onclick => "location.href='#{tree_project_ref_path(@project, commit.id)}';return false;"}
Browse Code
- if commit.author_email
= image_tag gravatar_icon(commit.author_email), :class => "left", :width => 40, :style => "padding-right:5px;"

View file

@ -9,7 +9,7 @@
- if diff.deleted_file
%strong{:id => "#{diff.b_path}"}= diff.a_path
- else
= link_to tree_file_project_path(@project, @commit.id, diff.b_path) do
= link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do
%strong{:id => "#{diff.b_path}"}= diff.b_path
%br/
.diff_file_content

View file

@ -18,7 +18,7 @@
= preserve @commit.safe_message
%tr
%td Tree
%td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id)
%td= link_to 'Browse Code', tree_project_ref_path(@project, @commit.id)
.clear
%br

View file

@ -5,7 +5,7 @@
GitLab #{" - #{@project.name}" if @project && !@project.new_record?}
= stylesheet_link_tag "application"
= javascript_include_tag "application"
- if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project))
- if current_page?(tree_project_ref_path(@project, @project.root_ref)) || current_page?(project_commits_path(@project))
= auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref, :private_token => current_user.private_token), :title => "Recent commits to #{@project.name}:#{@ref}")
- if request.path == project_issues_path(@project)
= auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, :private_token => current_user.private_token), :title => "#{@project.name} issues")
@ -24,7 +24,7 @@
%input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"}
%aside
= link_to "Activities", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil
= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil
= link_to "Tree", tree_project_ref_path(@project, @project.root_ref), :class => current_page?(:controller => "refs", :action => "tree", :project_id => @project, :id => @ref || @project.root_ref ) ? "current" : nil
= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil
= link_to "Network graph", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil
= link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do

View file

@ -1,5 +0,0 @@
<div>
<div id="tree-holder">
<%= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree} %>
</div>
</div>

View file

@ -5,7 +5,7 @@
%h2.icon
%span
%d
= link_to tree_project_path(@project, :path => nil, :commit_id => @commit.try(:id)), :remote => true do
= link_to tree_project_ref_path(@project, @ref, :path => nil), :remote => true do
= @project.name
- if params[:path]
- part_path = ""
@ -14,14 +14,14 @@
- if part_path.empty?
- part_path = part
\/
= link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id), :branch => @branch, :tag => @tag), :remote => :true
= link_to truncate(part, :length => 40), tree_file_project_ref_path(@project, @ref, :path => part_path), :remote => :true
&nbsp;
.right= render :partial => "projects/refs", :locals => { :destination => tree_project_path(@project) }
.right= render :partial => "projects/refs", :locals => { :destination => tree_project_ref_path(@project, @ref) }
.clear
#tree-content-holder
- if tree.is_a?(Grit::Blob)
= render :partial => "projects/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
= render :partial => "refs/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
- else
- contents = tree.contents
%table#tree-slider.round-borders
@ -30,20 +30,20 @@
%th Last Update
%th
Last commit
= link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch],:tag => params[:tag]), :class => "right"
= link_to "history", project_commits_path(@project, :path => params[:path], :ref => @ref), :class => "right"
- if params[:path]
- file = File.join(params[:path], "..")
%tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
%tr{ :class => "tree-item", :url => tree_file_project_ref_path(@project, @ref, file) }
%td.tree-item-file-name
= image_tag "dir.png"
= link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true
= link_to "..", tree_file_project_ref_path(@project, @ref, file), :remote => :true
%td
%td
- contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|
= render :partial => "projects/tree_item", :locals => { :content => content }
= render :partial => "refs/tree_item", :locals => { :content => content }
- contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|
= render :partial => "projects/tree_item", :locals => { :content => content }
= render :partial => "refs/tree_item", :locals => { :content => content }
:javascript
$(function(){

View file

@ -3,8 +3,8 @@
.view_file_header
%strong
= name
= link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank"
= link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch], :tag => params[:tag] ), :class => "right", :style => "margin-right:10px;"
= link_to "raw", blob_project_ref_path(@project, @ref, :path => params[:path] ), :class => "right", :target => "_blank"
= link_to "history", project_commits_path(@project, :path => params[:path], :ref => @ref ), :class => "right", :style => "margin-right:10px;"
%br/
- if file.text?
.view_file_content

View file

@ -1,13 +1,13 @@
- file = params[:path] ? File.join(params[:path], content.name) : content.name
- content_commit = @project.repo.log(@commit.id, file, :max_count => 1).last
- return unless content_commit
%tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
%tr{ :class => "tree-item", :url => tree_file_project_ref_path(@project, @ref, file) }
%td.tree-item-file-name
- if content.is_a?(Grit::Blob)
= image_tag "txt.png"
- else
= image_tag "dir.png"
= link_to truncate(content.name, :length => 40), tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true
= link_to truncate(content.name, :length => 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), :remote => :true
%td
= time_ago_in_words(content_commit.committed_date)
ago

View file

@ -0,0 +1 @@
#tree-holder= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree}

View file

@ -0,0 +1,5 @@
:plain
$("#tree-holder table").hide("slide", { direction: "left" }, 150, function(){
$("#tree-holder").html("#{escape_javascript(render(:partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree}))}");
$("#tree-holder table").show("slide", { direction: "right" }, 150);
});