diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..70516dacf72ad4db4d912a3f72f975b217ad8143 --- /dev/null +++ b/app/controllers/hooks_controller.rb @@ -0,0 +1,43 @@ +class HooksController < ApplicationController + before_filter :authenticate_user! + before_filter :project + layout "project" + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :authorize_admin_project!, :only => [:new, :create, :destroy] + + respond_to :html + + def index + @hooks = @project.web_hooks + end + + def new + @hook = @project.web_hooks.new + end + + def create + @hook = @project.web_hooks.new(params[:hook]) + @hook.author = current_user + @hook.save + + if @hook.valid? + redirect_to [@project, @hook] + else + respond_with(@hook) + end + end + + def show + @hook = @project.web_hooks.find(params[:id]) + end + + def destroy + @hook = @project.web_hooks.find(params[:id]) + @hook.destroy + + redirect_to project_hooks_path(@project) + end +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1e859ceac31135e6c0edfad4a56c6933204d8353..29fcb52eb9732c9e31524caef4f83540d5144c6d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -68,7 +68,7 @@ class ProjectsController < ApplicationController def show return render "projects/empty" unless @project.repo_exists? && @project.has_commits? - limit = (params[:limit] || 20).to_i + limit = (params[:limit] || 10).to_i @activities = @project.cached_updates(limit) end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9a112f4674fc44311049d6ad3926902ae2d67cd0..c0652cbeab99aca05dd4915d6412a466e6bff3bb 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController layout "project" def show - @activities = @project.fresh_commits(20) + @activities = @project.fresh_commits(10) end def branches diff --git a/app/models/user.rb b/app/models/user.rb index 8b136de90cf7addbf93c8480d50624067319d91d..ee9f0de11ece9411a194b4cf186f1e656cc42bbc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,5 +82,6 @@ end # linkedin :string(255) default(""), not null # twitter :string(255) default(""), not null # authentication_token :string(255) +# dark_scheme :boolean default(FALSE), not null # diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 0058bd57b919fd1772fc38a3e0a60062ab31f7ff..40b930c3a98c2b3331dbe3e51f21bc09f765104a 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -18,3 +18,14 @@ class WebHook < ActiveRecord::Base # There was a problem calling this web hook, let's forget about it. end end +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# + diff --git a/app/views/hooks/index.html.haml b/app/views/hooks/index.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..956367393cb3449469e0bfee04b72a3968d6b31b --- /dev/null +++ b/app/views/hooks/index.html.haml @@ -0,0 +1,10 @@ += render "repositories/head" +- unless @hooks.empty? + %div.update-data.ui-box.ui-box-small + .data + - @hooks.each do |hook| + %a.update-item{:href => project_hooks_path(@project, hook)} + %span.update-title{:style => "margin-bottom:0px;"} + = hook.url +- else + %h3 No hooks diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index d79f4599d804b7ee6e66660b16e41dc68c38f026..922a66ebf865f34f86d933e6e0668fadce209f56 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -1,4 +1,6 @@ class PostReceive + @queue = :post_receive + def self.perform(reponame, oldrev, newrev, ref) project = Project.find_by_path(reponame) return false if project.nil? diff --git a/config/routes.rb b/config/routes.rb index 90b391cd5a2d9680a61ca0553c1da64d0396d656..416ea6a9498132520cbacf0dd5baa8b4e8d360cf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,8 @@ Gitlab::Application.routes.draw do # Optionally, enable Resque here - # require 'resque/server' - # mount Resque::Server.new, at: '/info/resque' + require 'resque/server' + mount Resque::Server.new, at: '/info/resque' get 'tags'=> 'tags#index' get 'tags/:tag' => 'projects#index' @@ -83,6 +83,8 @@ Gitlab::Application.routes.draw do get :commits end end + + resources :hooks, :only => [:index, :new, :create, :destroy, :show] resources :snippets resources :commits resources :team_members diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3a3ac7c9c800451269bcddc386760b81177760fe..a62e56cdd30fd43894e9dc9ff0ca0acdebd511d7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -65,5 +65,6 @@ end # linkedin :string(255) default(""), not null # twitter :string(255) default(""), not null # authentication_token :string(255) +# dark_scheme :boolean default(FALSE), not null # diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index e73e554adbb00baeac5ae2046002cd107f187bb2..309bfc0fd533948b5e8b1a872da0b428e791dbf0 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -52,3 +52,14 @@ describe WebHook do end end end +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# +