Commit 5dc5ef7b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

branch/tag memorization

parent 06f72627
...@@ -41,4 +41,13 @@ class ApplicationController < ActionController::Base ...@@ -41,4 +41,13 @@ class ApplicationController < ActionController::Base
super super
end end
end end
def refs_from_cookie
# branch is high priority so we should reset
# it if tag selected
cookies[:branch] = nil if params[:tag]
params[:branch] ||= cookies[:branch]
params[:tag] ||= cookies[:tag]
end
end end
...@@ -8,6 +8,7 @@ class CommitsController < ApplicationController ...@@ -8,6 +8,7 @@ class CommitsController < ApplicationController
before_filter :authorize_read_project! before_filter :authorize_read_project!
def index def index
refs_from_cookie
@repo = project.repo @repo = project.repo
@branch = if !params[:branch].blank? @branch = if !params[:branch].blank?
params[:branch] params[:branch]
......
...@@ -16,6 +16,7 @@ class ProjectsController < ApplicationController ...@@ -16,6 +16,7 @@ class ProjectsController < ApplicationController
end end
def show def show
refs_from_cookie
@repo = project.repo @repo = project.repo
@commit = @repo.commits.first @commit = @repo.commits.first
@tree = @commit.tree @tree = @commit.tree
...@@ -32,6 +33,7 @@ class ProjectsController < ApplicationController ...@@ -32,6 +33,7 @@ class ProjectsController < ApplicationController
end end
def tree def tree
refs_from_cookie
@repo = project.repo @repo = project.repo
@branch = if !params[:branch].blank? @branch = if !params[:branch].blank?
params[:branch] params[:branch]
......
...@@ -13,3 +13,10 @@ ...@@ -13,3 +13,10 @@
%h3{:style => "color:#555"} /#{params[:path]} %h3{:style => "color:#555"} /#{params[:path]}
%div{:id => dom_id(@project)} %div{:id => dom_id(@project)}
= render "commits" = render "commits"
:javascript
$(function(){
$.cookie('branch', '#{params[:branch]}', { expires: 1 });
$.cookie('tag', '#{params[:tag]}', { expires: 1 });
});
...@@ -45,6 +45,13 @@ ...@@ -45,6 +45,13 @@
- contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|
= render :partial => "projects/tree_item", :locals => { :content => content } = render :partial => "projects/tree_item", :locals => { :content => content }
:javascript
$(function(){
$.cookie('branch', '#{params[:branch]}', { expires: 1 });
$.cookie('tag', '#{params[:tag]}', { expires: 1 });
});
:javascript :javascript
$(function(){ $(function(){
$('select#branch').selectmenu({style:'popup', width:200}); $('select#branch').selectmenu({style:'popup', width:200});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment