Merge branch 'master' into features/feeds
This commit is contained in:
commit
8d74123d61
56 changed files with 1042 additions and 758 deletions
|
@ -1,9 +1,6 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
before_filter :authenticate_user!
|
||||
before_filter :view_style
|
||||
|
||||
protect_from_forgery
|
||||
|
||||
helper_method :abilities, :can?
|
||||
|
||||
rescue_from Gitosis::AccessDenied do |exception|
|
||||
|
@ -64,7 +61,7 @@ class ApplicationController < ActionController::Base
|
|||
else
|
||||
@branch = params[:branch].blank? ? nil : params[:branch]
|
||||
@tag = params[:tag].blank? ? nil : params[:tag]
|
||||
@ref = @branch || @tag || "master"
|
||||
@ref = @branch || @tag || Repository.default_ref
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -76,20 +73,6 @@ class ApplicationController < ActionController::Base
|
|||
redirect_to @project unless @project.repo_exists?
|
||||
end
|
||||
|
||||
def view_style
|
||||
if params[:view_style] == "collapsed"
|
||||
cookies[:view_style] = "collapsed"
|
||||
elsif params[:view_style] == "fluid"
|
||||
cookies[:view_style] = ""
|
||||
end
|
||||
|
||||
@view_mode = if cookies[:view_style] == "collapsed"
|
||||
:fixed
|
||||
else
|
||||
:fluid
|
||||
end
|
||||
end
|
||||
|
||||
def respond_with_notes
|
||||
if params[:last_id] && params[:first_id]
|
||||
@notes = @notes.where("id >= ?", params[:first_id])
|
||||
|
|
|
@ -8,18 +8,18 @@ class CommitsController < ApplicationController
|
|||
before_filter :add_project_abilities
|
||||
before_filter :authorize_read_project!
|
||||
before_filter :require_non_empty_project
|
||||
before_filter :load_refs, :only => :index # load @branch, @tag & @ref
|
||||
|
||||
|
||||
def index
|
||||
load_refs # load @branch, @tag & @ref
|
||||
|
||||
@repo = project.repo
|
||||
limit, offset = (params[:limit] || 20), (params[:offset] || 0)
|
||||
|
||||
if params[:path]
|
||||
@commits = @repo.log(@ref, params[:path], :max_count => limit, :skip => offset)
|
||||
else
|
||||
@commits = @repo.commits(@ref, limit, offset)
|
||||
end
|
||||
@commits = if params[:path]
|
||||
@repo.log(@ref, params[:path], :max_count => limit, :skip => offset)
|
||||
else
|
||||
@repo.commits(@ref, limit, offset)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
@ -30,8 +30,8 @@ class CommitsController < ApplicationController
|
|||
|
||||
def show
|
||||
@commit = project.repo.commits(params[:id]).first
|
||||
@notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit").order("created_at DESC").limit(20)
|
||||
@note = @project.notes.new(:noteable_id => @commit.id, :noteable_type => "Commit")
|
||||
@notes = project.commit_notes(@commit).fresh.limit(20)
|
||||
@note = @project.build_commit_note(@commit)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require File.join(Rails.root, 'lib', 'graph_commit')
|
||||
|
||||
class ProjectsController < ApplicationController
|
||||
before_filter :project, :except => [:index, :new, :create]
|
||||
layout :determine_layout
|
||||
|
@ -6,8 +8,8 @@ class ProjectsController < ApplicationController
|
|||
before_filter :add_project_abilities
|
||||
before_filter :authorize_read_project!, :except => [:index, :new, :create]
|
||||
before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy]
|
||||
|
||||
before_filter :require_non_empty_project, :only => [:blob, :tree]
|
||||
before_filter :load_refs, :only => :tree # load @branch, @tag & @ref
|
||||
|
||||
def index
|
||||
source = current_user.projects
|
||||
|
@ -64,21 +66,8 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def show
|
||||
return render "projects/empty" unless @project.repo_exists?
|
||||
@date = case params[:view]
|
||||
when "week" then Date.today - 7.days
|
||||
when "day" then Date.today
|
||||
else nil
|
||||
end
|
||||
|
||||
if @date
|
||||
@date = @date.at_beginning_of_day
|
||||
|
||||
@commits = @project.commits_since(@date)
|
||||
@messages = project.notes.since(@date).order("created_at DESC")
|
||||
else
|
||||
@commits = @project.fresh_commits
|
||||
@messages = project.notes.fresh.limit(10)
|
||||
end
|
||||
limit = (params[:limit] || 40).to_i
|
||||
@activities = @project.updates(limit)
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -101,15 +90,13 @@ class ProjectsController < ApplicationController
|
|||
#
|
||||
|
||||
def tree
|
||||
load_refs # load @branch, @tag & @ref
|
||||
|
||||
@repo = project.repo
|
||||
|
||||
if params[:commit_id]
|
||||
@commit = @repo.commits(params[:commit_id]).first
|
||||
else
|
||||
@commit = @repo.commits(@ref || "master").first
|
||||
end
|
||||
@commit = if params[:commit_id]
|
||||
@repo.commits(params[:commit_id]).first
|
||||
else
|
||||
@repo.commits(@ref).first
|
||||
end
|
||||
|
||||
@tree = @commit.tree
|
||||
@tree = @tree / params[:path] if params[:path]
|
||||
|
@ -127,6 +114,34 @@ class ProjectsController < ApplicationController
|
|||
return render_404
|
||||
end
|
||||
|
||||
def graph
|
||||
@repo = project.repo
|
||||
commits = Grit::Commit.find_all(@repo, nil, {:max_count => 650})
|
||||
ref_cache = {}
|
||||
commits.collect! do |commit|
|
||||
add_refs(commit, ref_cache)
|
||||
GraphCommit.new(commit)
|
||||
end
|
||||
|
||||
days = GraphCommit.index_commits(commits)
|
||||
@days_json = days.compact.collect{|d| [d.day, d.strftime("%b")] }.to_json
|
||||
@commits_json = commits.collect do |c|
|
||||
h = {}
|
||||
h[:parents] = c.parents.collect do |p|
|
||||
[p.id,0,0]
|
||||
end
|
||||
h[:author] = c.author.name.force_encoding("UTF-8")
|
||||
h[:time] = c.time
|
||||
h[:space] = c.space
|
||||
h[:refs] = c.refs.collect{|r|r.name}.join(" ") unless c.refs.nil?
|
||||
h[:id] = c.sha
|
||||
h[:date] = c.date
|
||||
h[:message] = c.message.force_encoding("UTF-8")
|
||||
h[:login] = c.author.email
|
||||
h
|
||||
end.to_json
|
||||
end
|
||||
|
||||
def blob
|
||||
@repo = project.repo
|
||||
@commit = project.commit(params[:commit_id])
|
||||
|
@ -151,6 +166,17 @@ class ProjectsController < ApplicationController
|
|||
|
||||
protected
|
||||
|
||||
def add_refs(commit, ref_cache)
|
||||
if ref_cache.empty?
|
||||
@repo.refs.each do |ref|
|
||||
ref_cache[ref.commit.id] ||= []
|
||||
ref_cache[ref.commit.id] << ref
|
||||
end
|
||||
end
|
||||
commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id
|
||||
commit.refs ||= []
|
||||
end
|
||||
|
||||
def project
|
||||
@project ||= Project.find_by_code(params[:id])
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue