diff --git a/app/controllers/graph_controller.rb b/app/controllers/graph_controller.rb index b4bf956511295a2bccd8460fc746d8711690da29..22544ad82aabc9489135195cab5e9dfbd5f9a2b9 100644 --- a/app/controllers/graph_controller.rb +++ b/app/controllers/graph_controller.rb @@ -8,14 +8,8 @@ class GraphController < ProjectResourceController before_filter :require_non_empty_project def show - if params.has_key?(:q) - if params[:q].blank? - redirect_to project_graph_path(@project, params[:id]) - return - end - - @q = params[:q] - @commit = @project.repository.commit(@q) || @commit + if @options[:q] + @commit = @project.repository.commit(@options[:q]) || @commit end respond_to do |format| diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 69756bb8ecd2d127d658a0479177cc8679659be4..e7def3984f89c9d52c952dc3b61a40cdaf39450d 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -14,7 +14,7 @@ class RefsController < ProjectResourceController elsif params[:destination] == "blob" project_blob_path(@project, (@id)) elsif params[:destination] == "graph" - project_graph_path(@project, @id) + project_graph_path(@project, @id, @options) else project_commits_path(@project, @id) end diff --git a/app/views/graph/_head.html.haml b/app/views/graph/_head.html.haml index 04a668925845b4358f3be14984d5416d45051fff..e6be40aec9c6f33c162fc8bb01be3206d4b018d5 100644 --- a/app/views/graph/_head.html.haml +++ b/app/views/graph/_head.html.haml @@ -10,7 +10,9 @@ .control-group = label_tag :search , "Looking for commit:", class: 'control-label light' .controls - = text_field_tag :q, @q, placeholder: "Input SHA", class: "search-input xlarge" + = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge" = button_tag type: 'submit', class: 'btn vtop' do %i.icon-search + - @options.each do |key, value| + = hidden_field_tag(key, value, id: nil) unless key == "q" diff --git a/app/views/graph/show.html.haml b/app/views/graph/show.html.haml index 682d27989062bbf4bd5a03cd7c59391d05187430..f361b8b2ea85fc1da10a040c0cc08dffc0a639f2 100644 --- a/app/views/graph/show.html.haml +++ b/app/views/graph/show.html.haml @@ -7,9 +7,8 @@ :javascript var branch_graph; - branch_graph = new BranchGraph($("#holder"), { - url: '#{project_graph_path(@project, @ref, q: @q, format: :json)}', + url: '#{project_graph_path(@project, @ref, @options.merge(format: :json))}', commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', ref: '#{@ref}', commit_id: '#{@commit.id}' diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml index 8b44cf1944ee91793130cb8769c722c9090391e6..dc8c656e12e571b9024c572c377623dcaa982ca1 100644 --- a/app/views/shared/_ref_switcher.html.haml +++ b/app/views/shared/_ref_switcher.html.haml @@ -3,3 +3,5 @@ = hidden_field_tag :destination, destination - if defined?(path) = hidden_field_tag :path, path + - @options && @options.each do |key, value| + = hidden_field_tag key, value, id: nil diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 6025bb2a9f680132faf7f5eafa156b756f7c0de8..a81c80cfc6f2cd62f26a055b00ca4b0c62720dd4 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -106,6 +106,11 @@ module ExtractsPath @hex_path = Digest::SHA1.hexdigest(@path) @logs_path = logs_file_project_ref_path(@project, @ref, @path) + # assign allowed options + allowed_options = ["filter_ref", "q"] + @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } + @options = HashWithIndifferentAccess.new(@options) + raise InvalidPathError unless @tree.exists? rescue RuntimeError, NoMethodError, InvalidPathError not_found!