Commit 2d577cae9d71e8f293b87f5b6de04c3f130ecd22
1 parent
fc34fc86
Exists in
master
and in
4 other branches
branch/tag remember - to session instead of cookie
Showing
4 changed files
with
19 additions
and
17 deletions
Show diff stats
app/controllers/application_controller.rb
@@ -43,11 +43,14 @@ class ApplicationController < ActionController::Base | @@ -43,11 +43,14 @@ class ApplicationController < ActionController::Base | ||
43 | end | 43 | end |
44 | 44 | ||
45 | def refs_from_cookie | 45 | def refs_from_cookie |
46 | - # branch is high priority so we should reset | ||
47 | - # it if tag selected | ||
48 | - cookies[:branch] = nil if params[:tag] | ||
49 | - | ||
50 | - params[:branch] ||= cookies[:branch] | ||
51 | - params[:tag] ||= cookies[:tag] | 46 | + if @project && session[:ui] && |
47 | + session[:ui][@project.id] | ||
48 | + project_session = session[:ui][@project.id] | ||
49 | + project_session[:branch] = nil if params[:tag] | ||
50 | + params[:branch] ||= project_session[:branch] | ||
51 | + params[:tag] ||= project_session[:tag] | ||
52 | + end | ||
53 | + rescue | ||
54 | + session[:ui] = nil | ||
52 | end | 55 | end |
53 | end | 56 | end |
app/helpers/projects_helper.rb
@@ -3,4 +3,12 @@ module ProjectsHelper | @@ -3,4 +3,12 @@ module ProjectsHelper | ||
3 | cookies["project_view"] ||= "tile" | 3 | cookies["project_view"] ||= "tile" |
4 | cookies["project_view"] == type ? nil : "display:none" | 4 | cookies["project_view"] == type ? nil : "display:none" |
5 | end | 5 | end |
6 | + | ||
7 | + def remember_refs | ||
8 | + session[:ui] ||= {} | ||
9 | + session[:ui][@project.id] = { | ||
10 | + :branch => params[:branch], | ||
11 | + :tag => params[:tag] | ||
12 | + } | ||
13 | + end | ||
6 | end | 14 | end |
app/views/commits/index.html.haml
@@ -14,9 +14,4 @@ | @@ -14,9 +14,4 @@ | ||
14 | %div{:id => dom_id(@project)} | 14 | %div{:id => dom_id(@project)} |
15 | = render "commits" | 15 | = render "commits" |
16 | 16 | ||
17 | - | ||
18 | -:javascript | ||
19 | - $(function(){ | ||
20 | - $.cookie('branch', '#{params[:branch]}', { expires: 1 }); | ||
21 | - $.cookie('tag', '#{params[:tag]}', { expires: 1 }); | ||
22 | - }); | 17 | +- remember_refs |
app/views/projects/_tree.html.haml
@@ -46,11 +46,7 @@ | @@ -46,11 +46,7 @@ | ||
46 | = render :partial => "projects/tree_item", :locals => { :content => content } | 46 | = render :partial => "projects/tree_item", :locals => { :content => content } |
47 | 47 | ||
48 | 48 | ||
49 | -:javascript | ||
50 | - $(function(){ | ||
51 | - $.cookie('branch', '#{params[:branch]}', { expires: 1 }); | ||
52 | - $.cookie('tag', '#{params[:tag]}', { expires: 1 }); | ||
53 | - }); | 49 | +- remember_refs |
54 | 50 | ||
55 | :javascript | 51 | :javascript |
56 | $(function(){ | 52 | $(function(){ |