tag and branches selection
This commit is contained in:
parent
4f7c51b61f
commit
8692995969
|
@ -5,6 +5,11 @@ class Git::BaseController < ApplicationController
|
|||
before_filter :find_repository
|
||||
before_filter :find_project
|
||||
before_filter :find_git_repository
|
||||
before_filter :find_tags
|
||||
before_filter :find_branches
|
||||
before_filter :set_treeish
|
||||
before_filter :set_current_tag
|
||||
before_filter :set_current_branch
|
||||
|
||||
protected
|
||||
def find_platform
|
||||
|
@ -22,4 +27,24 @@ class Git::BaseController < ApplicationController
|
|||
def find_git_repository
|
||||
@git_repository = @project.git_repository
|
||||
end
|
||||
|
||||
def find_tags
|
||||
@tags = @git_repository.tags
|
||||
end
|
||||
|
||||
def find_branches
|
||||
@branches = @git_repository.branches
|
||||
end
|
||||
|
||||
def set_treeish
|
||||
@treeish = params[:treeish] ? params[:treeish] : "master"
|
||||
end
|
||||
|
||||
def set_current_tag
|
||||
@current_tag = @tags.select{|t| t.name == @treeish }.first
|
||||
end
|
||||
|
||||
def set_current_branch
|
||||
@current_branch = @branches.select{|b| b.name == @treeish }.first
|
||||
end
|
||||
end
|
|
@ -1,6 +1,5 @@
|
|||
class Git::BlobsController < Git::BaseController
|
||||
before_filter :set_path
|
||||
before_filter :set_treeish
|
||||
before_filter :set_commit_hash
|
||||
|
||||
def show
|
||||
|
@ -50,10 +49,6 @@ class Git::BlobsController < Git::BaseController
|
|||
@path = params[:path]
|
||||
end
|
||||
|
||||
def set_treeish
|
||||
@treeish = params[:treeish] ? params[:treeish] : "master"
|
||||
end
|
||||
|
||||
def set_commit_hash
|
||||
@commit_hash = params[:commit_hash].present? ? params[:commit_hash] : nil
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Git::TreesController < Git::BaseController
|
||||
|
||||
def show
|
||||
@treeish = params[:treeish] ? params[:treeish] : "master"
|
||||
@path = params[:path]
|
||||
|
||||
@tree = @git_repository.tree(@treeish)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Git::Repository
|
||||
delegate :commits, :commit, :tree, :tags, :heads, :commit_count, :log, :to => :repo
|
||||
delegate :commits, :commit, :tree, :tags, :heads, :commit_count, :log, :branches, :to => :repo
|
||||
|
||||
attr_accessor :path, :name
|
||||
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
= render :partial => "git/shared/navigation"
|
||||
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
= render :partial => "git/shared/info"
|
||||
|
||||
.block
|
||||
.content
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
= render :partial => "git/shared/navigation"
|
||||
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
= render :partial => "git/shared/info"
|
||||
|
||||
- if @commit
|
||||
.block
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li.active= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
= render :partial => "git/shared/navigation"
|
||||
|
||||
= render :partial => "git/shared/info"
|
||||
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
.block
|
||||
.content
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li.active= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
= render :partial => "git/shared/navigation"
|
||||
|
||||
= render :partial => "git/shared/info"
|
||||
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
.block
|
||||
.content
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
= render :partial => "git/shared/navigation"
|
||||
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
= render :partial => "git/shared/info"
|
||||
|
||||
- if @commit
|
||||
.block
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
- if @current_tag.present?
|
||||
%p
|
||||
%b Tag:
|
||||
|
||||
= link_to @current_tag.name, tree_path(@platform, @repository, @project, :treeish => @current_tag.name)
|
||||
|
||||
- if @current_branch.present?
|
||||
%p
|
||||
%b Branch:
|
||||
|
||||
= link_to @current_branch.name, tree_path(@platform, @repository, @project, :treeish => @current_branch.name)
|
|
@ -0,0 +1,24 @@
|
|||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
|
||||
%ul#git_submenu.sub-wat-cf.wat-cf
|
||||
%li
|
||||
%a{ :href => "#", :onmouseover => "menu.open('branches')", :onmouseout => "menu.close_time()" } Branches
|
||||
#branches{ :onmouseover => "menu.cancel_close_time()", :onmouseout => "menu.close_time()" }
|
||||
- @branches.each do |branch|
|
||||
- if branch.name == @treesh
|
||||
%span.current= branch.name
|
||||
- else
|
||||
= link_to branch.name, tree_path(@platform, @repository, @project, :treeish => branch.name)
|
||||
|
||||
%li
|
||||
%a{ :href => "#", :onmouseover => "menu.open('tags')", :onmouseout => "menu.close_time()" } Tags
|
||||
#tags{ :onmouseover => "menu.cancel_close_time()", :onmouseout => "menu.close_time()" }
|
||||
- @tags.each do |tag|
|
||||
- if tag.name == @treeish
|
||||
%span.current= tag.name
|
||||
- else
|
||||
= link_to tag.name, tree_path(@platform, @repository, @project, :treeish => tag.name)
|
||||
.clear
|
|
@ -2,6 +2,7 @@ javascripts:
|
|||
application:
|
||||
- public/javascripts/rails.js
|
||||
- public/javascripts/application.js
|
||||
- public/javascripts/drop_down_menu.js
|
||||
|
||||
stylesheets:
|
||||
application:
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
var DropDownMenu = function() {
|
||||
this.timeout = 500;
|
||||
this.close_timer = 0;
|
||||
this.menu_item = 0;
|
||||
};
|
||||
// open hidden layer
|
||||
DropDownMenu.prototype.open = function(id) {
|
||||
// cancel close timer
|
||||
this.cancel_close_time();
|
||||
|
||||
// close old layer
|
||||
if(this.menu_item) this.menu_item.hide();
|
||||
|
||||
// get new layer and show it
|
||||
this.menu_item = $("#" + id);
|
||||
this.menu_item.show();
|
||||
};
|
||||
|
||||
// close showed layer
|
||||
DropDownMenu.prototype.close = function() {
|
||||
if (this.menu_item) this.menu_item.hide();
|
||||
};
|
||||
|
||||
// go close timer
|
||||
DropDownMenu.prototype.close_time = function() {
|
||||
var _this = this;
|
||||
function mclose() {
|
||||
return _this.close();
|
||||
}
|
||||
this.close_timer = window.setTimeout(mclose, this.timeout);
|
||||
};
|
||||
|
||||
// cancel close timer
|
||||
DropDownMenu.prototype.cancel_close_time = function() {
|
||||
if(this.close_timer)
|
||||
{
|
||||
window.clearTimeout(this.close_timer);
|
||||
this.close_timer = null;
|
||||
}
|
||||
};
|
||||
|
||||
var menu = new DropDownMenu();
|
||||
document.onclick = menu.close;
|
|
@ -246,3 +246,35 @@ table.blame td.message .message {
|
|||
margin-left: 10px;
|
||||
width: 430px;
|
||||
}
|
||||
|
||||
#git_submenu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
#git_submenu li a:hover {
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
#git_submenu div {
|
||||
background: none repeat scroll 0 0 #F8F8F8;
|
||||
border: 1px solid #CCCCCC;
|
||||
display: none;
|
||||
max-height: 275px;
|
||||
overflow: auto;
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
#git_submenu div span {
|
||||
padding: 10px 15px;
|
||||
display: block;
|
||||
background: #ECECEC;
|
||||
}
|
||||
|
||||
|
||||
#git_submenu div a:hover {
|
||||
background: #ECECEC;
|
||||
color: #000;
|
||||
}
|
Loading…
Reference in New Issue