[refs #123] Merge master into 123-activity-feed

This commit is contained in:
konstantin.grabar 2012-02-06 19:46:32 +04:00
commit 96d3b35bdf
402 changed files with 15436 additions and 714 deletions

1
.gitignore vendored
View File

@ -12,6 +12,5 @@ public/assets/*
config/initializers/local.rb config/initializers/local.rb
public/system/* public/system/*
public/downloads/* public/downloads/*
.rvmrc
*.swp *.swp
*.tmproj *.tmproj

35
Gemfile
View File

@ -1,15 +1,17 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '3.0.11' #, :git => 'git://github.com/rails/rails.git' gem 'rails', '3.0.11' #, :git => 'git://github.com/rails/rails.git'
gem 'shotgun'
gem 'pg', '~> 0.11.0' gem 'pg', '~> 0.11.0'
gem 'silent-postgres', '~> 0.1.1' gem 'silent-postgres', '~> 0.1.1'
gem 'redhillonrails_core', '~> 1.2.0' # deprecated
# gem 'schema_plus', '~> 0.2.1' # buggy shit!
gem 'devise', '~> 1.5.2' gem 'devise', '~> 1.5.2'
gem 'omniauth', '~> 1.0.1' gem 'omniauth', '~> 1.0.1'
gem 'omniauth-openid', '~> 1.0.1' gem 'omniauth-openid', '~> 1.0.1'
gem 'cancan', '~> 1.6.7' gem 'cancan', '~> 1.6.7'
#gem 'bitmask_attributes'
gem "haml-rails", '~> 0.3.4' gem "haml-rails", '~> 0.3.4'
# gem "compass", '~> 0.11.5' # update when it will be needed # gem "compass", '~> 0.11.5' # update when it will be needed
@ -18,31 +20,39 @@ gem "yui-compressor", "0.9.5" # Higher versions depends on Platform gem which co
gem 'rails3-jquery-autocomplete' gem 'rails3-jquery-autocomplete'
gem 'ancestry', '~> 1.2.4' gem 'ancestry', '~> 1.2.4'
gem 'paperclip', "~> 2.3" gem 'paperclip', "~> 2.5"
gem "will_paginate", "~> 3.0.2" gem "will_paginate", "~> 3.0.2"
gem 'meta-tags', '~> 1.2.4', :require => 'meta_tags' gem 'meta-tags', '~> 1.2.4', :require => 'meta_tags'
gem "russian" gem "russian"
# gem 'ghoul_grack', '~> 0.0.1'
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http' gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
gem "grit" gem "grit", :git => 'git://github.com/mojombo/grit.git', :branch => 'master'
gem 'whenever', :require => false gem 'whenever', :require => false
gem 'delayed_job' gem 'delayed_job', '2.1.4'
gem 'highline', '~> 1.6.8' gem 'highline', '~> 1.6.8'
# Wiki
gem "gollum", "1.3.1"
gem "redcarpet", "1.17.2"
gem 'creole'
gem 'rdiscount'
#gem 'org-ruby'
gem 'RedCloth'
gem 'wikicloth'
# XML-RPC support # XML-RPC support
# gem 'actionwebservice' #, :git => 'git://github.com/ywen/actionwebservice.git'
gem "rails-xmlrpc", '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git' gem "rails-xmlrpc", '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git'
# gem 'passenger', '~> 3.0.11'
gem 'unicorn', '~> 4.1.1' gem 'unicorn', '~> 4.1.1'
group :production do group :production do
gem "airbrake", '~> 3.0.5' gem "airbrake", '~> 3.0.5'
# gem 'newrelic_rpm', '~> 3.1.1'
gem 'bluepill', :require => false gem 'bluepill', :require => false
end end
gem 'newrelic_rpm'
group :development do group :development do
# gem 'letter_opener' # gem 'letter_opener'
gem 'rails3-generators' gem 'rails3-generators'
@ -50,25 +60,16 @@ group :development do
gem 'hpricot' gem 'hpricot'
gem 'ruby_parser' gem 'ruby_parser'
# debug
gem 'ruby-debug'
# gem 'looksee'
# gem 'awesome_print'
# gem 'wirble'
gem 'hirb' gem 'hirb'
# gem 'rails-footnotes', '>= 3.7.5.rc4' # this shit is very buggy don't forget to switch it off back
# deploy # deploy
gem 'capistrano', :require => false gem 'capistrano', :require => false
gem 'capistrano-ext', :require => false gem 'capistrano-ext', :require => false
gem 'cape', :require => false gem 'cape', :require => false
# gem 'capistrano-exts', :require => false #, :git => 'git://github.com/chipiga/capistrano-exts.git'
# gem 'capistrano-recipes', :require => false
gem 'capistrano_colors', :require => false gem 'capistrano_colors', :require => false
end end
group :development, :test do group :development, :test do
gem 'mysql2', '<= 0.2.9'
gem 'rspec-rails', '~> 2.7.0' gem 'rspec-rails', '~> 2.7.0'
gem 'factory_girl_rails', '~> 1.4.0' gem 'factory_girl_rails', '~> 1.4.0'
gem 'rr' gem 'rr'

View File

@ -1,3 +1,13 @@
GIT
remote: git://github.com/mojombo/grit.git
revision: 3fc864f3c637e06e2fa7a81f6b48a5df58a9bc5b
branch: master
specs:
grit (2.4.1)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3.6)
GIT GIT
remote: git://github.com/rdblue/grack.git remote: git://github.com/rdblue/grack.git
revision: 020be3fef3fb308b9d214252522aa5945bf6584a revision: 020be3fef3fb308b9d214252522aa5945bf6584a
@ -7,6 +17,7 @@ GIT
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
RedCloth (4.2.9)
abstract (1.0.0) abstract (1.0.0)
actionmailer (3.0.11) actionmailer (3.0.11)
actionpack (= 3.0.11) actionpack (= 3.0.11)
@ -34,21 +45,23 @@ GEM
activemodel (= 3.0.11) activemodel (= 3.0.11)
activesupport (= 3.0.11) activesupport (= 3.0.11)
activesupport (3.0.11) activesupport (3.0.11)
airbrake (3.0.5) airbrake (3.0.9)
activesupport activesupport
builder builder
albino (1.3.3)
posix-spawn (>= 0.3.6)
ancestry (1.2.4) ancestry (1.2.4)
activerecord (>= 2.2.2) activerecord (>= 2.2.2)
arel (2.0.10) arel (2.0.10)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
bluepill (0.0.51) bluepill (0.0.52)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
daemons (~> 1.1.0) daemons (~> 1.1.0)
i18n (>= 0.5.0) i18n (>= 0.5.0)
state_machine (~> 0.9.4) state_machine (~> 1.1.0)
builder (2.1.2) builder (2.1.2)
cancan (1.6.7) cancan (1.6.7)
cape (1.0.1) cape (1.2.0)
capistrano (2.9.0) capistrano (2.9.0)
highline highline
net-scp (>= 1.0.0) net-scp (>= 1.0.0)
@ -58,28 +71,36 @@ GEM
capistrano-ext (1.2.1) capistrano-ext (1.2.1)
capistrano (>= 1.0.0) capistrano (>= 1.0.0)
capistrano_colors (0.5.5) capistrano_colors (0.5.5)
chronic (0.6.6) chronic (0.6.7)
cocaine (0.2.0) cocaine (0.2.1)
columnize (0.3.5) creole (0.4.2)
daemons (1.1.4) daemons (1.1.6)
delayed_job (2.1.4) delayed_job (2.1.4)
activesupport (~> 3.0) activesupport (~> 3.0)
daemons daemons
devise (1.5.2) devise (1.5.3)
bcrypt-ruby (~> 3.0) bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3) orm_adapter (~> 0.0.3)
warden (~> 1.1) warden (~> 1.1)
diff-lcs (1.1.3) diff-lcs (1.1.3)
erubis (2.6.6) erubis (2.6.6)
abstract (>= 1.0.0) abstract (>= 1.0.0)
expression_parser (0.9.0)
factory_girl (2.3.2) factory_girl (2.3.2)
activesupport activesupport
factory_girl_rails (1.4.0) factory_girl_rails (1.4.0)
factory_girl (~> 2.3.0) factory_girl (~> 2.3.0)
railties (>= 3.0.0) railties (>= 3.0.0)
grit (2.4.1) github-markup (0.7.0)
diff-lcs (~> 1.1) gollum (1.3.1)
mime-types (~> 1.15) albino (~> 1.3.2)
github-markup (>= 0.4.0, < 1.0.0)
grit (~> 2.4.1)
mustache (>= 0.11.2, < 1.0.0)
nokogiri (~> 1.4)
redcarpet
sanitize (~> 2.0.0)
sinatra (~> 1.0)
haml (3.1.4) haml (3.1.4)
haml-rails (0.3.4) haml-rails (0.3.4)
actionpack (~> 3.0) actionpack (~> 3.0)
@ -87,16 +108,14 @@ GEM
haml (~> 3.0) haml (~> 3.0)
railties (~> 3.0) railties (~> 3.0)
hashie (1.2.0) hashie (1.2.0)
highline (1.6.8) highline (1.6.11)
hirb (0.6.0) hirb (0.6.0)
hpricot (0.8.5) hpricot (0.8.6)
i18n (0.5.0) i18n (0.5.0)
jammit (0.6.5) jammit (0.6.5)
yui-compressor (>= 0.9.3) yui-compressor (>= 0.9.3)
json (1.6.3) json (1.6.5)
kgio (2.6.0) kgio (2.7.2)
linecache (0.46)
rbx-require-relative (> 0.0.4)
mail (2.2.19) mail (2.2.19)
activesupport (>= 2.3.6) activesupport (>= 2.3.6)
i18n (>= 0.4.0) i18n (>= 0.4.0)
@ -105,29 +124,32 @@ GEM
meta-tags (1.2.4) meta-tags (1.2.4)
actionpack actionpack
mime-types (1.17.2) mime-types (1.17.2)
mysql2 (0.2.9) mustache (0.99.4)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
net-sftp (2.0.5) net-sftp (2.0.5)
net-ssh (>= 2.0.9) net-ssh (>= 2.0.9)
net-ssh (2.2.1) net-ssh (2.3.0)
net-ssh-gateway (1.1.0) net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
omniauth (1.0.1) newrelic_rpm (3.3.1)
nokogiri (1.5.0)
omniauth (1.0.2)
hashie (~> 1.2) hashie (~> 1.2)
rack rack
omniauth-openid (1.0.1) omniauth-openid (1.0.1)
omniauth (~> 1.0) omniauth (~> 1.0)
rack-openid (~> 1.3.1) rack-openid (~> 1.3.1)
orm_adapter (0.0.5) orm_adapter (0.0.6)
paperclip (2.4.5) paperclip (2.5.2)
activerecord (>= 2.3.0) activerecord (>= 2.3.0)
activesupport (>= 2.3.2) activesupport (>= 2.3.2)
cocaine (>= 0.0.2) cocaine (>= 0.0.2)
mime-types mime-types
pg (0.11.0) pg (0.11.0)
polyglot (0.3.3) polyglot (0.3.3)
rack (1.2.4) posix-spawn (0.3.6)
rack (1.2.5)
rack-mount (0.6.14) rack-mount (0.6.14)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-openid (1.3.1) rack-openid (1.3.1)
@ -146,7 +168,7 @@ GEM
rails-xmlrpc (0.3.6) rails-xmlrpc (0.3.6)
rails3-generators (0.17.4) rails3-generators (0.17.4)
railties (>= 3.0.0) railties (>= 3.0.0)
rails3-jquery-autocomplete (1.0.4) rails3-jquery-autocomplete (1.0.5)
rails (~> 3.0) rails (~> 3.0)
railties (3.0.11) railties (3.0.11)
actionpack (= 3.0.11) actionpack (= 3.0.11)
@ -156,9 +178,12 @@ GEM
thor (~> 0.14.4) thor (~> 0.14.4)
raindrops (0.8.0) raindrops (0.8.0)
rake (0.9.2.2) rake (0.9.2.2)
rbx-require-relative (0.0.5) rdiscount (1.6.8)
rdoc (3.11) rdoc (3.12)
json (~> 1.4) json (~> 1.4)
redcarpet (1.17.2)
redhillonrails_core (1.2.0)
activerecord (>= 2)
rr (1.0.4) rr (1.0.4)
rspec (2.7.0) rspec (2.7.0)
rspec-core (~> 2.7.0) rspec-core (~> 2.7.0)
@ -173,20 +198,23 @@ GEM
activesupport (~> 3.0) activesupport (~> 3.0)
railties (~> 3.0) railties (~> 3.0)
rspec (~> 2.7.0) rspec (~> 2.7.0)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
ruby-openid (2.1.8) ruby-openid (2.1.8)
ruby_parser (2.3.1) ruby_parser (2.3.1)
sexp_processor (~> 3.0) sexp_processor (~> 3.0)
russian (0.6.0) russian (0.6.0)
i18n (>= 0.5.0) i18n (>= 0.5.0)
sexp_processor (3.0.8) sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sexp_processor (3.0.10)
shotgun (0.9)
rack (>= 1.0)
silent-postgres (0.1.1) silent-postgres (0.1.1)
state_machine (0.9.4) sinatra (1.2.8)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
state_machine (1.1.2)
thor (0.14.6) thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10) treetop (1.4.10)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
@ -198,16 +226,20 @@ GEM
warden (1.1.0) warden (1.1.0)
rack (>= 1.0) rack (>= 1.0)
web-app-theme (0.7.0) web-app-theme (0.7.0)
whenever (0.7.0) whenever (0.7.2)
activesupport (>= 2.3.4) activesupport (>= 2.3.4)
chronic (~> 0.6.3) chronic (~> 0.6.3)
will_paginate (3.0.2) wikicloth (0.7.1)
builder
expression_parser
will_paginate (3.0.3)
yui-compressor (0.9.5) yui-compressor (0.9.5)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
RedCloth
airbrake (~> 3.0.5) airbrake (~> 3.0.5)
ancestry (~> 1.2.4) ancestry (~> 1.2.4)
bluepill bluepill
@ -216,34 +248,40 @@ DEPENDENCIES
capistrano capistrano
capistrano-ext capistrano-ext
capistrano_colors capistrano_colors
delayed_job creole
delayed_job (= 2.1.4)
devise (~> 1.5.2) devise (~> 1.5.2)
factory_girl_rails (~> 1.4.0) factory_girl_rails (~> 1.4.0)
gollum (= 1.3.1)
grack! grack!
grit grit!
haml-rails (~> 0.3.4) haml-rails (~> 0.3.4)
highline (~> 1.6.8) highline (~> 1.6.8)
hirb hirb
hpricot hpricot
jammit jammit
meta-tags (~> 1.2.4) meta-tags (~> 1.2.4)
mysql2 (<= 0.2.9) newrelic_rpm
omniauth (~> 1.0.1) omniauth (~> 1.0.1)
omniauth-openid (~> 1.0.1) omniauth-openid (~> 1.0.1)
paperclip (~> 2.3) paperclip (~> 2.5)
pg (~> 0.11.0) pg (~> 0.11.0)
rails (= 3.0.11) rails (= 3.0.11)
rails-xmlrpc (~> 0.3.6) rails-xmlrpc (~> 0.3.6)
rails3-generators rails3-generators
rails3-jquery-autocomplete rails3-jquery-autocomplete
rdiscount
redcarpet (= 1.17.2)
redhillonrails_core (~> 1.2.0)
rr rr
rspec-rails (~> 2.7.0) rspec-rails (~> 2.7.0)
ruby-debug
ruby_parser ruby_parser
russian russian
shotgun
silent-postgres (~> 0.1.1) silent-postgres (~> 0.1.1)
unicorn (~> 4.1.1) unicorn (~> 4.1.1)
web-app-theme web-app-theme
whenever whenever
wikicloth
will_paginate (~> 3.0.2) will_paginate (~> 3.0.2)
yui-compressor (= 0.9.5) yui-compressor (= 0.9.5)

View File

@ -1,4 +1,4 @@
# coding: UTF-8 # -*- encoding : utf-8 -*-
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class AutoBuildListsController < ApplicationController class AutoBuildListsController < ApplicationController
before_filter :authenticate_user!, :except => :auto_build before_filter :authenticate_user!, :except => :auto_build
before_filter :find_auto_build_list, :only => :destroy before_filter :find_auto_build_list, :only => :destroy

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class BuildListsController < ApplicationController class BuildListsController < ApplicationController
CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt] CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
NESTED_ACTIONS = [:index, :new, :create] NESTED_ACTIONS = [:index, :new, :create]
@ -13,20 +14,29 @@ class BuildListsController < ApplicationController
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS) load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
def index def index
filter_params = params[:filter] || {} if request.post?
if @project new_params = {:filter => {}}
@action_url = project_build_lists_path(@project) params[:filter].each do |k,v|
new_params[:filter][k] = v unless v.empty?
end
redirect_to build_lists_path(new_params)
else else
@action_url = build_lists_path filter_params = params[:filter] || {}
end if @project
@action_url = project_build_lists_path(@project)
else
@action_url = build_lists_path
end
@filter = BuildList::Filter.new(@project, filter_params) @filter = BuildList::Filter.new(@project, filter_params)
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page] @build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
@build_server_status = begin @build_server_status = begin
BuildServer.get_status BuildServer.get_status
rescue Exception # Timeout::Error rescue Exception # Timeout::Error
{} {}
end
end end
end end
@ -39,7 +49,7 @@ class BuildListsController < ApplicationController
Arch.where(:id => params[:arches]).each do |arch| Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => params[:bpls]).each do |bpl| Platform.main.where(:id => params[:bpls]).each do |bpl|
@build_list = @project.build_lists.build(params[:build_list]) @build_list = @project.build_lists.build(params[:build_list])
@build_list.commit_hash = @project.git_repository.commits(@build_list.project_version.match(/(.+)_latest$/).to_a.last || @build_list.project_version).first.id @build_list.commit_hash = @project.git_repository.commits(@build_list.project_version.match(/^latest_(.+)/).to_a.last || @build_list.project_version).first.id
@build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user @build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl} flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl}
if @build_list.save if @build_list.save
@ -120,9 +130,9 @@ class BuildListsController < ApplicationController
@build_list.notified_at = Time.current @build_list.notified_at = Time.current
@build_list.save @build_list.save
@build_list.delay.publish if @build_list.auto_publish # && @build_list.can_publish?
render :nothing => true, :status => 200 render :nothing => true, :status => 200
@build_list.delay.publish if @build_list.auto_publish # && @build_list.can_publish?
end end
def circle_build def circle_build

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_category, :only => [:show, :edit, :update, :destroy] before_filter :find_category, :only => [:show, :edit, :update, :destroy]

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class CollaboratorsController < ApplicationController class CollaboratorsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class CommentsController < ApplicationController class CommentsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy] before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy]
@ -13,7 +14,7 @@ class CommentsController < ApplicationController
def create def create
@comment = @commentable.comments.build(params[:comment]) if @commentable.class == Issue @comment = @commentable.comments.build(params[:comment]) if @commentable.class == Issue
@comment = Comment.new(params[:comment].merge(:commentable_id => @commentable.id, :commentable_type => @commentable.class.name)) if @commentable.class == Grit::Commit @comment = Comment.new(params[:comment].merge(:commentable_id => @commentable.id, :commentable_type => @commentable.class.name, :project => @project)) if @commentable.class == Grit::Commit
@comment.user = current_user @comment.user = current_user
if @comment.save if @comment.save
flash[:notice] = I18n.t("flash.comment.saved") flash[:notice] = I18n.t("flash.comment.saved")
@ -74,7 +75,10 @@ class CommentsController < ApplicationController
def find_comment def find_comment
@comment = Comment.find(params[:id]) @comment = Comment.find(params[:id])
@comment.project = @project if @comment.commentable_type == 'Grit::Commit' if @comment.commentable_type == 'Grit::Commit'
@comment.project = @project
@comment.helper
end
end end
def find_project def find_project

View File

@ -0,0 +1,32 @@
# -*- encoding : utf-8 -*-
class CommitSubscribesController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :project
before_filter :find_commit
def create
if Subscribe.subscribe_to_commit(@options)
flash[:notice] = I18n.t("flash.subscribe.commit.saved")
# TODO js
redirect_to commit_path(@project, @commit)
else
flash[:error] = I18n.t("flash.subscribe.saved_error")
redirect_to commit_path(@project, @commit)
end
end
def destroy
Subscribe.unsubscribe_from_commit(@options)
flash[:notice] = t("flash.subscribe.commit.destroyed")
redirect_to commit_path(@project, @commit)
end
protected
def find_commit
@commit = @project.git_repository.commit(params[:commit_id])
@options = {:project_id => @project.id, :subscribeable_id => @commit.id, :subscribeable_type => @commit.class.name, :user_id => current_user.id}
end
end

View File

@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
class ContainersController < ApplicationController class ContainersController < ApplicationController
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class DownloadsController < ApplicationController class DownloadsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource load_and_authorize_resource

View File

@ -1,4 +1,4 @@
# coding: UTF-8 # -*- encoding : utf-8 -*-
class EventLogsController < ApplicationController class EventLogsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource load_and_authorize_resource

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Git::BaseController < ApplicationController class Git::BaseController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
@ -39,4 +40,4 @@ class Git::BaseController < ApplicationController
def set_current_branch def set_current_branch
@current_branch = @branches.select{|b| b.name == @treeish }.first @current_branch = @branches.select{|b| b.name == @treeish }.first
end end
end end

View File

@ -1,11 +1,10 @@
# -*- encoding : utf-8 -*-
class Git::BlobsController < Git::BaseController class Git::BlobsController < Git::BaseController
before_filter :set_path
before_filter :set_commit_hash
before_filter :find_tree before_filter :find_tree
before_filter :set_path_blob
before_filter :set_commit_hash
def show def show
@blob = @tree / @path
if params[:raw] if params[:raw]
image_url = Rails.root.to_s + "/" + @path image_url = Rails.root.to_s + "/" + @path
@ -18,21 +17,18 @@ class Git::BlobsController < Git::BaseController
end end
def blame def blame
@blob = @tree / @path
@blame = Grit::Blob.blame(@git_repository.repo, @commit.try(:id), @path) @blame = Grit::Blob.blame(@git_repository.repo, @commit.try(:id), @path)
end end
def raw def raw
@blob = @tree / @path
headers["Content-Disposition"] = %[attachment;filename="#{@blob.name}"] headers["Content-Disposition"] = %[attachment;filename="#{@blob.name}"]
render :text => @blob.data, :content_type => @blob.mime_type render :text => @blob.data, :content_type => @blob.mime_type
end end
protected protected
def set_path def set_path_blob
@path = params[:path] @path = params[:path]
@blob = @tree / @path.encode_to_default
end end
def set_commit_hash def set_commit_hash

View File

@ -1,7 +1,8 @@
# -*- encoding : utf-8 -*-
class Git::CommitsController < Git::BaseController class Git::CommitsController < Git::BaseController
def index def index
@branch_name = (params[:branch] ? params[:branch] : "master") @branch_name = params[:treeish] || "master"
@path = params[:path] @path = params[:path]
if @path.present? if @path.present?

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Git::RepositoriesController < Git::BaseController class Git::RepositoriesController < Git::BaseController
def show def show
@ -7,4 +8,4 @@ class Git::RepositoriesController < Git::BaseController
render :template => "git/repositories/empty" unless @tree render :template => "git/repositories/empty" unless @tree
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Git::TreesController < Git::BaseController class Git::TreesController < Git::BaseController
def show def show
@ -13,4 +14,4 @@ class Git::TreesController < Git::BaseController
render :template => "git/repositories/show" render :template => "git/repositories/show"
end end
end end

View File

@ -1,4 +1,4 @@
# coding: UTF-8 # -*- encoding : utf-8 -*-
class GroupsController < ApplicationController class GroupsController < ApplicationController
is_related_controller! is_related_controller!

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class IssuesController < ApplicationController class IssuesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_project before_filter :find_project

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class MembersController < ApplicationController class MembersController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
is_related_controller! is_related_controller!

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class PersonalRepositoriesController < ApplicationController class PersonalRepositoriesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_repository#, :only => [:show, :destroy, :add_project, :remove_project, :make_private, :settings] before_filter :find_repository#, :only => [:show, :destroy, :add_project, :remove_project, :make_private, :settings]
@ -7,7 +8,7 @@ class PersonalRepositoriesController < ApplicationController
def show def show
if params[:query] if params[:query]
@projects = @repository.projects.recent.by_name(params[:query]).paginate :page => params[:project_page], :per_page => 30 @projects = @repository.projects.recent.by_name("%#{params[:query]}%").paginate :page => params[:project_page], :per_page => 30
else else
@projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30 @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30
end end

View File

@ -1,4 +1,4 @@
# coding: UTF-8 # -*- encoding : utf-8 -*-
class PlatformsController < ApplicationController class PlatformsController < ApplicationController
before_filter :authenticate_user!, :except => :easy_urpmi before_filter :authenticate_user!, :except => :easy_urpmi
before_filter :find_platform, :only => [:freeze, :unfreeze, :clone, :edit, :destroy] before_filter :find_platform, :only => [:freeze, :unfreeze, :clone, :edit, :destroy]
@ -113,7 +113,7 @@ class PlatformsController < ApplicationController
@cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], @cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'],
:owner_id => current_user.id, :owner_type => current_user.class.to_s) :owner_id => current_user.id, :owner_type => current_user.class.to_s)
if @cloned.persisted? if @cloned.persisted?
flash[:notice] = 'Клонирование успешно' flash[:notice] = I18n.t("flash.platform.clone_success")
redirect_to @cloned redirect_to @cloned
else else
flash[:error] = @cloned.errors.full_messages.join('. ') flash[:error] = @cloned.errors.full_messages.join('. ')

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class PrivateUsersController < ApplicationController class PrivateUsersController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_platform_and_private_users before_filter :find_platform_and_private_users
@ -13,7 +14,7 @@ class PrivateUsersController < ApplicationController
@pair = PrivateUser.generate_pair(params[:platform_id], current_user.id) @pair = PrivateUser.generate_pair(params[:platform_id], current_user.id)
@urpmi_list = @platform.urpmi_list(request.host, @pair) @urpmi_list = @platform.urpmi_list(request.host, @pair)
redirect_to platform_private_users_path(params[:platform_id]), :notice => "Логин: #{@pair[:login]} Пароль: #{@pair[:pass]}" redirect_to platform_private_users_path(params[:platform_id]), :notice => I18n.t('flash.private_users', :login => @pair[:login], :password => @pair[:pass])
end end
#def destroy #def destroy

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class PrivatesController < ApplicationController class PrivatesController < ApplicationController
require 'digest/sha2' require 'digest/sha2'

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class ProductBuildListsController < ApplicationController class ProductBuildListsController < ApplicationController
before_filter :authenticate_user!, :except => [:status_build] before_filter :authenticate_user!, :except => [:status_build]
load_and_authorize_resource :platform, :only => [:create] load_and_authorize_resource :platform, :only => [:create]

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class ProductsController < ApplicationController class ProductsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_product, :only => [:show, :edit, :update, :destroy] before_filter :find_product, :only => [:show, :edit, :update, :destroy]

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class ProjectsController < ApplicationController class ProjectsController < ApplicationController
is_related_controller! is_related_controller!
@ -17,13 +18,13 @@ class ProjectsController < ApplicationController
end.accessible_by(current_ability) end.accessible_by(current_ability)
@projects = if params[:query] @projects = if params[:query]
@projects.by_name(params[:query]).order("CHAR_LENGTH(name) ASC") @projects.by_name("%#{params[:query]}%").order("CHAR_LENGTH(name) ASC")
else else
@projects @projects
end.paginate(:page => params[:project_page]) end.paginate(:page => params[:project_page])
@own_projects = current_user.own_projects @own_projects = current_user.own_projects
@part_projects = current_user.projects + current_user.groups.map(&:projects).flatten.uniq - @own_projects #@part_projects = current_user.projects + current_user.groups.map(&:projects).flatten.uniq - @own_projects
end end
def show def show

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class RepositoriesController < ApplicationController class RepositoriesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_repository, :except => [:index, :new, :create] before_filter :find_repository, :except => [:index, :new, :create]
@ -19,7 +20,7 @@ class RepositoriesController < ApplicationController
def show def show
if params[:query] if params[:query]
@projects = @repository.projects.recent.by_name(params[:query]).paginate :page => params[:project_page], :per_page => 30 @projects = @repository.projects.recent.by_name("%#{params[:query]}%").paginate :page => params[:project_page], :per_page => 30
else else
@projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30 @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class RpcController < ApplicationController class RpcController < ApplicationController
exposes_xmlrpc_methods exposes_xmlrpc_methods
@ -11,30 +12,30 @@ class RpcController < ApplicationController
# client.call("project_versions", 1) # client.call("project_versions", 1)
def platforms def platforms
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список платформ') ActiveSupport::Notifications.instrument "event_log.observer", :message => I18n.t('event_log.notices.platforms_list')
Platform.select('name').where("platform_type = ?", 'main').map(&:name) Platform.select('name').where("platform_type = ?", 'main').map(&:name)
end end
def user_projects def user_projects
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список пользовательских проектов') ActiveSupport::Notifications.instrument "event_log.observer", :message => I18n.t('event_log.notices.users_list')
current_user.projects.map{|p| { :id => p.id, :name => p.name } } current_user.projects.map{|p| { :id => p.id, :name => p.name } }
end end
def project_versions id def project_versions id
p = Project.find_by_id(id) p = Project.find_by_id(id)
ActiveSupport::Notifications.instrument("event_log.observer", :object => p, :message => "список версий") ActiveSupport::Notifications.instrument "event_log.observer", :object => p, :message => I18n.t('event_log.notices.versions_list')
p.project_versions.collect {|tag| tag.name.gsub(/^\w+\./, "")} rescue 'not found' p.tags.map(&:name) rescue 'not found'
end end
def build_status id def build_status id
bl = BuildList.find_by_id(id) bl = BuildList.find_by_id(id)
ActiveSupport::Notifications.instrument("event_log.observer", :object => bl, :message => 'статус сборки') ActiveSupport::Notifications.instrument "event_log.observer", :object => bl, :message => I18n.t('event_log.notices.status')
bl.try(:status) || 'not found' bl.try(:status) || 'not found'
end end
def build_packet project_id, repo_id def build_packet project_id, repo_id
# p = Project.find_by_id(project_id); r = Repository.find_by_id(repo_id) # p = Project.find_by_id(project_id); r = Repository.find_by_id(repo_id)
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'сборка пакета') ActiveSupport::Notifications.instrument "event_log.observer", :message => I18n.t('event_log.notices.project_build')
'unknown' # TODO: build packet 'unknown' # TODO: build packet
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Settings::NotifiersController < ApplicationController class Settings::NotifiersController < ApplicationController
layout "sessions" layout "sessions"
@ -12,10 +13,10 @@ class Settings::NotifiersController < ApplicationController
def update def update
if @notifier.update_attributes(params[:settings_notifier]) if @notifier.update_attributes(params[:settings_notifier])
flash[:notice] = I18n.t("flash.settings.saved") flash[:notice] = I18n.t("flash.settings.saved")
redirect_to [@user, @notifier] redirect_to user_settings_notifier_path(@user)
else else
flash[:notice] = I18n.t("flash.settings.save_error") flash[:notice] = I18n.t("flash.settings.save_error")
redirect_to [@user, @notifier] redirect_to user_settings_notifier_path(@user)
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class SubscribesController < ApplicationController class SubscribesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def open_id def open_id
# raise env['omniauth.auth'].inspect # raise env['omniauth.auth'].inspect

View File

@ -1,4 +1,4 @@
# coding: UTF-8 # -*- encoding : utf-8 -*-
class UsersController < ApplicationController class UsersController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_user, :only => [:show, :edit, :update, :destroy] before_filter :find_user, :only => [:show, :edit, :update, :destroy]

View File

@ -0,0 +1,277 @@
# -*- encoding : utf-8 -*-
#require 'lib/gollum'
require 'cgi'
class WikiController < ApplicationController
WIKI_OPTIONS = {}
before_filter :authenticate_user!
load_resource :project
before_filter :authorize_read_actions, :only => [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages]
before_filter :authorize_write_actions, :only => [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview]
before_filter :get_wiki
def index
@name = 'Home'
@page = @wiki.page(@name)
show_or_create_page
end
def show
@name = CGI.unescape(params['id'])
redirect_to project_wiki_index_path(@project) and return if @name == 'Home'
ref = params['ref'] ? params['ref'] : @wiki.ref
@page = @wiki.page(@name, ref)
if !@page && @wiki.page(@name)
flash[:error] = t('flash.wiki.ref_not_exist')
redirect_to project_wiki_path(@project, CGI.escape(@name)) and return
end
show_or_create_page
end
def edit
@name = CGI.unescape(params[:id])
if page = @wiki.page(@name)
@page = page
@content = page.text_data
render :edit
else
render :new
end
end
def update
@name = CGI.unescape(params[:id])
@page = @wiki.page(@name)
name = params[:rename] || @name
committer = Gollum::Committer.new(@wiki, commit)
commit_arg = {:committer => committer}
update_wiki_page(@wiki, @page, params[:content], commit_arg, name, params[:format])
update_wiki_page(@wiki, @page.footer, params[:footer], commit_arg) if params[:footer]
update_wiki_page(@wiki, @page.sidebar, params[:sidebar], commit_arg) if params[:sidebar]
committer.commit
flash[:notice] = t('flash.wiki.successfully_updated', :name => @name)
redirect_to project_wiki_path(@project, CGI.escape(@name))
end
def new
@name = ''
end
def create
@name = CGI.unescape(params['page'])
format = params['format'].intern
begin
@wiki.write_page(@name, format, params['content'] || '', commit)
redirect_to project_wiki_path(@project, CGI.escape(@name))
rescue Gollum::DuplicatePageError => e
flash[:error] = t("flash.wiki.duplicate_page", :name => @name)
render :action => :new
end
end
def destroy
@name = CGI.unescape(params[:id])
page = @wiki.page(@name)
if page
@wiki.delete_page(page, commit.merge(:message => 'Page removed'))
flash[:notice] = t("flash.wiki.page_successfully_removed")
else
flash[:notice] = t("flash.wiki.page_not_found", :name => params[:id])
end
redirect_to project_wiki_index_path(@project)
end
def git
end
def compare
@name = CGI.unescape(params[:id])
if request.post?
@versions = params[:versions] || []
if @versions.size < 2
redirect_to history_project_wiki_path(@project, CGI.escape(@name))
else
redirect_to compare_versions_project_wiki_path(@project, CGI.escape(@name),
sprintf('%s...%s', @versions.last, @versions.first))
end
elsif request.get?
@versions = params[:versions].split(/\.{2,3}/)
if @versions.size < 2
redirect_to history_project_wiki_path(@project, CGI.escape(@name))
return
end
@page = @wiki.page(@name)
@diffs = [@wiki.repo.diff(@versions.first, @versions.last, @page.path).first]
render :compare
else
redirect_to project_wiki_path(@project, CGI.escape(@name))
end
end
def compare_wiki
if request.post?
@versions = params[:versions] || []
if @versions.size < 2
redirect_to history_project_wiki_index_path(@project)
else
redirect_to compare_versions_project_wiki_index_path(@project,
sprintf('%s...%s', @versions.last, @versions.first))
end
elsif request.get?
@versions = params[:versions].split(/\.{2,3}/)
if @versions.size < 2
redirect_to history_project_wiki_index_path(@project)
return
end
@diffs = @wiki.repo.diff(@versions.first, @versions.last)
render :compare
else
redirect_to project_wiki_path(@project, CGI.escape(@name))
end
end
def revert
@name = CGI.unescape(params[:id])
@page = @wiki.page(@name)
sha1 = params[:sha1]
sha2 = params[:sha2]
if @wiki.revert_page(@page, sha1, sha2, commit)
flash[:notice] = t("flash.wiki.revert_success")
redirect_to project_wiki_path(@project, CGI.escape(@name))
else
# if revert wasn't successful then redirect back to comparsion.
# if second commit version is missed, then second version is
# params[:sha1] and first version is parent of params[:sha1]
# (see Gollum::Wiki#revert_page)
sha2, sha1 = sha1, "#{sha1}^" if !sha2
@versions = [sha1, sha2]
diffs = @wiki.repo.diff(@versions.first, @versions.last, @page.path)
@diffs = [diffs.first]
flash[:error] = t("flash.wiki.patch_does_not_apply")
render :compare
end
end
def revert_wiki
sha1 = params[:sha1]
sha2 = params[:sha2]
if @wiki.revert_commit(sha1, sha2, commit)
flash[:notice] = t("flash.wiki.revert_success")
redirect_to project_wiki_index_path(@project)
else
sha2, sha1 = sha1, "#{sha1}^" if !sha2
@versions = [sha1, sha2]
diffs = @wiki.repo.diff(@versions.first, @versions.last)
@diffs = [diffs.first]
flash[:error] = t("flash.wiki.patch_does_not_apply")
render :compare
end
end
def preview
@name = params['page']
@page = @wiki.preview_page(@name, params['content'], params['format'])
@content = @page.formatted_data
@editable = false
render :show
end
def history
@name = CGI.unescape(params[:id])
if @page = @wiki.page(@name)
@versions = @page.versions
else
redirect_to :back
end
end
def wiki_history
@versions = @wiki.log
render :history
end
def search
@query = params[:q]
@results = @wiki.search @query
end
def pages
@results = @wiki.pages
@ref = @wiki.ref
end
protected
def get_wiki
@wiki = Gollum::Wiki.new(@project.wiki_path,
WIKI_OPTIONS.merge(:base_path => project_wiki_index_path(@project)))
end
# This method was grabbed from sinatra application, shipped with Gollum gem.
# See Gollum gem and Gollum License if you have any questions about license notes.
# https://github.com/github/gollum https://github.com/github/gollum/blob/master/LICENSE
def update_wiki_page(wiki, page, content, commit_msg, name = nil, format = nil)
return if !page ||
((!content || page.raw_data == content) && page.format == format)
name ||= page.name
format = (format || page.format).to_sym
content ||= page.raw_data
wiki.update_page(page, name, format, content.to_s, commit_msg)
end
def commit_message
if params['message'] and !params['message'].empty?
msg = params['message']
else
# msg = "#{!!@wiki.page(@name) ? 'Updated page' : 'Created page'} #{@name}"
msg = case action_name.to_s
when 'create' then "Created page #{@name.to_s}"
when 'update' then "Updated page #{@name.to_s}"
when 'revert' then "Reverted page #{@name.to_s}"
when 'revert_wiki' then "Reverted wiki"
end
msg += " (#{params['format']})" if params['format']
end
msg = 'Unhandled action' if !msg || msg.empty?
{ :message => msg }
end
def commit
commit_message.merge({:name => current_user.uname, :email => current_user.email})
end
def show_or_create_page
if @page
@content = @page.formatted_data
@editable = can?(:write, @project)
render :show
elsif file = @wiki.file(@name)
render :text => file.raw_data, :content_type => file.mime_type
elsif can? :write, @project
# @name = CGI.escape(@name)
@new = true
render :new
else
redirect_to forbidden_path
end
end
def authorize_read_actions
redirect_to forbidden_path and return if cannot? :read, @project
end
def authorize_write_actions
redirect_to forbidden_path and return if cannot? :write, @project
end
end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module ApplicationHelper module ApplicationHelper
def choose_title def choose_title
title = if ['categories', 'personal_repositories', 'downloads'].include?(controller.controller_name) title = if ['categories', 'personal_repositories', 'downloads'].include?(controller.controller_name)

View File

@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
module CommentsHelper module CommentsHelper
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module CommitHelper module CommitHelper
def render_commit_stats(stats) def render_commit_stats(stats)
@ -12,7 +13,7 @@ module CommitHelper
end end
res << "</table>" res << "</table>"
res.join("\n").html_safe res.join("\n").encode_to_default.html_safe
end end
# def format_commit_message(message) # def format_commit_message(message)
@ -33,7 +34,7 @@ module CommitHelper
def short_commit_message(message) def short_commit_message(message)
# Why 42? Because it is the Answer! # Why 42? Because it is the Answer!
truncate(message, :length => 42, :omission => "...") truncate(message, :length => 42, :omission => "...").encode_to_default
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module DiffHelper module DiffHelper
def render_diff(diff) def render_diff(diff)
@ -11,7 +12,7 @@ module DiffHelper
res += "</tbody>" res += "</tbody>"
res += "</table>" res += "</table>"
res.html_safe res.html_safe.force_encoding(Encoding.default_internal || Encoding::UTF_8)
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module GitHelper module GitHelper
def render_path def render_path
@ -25,7 +26,7 @@ module GitHelper
res = "#{link_to @project.name, tree_path(@project)} /" res = "#{link_to @project.name, tree_path(@project)} /"
end end
res.html_safe res.encode_to_default.html_safe
end end
def render_line_numbers(n) def render_line_numbers(n)
@ -37,7 +38,9 @@ module GitHelper
def render_blob(blob) def render_blob(blob)
res = "" res = ""
blob.data.split("\n").collect{|line| "<div>#{line.present? ? h(line) : "<br>"}</div>"}.join blob.data.encode_to_default.split("\n").collect do |line|
"<div>#{line.present? ? h(line) : "<br>"}</div>"
end.join
end end
def choose_render_way(blob) def choose_render_way(blob)
@ -45,4 +48,9 @@ module GitHelper
return :text if blob.mime_type.match(/text|xml|json/) return :text if blob.mime_type.match(/text|xml|json/)
:binary :binary
end end
def force_encoding_to_site(string)
string.dup.encode_to_default
end
end end

View File

@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
module IssuesHelper module IssuesHelper
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module PlatformsHelper module PlatformsHelper
def repository_name_postfix(platform) def repository_name_postfix(platform)
return "" unless platform return "" unless platform

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module ProjectsHelper module ProjectsHelper
def git_repo_url(name) def git_repo_url(name)
if current_user if current_user

View File

@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
module Settings::NotifiersHelper module Settings::NotifiersHelper
end end

View File

@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
module SubscribesHelper module SubscribesHelper
end end

111
app/helpers/wiki_helper.rb Normal file
View File

@ -0,0 +1,111 @@
# -*- encoding : utf-8 -*-
module WikiHelper
def revert_path(project, first, second, name)
if name
revert_page_project_wiki_path(project, CGI.escape(name), first, second)
else
revert_project_wiki_index_path(project, first, second)
end
end
def compare_path(project, name)
if name
compare_project_wiki_path(@project, CGI.escape(name))
else
compare_project_wiki_index_path(@project)
end
end
def gravatar_url(email)
"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.downcase)}?s=16&r=pg"
end
def escaped_name
CGI.escape(@name)
end
def editor_path(project, name)
if @new
url_for(:controller => :wiki, :action => :create, :project_id => project.id)
else
url_for(:controller => :wiki, :action => :update, :project_id => project.id, :id => name)
end
end
def view_path(project, name)
name == 'Home' ? project_wiki_index_path(project) : project_wiki_path(project, name)
end
def wiki_formats
APP_CONFIG['wiki_formats'].map do |key, val|
[ val, key.to_s ]
end.sort do |a, b|
a.first.downcase <=> b.first.downcase
end
end
def footer
if @footer.nil?
@footer = !!@page.footer ? @page.footer : false
end
@footer
end
def sidebar
if @sidebar.nil?
@sidebar = !!@page.sidebar ? @page.sidebar : false
end
@sidebar
end
def has_footer?
@footer = (@page.footer || false) if @footer.nil? && @page
!!@footer
end
def has_sidebar?
@sidebar = (@page.sidebar || false) if @sidebar.nil? && @page
!!@sidebar
end
def footer_content
has_footer? && @footer.formatted_data
end
def footer_format
has_footer? && @footer.format.to_s
end
def sidebar_content
has_sidebar? && @sidebar.formatted_data
end
def sidebar_format
has_sidebar? && @sidebar.format.to_s
end
def author
@page.version.author.name.force_encoding(Encoding.default_internal || Encoding::UTF_8)
end
def author_email
@page.version.author.email
end
def user_path_by_user(user)
(user.present?) ? user_path(user) : 'javascript:void(0)'
end
def user_link_by_user(user)
link_to (user.present?) ? user.uname : author, user_path_by_user(user)
end
def date
@page.version.authored_date.strftime("%Y-%m-%d %H:%M:%S")
end
def format
@new ? 'markdown' : @page.format
end
end

View File

@ -1,4 +1,4 @@
# coding: UTF-8 # -*- encoding : utf-8 -*-
class UserMailer < ActionMailer::Base class UserMailer < ActionMailer::Base
default :from => APP_CONFIG['do-not-reply-email'] default :from => APP_CONFIG['do-not-reply-email']
@ -13,15 +13,7 @@ class UserMailer < ActionMailer::Base
def new_comment_notification(comment, user) def new_comment_notification(comment, user)
@user = user @user = user
@comment = comment @comment = comment
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_comment_notification")) do |format| mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commentable.class == Grit::Commit ? 'commit_' : ''}comment_notification")) do |format|
format.html
end
end
def new_comment_reply_notification(comment, user)
@user = user
@comment = comment
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_comment_reply_notification")) do |format|
format.html format.html
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# If rules goes one by one CanCan joins them by 'OR' sql operator # If rules goes one by one CanCan joins them by 'OR' sql operator
# If rule has multiple conditions CanCan joins them by 'AND' sql operator # If rule has multiple conditions CanCan joins them by 'AND' sql operator
# WARNING: # WARNING:
@ -30,7 +31,7 @@ class Ability
can [:show, :update], Settings::Notifier, :user_id => user.id can [:show, :update], Settings::Notifier, :user_id => user.id
can [:read, :create], Group can [:read, :create, :autocomplete_group_uname], Group
can [:update, :manage_members], Group do |group| can [:update, :manage_members], Group do |group|
group.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin') # or group.owner_id = user.id group.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin') # or group.owner_id = user.id
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Arch < ActiveRecord::Base class Arch < ActiveRecord::Base
has_many :build_lists, :dependent => :destroy has_many :build_lists, :dependent => :destroy

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Authentication < ActiveRecord::Base class Authentication < ActiveRecord::Base
belongs_to :user belongs_to :user

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class AutoBuildList < ActiveRecord::Base class AutoBuildList < ActiveRecord::Base
belongs_to :project belongs_to :project
belongs_to :arch belongs_to :arch

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class BuildList < ActiveRecord::Base class BuildList < ActiveRecord::Base
belongs_to :project belongs_to :project
belongs_to :arch belongs_to :arch

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class BuildList::Filter class BuildList::Filter
def initialize(project, options = {}) def initialize(project, options = {})
@project = project @project = project
@ -67,10 +68,10 @@ class BuildList::Filter
def build_date_from_params(field_name, params) def build_date_from_params(field_name, params)
if params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present? if params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present?
Date.civil((params["#{field_name}(1i)"].presence || Date.today.year).to_i, Date.civil((params["#{field_name}(1i)"].presence || Date.today.year).to_i,
(params["#{field_name}(2i)"].presence || Date.today.mohth).to_i, (params["#{field_name}(2i)"].presence || Date.today.month).to_i,
(params["#{field_name}(3i)"].presence || Date.today.day).to_i) (params["#{field_name}(3i)"].presence || Date.today.day).to_i)
else else
nil nil
end end
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class BuildList::Item < ActiveRecord::Base class BuildList::Item < ActiveRecord::Base
belongs_to :build_list belongs_to :build_list

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Category < ActiveRecord::Base class Category < ActiveRecord::Base
has_many :projects, :dependent => :nullify has_many :projects, :dependent => :nullify

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true belongs_to :commentable, :polymorphic => true
belongs_to :user belongs_to :user
@ -8,6 +9,17 @@ class Comment < ActiveRecord::Base
# FIXME # FIXME
after_create :subscribe_on_reply, :unless => "commentable_type == 'Grit::Commit'" after_create :subscribe_on_reply, :unless => "commentable_type == 'Grit::Commit'"
#after_create :deliver_new_comment_notification, :unless => "commentable_type == 'Grit::Commit'" #after_create :deliver_new_comment_notification, :unless => "commentable_type == 'Grit::Commit'"
after_create :invoke_helper, :if => "commentable_type == 'Grit::Commit'"
after_create :subscribe_users
after_create {|comment| Subscribe.new_comment_notification(comment)}
def helper
class_eval "def commentable; project.git_repository.commit('#{commentable_id}'); end" if commentable_type == 'Grit::Commit'
end
def own_comment?(user)
user_id == user.id
end
def reply?(subscribe) def reply?(subscribe)
self.commentable.comments.exists?(:user_id => subscribe.user.id) self.commentable.comments.exists?(:user_id => subscribe.user.id)
@ -40,4 +52,22 @@ class Comment < ActiveRecord::Base
def subscribe_on_reply def subscribe_on_reply
self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id) self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id)
end end
def invoke_helper
self.helper
end
def subscribe_users
if self.commentable.class == Issue
self.commentable.subscribes.create(:user => self.user) if !self.commentable.subscribes.exists?(:user_id => self.user.id)
elsif self.commentable.class == Grit::Commit
recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map &:object # admins
recipients << self.user << User.where(:email => self.commentable.committer.email).first # commentor and committer
recipients << self.project.owner if self.project.owner_type == 'User' # project owner
recipients.compact.uniq.each do |user|
options = {:project_id => self.project.id, :subscribeable_id => self.commentable.id, :subscribeable_type => self.commentable.class.name, :user_id => user.id}
Subscribe.subscribe_to_commit(options) if Subscribe.subscribed_to_commit?(self.project, user, self.commentable)
end
end
end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Container < ActiveRecord::Base class Container < ActiveRecord::Base
belongs_to :project belongs_to :project
belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id' belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id'

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Download < ActiveRecord::Base class Download < ActiveRecord::Base
PREV_LOG_FILE = "#{ APP_CONFIG['nginx_log'] }.0" PREV_LOG_FILE = "#{ APP_CONFIG['nginx_log'] }.0"

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class EventLog < ActiveRecord::Base class EventLog < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :object, :polymorphic => true belongs_to :object, :polymorphic => true

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class EventLogObserver < ActiveRecord::Observer class EventLogObserver < ActiveRecord::Observer
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :auto_build_list, :product_build_list observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :auto_build_list, :product_build_list

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Git::Repository class Git::Repository
delegate :commits, :commit, :tree, :tags, :heads, :commit_count, :log, :branches, :to => :repo delegate :commits, :commit, :tree, :tags, :heads, :commit_count, :log, :branches, :to => :repo
@ -37,4 +38,4 @@ class Git::Repository
[commits(treeish, options[:per_page], skip), options[:page], last_page] [commits(treeish, options[:per_page], skip), options[:page], last_page]
end end
end end

56
app/models/git_hook.rb Normal file
View File

@ -0,0 +1,56 @@
class GitHook
attr_reader :repo, :newrev, :oldrev, :newrev_type, :oldrev_type, :refname,
:change_type, :rev, :rev_type, :refname_type, :owner, :project
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
@repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type
@owner = User.find_by_uname owner_uname
@project = @owner.projects.where(:name => repo).first
@change_type = git_change_type
git_revision_types
commit_type
end
def git_change_type
if @oldrev =~ /0+$/
return 'create'
elsif @newrev =~ /0+$/
return 'delete'
else
return 'update'
end
end
def git_revision_types
case @change_type
when 'create', 'update'
@rev = @newrev
@rev_type = @newrev_type
when 'delete'
@rev = @oldrev
@rev_type = @oldrev_type
end
end
def commit_type
if @refname =~ /refs\/tags\/*/ && @rev_type == 'commit'
# un-annotated tag
@refname_type= 'tag'
#~ short_refname=refname + '##refs/tags/'
elsif @refname =~ /refs\/tags\/*/ && @rev_type == 'tag'
# annotated tag
@refname_type="annotated tag"
#~ short_refname= refname + '##refs/tags/'
elsif @refname =~ /refs\/heads\/*/ && @rev_type == 'commit'
# branch
@refname_type= 'branch'
elsif @refname =~ /refs\/remotes\/*'/ && @rev_type == 'commit'
# tracking branch
@refname_type="tracking branch"
@short_refname= @refname + '##refs/remotes/'
else
# Anything else (is there anything else?)
@refname_type= "*** Unknown type of update to $refname (#{rev_type})"
end
end
end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Group < ActiveRecord::Base class Group < ActiveRecord::Base
belongs_to :owner, :class_name => 'User' belongs_to :owner, :class_name => 'User'
@ -16,11 +17,12 @@ class Group < ActiveRecord::Base
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? } validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? }
attr_readonly :uname attr_readonly :uname, :own_projects_count
delegate :ssh_key, :to => :owner delegate :ssh_key, :to => :owner
after_create :add_owner_to_members after_create :add_owner_to_members
after_initialize lambda {|r| r.name ||= r.uname } # default
include Modules::Models::PersonalRepository include Modules::Models::PersonalRepository
# include Modules::Models::Owner # include Modules::Models::Owner

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Issue < ActiveRecord::Base class Issue < ActiveRecord::Base
STATUSES = ['open', 'closed'] STATUSES = ['open', 'closed']
@ -5,13 +6,9 @@ class Issue < ActiveRecord::Base
belongs_to :user belongs_to :user
has_many :comments, :as => :commentable, has_many :comments, :as => :commentable,
:finder_sql => proc { "comments.commentable_id = '#{self.id}' " + :finder_sql => proc { "comments.commentable_id = '#{self.id}' AND comments.commentable_type = '#{self.class.name}'"}
" AND comments.commentable_type = '#{self.class.name}'"} has_many :subscribes, :as => :subscribeable,
#'SELECT comments.* FROM comments ' + :finder_sql => proc { "subscribes.subscribeable_id = '#{self.id}' AND subscribes.subscribeable_type = '#{self.class.name}'"}
#'WHERE comments.commentable_id = \'#{self.id}\' ' +
#' AND comments.commentable_type = \'#{self.class.name}\' ' +
#'ORDER BY comments.created_at'
has_many :subscribes, :as => :subscribeable
validates :title, :body, :project_id, :presence => true validates :title, :body, :project_id, :presence => true

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
#require 'lib/build_server.rb' #require 'lib/build_server.rb'
class Platform < ActiveRecord::Base class Platform < ActiveRecord::Base
VISIBILITIES = ['open', 'hidden'] VISIBILITIES = ['open', 'hidden']
@ -14,7 +15,7 @@ class Platform < ActiveRecord::Base
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :description, :presence => true, :uniqueness => true validates :description, :presence => true, :uniqueness => true
validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ } validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class PrivateUser < ActiveRecord::Base class PrivateUser < ActiveRecord::Base
require 'digest/sha2' require 'digest/sha2'
require 'active_support/secure_random' require 'active_support/secure_random'

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Product < ActiveRecord::Base class Product < ActiveRecord::Base
ATTRS_TO_CLONE = [ 'build_path', 'build_script', 'counter', 'ks', 'menu', 'tar', 'use_cron', 'cron_tab' ] ATTRS_TO_CLONE = [ 'build_path', 'build_script', 'counter', 'ks', 'menu', 'tar', 'use_cron', 'cron_tab' ]
@ -9,7 +10,7 @@ class Product < ActiveRecord::Base
has_attached_file :tar has_attached_file :tar
validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip", "application/x-bzip2", "application/x-tar"], :message => I18n.t('layout.products.invalid_content_type') validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip", "application/x-bzip", "application/x-bzip2", "application/x-tar"], :message => I18n.t('layout.invalid_content_type')
validates :name, :presence => true, :uniqueness => {:scope => :platform_id} validates :name, :presence => true, :uniqueness => {:scope => :platform_id}
scope :recent, order("name ASC") scope :recent, order("name ASC")

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class ProductBuildList < ActiveRecord::Base class ProductBuildList < ActiveRecord::Base
BUILD_STARTED = 2 BUILD_STARTED = 2
BUILD_COMPLETED = 0 BUILD_COMPLETED = 0

View File

@ -1,13 +1,16 @@
# -*- encoding : utf-8 -*-
class Project < ActiveRecord::Base class Project < ActiveRecord::Base
VISIBILITIES = ['open', 'hidden'] VISIBILITIES = ['open', 'hidden']
MAX_OWN_PROJECTS = 32000
belongs_to :category, :counter_cache => true belongs_to :category, :counter_cache => true
belongs_to :owner, :polymorphic => true belongs_to :owner, :polymorphic => true, :counter_cache => :own_projects_count
has_many :issues, :dependent => :destroy has_many :issues, :dependent => :destroy
has_many :build_lists, :dependent => :destroy has_many :build_lists, :dependent => :destroy
has_many :auto_build_lists, :dependent => :destroy has_many :auto_build_lists, :dependent => :destroy
has_many :project_imports, :dependent => :destroy
has_many :project_to_repositories, :dependent => :destroy has_many :project_to_repositories, :dependent => :destroy
has_many :repositories, :through => :project_to_repositories has_many :repositories, :through => :project_to_repositories
@ -15,26 +18,35 @@ class Project < ActiveRecord::Base
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User' has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group' has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ } validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ }
validates :owner, :presence => true validates :owner, :presence => true
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
# validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?} # validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
validates_attachment_size :srpm, :less_than => 500.megabytes
validates_attachment_content_type :srpm, :content_type => ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], :message => I18n.t('layout.invalid_content_type')
#attr_accessible :category_id, :name, :description, :visibility #attr_accessible :category_id, :name, :description, :visibility
attr_readonly :name attr_readonly :name
scope :recent, order("name ASC") scope :recent, order("name ASC")
scope :by_name, lambda { |name| where('name like ?', "%#{ name }%") } scope :by_name, lambda {|name| where('projects.name ILIKE ?', name)}
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}} scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id = #{ repository_id }))") } scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id = #{ repository_id }))") }
scope :automateable, where("projects.id NOT IN (SELECT auto_build_lists.project_id FROM auto_build_lists)") scope :automateable, where("projects.id NOT IN (SELECT auto_build_lists.project_id FROM auto_build_lists)")
after_create :attach_to_personal_repository after_create :attach_to_personal_repository
after_create :create_git_repo after_create :create_git_repo
after_save :create_wiki
after_destroy :destroy_git_repo after_destroy :destroy_git_repo
after_destroy :destroy_wiki
after_save {|p| p.delay.import_attached_srpm if p.srpm?} # should be after create_git_repo
# after_rollback lambda { destroy_git_repo rescue true if new_record? } # after_rollback lambda { destroy_git_repo rescue true if new_record? }
has_ancestry has_ancestry
has_attached_file :srpm
include Modules::Models::Owner include Modules::Models::Owner
def auto_build def auto_build
@ -43,20 +55,20 @@ class Project < ActiveRecord::Base
:pl => auto_build_list.pl, :pl => auto_build_list.pl,
:bpl => auto_build_list.bpl, :bpl => auto_build_list.bpl,
:arch => auto_build_list.arch, :arch => auto_build_list.arch,
:project_version => collected_project_versions.last, :project_version => versions.last,
:build_requires => true, :build_requires => true,
:update_type => 'bugfix') unless build_lists.for_creation_date_period(Time.current - 15.seconds, Time.current).present? :update_type => 'bugfix') unless build_lists.for_creation_date_period(Time.current - 15.seconds, Time.current).present?
end end
end end
def build_for(platform, user) def build_for(platform, user)
build_lists.create do |bl| build_lists.create do |bl|
bl.pl = platform bl.pl = platform
bl.bpl = platform bl.bpl = platform
bl.update_type = 'recommended' bl.update_type = 'recommended'
bl.arch = Arch.find_by_name('i586') bl.arch = Arch.find_by_name('x86_64') # Return i586 after mass rebuild
# FIXME: Need to set "latest_#{platform.name}" # FIXME: Need to set "latest_#{platform.name}"
bl.project_version = "latest_mandriva2011" bl.project_version = "latest_import_mandriva2011"
bl.build_requires = false # already set as db default bl.build_requires = false # already set as db default
bl.user = user bl.user = user
bl.auto_publish = true # already set as db default bl.auto_publish = true # already set as db default
@ -64,16 +76,6 @@ class Project < ActiveRecord::Base
end end
end end
# TODO deprecate and remove project_versions and collected_project_versions ?
def project_versions
res = tags.select{|tag| tag.name =~ /^v\./}
return res if res and res.size > 0
tags
end
def collected_project_versions
project_versions.collect{|tag| tag.name.gsub(/^\w+\./, "")}
end
def tags def tags
self.git_repository.tags #.sort_by{|t| t.name.gsub(/[a-zA-Z.]+/, '').to_i} self.git_repository.tags #.sort_by{|t| t.name.gsub(/[a-zA-Z.]+/, '').to_i}
end end
@ -98,6 +100,10 @@ class Project < ActiveRecord::Base
File.join owner.uname, name File.join owner.uname, name
end end
def wiki_repo_name
File.join owner.uname, "#{name}.wiki"
end
def public? def public?
visibility == 'open' visibility == 'open'
end end
@ -115,6 +121,10 @@ class Project < ActiveRecord::Base
build_path(git_repo_name) build_path(git_repo_name)
end end
def wiki_path
build_wiki_path(git_repo_name)
end
def xml_rpc_create(repository) def xml_rpc_create(repository)
result = BuildServer.create_project name, repository.platform.name, repository.name, path result = BuildServer.create_project name, repository.platform.name, repository.name, path
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
@ -137,28 +147,74 @@ class Project < ActiveRecord::Base
@platforms ||= repositories.map(&:platform).uniq @platforms ||= repositories.map(&:platform).uniq
end end
def import_srpm(srpm_path = srpm.path, branch_name = 'import')
system("#{Rails.root.join('bin', 'import_srpm.sh')} #{srpm_path} #{path} #{branch_name} >> /dev/null 2>&1")
end
class << self class << self
def commit_comments(commit, project) def commit_comments(commit, project)
comments = Comment.where(:commentable_id => commit.id, :commentable_type => 'Grit::Commit').order(:created_at) comments = Comment.where(:commentable_id => commit.id, :commentable_type => 'Grit::Commit').order(:created_at)
comments.each {|x| x.project = project} comments.each {|x| x.project = project; x.helper}
end end
end end
def owner?(user)
owner == user
end
def self.process_hook(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
rec = GitHook.new(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
#ActivityFeedObserver.instance.after_create rec # for example
end
protected protected
def build_path(dir) def build_path(dir)
File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.git") File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.git")
end end
def attach_to_personal_repository def build_wiki_path(dir)
repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository) File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.wiki.git")
end end
def create_git_repo def attach_to_personal_repository
is_root? ? Grit::Repo.init_bare(path) : parent.git_repository.repo.delay.fork_bare(path) repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository)
end end
def destroy_git_repo def create_git_repo
FileUtils.rm_rf path is_root? ? Grit::Repo.init_bare(path) : parent.git_repository.repo.delay.fork_bare(path)
write_hook.delay
end
def destroy_git_repo
FileUtils.rm_rf path
end
def import_attached_srpm
if srpm?
import_srpm # srpm.path
self.srpm = nil; save # clear srpm
end end
end
def create_wiki
if has_wiki && !FileTest.exist?(wiki_path)
Grit::Repo.init_bare(wiki_path)
wiki = Gollum::Wiki.new(wiki_path, {:base_path => Rails.application.routes.url_helpers.project_wiki_index_path(self)})
wiki.write_page('Home', :markdown, I18n.t("wiki.seed.welcome_content"),
{:name => owner.name, :email => owner.email, :message => 'Initial commit'})
end
end
def destroy_wiki
FileUtils.rm_rf wiki_path
end
def write_hook
hook_file = File.join(path, 'hooks', 'post-receive')
FileUtils.cp(File.join(::Rails.root.to_s, 'lib', 'post-receive-hook'), hook_file)
#File.chmod(0775, hook_file) # need?
rescue Exception # FIXME
end
end end

View File

@ -0,0 +1,12 @@
# -*- encoding : utf-8 -*-
class ProjectImport < ActiveRecord::Base
belongs_to :project
belongs_to :platform
validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}
validates :name, :platform_id, :version, :presence => true
scope :by_name, lambda {|name| where('project_imports.name ILIKE ?', name)}
after_initialize lambda {|r| r.file_mtime ||= Time.current - 10.years } # default
end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class ProjectToRepository < ActiveRecord::Base class ProjectToRepository < ActiveRecord::Base
belongs_to :project belongs_to :project
belongs_to :repository belongs_to :repository
@ -13,8 +14,7 @@ class ProjectToRepository < ActiveRecord::Base
protected protected
def one_project_in_platform_repositories def one_project_in_platform_repositories
c = Platform.scoped.select('projects.*').joins(:repositories => :projects).where( errors.add(:project, 'should be one in platform') if Project.joins(:repositories => :platform).
:projects => {:name => project.name}, :id => repository.platform_id).count where('platforms.id = ?', repository.platform_id).by_name(project.name).count > 0
errors.add(:project, 'should be one in platform') if c > 0
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Relation < ActiveRecord::Base class Relation < ActiveRecord::Base
belongs_to :target, :polymorphic => true belongs_to :target, :polymorphic => true
belongs_to :object, :polymorphic => true belongs_to :object, :polymorphic => true

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Repository < ActiveRecord::Base class Repository < ActiveRecord::Base
belongs_to :platform belongs_to :platform
belongs_to :owner, :polymorphic => true belongs_to :owner, :polymorphic => true
@ -11,7 +12,7 @@ class Repository < ActiveRecord::Base
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :description, :uniqueness => {:scope => :platform_id}, :presence => true validates :description, :uniqueness => {:scope => :platform_id}, :presence => true
validates :name, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-z0-9_\-]+$/ } validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => { :with => /^[a-z0-9_\-]+$/ }
# validates :platform_id, :presence => true # if you uncomment this platform clone will not work # validates :platform_id, :presence => true # if you uncomment this platform clone will not work
scope :recent, order("name ASC") scope :recent, order("name ASC")
@ -56,7 +57,7 @@ class Repository < ActiveRecord::Base
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
else else
raise "Failed to delete repository #{name} inside platform #{platform.name}." raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}."
end end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Rpm < ActiveRecord::Base class Rpm < ActiveRecord::Base
belongs_to :arch belongs_to :arch
belongs_to :project belongs_to :project

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module Settings module Settings
def self.table_name_prefix def self.table_name_prefix
'settings_' 'settings_'

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Settings::Notifier < ActiveRecord::Base class Settings::Notifier < ActiveRecord::Base
belongs_to :user belongs_to :user

View File

@ -1,4 +1,67 @@
# -*- encoding : utf-8 -*-
class Subscribe < ActiveRecord::Base class Subscribe < ActiveRecord::Base
belongs_to :subscribeable, :polymorphic => true belongs_to :subscribeable, :polymorphic => true
belongs_to :user belongs_to :user
belongs_to :project
scope :finder_hack, order('') # FIXME .subscribes - error; .subscribes.finder_hack - success Oo
def subscribed?
status
end
def self.comment_subscribes(comment)
Subscribe.where(:subscribeable_id => comment.commentable.id, :subscribeable_type => comment.commentable.class.name, :project_id => comment.project)
end
def self.new_comment_notification(comment)
commentable_class = comment.commentable.class
Subscribe.new_comment_issue_notification(comment) if commentable_class == Issue
Subscribe.new_comment_commit_notification(comment) if commentable_class == Grit::Commit
end
def self.new_comment_issue_notification(comment)
comment.commentable.subscribes.finder_hack.each do |subscribe|
next if comment.own_comment?(subscribe.user) || !subscribe.user.notifier.can_notify
UserMailer.delay.new_comment_notification(comment, subscribe.user) if subscribe.user.notifier.new_comment_reply
end
end
def self.new_comment_commit_notification(comment)
subscribes = Subscribe.comment_subscribes(comment).where(:status => true)
subscribes.each do |subscribe|
next if comment.own_comment?(subscribe.user) || !subscribe.user.notifier.can_notify
UserMailer.delay.new_comment_notification(comment, subscribe.user)
end
end
def self.subscribed_to_commit?(project, user, commit)
subscribe = user.subscribes.where(:subscribeable_id => commit.id, :subscribeable_type => commit.class.name, :project_id => project.id).first
return subscribe.subscribed? if subscribe # return status if already subscribe present
# return status by settings
(project.owner?(user) && user.notifier.new_comment_commit_repo_owner) or
(user.commentor?(commit) && user.notifier.new_comment_commit_commentor) or
(user.committer?(commit) && user.notifier.new_comment_commit_owner)
end
def self.subscribe_to_commit(options)
Subscribe.set_subscribe_to_commit(options, true)
end
def self.unsubscribe_from_commit(options)
Subscribe.set_subscribe_to_commit(options, false)
end
private
def self.set_subscribe_to_commit(options, status)
if subscribe = Subscribe.where(options).first
subscribe.update_attribute(:status, status)
else
Subscribe.create(options.merge(:status => status))
end
end
end end

View File

@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class User < ActiveRecord::Base class User < ActiveRecord::Base
ROLES = ['admin'] ROLES = ['admin']
LANGUAGES_FOR_SELECT = [['Russian', 'ru'], ['English', 'en']] LANGUAGES_FOR_SELECT = [['Russian', 'ru'], ['English', 'en']]
@ -25,6 +26,9 @@ class User < ActiveRecord::Base
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy
has_many :comments, :dependent => :destroy
include Modules::Models::PersonalRepository include Modules::Models::PersonalRepository
@ -35,6 +39,7 @@ class User < ActiveRecord::Base
validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true
attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :name, :ssh_key, :uname, :language attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :name, :ssh_key, :uname, :language
attr_readonly :uname, :own_projects_count
attr_readonly :uname attr_readonly :uname
attr_accessor :login attr_accessor :login
@ -43,7 +48,7 @@ class User < ActiveRecord::Base
def admin? def admin?
role == 'admin' role == 'admin'
end end
def guest? def guest?
self.id.blank? # persisted? self.id.blank? # persisted?
end end
@ -84,7 +89,15 @@ class User < ActiveRecord::Base
clean_up_passwords clean_up_passwords
result result
end end
def commentor?(commentable)
comments.exists?(:commentable_type => commentable.class.name, :commentable_id => commentable.id)
end
def committer?(commit)
email.downcase == commit.committer.email.downcase
end
private private
def create_settings_notifier def create_settings_notifier

View File

@ -1,6 +1,6 @@
%h2.title= t("layout.build_lists.filter_header") %h2.title= t("layout.build_lists.filter_header")
= form_for :filter, :url => @action_url, :html => { :method => :get, :class => :form } do |f| = form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f|
.columns.wat-cf .columns.wat-cf
.column.left .column.left
.group .group

View File

@ -1,13 +1,13 @@
- if controller_name != 'sessions' - if controller_name != 'sessions'
= link_to "Войти", new_session_path(resource_name), :class => "text_button_padding link_button" = link_to t("layout.devise.shared_links.sign_in"), new_session_path(resource_name), :class => "text_button_padding link_button"
- if devise_mapping.registerable? && controller_name != 'registrations' - if devise_mapping.registerable? && controller_name != 'registrations'
= link_to "Зарегистрироваться", new_registration_path(resource_name), :class => "text_button_padding link_button" = link_to t("layout.devise.shared_links.sign_up"), new_registration_path(resource_name), :class => "text_button_padding link_button"
- if devise_mapping.recoverable? && controller_name != 'passwords' - if devise_mapping.recoverable? && controller_name != 'passwords'
= link_to "Забыли пароль?", new_password_path(resource_name), :class => "text_button_padding link_button" = link_to t("layout.devise.shared_links.forgot_password"), new_password_path(resource_name), :class => "text_button_padding link_button"
- if devise_mapping.confirmable? && controller_name != 'confirmations' - if devise_mapping.confirmable? && controller_name != 'confirmations'
= link_to "Не получили инструкции по подтверждению?", new_confirmation_path(resource_name), :class => "text_button_padding link_button" = link_to t("layout.devise.shared_links.confirm_again"), new_confirmation_path(resource_name), :class => "text_button_padding link_button"
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
= link_to "Не получили инструкции по разблокировке?", new_unlock_path(resource_name), :class => "text_button_padding link_button" = link_to t("layout.devise.shared_links.unlock"), new_unlock_path(resource_name), :class => "text_button_padding link_button"
- if devise_mapping.omniauthable? - if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider| - resource_class.omniauth_providers.each do |provider|
= link_to "Войти через #{provider.to_s.classify}", omniauth_authorize_path(resource_name, provider), :class => "text_button_padding link_button" = link_to t("layout.devise.shared_links.sign_in_through", :provider => provider.to_s.classify), omniauth_authorize_path(resource_name, provider), :class => "text_button_padding link_button"

View File

@ -29,7 +29,9 @@
- @blame.each do |elem| - @blame.each do |elem|
%tr %tr
%td.message{ :rowspan => elem[1].length } %td.message{ :rowspan => elem[1].length }
.commit #{link_to shortest_hash_id(elem[0].id), commit_path(@project, elem[0].id)} by #{elem[0].author} #{elem[0].author != elem[0].committer ? "(#{elem[0].committer})" : "" } .commit
#{link_to shortest_hash_id(elem[0].id), commit_path(@project, elem[0].id)} by
#{elem[0].author.to_s.encode_to_default} #{elem[0].author != elem[0].committer ? "(#{elem[0].committer.to_s.encode_to_default})" : "" }
.message .message
%span.date= commit_date(elem[0].committed_date) %span.date= commit_date(elem[0].committed_date)
%span.message= short_commit_message(elem[0].message) %span.message= short_commit_message(elem[0].message)
@ -40,7 +42,7 @@
%td.code %td.code
%pre %pre
%div= elem[1].first %div= elem[1].first.encode_to_default
- elem[1][1..-1].each do |line| - elem[1][1..-1].each do |line|
%tr %tr
@ -49,6 +51,6 @@
- index += 1 - index += 1
%td.code %td.code
%pre %pre
%div= line %div= line.encode_to_default
- content_for :sidebar, render(:partial => 'git/shared/sidebar') - content_for :sidebar, render(:partial => 'git/shared/sidebar')

View File

@ -49,7 +49,7 @@
%td.blob %td.blob
:plain :plain
<br/> <br/>
<pre>#{ link_to @blob.basename, raw_path(@project, @treeish, @path) }</pre> <pre>#{ link_to @blob.basename.encode_to_default, raw_path(@project, @treeish, @path) }</pre>
<br/> <br/>
- content_for :sidebar, render(:partial => 'git/shared/sidebar') - content_for :sidebar, render(:partial => 'git/shared/sidebar')

View File

@ -2,13 +2,13 @@
.content .content
.inner .inner
%a{ :name => h(commit_diff.a_path) } %a{ :name => h(commit_diff.a_path.encode_to_default) }
.blob_header .blob_header
.size= h(commit_diff.a_path) .size= h(commit_diff.a_path.encode_to_default)
- if commit_diff.b_path.present? - if commit_diff.b_path.present?
.buttons .buttons
= link_to("view file @ #{short_hash_id(@commit.id)}", blob_commit_path(@project, @commit.id, commit_diff.b_path)) = link_to("view file @ #{short_hash_id(@commit.id)}", blob_commit_path(@project, @commit.id, commit_diff.b_path.encode_to_default))
.clear .clear
.diff_data .diff_data

View File

@ -4,12 +4,12 @@
%table %table
%tr %tr
%td.committers %td.committers
.author #{commit.author}, #{commit_date(commit.authored_date)} .author #{commit.author.to_s.encode_to_default}, #{commit_date(commit.authored_date)}
- if commit.committer != commit.author - if commit.committer != commit.author
.committer .committer
(committed by: #{commit.committer}, #{commit_date(commit.committed_date)}) (committed by: #{commit.committer.to_s.encode_to_default}, #{commit_date(commit.committed_date)})
%td.message %td.message
%p= link_to commit.message, commit_path(@project, commit.id) %p= link_to commit.message.encode_to_default, commit_path(@project, commit.id)
%td.trees %td.trees
.commit .commit
Commit: Commit:
@ -23,4 +23,4 @@
.parent .parent
Parent: Parent:
%span{ :style => "float: right;"} %span{ :style => "float: right;"}
#{link_to short_hash_id(parent.id), tree_path(@project, :treeish => parent.id)} #{link_to short_hash_id(parent.id), tree_path(@project, :treeish => parent.id)}

View File

@ -14,7 +14,9 @@
.content .content
.inner .inner
.patch_and_diff .patch_and_diff
#{link_to "raw diff", commit_path(@project, @commit.id, :diff)} | #{link_to "patch", commit_path(@project, @commit.id, :patch)} = link_to "raw diff", commit_path(@project, @commit.id, :diff)
\|
= link_to "patch", commit_path(@project, @commit.id, :patch)
.clear .clear
= render_commit_stats(@commit.stats) = render_commit_stats(@commit.stats)
@ -28,3 +30,11 @@
- content_for :sidebar, render(:partial => 'git/shared/sidebar') - content_for :sidebar, render(:partial => 'git/shared/sidebar')
= render :partial => "comments/list", :locals => {:list => Project.commit_comments(@commit, @project), :project => @project, :commentable => @commit} = render :partial => "comments/list", :locals => {:list => Project.commit_comments(@commit, @project), :project => @project, :commentable => @commit}
%p
%b
= t('layout.issues.subscribe')
\:
- if Subscribe.subscribed_to_commit?(@project, current_user, @commit)
= link_to t('layout.commits.unsubscribe_btn'), unsubscribe_commit_path(@project, @commit), :method => :delete
- else
= link_to t('layout.commits.subscribe_btn'), subscribe_commit_path(@project, @commit), :method => :post

View File

@ -37,10 +37,10 @@
= image_tag("git/icons/folder_16.png") = image_tag("git/icons/folder_16.png")
%td.tree_element %td.tree_element
- if entry.is_a?(Grit::Blob) - if entry.is_a?(Grit::Blob)
= link_to entry.name, blob_path(@project, @treeish, File.join([@path, entry.name].compact)) = link_to entry.name.encode_to_default, blob_path(@project, @treeish, File.join([@path, entry.name.encode_to_default].compact))
- else - else
= link_to "#{entry.name}/", tree_path(@project, @treeish, File.join([@path, entry.name].compact)) = link_to "#{entry.name.encode_to_default}/", tree_path(@project, @treeish, File.join([@path, entry.name.encode_to_default].compact))
%td== &nbsp; %td== &nbsp;
%td.last== &nbsp; %td.last== &nbsp;
- content_for :sidebar, render(:partial => 'git/shared/sidebar') - content_for :sidebar, render(:partial => 'git/shared/sidebar')

View File

@ -22,7 +22,8 @@
%td %td
= link_to group.owner.name, user_path(group.owner) = link_to group.owner.name, user_path(group.owner)
%td.last %td.last
#{link_to t("layout.show"), group_path(group)} | #{link_to t("layout.edit"), edit_group_path(group)} | #{link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete")} = raw [(link_to t("layout.edit"), edit_group_path(group) if can? :update, group),
(link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete") if can? :destroy, group)].compact.join('&nbsp;|&nbsp;')
.actions-bar.wat-cf .actions-bar.wat-cf
.actions= will_paginate @groups, :param_name => :group_page .actions= will_paginate @groups, :param_name => :group_page

View File

@ -52,6 +52,7 @@
= yield = yield
#footer #footer
.block .block
= yield :footer
#sidebar #sidebar
= yield :sidebar = yield :sidebar

View File

@ -4,7 +4,8 @@
%th.last &nbsp; %th.last &nbsp;
- @projects.each do |project| - @projects.each do |project|
%tr{:class => cycle("odd", "even")} %tr{:class => cycle("odd", "even")}
%td %td= link_to project.name, project_path(project)
= link_to project.name, project_path(project)
%td.last %td.last
#{link_to t("layout.show"), project_path(project)} | #{link_to t("layout.delete"), url_for (:action => :remove_project, :project_id => project.id), :confirm => t("layout.projects.confirm_delete")} = link_to t("layout.show"), project_path(project)
\|
= link_to t("layout.delete"), url_for(:action => :remove_project, :project_id => project.id), :confirm => t("layout.projects.confirm_delete")

View File

@ -13,6 +13,12 @@
.group .group
= f.label :has_issues, t("activerecord.attributes.project.has_issues"), :class => :label = f.label :has_issues, t("activerecord.attributes.project.has_issues"), :class => :label
= f.check_box :has_issues = f.check_box :has_issues
.group
= f.label :has_wiki, t("activerecord.attributes.project.has_wiki"), :class => :label
= f.check_box :has_wiki
.group
= f.label :srpm, t("activerecord.attributes.project.srpm"), :class => :label
= f.file_field :srpm, :class => 'file_field'
.group.navform.wat-cf .group.navform.wat-cf
%button.button{:type => "submit"} %button.button{:type => "submit"}

View File

@ -6,11 +6,11 @@
- @own_projects.each do |project| - @own_projects.each do |project|
%li %li
= link_to project.name, project_path(project) = link_to project.name, project_path(project)
.block.notice -#.block.notice
%h3= t("layout.users.part_projects") -# %h3= t("layout.users.part_projects")
.content -# .content
%p -# %p
%ul -# %ul
- @part_projects.each do |project| -# - @part_projects.each do |project|
%li -# %li
= link_to project.owner.uname + '/' + project.name, project_path(project) -# = link_to project.owner.uname + '/' + project.name, project_path(project)

View File

@ -8,7 +8,7 @@
.content .content
%h2.title= t("layout.projects.edit_header") %h2.title= t("layout.projects.edit_header")
.inner .inner
= form_for @project, :html => { :class => :form } do |f| = form_for @project, :html => { :class => :form, :multipart => true } do |f|
= render :partial => "form", :locals => {:f => f} = render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render('sidebar') - content_for :sidebar, render('sidebar')

View File

@ -9,7 +9,7 @@
.content .content
%h2.title= t("layout.projects.new_header") %h2.title= t("layout.projects.new_header")
.inner .inner
= form_for [get_owner, @project], :html => { :class => :form } do |f| = form_for [get_owner, @project], :html => { :class => :form, :multipart => true } do |f|
= render :partial => "form", :locals => {:f => f} = render :partial => "form", :locals => {:f => f}
-# content_for :sidebar, render('sidebar') -# content_for :sidebar, render('sidebar')

View File

@ -7,6 +7,8 @@
%li= link_to t("layout.git.repositories.source"), project_repo_path(@project) %li= link_to t("layout.git.repositories.source"), project_repo_path(@project)
%li= link_to t("layout.projects.build"), new_project_build_list_path(@project) %li= link_to t("layout.projects.build"), new_project_build_list_path(@project)
%li= link_to t("layout.projects.issues"), project_issues_path(@project) %li= link_to t("layout.projects.issues"), project_issues_path(@project)
- if @project.has_wiki
%li= link_to t("layout.projects.wiki"), project_wiki_index_path(@project)
.content .content
.inner .inner
@ -30,7 +32,6 @@
= t("activerecord.attributes.project.repository") = t("activerecord.attributes.project.repository")
\: \:
= git_repo_url @project.git_repo_name = git_repo_url @project.git_repo_name
.wat-cf .wat-cf
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_project_path(@project), :class => "button" if can? :update, @project = link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_project_path(@project), :class => "button" if can? :update, @project
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_path(@project), :method => "delete", :class => "button", :confirm => t("layout.projects.confirm_delete") if can? :destroy, @project = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_path(@project), :method => "delete", :class => "button", :confirm => t("layout.projects.confirm_delete") if can? :destroy, @project

View File

@ -7,4 +7,6 @@
%td %td
= link_to project.name, project_path(project) = link_to project.name, project_path(project)
%td.last %td.last
#{link_to t("layout.show"), project_path(project)} | #{link_to t("layout.delete"), url_for (:action => :remove_project, :project_id => project.id), :confirm => t("layout.projects.confirm_delete")} = link_to t("layout.show"), project_path(project)
\|
= link_to t("layout.delete"), url_for(:action => :remove_project, :project_id => project.id), :confirm => t("layout.projects.confirm_delete")

View File

@ -17,7 +17,19 @@
.group .group
= f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign'), :class => :label = f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign'), :class => :label
= f.check_box :issue_assign, :class => 'notify_cbx' = f.check_box :issue_assign, :class => 'notify_cbx'
.group
= f.label :new_comment_commit_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_owner'), :class => :label
= f.check_box :new_comment_commit_owner, :class => 'notify_cbx'
.group
= f.label :new_comment_commit_repo_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_repo_owner'), :class => :label
= f.check_box :new_comment_commit_repo_owner, :class => 'notify_cbx'
.group
= f.label :new_comment_commit_commentor, t('activerecord.attributes.settings.notifier.new_comment_commit_commentor'), :class => :label
= f.check_box :new_comment_commit_commentor, :class => 'notify_cbx'
.group.navform.wat-cf .group.navform.wat-cf
%button.button{:type => "submit"} %button.button{:type => "submit"}
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))

View File

@ -0,0 +1,7 @@
%p== Hello, #{@user.name}.
%p You have been assigned to issue #{ link_to @issue.title, [@issue.project, @issue] }
%p== Support team «ROSA Build System»

View File

@ -0,0 +1,14 @@
%p== Hello, #{@user.name}.
- if @comment.commentable.class == Issue
- link = link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable]
- object = 'issue'
- elsif @comment.commentable.class == Grit::Commit
- link = link_to @comment.commentable.message, commit_path(@comment.project, @comment.commentable_id)
- object = 'commit'
%p #{ link_to @comment.user.uname, user_path(@comment.user)} added new comment to #{object} #{link}.
%p "#{ @comment.body }"
%p== Support team «ROSA Build System»

View File

@ -1,9 +0,0 @@
%p== Здравствуйте, #{@user.name}.
%p К задаче #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } был добавлен новый комментарий.
%p "#{ @comment.body }"
%p== Команда поддержки «ROSA Build System»

Some files were not shown because too many files have changed in this diff Show More