Commit 2d577cae authored by gitlabhq's avatar gitlabhq

branch/tag remember - to session instead of cookie

parent fc34fc86
...@@ -43,11 +43,14 @@ class ApplicationController < ActionController::Base ...@@ -43,11 +43,14 @@ class ApplicationController < ActionController::Base
end end
def refs_from_cookie def refs_from_cookie
# branch is high priority so we should reset if @project && session[:ui] &&
# it if tag selected session[:ui][@project.id]
cookies[:branch] = nil if params[:tag] project_session = session[:ui][@project.id]
project_session[:branch] = nil if params[:tag]
params[:branch] ||= cookies[:branch] params[:branch] ||= project_session[:branch]
params[:tag] ||= cookies[:tag] params[:tag] ||= project_session[:tag]
end
rescue
session[:ui] = nil
end end
end end
...@@ -3,4 +3,12 @@ module ProjectsHelper ...@@ -3,4 +3,12 @@ module ProjectsHelper
cookies["project_view"] ||= "tile" cookies["project_view"] ||= "tile"
cookies["project_view"] == type ? nil : "display:none" cookies["project_view"] == type ? nil : "display:none"
end end
def remember_refs
session[:ui] ||= {}
session[:ui][@project.id] = {
:branch => params[:branch],
:tag => params[:tag]
}
end
end end
...@@ -14,9 +14,4 @@ ...@@ -14,9 +14,4 @@
%div{:id => dom_id(@project)} %div{:id => dom_id(@project)}
= render "commits" = render "commits"
- remember_refs
:javascript
$(function(){
$.cookie('branch', '#{params[:branch]}', { expires: 1 });
$.cookie('tag', '#{params[:tag]}', { expires: 1 });
});
...@@ -46,11 +46,7 @@ ...@@ -46,11 +46,7 @@
= render :partial => "projects/tree_item", :locals => { :content => content } = render :partial => "projects/tree_item", :locals => { :content => content }
:javascript - remember_refs
$(function(){
$.cookie('branch', '#{params[:branch]}', { expires: 1 });
$.cookie('tag', '#{params[:tag]}', { expires: 1 });
});
:javascript :javascript
$(function(){ $(function(){
......
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