graph_controller.rb 642 Bytes
Newer Older
1 2
class GraphController < ProjectResourceController
  include ExtractsPath
3
  include ApplicationHelper
4 5 6 7 8 9 10

  # Authorize
  before_filter :authorize_read_project!
  before_filter :authorize_code_access!
  before_filter :require_non_empty_project

  def show
11
    if params.has_key?(:q)
12 13 14 15 16
      if params[:q].blank?
        redirect_to project_graph_path(@project, params[:id])
        return
      end

17 18 19 20
      @q = params[:q]
      @commit = @project.repository.commit(@q) || @commit
    end

21 22
    respond_to do |format|
      format.html
23

24
      format.json do
25
        @graph = Graph::JsonBuilder.new(project, @ref, @commit)
26 27 28 29
      end
    end
  end
end