1.0.1
This commit is contained in:
parent
d378468794
commit
0541b3f3c5
25 changed files with 235 additions and 180 deletions
|
@ -41,4 +41,24 @@ class ApplicationController < ActionController::Base
|
|||
super
|
||||
end
|
||||
end
|
||||
|
||||
def load_refs
|
||||
@branch = unless params[:branch].blank?
|
||||
params[:branch]
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@tag = unless params[:tag].blank?
|
||||
params[:tag]
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@ref = @branch || @tag || "master"
|
||||
end
|
||||
|
||||
def render_404
|
||||
render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,25 +8,19 @@ class CommitsController < ApplicationController
|
|||
before_filter :authorize_read_project!
|
||||
|
||||
def index
|
||||
load_refs # load @branch, @tag & @ref
|
||||
|
||||
@repo = project.repo
|
||||
@branch = if !params[:branch].blank?
|
||||
params[:branch]
|
||||
elsif !params[:tag].blank?
|
||||
params[:tag]
|
||||
else
|
||||
"master"
|
||||
end
|
||||
|
||||
if params[:path]
|
||||
@commits = @repo.log(@branch, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0)
|
||||
@commits = @repo.log(@ref, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0)
|
||||
else
|
||||
@commits = @repo.commits(@branch, params[:limit] || 100, params[:offset] || 0)
|
||||
@commits = @repo.commits(@ref, params[:limit] || 100, params[:offset] || 0)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.js
|
||||
format.json { render json: @commits }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,7 +32,6 @@ class CommitsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.js
|
||||
format.json { render json: @commit }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,11 +3,6 @@ class KeysController < ApplicationController
|
|||
|
||||
def index
|
||||
@keys = current_user.keys.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @keys }
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
@ -23,8 +18,6 @@ class KeysController < ApplicationController
|
|||
respond_with(@key)
|
||||
end
|
||||
|
||||
# DELETE /keys/1
|
||||
# DELETE /keys/1.json
|
||||
def destroy
|
||||
@key = current_user.keys.find(params[:id])
|
||||
@key.destroy
|
||||
|
@ -32,7 +25,6 @@ class KeysController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html { redirect_to keys_url }
|
||||
format.js { render :nothing => true }
|
||||
format.json { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,78 +8,10 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def index
|
||||
@projects = current_user.projects.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @projects }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@repo = project.repo
|
||||
@commit = @repo.commits.first
|
||||
@tree = @commit.tree
|
||||
@tree = @tree / params[:path] if params[:path]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: project }
|
||||
end
|
||||
rescue Grit::NoSuchPathError => ex
|
||||
respond_to do |format|
|
||||
format.html {render "projects/empty"}
|
||||
end
|
||||
end
|
||||
|
||||
def tree
|
||||
@repo = project.repo
|
||||
@branch = if !params[:branch].blank?
|
||||
params[:branch]
|
||||
elsif !params[:tag].blank?
|
||||
params[:tag]
|
||||
else
|
||||
"master"
|
||||
end
|
||||
|
||||
if params[:commit_id]
|
||||
@commit = @repo.commits(params[:commit_id]).first
|
||||
else
|
||||
@commit = @repo.commits(@branch || "master").first
|
||||
end
|
||||
@tree = @commit.tree
|
||||
@tree = @tree / params[:path] if params[:path]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.js do
|
||||
# temp solution
|
||||
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
|
||||
response.headers["Pragma"] = "no-cache"
|
||||
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
|
||||
end
|
||||
format.json { render json: project }
|
||||
end
|
||||
end
|
||||
|
||||
def blob
|
||||
@repo = project.repo
|
||||
@commit = project.commit(params[:commit_id])
|
||||
@tree = project.tree(@commit, params[:path])
|
||||
|
||||
if @tree.is_a?(Grit::Blob)
|
||||
send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name)
|
||||
else
|
||||
head(404)
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@project = Project.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @project }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -98,11 +30,9 @@ class ProjectsController < ApplicationController
|
|||
if @project.valid?
|
||||
format.html { redirect_to @project, notice: 'Project was successfully created.' }
|
||||
format.js
|
||||
format.json { render json: @project, status: :created, location: @project }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.js
|
||||
format.json { render json: @project.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
rescue Gitosis::AccessDenied
|
||||
|
@ -112,7 +42,6 @@ class ProjectsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html { render action: "new" }
|
||||
format.js
|
||||
format.json { render json: @project.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -121,29 +50,87 @@ class ProjectsController < ApplicationController
|
|||
if project.update_attributes(params[:project])
|
||||
format.html { redirect_to project, notice: 'Project was successfully updated.' }
|
||||
format.js
|
||||
format.json { head :ok }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.js
|
||||
format.json { render json: project.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@repo = project.repo
|
||||
@commit = @repo.commits.first
|
||||
@tree = @commit.tree
|
||||
@tree = @tree / params[:path] if params[:path]
|
||||
|
||||
rescue Grit::NoSuchPathError => ex
|
||||
respond_to do |format|
|
||||
format.html {render "projects/empty"}
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Wall
|
||||
#
|
||||
|
||||
def wall
|
||||
@notes = @project.common_notes
|
||||
@note = Note.new
|
||||
end
|
||||
|
||||
#
|
||||
# Repository preview
|
||||
#
|
||||
|
||||
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
|
||||
|
||||
@tree = @commit.tree
|
||||
@tree = @tree / params[:path] if params[:path]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.js do
|
||||
# diasbale cache to allow back button works
|
||||
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
|
||||
response.headers["Pragma"] = "no-cache"
|
||||
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
|
||||
end
|
||||
end
|
||||
rescue
|
||||
return render_404
|
||||
end
|
||||
|
||||
def blob
|
||||
@repo = project.repo
|
||||
@commit = project.commit(params[:commit_id])
|
||||
@tree = project.tree(@commit, params[:path])
|
||||
|
||||
if @tree.is_a?(Grit::Blob)
|
||||
send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name)
|
||||
else
|
||||
head(404)
|
||||
end
|
||||
rescue
|
||||
return render_404
|
||||
end
|
||||
|
||||
def destroy
|
||||
project.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to projects_url }
|
||||
format.json { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
def wall
|
||||
@notes = @project.common_notes
|
||||
@note = Note.new
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def project
|
||||
|
|
|
@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.js
|
||||
format.json { render json: @team_member }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.js
|
||||
format.json { render json: @team_member }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController
|
|||
if @team_member.save
|
||||
format.html { redirect_to @team_member, notice: 'Team member was successfully created.' }
|
||||
format.js
|
||||
format.json { render json: @team_member, status: :created, location: @team_member }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.js
|
||||
format.json { render json: @team_member.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to root_path }
|
||||
format.json { head :ok }
|
||||
format.js { render :nothing => true }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue