diff --git a/.gitignore b/.gitignore index 6f93b8b07..fcd2664e1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,5 @@ public/assets/* config/initializers/local.rb public/system/* public/downloads/* -.rvmrc *.swp *.tmproj diff --git a/Gemfile b/Gemfile index bd75f3d66..dd9ed33ea 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,17 @@ source 'http://rubygems.org' gem 'rails', '3.0.11' #, :git => 'git://github.com/rails/rails.git' +gem 'shotgun' gem 'pg', '~> 0.11.0' 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 'omniauth', '~> 1.0.1' gem 'omniauth-openid', '~> 1.0.1' gem 'cancan', '~> 1.6.7' -#gem 'bitmask_attributes' gem "haml-rails", '~> 0.3.4' # 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 'ancestry', '~> 1.2.4' -gem 'paperclip', "~> 2.3" +gem 'paperclip', "~> 2.5" gem "will_paginate", "~> 3.0.2" gem 'meta-tags', '~> 1.2.4', :require => 'meta_tags' gem "russian" -# gem 'ghoul_grack', '~> 0.0.1' 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 'delayed_job' +gem 'delayed_job', '2.1.4' 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 -# gem 'actionwebservice' #, :git => 'git://github.com/ywen/actionwebservice.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' group :production do gem "airbrake", '~> 3.0.5' - # gem 'newrelic_rpm', '~> 3.1.1' gem 'bluepill', :require => false end +gem 'newrelic_rpm' + group :development do # gem 'letter_opener' gem 'rails3-generators' @@ -50,25 +60,16 @@ group :development do gem 'hpricot' gem 'ruby_parser' - # debug - gem 'ruby-debug' - # gem 'looksee' - # gem 'awesome_print' -# gem 'wirble' gem 'hirb' - # gem 'rails-footnotes', '>= 3.7.5.rc4' # this shit is very buggy don't forget to switch it off back # deploy gem 'capistrano', :require => false gem 'capistrano-ext', :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 end group :development, :test do - gem 'mysql2', '<= 0.2.9' gem 'rspec-rails', '~> 2.7.0' gem 'factory_girl_rails', '~> 1.4.0' gem 'rr' diff --git a/Gemfile.lock b/Gemfile.lock index 33a001a38..d71c4ed97 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 remote: git://github.com/rdblue/grack.git revision: 020be3fef3fb308b9d214252522aa5945bf6584a @@ -7,6 +17,7 @@ GIT GEM remote: http://rubygems.org/ specs: + RedCloth (4.2.9) abstract (1.0.0) actionmailer (3.0.11) actionpack (= 3.0.11) @@ -34,21 +45,23 @@ GEM activemodel (= 3.0.11) activesupport (= 3.0.11) activesupport (3.0.11) - airbrake (3.0.5) + airbrake (3.0.9) activesupport builder + albino (1.3.3) + posix-spawn (>= 0.3.6) ancestry (1.2.4) activerecord (>= 2.2.2) arel (2.0.10) bcrypt-ruby (3.0.1) - bluepill (0.0.51) + bluepill (0.0.52) activesupport (>= 3.0.0) daemons (~> 1.1.0) i18n (>= 0.5.0) - state_machine (~> 0.9.4) + state_machine (~> 1.1.0) builder (2.1.2) cancan (1.6.7) - cape (1.0.1) + cape (1.2.0) capistrano (2.9.0) highline net-scp (>= 1.0.0) @@ -58,28 +71,36 @@ GEM capistrano-ext (1.2.1) capistrano (>= 1.0.0) capistrano_colors (0.5.5) - chronic (0.6.6) - cocaine (0.2.0) - columnize (0.3.5) - daemons (1.1.4) + chronic (0.6.7) + cocaine (0.2.1) + creole (0.4.2) + daemons (1.1.6) delayed_job (2.1.4) activesupport (~> 3.0) daemons - devise (1.5.2) + devise (1.5.3) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) warden (~> 1.1) diff-lcs (1.1.3) erubis (2.6.6) abstract (>= 1.0.0) + expression_parser (0.9.0) factory_girl (2.3.2) activesupport factory_girl_rails (1.4.0) factory_girl (~> 2.3.0) railties (>= 3.0.0) - grit (2.4.1) - diff-lcs (~> 1.1) - mime-types (~> 1.15) + github-markup (0.7.0) + gollum (1.3.1) + 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-rails (0.3.4) actionpack (~> 3.0) @@ -87,16 +108,14 @@ GEM haml (~> 3.0) railties (~> 3.0) hashie (1.2.0) - highline (1.6.8) + highline (1.6.11) hirb (0.6.0) - hpricot (0.8.5) + hpricot (0.8.6) i18n (0.5.0) jammit (0.6.5) yui-compressor (>= 0.9.3) - json (1.6.3) - kgio (2.6.0) - linecache (0.46) - rbx-require-relative (> 0.0.4) + json (1.6.5) + kgio (2.7.2) mail (2.2.19) activesupport (>= 2.3.6) i18n (>= 0.4.0) @@ -105,29 +124,32 @@ GEM meta-tags (1.2.4) actionpack mime-types (1.17.2) - mysql2 (0.2.9) + mustache (0.99.4) net-scp (1.0.4) net-ssh (>= 1.99.1) net-sftp (2.0.5) net-ssh (>= 2.0.9) - net-ssh (2.2.1) + net-ssh (2.3.0) net-ssh-gateway (1.1.0) 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) rack omniauth-openid (1.0.1) omniauth (~> 1.0) rack-openid (~> 1.3.1) - orm_adapter (0.0.5) - paperclip (2.4.5) + orm_adapter (0.0.6) + paperclip (2.5.2) activerecord (>= 2.3.0) activesupport (>= 2.3.2) cocaine (>= 0.0.2) mime-types pg (0.11.0) polyglot (0.3.3) - rack (1.2.4) + posix-spawn (0.3.6) + rack (1.2.5) rack-mount (0.6.14) rack (>= 1.0.0) rack-openid (1.3.1) @@ -146,7 +168,7 @@ GEM rails-xmlrpc (0.3.6) rails3-generators (0.17.4) railties (>= 3.0.0) - rails3-jquery-autocomplete (1.0.4) + rails3-jquery-autocomplete (1.0.5) rails (~> 3.0) railties (3.0.11) actionpack (= 3.0.11) @@ -156,9 +178,12 @@ GEM thor (~> 0.14.4) raindrops (0.8.0) rake (0.9.2.2) - rbx-require-relative (0.0.5) - rdoc (3.11) + rdiscount (1.6.8) + rdoc (3.12) json (~> 1.4) + redcarpet (1.17.2) + redhillonrails_core (1.2.0) + activerecord (>= 2) rr (1.0.4) rspec (2.7.0) rspec-core (~> 2.7.0) @@ -173,20 +198,23 @@ GEM activesupport (~> 3.0) railties (~> 3.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_parser (2.3.1) sexp_processor (~> 3.0) russian (0.6.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) - 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) + tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) @@ -198,16 +226,20 @@ GEM warden (1.1.0) rack (>= 1.0) web-app-theme (0.7.0) - whenever (0.7.0) + whenever (0.7.2) activesupport (>= 2.3.4) 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) PLATFORMS ruby DEPENDENCIES + RedCloth airbrake (~> 3.0.5) ancestry (~> 1.2.4) bluepill @@ -216,34 +248,40 @@ DEPENDENCIES capistrano capistrano-ext capistrano_colors - delayed_job + creole + delayed_job (= 2.1.4) devise (~> 1.5.2) factory_girl_rails (~> 1.4.0) + gollum (= 1.3.1) grack! - grit + grit! haml-rails (~> 0.3.4) highline (~> 1.6.8) hirb hpricot jammit meta-tags (~> 1.2.4) - mysql2 (<= 0.2.9) + newrelic_rpm omniauth (~> 1.0.1) omniauth-openid (~> 1.0.1) - paperclip (~> 2.3) + paperclip (~> 2.5) pg (~> 0.11.0) rails (= 3.0.11) rails-xmlrpc (~> 0.3.6) rails3-generators rails3-jquery-autocomplete + rdiscount + redcarpet (= 1.17.2) + redhillonrails_core (~> 1.2.0) rr rspec-rails (~> 2.7.0) - ruby-debug ruby_parser russian + shotgun silent-postgres (~> 0.1.1) unicorn (~> 4.1.1) web-app-theme whenever + wikicloth will_paginate (~> 3.0.2) yui-compressor (= 0.9.5) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 494f54ae1..ce09242b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,4 @@ -# coding: UTF-8 +# -*- encoding : utf-8 -*- class ApplicationController < ActionController::Base protect_from_forgery diff --git a/app/controllers/auto_build_lists_controller.rb b/app/controllers/auto_build_lists_controller.rb index 4354b91d8..e69f6ecc1 100644 --- a/app/controllers/auto_build_lists_controller.rb +++ b/app/controllers/auto_build_lists_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AutoBuildListsController < ApplicationController before_filter :authenticate_user!, :except => :auto_build before_filter :find_auto_build_list, :only => :destroy diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index e0ce08136..0104bee2d 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class BuildListsController < ApplicationController CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt] NESTED_ACTIONS = [:index, :new, :create] @@ -13,20 +14,29 @@ class BuildListsController < ApplicationController load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS) def index - filter_params = params[:filter] || {} - if @project - @action_url = project_build_lists_path(@project) + if request.post? + new_params = {:filter => {}} + params[:filter].each do |k,v| + new_params[:filter][k] = v unless v.empty? + end + + redirect_to build_lists_path(new_params) else - @action_url = build_lists_path - end + filter_params = params[:filter] || {} + if @project + @action_url = project_build_lists_path(@project) + else + @action_url = build_lists_path + end - @filter = BuildList::Filter.new(@project, filter_params) - @build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page] + @filter = BuildList::Filter.new(@project, filter_params) + @build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page] - @build_server_status = begin - BuildServer.get_status - rescue Exception # Timeout::Error - {} + @build_server_status = begin + BuildServer.get_status + rescue Exception # Timeout::Error + {} + end end end @@ -39,7 +49,7 @@ class BuildListsController < ApplicationController Arch.where(:id => params[:arches]).each do |arch| Platform.main.where(:id => params[:bpls]).each do |bpl| @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 flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl} if @build_list.save @@ -120,9 +130,9 @@ class BuildListsController < ApplicationController @build_list.notified_at = Time.current @build_list.save - @build_list.delay.publish if @build_list.auto_publish # && @build_list.can_publish? - render :nothing => true, :status => 200 + + @build_list.delay.publish if @build_list.auto_publish # && @build_list.can_publish? end def circle_build diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index df0944d58..3dae0ee00 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class CategoriesController < ApplicationController before_filter :authenticate_user! before_filter :find_category, :only => [:show, :edit, :update, :destroy] diff --git a/app/controllers/collaborators_controller.rb b/app/controllers/collaborators_controller.rb index 2c11b6172..f05ab25ac 100644 --- a/app/controllers/collaborators_controller.rb +++ b/app/controllers/collaborators_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class CollaboratorsController < ApplicationController before_filter :authenticate_user! diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 6f699a602..690695126 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class CommentsController < ApplicationController before_filter :authenticate_user! before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy] @@ -13,7 +14,7 @@ class CommentsController < ApplicationController def create @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 if @comment.save flash[:notice] = I18n.t("flash.comment.saved") @@ -74,7 +75,10 @@ class CommentsController < ApplicationController def find_comment @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 def find_project diff --git a/app/controllers/commit_subscribes_controller.rb b/app/controllers/commit_subscribes_controller.rb new file mode 100644 index 000000000..4eef9eff0 --- /dev/null +++ b/app/controllers/commit_subscribes_controller.rb @@ -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 diff --git a/app/controllers/containers_controller.rb b/app/controllers/containers_controller.rb index 57c27003c..1475672a2 100644 --- a/app/controllers/containers_controller.rb +++ b/app/controllers/containers_controller.rb @@ -1,2 +1,3 @@ +# -*- encoding : utf-8 -*- class ContainersController < ApplicationController end diff --git a/app/controllers/downloads_controller.rb b/app/controllers/downloads_controller.rb index 41d3072f0..8c10a3940 100644 --- a/app/controllers/downloads_controller.rb +++ b/app/controllers/downloads_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class DownloadsController < ApplicationController before_filter :authenticate_user! load_and_authorize_resource diff --git a/app/controllers/event_logs_controller.rb b/app/controllers/event_logs_controller.rb index 91b16e482..1b491ba0a 100644 --- a/app/controllers/event_logs_controller.rb +++ b/app/controllers/event_logs_controller.rb @@ -1,4 +1,4 @@ -# coding: UTF-8 +# -*- encoding : utf-8 -*- class EventLogsController < ApplicationController before_filter :authenticate_user! load_and_authorize_resource diff --git a/app/controllers/git/base_controller.rb b/app/controllers/git/base_controller.rb index 90ed02ecf..6fd5a43c7 100644 --- a/app/controllers/git/base_controller.rb +++ b/app/controllers/git/base_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Git::BaseController < ApplicationController before_filter :authenticate_user! @@ -39,4 +40,4 @@ class Git::BaseController < ApplicationController def set_current_branch @current_branch = @branches.select{|b| b.name == @treeish }.first end -end \ No newline at end of file +end diff --git a/app/controllers/git/blobs_controller.rb b/app/controllers/git/blobs_controller.rb index eb788d211..0bfe6b4b4 100644 --- a/app/controllers/git/blobs_controller.rb +++ b/app/controllers/git/blobs_controller.rb @@ -1,11 +1,10 @@ +# -*- encoding : utf-8 -*- class Git::BlobsController < Git::BaseController - before_filter :set_path - before_filter :set_commit_hash before_filter :find_tree + before_filter :set_path_blob + before_filter :set_commit_hash def show - @blob = @tree / @path - if params[:raw] image_url = Rails.root.to_s + "/" + @path @@ -18,21 +17,18 @@ class Git::BlobsController < Git::BaseController end def blame - @blob = @tree / @path - @blame = Grit::Blob.blame(@git_repository.repo, @commit.try(:id), @path) end def raw - @blob = @tree / @path - headers["Content-Disposition"] = %[attachment;filename="#{@blob.name}"] render :text => @blob.data, :content_type => @blob.mime_type end protected - def set_path + def set_path_blob @path = params[:path] + @blob = @tree / @path.encode_to_default end def set_commit_hash diff --git a/app/controllers/git/commits_controller.rb b/app/controllers/git/commits_controller.rb index 021d60cee..dbf9becaa 100644 --- a/app/controllers/git/commits_controller.rb +++ b/app/controllers/git/commits_controller.rb @@ -1,7 +1,8 @@ +# -*- encoding : utf-8 -*- class Git::CommitsController < Git::BaseController def index - @branch_name = (params[:branch] ? params[:branch] : "master") + @branch_name = params[:treeish] || "master" @path = params[:path] if @path.present? diff --git a/app/controllers/git/repositories_controller.rb b/app/controllers/git/repositories_controller.rb index 5aea592cd..7b5420c80 100644 --- a/app/controllers/git/repositories_controller.rb +++ b/app/controllers/git/repositories_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Git::RepositoriesController < Git::BaseController def show @@ -7,4 +8,4 @@ class Git::RepositoriesController < Git::BaseController render :template => "git/repositories/empty" unless @tree end -end \ No newline at end of file +end diff --git a/app/controllers/git/trees_controller.rb b/app/controllers/git/trees_controller.rb index 0ee9ed4f0..081fa7e8b 100644 --- a/app/controllers/git/trees_controller.rb +++ b/app/controllers/git/trees_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Git::TreesController < Git::BaseController def show @@ -13,4 +14,4 @@ class Git::TreesController < Git::BaseController render :template => "git/repositories/show" end -end \ No newline at end of file +end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 37b95ac33..0ff9ec811 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,4 +1,4 @@ -# coding: UTF-8 +# -*- encoding : utf-8 -*- class GroupsController < ApplicationController is_related_controller! diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 99f13be95..466e574db 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class IssuesController < ApplicationController before_filter :authenticate_user! before_filter :find_project diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index e139e2234..8d22c69f3 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class MembersController < ApplicationController before_filter :authenticate_user! is_related_controller! diff --git a/app/controllers/personal_repositories_controller.rb b/app/controllers/personal_repositories_controller.rb index 1b9e84556..c76c21623 100644 --- a/app/controllers/personal_repositories_controller.rb +++ b/app/controllers/personal_repositories_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class PersonalRepositoriesController < ApplicationController before_filter :authenticate_user! before_filter :find_repository#, :only => [:show, :destroy, :add_project, :remove_project, :make_private, :settings] @@ -7,7 +8,7 @@ class PersonalRepositoriesController < ApplicationController def show 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 @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30 end diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 3ce47f9a7..060fe99e0 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -1,4 +1,4 @@ -# coding: UTF-8 +# -*- encoding : utf-8 -*- class PlatformsController < ApplicationController before_filter :authenticate_user!, :except => :easy_urpmi 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'], :owner_id => current_user.id, :owner_type => current_user.class.to_s) if @cloned.persisted? - flash[:notice] = 'Клонирование успешно' + flash[:notice] = I18n.t("flash.platform.clone_success") redirect_to @cloned else flash[:error] = @cloned.errors.full_messages.join('. ') diff --git a/app/controllers/private_users_controller.rb b/app/controllers/private_users_controller.rb index 8583eed73..0b25d1202 100644 --- a/app/controllers/private_users_controller.rb +++ b/app/controllers/private_users_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class PrivateUsersController < ApplicationController before_filter :authenticate_user! before_filter :find_platform_and_private_users @@ -13,7 +14,7 @@ class PrivateUsersController < ApplicationController @pair = PrivateUser.generate_pair(params[:platform_id], current_user.id) @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 #def destroy diff --git a/app/controllers/privates_controller.rb b/app/controllers/privates_controller.rb index a722eaa5c..a375d9ce9 100644 --- a/app/controllers/privates_controller.rb +++ b/app/controllers/privates_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class PrivatesController < ApplicationController require 'digest/sha2' diff --git a/app/controllers/product_build_lists_controller.rb b/app/controllers/product_build_lists_controller.rb index 9af5761aa..fac839015 100644 --- a/app/controllers/product_build_lists_controller.rb +++ b/app/controllers/product_build_lists_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ProductBuildListsController < ApplicationController before_filter :authenticate_user!, :except => [:status_build] load_and_authorize_resource :platform, :only => [:create] diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 4ba424475..66beed7b7 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ProductsController < ApplicationController before_filter :authenticate_user! before_filter :find_product, :only => [:show, :edit, :update, :destroy] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a870d584c..54c5d5496 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ProjectsController < ApplicationController is_related_controller! @@ -17,13 +18,13 @@ class ProjectsController < ApplicationController end.accessible_by(current_ability) @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 @projects end.paginate(:page => params[:project_page]) @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 def show diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 85d0175cc..317683699 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class RepositoriesController < ApplicationController before_filter :authenticate_user! before_filter :find_repository, :except => [:index, :new, :create] @@ -19,7 +20,7 @@ class RepositoriesController < ApplicationController def show 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 @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30 end diff --git a/app/controllers/rpc_controller.rb b/app/controllers/rpc_controller.rb index 9ce8e9d38..e9e5ba78a 100644 --- a/app/controllers/rpc_controller.rb +++ b/app/controllers/rpc_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class RpcController < ApplicationController exposes_xmlrpc_methods @@ -11,30 +12,30 @@ class RpcController < ApplicationController # client.call("project_versions", 1) 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) end 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 } } end def project_versions id p = Project.find_by_id(id) - ActiveSupport::Notifications.instrument("event_log.observer", :object => p, :message => "список версий") - p.project_versions.collect {|tag| tag.name.gsub(/^\w+\./, "")} rescue 'not found' + ActiveSupport::Notifications.instrument "event_log.observer", :object => p, :message => I18n.t('event_log.notices.versions_list') + p.tags.map(&:name) rescue 'not found' end def build_status 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' end def build_packet project_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 end end diff --git a/app/controllers/settings/notifiers_controller.rb b/app/controllers/settings/notifiers_controller.rb index 03df52237..0b8aef12f 100644 --- a/app/controllers/settings/notifiers_controller.rb +++ b/app/controllers/settings/notifiers_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Settings::NotifiersController < ApplicationController layout "sessions" @@ -12,10 +13,10 @@ class Settings::NotifiersController < ApplicationController def update if @notifier.update_attributes(params[:settings_notifier]) flash[:notice] = I18n.t("flash.settings.saved") - redirect_to [@user, @notifier] + redirect_to user_settings_notifier_path(@user) else flash[:notice] = I18n.t("flash.settings.save_error") - redirect_to [@user, @notifier] + redirect_to user_settings_notifier_path(@user) end end diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/subscribes_controller.rb index e9ff43abf..ddf208c64 100644 --- a/app/controllers/subscribes_controller.rb +++ b/app/controllers/subscribes_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class SubscribesController < ApplicationController before_filter :authenticate_user! diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 55665e78d..a23a8c7e1 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def open_id # raise env['omniauth.auth'].inspect diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 79a088b01..fcb1079d4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,4 +1,4 @@ -# coding: UTF-8 +# -*- encoding : utf-8 -*- class UsersController < ApplicationController before_filter :authenticate_user! before_filter :find_user, :only => [:show, :edit, :update, :destroy] diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb new file mode 100644 index 000000000..a79e713b8 --- /dev/null +++ b/app/controllers/wiki_controller.rb @@ -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 + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2a0a40d45..05055fa4f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module ApplicationHelper def choose_title title = if ['categories', 'personal_repositories', 'downloads'].include?(controller.controller_name) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 0ec9ca5f2..cb5f47b33 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -1,2 +1,3 @@ +# -*- encoding : utf-8 -*- module CommentsHelper end diff --git a/app/helpers/commit_helper.rb b/app/helpers/commit_helper.rb index 58f1bcd57..180374610 100644 --- a/app/helpers/commit_helper.rb +++ b/app/helpers/commit_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module CommitHelper def render_commit_stats(stats) @@ -12,7 +13,7 @@ module CommitHelper end res << "" - res.join("\n").html_safe + res.join("\n").encode_to_default.html_safe end # def format_commit_message(message) @@ -33,7 +34,7 @@ module CommitHelper def short_commit_message(message) # Why 42? Because it is the Answer! - truncate(message, :length => 42, :omission => "...") + truncate(message, :length => 42, :omission => "...").encode_to_default end -end \ No newline at end of file +end diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index e130c38b0..a7f1163cf 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module DiffHelper def render_diff(diff) @@ -11,7 +12,7 @@ module DiffHelper res += "" res += "" - res.html_safe + res.html_safe.force_encoding(Encoding.default_internal || Encoding::UTF_8) end -end \ No newline at end of file +end diff --git a/app/helpers/git_helper.rb b/app/helpers/git_helper.rb index 286fba6f2..f302b5aed 100644 --- a/app/helpers/git_helper.rb +++ b/app/helpers/git_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module GitHelper def render_path @@ -25,7 +26,7 @@ module GitHelper res = "#{link_to @project.name, tree_path(@project)} /" end - res.html_safe + res.encode_to_default.html_safe end def render_line_numbers(n) @@ -37,7 +38,9 @@ module GitHelper def render_blob(blob) res = "" - blob.data.split("\n").collect{|line| "
#{line.present? ? h(line) : "
"}
"}.join + blob.data.encode_to_default.split("\n").collect do |line| + "
#{line.present? ? h(line) : "
"}
" + end.join end def choose_render_way(blob) @@ -45,4 +48,9 @@ module GitHelper return :text if blob.mime_type.match(/text|xml|json/) :binary end + + def force_encoding_to_site(string) + string.dup.encode_to_default + end + end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index bfb9d25e5..07236a9d0 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,2 +1,3 @@ +# -*- encoding : utf-8 -*- module IssuesHelper end diff --git a/app/helpers/platforms_helper.rb b/app/helpers/platforms_helper.rb index c27de0604..deebfa87e 100644 --- a/app/helpers/platforms_helper.rb +++ b/app/helpers/platforms_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module PlatformsHelper def repository_name_postfix(platform) return "" unless platform diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 363bde95d..06c4de5b0 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module ProjectsHelper def git_repo_url(name) if current_user diff --git a/app/helpers/settings/notifiers_helper.rb b/app/helpers/settings/notifiers_helper.rb index 295af1e51..218ea67f6 100644 --- a/app/helpers/settings/notifiers_helper.rb +++ b/app/helpers/settings/notifiers_helper.rb @@ -1,2 +1,3 @@ +# -*- encoding : utf-8 -*- module Settings::NotifiersHelper end diff --git a/app/helpers/subscribes_helper.rb b/app/helpers/subscribes_helper.rb index dc1b490ec..dbf4053de 100644 --- a/app/helpers/subscribes_helper.rb +++ b/app/helpers/subscribes_helper.rb @@ -1,2 +1,3 @@ +# -*- encoding : utf-8 -*- module SubscribesHelper end diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb new file mode 100644 index 000000000..9b406a88b --- /dev/null +++ b/app/helpers/wiki_helper.rb @@ -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 diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 39ceffa17..4fcc5488b 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,4 +1,4 @@ -# coding: UTF-8 +# -*- encoding : utf-8 -*- class UserMailer < ActionMailer::Base default :from => APP_CONFIG['do-not-reply-email'] @@ -13,15 +13,7 @@ class UserMailer < ActionMailer::Base def new_comment_notification(comment, user) @user = user @comment = comment - mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_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| + mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commentable.class == Grit::Commit ? 'commit_' : ''}comment_notification")) do |format| format.html end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 7709990ee..735aaed2a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # 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 # WARNING: @@ -30,7 +31,7 @@ class Ability 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| group.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin') # or group.owner_id = user.id end diff --git a/app/models/arch.rb b/app/models/arch.rb index 90258febf..7a65eb3fe 100644 --- a/app/models/arch.rb +++ b/app/models/arch.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Arch < ActiveRecord::Base has_many :build_lists, :dependent => :destroy diff --git a/app/models/authentication.rb b/app/models/authentication.rb index 26ba03317..0f29e3da9 100644 --- a/app/models/authentication.rb +++ b/app/models/authentication.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Authentication < ActiveRecord::Base belongs_to :user diff --git a/app/models/auto_build_list.rb b/app/models/auto_build_list.rb index 9f607121d..ce88aa10a 100644 --- a/app/models/auto_build_list.rb +++ b/app/models/auto_build_list.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AutoBuildList < ActiveRecord::Base belongs_to :project belongs_to :arch diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 91534a5a5..4da5118a8 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class BuildList < ActiveRecord::Base belongs_to :project belongs_to :arch diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index 6340dc1b7..70b491286 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class BuildList::Filter def initialize(project, options = {}) @project = project @@ -67,10 +68,10 @@ class BuildList::Filter def build_date_from_params(field_name, params) 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, - (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) else nil end end -end \ No newline at end of file +end diff --git a/app/models/build_list/item.rb b/app/models/build_list/item.rb index ec49f740c..e419526a9 100644 --- a/app/models/build_list/item.rb +++ b/app/models/build_list/item.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class BuildList::Item < ActiveRecord::Base belongs_to :build_list diff --git a/app/models/category.rb b/app/models/category.rb index 31e8001df..d84e8c70a 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Category < ActiveRecord::Base has_many :projects, :dependent => :nullify diff --git a/app/models/comment.rb b/app/models/comment.rb index 6b6f5a92a..bd84e8f68 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true belongs_to :user @@ -8,6 +9,17 @@ class Comment < ActiveRecord::Base # FIXME after_create :subscribe_on_reply, :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) self.commentable.comments.exists?(:user_id => subscribe.user.id) @@ -40,4 +52,22 @@ class Comment < ActiveRecord::Base def subscribe_on_reply self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id) 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 diff --git a/app/models/container.rb b/app/models/container.rb index 7008fa54d..f2564b763 100644 --- a/app/models/container.rb +++ b/app/models/container.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Container < ActiveRecord::Base belongs_to :project belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id' diff --git a/app/models/download.rb b/app/models/download.rb index 6d0630bbf..bbdcbfa6e 100644 --- a/app/models/download.rb +++ b/app/models/download.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Download < ActiveRecord::Base PREV_LOG_FILE = "#{ APP_CONFIG['nginx_log'] }.0" diff --git a/app/models/event_log.rb b/app/models/event_log.rb index e69226f6c..ba1e2343e 100644 --- a/app/models/event_log.rb +++ b/app/models/event_log.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class EventLog < ActiveRecord::Base belongs_to :user belongs_to :object, :polymorphic => true diff --git a/app/models/event_log_observer.rb b/app/models/event_log_observer.rb index 4d1163327..7adbeb446 100644 --- a/app/models/event_log_observer.rb +++ b/app/models/event_log_observer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class EventLogObserver < ActiveRecord::Observer observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :auto_build_list, :product_build_list diff --git a/app/models/git/repository.rb b/app/models/git/repository.rb index 12bec4ee3..4ed82b210 100644 --- a/app/models/git/repository.rb +++ b/app/models/git/repository.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Git::Repository 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] end -end \ No newline at end of file +end diff --git a/app/models/git_hook.rb b/app/models/git_hook.rb new file mode 100644 index 000000000..1a2ef2b50 --- /dev/null +++ b/app/models/git_hook.rb @@ -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 \ No newline at end of file diff --git a/app/models/group.rb b/app/models/group.rb index 9e8e15905..a720995ef 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Group < ActiveRecord::Base 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_]+$/ } 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 after_create :add_owner_to_members + after_initialize lambda {|r| r.name ||= r.uname } # default include Modules::Models::PersonalRepository # include Modules::Models::Owner diff --git a/app/models/issue.rb b/app/models/issue.rb index 8d1343595..c8d540735 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Issue < ActiveRecord::Base STATUSES = ['open', 'closed'] @@ -5,13 +6,9 @@ class Issue < ActiveRecord::Base belongs_to :user has_many :comments, :as => :commentable, - :finder_sql => proc { "comments.commentable_id = '#{self.id}' " + - " AND comments.commentable_type = '#{self.class.name}'"} - #'SELECT comments.* FROM comments ' + - #'WHERE comments.commentable_id = \'#{self.id}\' ' + - #' AND comments.commentable_type = \'#{self.class.name}\' ' + - #'ORDER BY comments.created_at' - has_many :subscribes, :as => :subscribeable + :finder_sql => proc { "comments.commentable_id = '#{self.id}' AND comments.commentable_type = '#{self.class.name}'"} + has_many :subscribes, :as => :subscribeable, + :finder_sql => proc { "subscribes.subscribeable_id = '#{self.id}' AND subscribes.subscribeable_type = '#{self.class.name}'"} validates :title, :body, :project_id, :presence => true diff --git a/app/models/platform.rb b/app/models/platform.rb index e0768062a..e7b552ba2 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- #require 'lib/build_server.rb' class Platform < ActiveRecord::Base VISIBILITIES = ['open', 'hidden'] @@ -14,7 +15,7 @@ class Platform < ActiveRecord::Base has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' 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']} before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} diff --git a/app/models/private_user.rb b/app/models/private_user.rb index 48afa84f9..c21e6f97d 100644 --- a/app/models/private_user.rb +++ b/app/models/private_user.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class PrivateUser < ActiveRecord::Base require 'digest/sha2' require 'active_support/secure_random' diff --git a/app/models/product.rb b/app/models/product.rb index 36337f4f9..94e355d20 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Product < ActiveRecord::Base 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 - 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} scope :recent, order("name ASC") diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 09d936ea2..b01ee85e4 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ProductBuildList < ActiveRecord::Base BUILD_STARTED = 2 BUILD_COMPLETED = 0 diff --git a/app/models/project.rb b/app/models/project.rb index 0935e37ad..c15332d5e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,13 +1,16 @@ +# -*- encoding : utf-8 -*- class Project < ActiveRecord::Base VISIBILITIES = ['open', 'hidden'] + MAX_OWN_PROJECTS = 32000 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 :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 :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 :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 + 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?} + 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_readonly :name 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 :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)") after_create :attach_to_personal_repository after_create :create_git_repo + after_save :create_wiki + 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? } has_ancestry + has_attached_file :srpm + include Modules::Models::Owner def auto_build @@ -43,20 +55,20 @@ class Project < ActiveRecord::Base :pl => auto_build_list.pl, :bpl => auto_build_list.bpl, :arch => auto_build_list.arch, - :project_version => collected_project_versions.last, + :project_version => versions.last, :build_requires => true, :update_type => 'bugfix') unless build_lists.for_creation_date_period(Time.current - 15.seconds, Time.current).present? end end - def build_for(platform, user) + def build_for(platform, user) build_lists.create do |bl| bl.pl = platform bl.bpl = platform 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}" - bl.project_version = "latest_mandriva2011" + bl.project_version = "latest_import_mandriva2011" bl.build_requires = false # already set as db default bl.user = user bl.auto_publish = true # already set as db default @@ -64,16 +76,6 @@ class Project < ActiveRecord::Base 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 self.git_repository.tags #.sort_by{|t| t.name.gsub(/[a-zA-Z.]+/, '').to_i} end @@ -98,6 +100,10 @@ class Project < ActiveRecord::Base File.join owner.uname, name end + def wiki_repo_name + File.join owner.uname, "#{name}.wiki" + end + def public? visibility == 'open' end @@ -115,6 +121,10 @@ class Project < ActiveRecord::Base build_path(git_repo_name) end + def wiki_path + build_wiki_path(git_repo_name) + end + def xml_rpc_create(repository) result = BuildServer.create_project name, repository.platform.name, repository.name, path if result == BuildServer::SUCCESS @@ -137,28 +147,74 @@ class Project < ActiveRecord::Base @platforms ||= repositories.map(&:platform).uniq 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 def commit_comments(commit, project) 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 + 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 - def build_path(dir) - File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.git") - end + def build_path(dir) + File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.git") + end - def attach_to_personal_repository - repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository) - end + def build_wiki_path(dir) + File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.wiki.git") + end - def create_git_repo - is_root? ? Grit::Repo.init_bare(path) : parent.git_repository.repo.delay.fork_bare(path) - end + def attach_to_personal_repository + repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository) + end - def destroy_git_repo - FileUtils.rm_rf path + def create_git_repo + 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 + + + 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 diff --git a/app/models/project_import.rb b/app/models/project_import.rb new file mode 100644 index 000000000..10a45b1a3 --- /dev/null +++ b/app/models/project_import.rb @@ -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 diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb index a5a623123..7bf5adba5 100644 --- a/app/models/project_to_repository.rb +++ b/app/models/project_to_repository.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ProjectToRepository < ActiveRecord::Base belongs_to :project belongs_to :repository @@ -13,8 +14,7 @@ class ProjectToRepository < ActiveRecord::Base protected def one_project_in_platform_repositories - c = Platform.scoped.select('projects.*').joins(:repositories => :projects).where( - :projects => {:name => project.name}, :id => repository.platform_id).count - errors.add(:project, 'should be one in platform') if c > 0 + errors.add(:project, 'should be one in platform') if Project.joins(:repositories => :platform). + where('platforms.id = ?', repository.platform_id).by_name(project.name).count > 0 end end diff --git a/app/models/relation.rb b/app/models/relation.rb index a08ddf6a9..59c31d29d 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Relation < ActiveRecord::Base belongs_to :target, :polymorphic => true belongs_to :object, :polymorphic => true diff --git a/app/models/repository.rb b/app/models/repository.rb index b9246f86a..379d3deac 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Repository < ActiveRecord::Base belongs_to :platform belongs_to :owner, :polymorphic => true @@ -11,7 +12,7 @@ class Repository < ActiveRecord::Base has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' 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 scope :recent, order("name ASC") @@ -56,7 +57,7 @@ class Repository < ActiveRecord::Base if result == BuildServer::SUCCESS return true 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 diff --git a/app/models/rpm.rb b/app/models/rpm.rb index e954c8247..577028102 100644 --- a/app/models/rpm.rb +++ b/app/models/rpm.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Rpm < ActiveRecord::Base belongs_to :arch belongs_to :project diff --git a/app/models/settings.rb b/app/models/settings.rb index f6af89076..fee53706e 100644 --- a/app/models/settings.rb +++ b/app/models/settings.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module Settings def self.table_name_prefix 'settings_' diff --git a/app/models/settings/notifier.rb b/app/models/settings/notifier.rb index af21fd811..034117b26 100644 --- a/app/models/settings/notifier.rb +++ b/app/models/settings/notifier.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Settings::Notifier < ActiveRecord::Base belongs_to :user diff --git a/app/models/subscribe.rb b/app/models/subscribe.rb index 0c3a52698..a8fd5cc31 100644 --- a/app/models/subscribe.rb +++ b/app/models/subscribe.rb @@ -1,4 +1,67 @@ +# -*- encoding : utf-8 -*- class Subscribe < ActiveRecord::Base belongs_to :subscribeable, :polymorphic => true 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 diff --git a/app/models/user.rb b/app/models/user.rb index 5183b86b8..7cad3bd65 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class User < ActiveRecord::Base ROLES = ['admin'] 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 :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :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 @@ -35,6 +39,7 @@ class User < ActiveRecord::Base validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :name, :ssh_key, :uname, :language + attr_readonly :uname, :own_projects_count attr_readonly :uname attr_accessor :login @@ -43,7 +48,7 @@ class User < ActiveRecord::Base def admin? role == 'admin' end - + def guest? self.id.blank? # persisted? end @@ -84,7 +89,15 @@ class User < ActiveRecord::Base clean_up_passwords result 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 def create_settings_notifier diff --git a/app/views/build_lists/_filter.html.haml b/app/views/build_lists/_filter.html.haml index 9a184f655..f5d3615b6 100644 --- a/app/views/build_lists/_filter.html.haml +++ b/app/views/build_lists/_filter.html.haml @@ -1,6 +1,6 @@ %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 .column.left .group diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index f3c6883ac..958f5ec3c 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -1,13 +1,13 @@ - 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' - = 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' - = 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' - = 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' - = 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? - 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" \ No newline at end of file + = 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" diff --git a/app/views/git/blobs/blame.html.haml b/app/views/git/blobs/blame.html.haml index c39582dd1..aaf184b15 100644 --- a/app/views/git/blobs/blame.html.haml +++ b/app/views/git/blobs/blame.html.haml @@ -29,7 +29,9 @@ - @blame.each do |elem| %tr %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 %span.date= commit_date(elem[0].committed_date) %span.message= short_commit_message(elem[0].message) @@ -40,7 +42,7 @@ %td.code %pre - %div= elem[1].first + %div= elem[1].first.encode_to_default - elem[1][1..-1].each do |line| %tr @@ -49,6 +51,6 @@ - index += 1 %td.code %pre - %div= line + %div= line.encode_to_default -- content_for :sidebar, render(:partial => 'git/shared/sidebar') \ No newline at end of file +- content_for :sidebar, render(:partial => 'git/shared/sidebar') diff --git a/app/views/git/blobs/show.html.haml b/app/views/git/blobs/show.html.haml index 04b3a19b3..43127ac7e 100644 --- a/app/views/git/blobs/show.html.haml +++ b/app/views/git/blobs/show.html.haml @@ -49,7 +49,7 @@ %td.blob :plain
-
#{ link_to @blob.basename, raw_path(@project, @treeish, @path) }
+
#{ link_to @blob.basename.encode_to_default, raw_path(@project, @treeish, @path) }

- content_for :sidebar, render(:partial => 'git/shared/sidebar') diff --git a/app/views/git/commits/_commit_diff.html.haml b/app/views/git/commits/_commit_diff.html.haml index 5d387b06a..05f68c621 100644 --- a/app/views/git/commits/_commit_diff.html.haml +++ b/app/views/git/commits/_commit_diff.html.haml @@ -2,13 +2,13 @@ .content .inner - %a{ :name => h(commit_diff.a_path) } + %a{ :name => h(commit_diff.a_path.encode_to_default) } .blob_header - .size= h(commit_diff.a_path) + .size= h(commit_diff.a_path.encode_to_default) - if commit_diff.b_path.present? .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 .diff_data diff --git a/app/views/git/commits/_commits.html.haml b/app/views/git/commits/_commits.html.haml index b248234eb..9e4d9ae50 100644 --- a/app/views/git/commits/_commits.html.haml +++ b/app/views/git/commits/_commits.html.haml @@ -4,12 +4,12 @@ %table %tr %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 .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 - %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 .commit Commit: @@ -23,4 +23,4 @@ .parent Parent: %span{ :style => "float: right;"} - #{link_to short_hash_id(parent.id), tree_path(@project, :treeish => parent.id)} \ No newline at end of file + #{link_to short_hash_id(parent.id), tree_path(@project, :treeish => parent.id)} diff --git a/app/views/git/commits/show.html.haml b/app/views/git/commits/show.html.haml index 8f3ec67f8..11c1a9eea 100644 --- a/app/views/git/commits/show.html.haml +++ b/app/views/git/commits/show.html.haml @@ -14,7 +14,9 @@ .content .inner .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 = render_commit_stats(@commit.stats) @@ -28,3 +30,11 @@ - content_for :sidebar, render(:partial => 'git/shared/sidebar') = 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 diff --git a/app/views/git/repositories/show.html.haml b/app/views/git/repositories/show.html.haml index a0e547531..41c205ebd 100644 --- a/app/views/git/repositories/show.html.haml +++ b/app/views/git/repositories/show.html.haml @@ -37,10 +37,10 @@ = image_tag("git/icons/folder_16.png") %td.tree_element - 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 - = 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==   %td.last==   -- content_for :sidebar, render(:partial => 'git/shared/sidebar') \ No newline at end of file +- content_for :sidebar, render(:partial => 'git/shared/sidebar') diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 06f7bc6e4..ab8e9eab0 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -22,7 +22,8 @@ %td = link_to group.owner.name, user_path(group.owner) %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(' | ') .actions-bar.wat-cf .actions= will_paginate @groups, :param_name => :group_page diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2520f8616..1e72aff63 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -52,6 +52,7 @@ = yield #footer .block + = yield :footer #sidebar = yield :sidebar diff --git a/app/views/personal_repositories/_proj_list1.html.haml b/app/views/personal_repositories/_proj_list1.html.haml index c37d33bf7..8f98f58cd 100644 --- a/app/views/personal_repositories/_proj_list1.html.haml +++ b/app/views/personal_repositories/_proj_list1.html.haml @@ -4,7 +4,8 @@ %th.last   - @projects.each do |project| %tr{:class => cycle("odd", "even")} - %td - = link_to project.name, project_path(project) + %td= link_to project.name, project_path(project) %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") \ No newline at end of file diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index d0cc3e7bf..0f318764e 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -13,6 +13,12 @@ .group = f.label :has_issues, t("activerecord.attributes.project.has_issues"), :class => :label = 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 %button.button{:type => "submit"} diff --git a/app/views/projects/_own_projects_sidebar.html.haml b/app/views/projects/_own_projects_sidebar.html.haml index ca8ba9880..5b7ac9a92 100644 --- a/app/views/projects/_own_projects_sidebar.html.haml +++ b/app/views/projects/_own_projects_sidebar.html.haml @@ -6,11 +6,11 @@ - @own_projects.each do |project| %li = link_to project.name, project_path(project) -.block.notice - %h3= t("layout.users.part_projects") - .content - %p - %ul - - @part_projects.each do |project| - %li - = link_to project.owner.uname + '/' + project.name, project_path(project) +-#.block.notice +-# %h3= t("layout.users.part_projects") +-# .content +-# %p +-# %ul +-# - @part_projects.each do |project| +-# %li +-# = link_to project.owner.uname + '/' + project.name, project_path(project) diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index ba3c5c14f..1017c5329 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -8,7 +8,7 @@ .content %h2.title= t("layout.projects.edit_header") .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} - content_for :sidebar, render('sidebar') diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index f9304bdd8..6e5ec7973 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -9,7 +9,7 @@ .content %h2.title= t("layout.projects.new_header") .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} -# content_for :sidebar, render('sidebar') diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index e302150d9..cab48a9b3 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -7,6 +7,8 @@ %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.issues"), project_issues_path(@project) + - if @project.has_wiki + %li= link_to t("layout.projects.wiki"), project_wiki_index_path(@project) .content .inner @@ -30,7 +32,6 @@ = t("activerecord.attributes.project.repository") \: = git_repo_url @project.git_repo_name - .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/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 diff --git a/app/views/repositories/_proj_list1.html.haml b/app/views/repositories/_proj_list1.html.haml index c37d33bf7..c548783b5 100644 --- a/app/views/repositories/_proj_list1.html.haml +++ b/app/views/repositories/_proj_list1.html.haml @@ -7,4 +7,6 @@ %td = link_to project.name, project_path(project) %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") diff --git a/app/views/settings/notifiers/_form.html.haml b/app/views/settings/notifiers/_form.html.haml index 2631874bc..5cd3e4e3d 100644 --- a/app/views/settings/notifiers/_form.html.haml +++ b/app/views/settings/notifiers/_form.html.haml @@ -17,7 +17,19 @@ .group = f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign'), :class => :label = 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 %button.button{:type => "submit"} = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) diff --git a/app/views/user_mailer/issue_assign_notification.en.haml b/app/views/user_mailer/issue_assign_notification.en.haml new file mode 100644 index 000000000..83c33e8ac --- /dev/null +++ b/app/views/user_mailer/issue_assign_notification.en.haml @@ -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» diff --git a/app/views/user_mailer/issue_assign_notification.haml b/app/views/user_mailer/issue_assign_notification.ru.haml similarity index 100% rename from app/views/user_mailer/issue_assign_notification.haml rename to app/views/user_mailer/issue_assign_notification.ru.haml diff --git a/app/views/user_mailer/new_comment_notification.en.haml b/app/views/user_mailer/new_comment_notification.en.haml new file mode 100644 index 000000000..2c7fb66cb --- /dev/null +++ b/app/views/user_mailer/new_comment_notification.en.haml @@ -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» \ No newline at end of file diff --git a/app/views/user_mailer/new_comment_notification.haml b/app/views/user_mailer/new_comment_notification.haml deleted file mode 100644 index 315a56b88..000000000 --- a/app/views/user_mailer/new_comment_notification.haml +++ /dev/null @@ -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» diff --git a/app/views/user_mailer/new_comment_notification.ru.haml b/app/views/user_mailer/new_comment_notification.ru.haml new file mode 100644 index 000000000..d1c0734dd --- /dev/null +++ b/app/views/user_mailer/new_comment_notification.ru.haml @@ -0,0 +1,14 @@ +%p== Здравствуйте, #{@user.name}. + +- if @comment.commentable.class == Issue + - link = link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] + - object = 'задаче' +- elsif @comment.commentable.class == Grit::Commit + - link = link_to @comment.commentable.message, commit_path(@comment.project, @comment.commentable_id) + - object = 'коммиту' +%p #{ link_to @comment.user.uname, user_path(@comment.user)} добавил комментарий к #{object} #{link}. + +%p "#{ @comment.body }" + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/user_mailer/new_comment_reply_notification.en.haml b/app/views/user_mailer/new_comment_reply_notification.en.haml new file mode 100644 index 000000000..9324062f2 --- /dev/null +++ b/app/views/user_mailer/new_comment_reply_notification.en.haml @@ -0,0 +1,9 @@ +%p== Hello, #{@user.name}. + + +%p Your comment into issue #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } has been answered. + +%p "#{ @comment.body }" + + +%p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/new_comment_reply_notification.haml b/app/views/user_mailer/new_comment_reply_notification.haml deleted file mode 100644 index 48ff0ab4b..000000000 --- a/app/views/user_mailer/new_comment_reply_notification.haml +++ /dev/null @@ -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» diff --git a/app/views/user_mailer/new_issue_notification.en.haml b/app/views/user_mailer/new_issue_notification.en.haml new file mode 100644 index 000000000..f814fa617 --- /dev/null +++ b/app/views/user_mailer/new_issue_notification.en.haml @@ -0,0 +1,7 @@ +%p== Hello, #{@user.name}. + + +%p To project #{ link_to @issue.project.name, project_path(@issue.project) } has been added an issue #{ link_to @issue.title, [@issue.project, @issue] } + + +%p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/new_issue_notification.haml b/app/views/user_mailer/new_issue_notification.ru.haml similarity index 100% rename from app/views/user_mailer/new_issue_notification.haml rename to app/views/user_mailer/new_issue_notification.ru.haml diff --git a/app/views/user_mailer/new_user_notification.en.haml b/app/views/user_mailer/new_user_notification.en.haml new file mode 100644 index 000000000..d1a0722bf --- /dev/null +++ b/app/views/user_mailer/new_user_notification.en.haml @@ -0,0 +1,12 @@ +%p== Hello, #{@user.name}. + + +%p You have been sign up to project «ROSA Build System» and now can sign in. + + +%p + ==Your email : #{@user.email} + %br/ + ==Your password: #{@user.password} + +%p== Support team «ROSA Build System» diff --git a/app/views/user_mailer/new_user_notification.haml b/app/views/user_mailer/new_user_notification.ru.haml similarity index 100% rename from app/views/user_mailer/new_user_notification.haml rename to app/views/user_mailer/new_user_notification.ru.haml diff --git a/app/views/wiki/_compare.html.haml b/app/views/wiki/_compare.html.haml new file mode 100644 index 000000000..0b58242e7 --- /dev/null +++ b/app/views/wiki/_compare.html.haml @@ -0,0 +1,20 @@ +- revert_button = capture do + = link_to t("layout.wiki.revert_page#{action_name == 'revert' ? '' : 's'}"), '#', :class => "gollum-revert-button" + +#compare-content + - if action_name != 'revert' + %ul.actions + %li.minibutton + = form_tag revert_path(@project, @versions[0][0..6], @versions[1][0..6], @name), + :name => "gollum-revert", :id => "gollum-revert-form" do + = revert_button if can? :write, @project + + = render :partial => 'diff_data', :collection => @diffs, :as => :diff + .spacer + +#gollum-footer + %ul.actions + - if action_name != 'revert' + %li.minibutton + = revert_button if can? :write, @project + %li.minibutton= link_to t("layout.wiki.back_to_top"), '#wiki' diff --git a/app/views/wiki/_diff_data.html.haml b/app/views/wiki/_diff_data.html.haml new file mode 100644 index 000000000..cd8fb1f9a --- /dev/null +++ b/app/views/wiki/_diff_data.html.haml @@ -0,0 +1,9 @@ +.blob_header + .size= h(diff.deleted_file ? diff.a_path : diff.b_path) + - puts 'in view' + - puts diff.a_path + - puts diff.b_path + .clear + +.diff_data.highlight + = render_diff(diff) diff --git a/app/views/wiki/_editor.html.haml b/app/views/wiki/_editor.html.haml new file mode 100644 index 000000000..1be8c1735 --- /dev/null +++ b/app/views/wiki/_editor.html.haml @@ -0,0 +1,46 @@ +#gollum-editor{:class => "#{@new ? 'create' : 'edit'}", :'data-escaped-name' => escaped_name} + = form_tag editor_path(@project, @name), :name => 'gollum-editor', :method => @new ? :post : :put do + %fieldset#gollum-editor-fields + - if @new + #gollum-editor-title-field.singleline + = label_tag :page, t("layout.wiki.page_title"), :class => 'jaws' + = text_field_tag :page, @name, :id => "gollum-editor-page-title" + - else + = hidden_field_tag :page, @name, :id => "gollum-editor-page-title" + + = render :partial => 'editor_toolbar' + + = text_area_tag :content, @content, :id => "gollum-editor-body", :'data-markup-lang' => format + + - if has_footer? + #gollum-editor-edit-footer.collapsed + = link_to "#", :class => "button" do + %span= t("layout.wiki.expand_collapse") + %h4 + Footer + = text_area_tag :footer, footer.text_data + + - if has_sidebar? + #gollum-editor-edit-sidebar.collapsed + = link_to "#", :class => "button" do + %span= t("layout.wiki.expand_collapse") + %h4 + Sidebar + = text_area_tag :sidebar, sidebar.text_data + + #gollum-editor-edit-summary.singleline + = label_tag :message, t("layout.wiki.edit_commit_message"), :class => "jaws" + = text_field_tag :message, t("layout.wiki.commit_message_placeholder"), :id => "gollum-editor-message-field" + + %span.jaws + %br + + = submit_tag t("layout.wiki.save_button"), :id => "gollum-editor-submit", :title => t("layout.wiki.save_changes") + = link_to t("layout.wiki.preview"), "javascript:void(0)", :id => "gollum-editor-preview", + :class => "minibutton", :title => t("layout.wiki.preview_title"), :'data-url' => preview_project_wiki_index_path(@project) + +- content_for :javascripts do + = javascript_include_tag 'gollum/editor/gollum.editor.js' + +- content_for :stylesheets do + = stylesheet_link_tag 'gollum/editor.css' diff --git a/app/views/wiki/_editor_toolbar.html.haml b/app/views/wiki/_editor_toolbar.html.haml new file mode 100644 index 000000000..18400d172 --- /dev/null +++ b/app/views/wiki/_editor_toolbar.html.haml @@ -0,0 +1,65 @@ +#gollum-editor-function-bar + #gollum-editor-function-buttons + = link_to "#", :id => "function-bold", :class => "function-button", :title => t("layout.wiki.editor.bold") do + %span= t("layout.wiki.editor.bold") + = link_to "#", :id => "function-italic", :class => "function-button", :title => t("layout.wiki.editor.italic") do + %span= t("layout.wiki.editor.italic") + = link_to "#", :id => "function-code", :class => "function-button", :title => t("layout.wiki.editor.code") do + %span= t("layout.wiki.editor.code") + + %span.function-divider +   + + = link_to "#", :id => "function-ul", :class => "function-button", :title => t("layout.wiki.editor.unordered_list") do + %span= t("layout.wiki.editor.unordered_list") + = link_to "#", :id => "function-ol", :class => "function-button", :title => t("layout.wiki.editor.ordered_list") do + %span= t("layout.wiki.editor.ordered_list") + = link_to "#", :id => "function-blockquote", :class => "function-button", :title => t("layout.wiki.editor.blockquote") do + %span= t("layout.wiki.editor.blockquote") + = link_to "#", :id => "function-hr", :class => "function-button", :title => t("layout.wiki.editor.horizontal_rule") do + %span= t("layout.wiki.editor.horizontal_rule") + + %span.function-divider +   + + = link_to "#", :id => "function-h1", :class => "function-button", :title => t("layout.wiki.editor.h1") do + %span= t("layout.wiki.editor.h1") + = link_to "#", :id => "function-h2", :class => "function-button", :title => t("layout.wiki.editor.h2") do + %span= t("layout.wiki.editor.h2") + = link_to "#", :id => "function-h3", :class => "function-button", :title => t("layout.wiki.editor.h3") do + %span= t("layout.wiki.editor.h3") + + %span.function-divider +   + + = link_to "#", :id => "function-link", :class => "function-button", :title => t("layout.wiki.editor.link") do + %span= t("layout.wiki.editor.link") + = link_to "#", :id => "function-image", :class => "function-button", :title => t("layout.wiki.editor.image") do + %span= t("layout.wiki.editor.image") + + %span.function-divider +   + + = link_to "#", :id => "function-help", :class => "function-button", :title => t("layout.wiki.editor.help") do + %span= t("layout.wiki.editor.help") + + #gollum-editor-format-selector + = select_tag :format, options_for_select(wiki_formats, format), :id => "wiki_format" + = label_tag :format, t("layout.wiki.editor.format") +#gollum-editor-help.jaws + %ul#gollum-editor-help-parent + %li= link_to "help_1", "javascript:void(0);", :class => "selected" + %li= link_to "help_1", "javascript:void(0);" + %li= link_to "help_1", "javascript:void(0);" + %ul#gollum-editor-help-list + %li= link_to "help_2", "javascript:void(0);" + %li= link_to "help_3", "javascript:void(0);" + %li= link_to "help_4", "javascript:void(0);" + %li= link_to "help_5", "javascript:void(0);" + %li= link_to "help_6", "javascript:void(0);" + %li= link_to "help_7", "javascript:void(0);" + %li= link_to "help_8", "javascript:void(0);" + #gollum-editor-help-wrapper + #gollum-editor-help-content + %p + diff --git a/app/views/wiki/_git_access.html.haml b/app/views/wiki/_git_access.html.haml new file mode 100644 index 000000000..ee4e52214 --- /dev/null +++ b/app/views/wiki/_git_access.html.haml @@ -0,0 +1,23 @@ +.url-box + %ul.clone-urls + %li.http-clone-url.selected + = link_to t("layout.wiki.clones.http"), git_repo_url(@project.wiki_repo_name), + :'data-permissions' => (can? :write, @project) ? 'Read+Write' : 'Read' + %input.url-field{:type => 'text', :spellcheck => 'false'} + %p.url-description + %strong + access + +:javascript + $(document).ready(function() { + var link = $('li.http-clone-url a').first(); + + $('.url-box input.url-field').attr('value', link.attr('href')); + $('.url-box p.url-description strong').text(link.attr('data-permissions')); + + $('li.http-clone-url a').live('click', function(e) { + e.preventDefault(); + $('.url-box input.url-field').attr('value', $(this).attr('href')); + $('.url-box p.url-description strong').text($(this).attr('data-permissions')); + }); + }); diff --git a/app/views/wiki/_git_access_message.en.html.haml b/app/views/wiki/_git_access_message.en.html.haml new file mode 100644 index 000000000..599cf7da5 --- /dev/null +++ b/app/views/wiki/_git_access_message.en.html.haml @@ -0,0 +1,17 @@ +#template + %p + Your wiki data can be cloned from a git repository for offline access. + You have several options for editing it at this point: + %ol + %li + With your favorite text editor or IDE. + %li + With the built-in web interface, included with the + = link_to 'Gollum', "https://github.com/github/gollum" + Ruby API. + %li + With the Gollum Ruby API. + %p + When you're done, you can simply push your changes back to our system to + see them reflected on the site. The wiki repositories obey the same + access rules as the source repository that they belong to. diff --git a/app/views/wiki/_git_access_message.ru.html.haml b/app/views/wiki/_git_access_message.ru.html.haml new file mode 100644 index 000000000..37176047f --- /dev/null +++ b/app/views/wiki/_git_access_message.ru.html.haml @@ -0,0 +1,18 @@ +#template + %p + Все данные вашей Wiki могут быть клонированы из Git-репозитория для + доступа без интернета. В этом случае вы можете редактировать страницы + следующими способами: + %ol + %li + Вашим любимым текстовым редактором или IDE. + %li + С помощью встроенного Web-интерфейса, включенного в + = link_to 'Gollum', "https://github.com/github/gollum" + Ruby API. + %li + С помощью Gollum Ruby API. + %p + Когда изменения будут завершены, просто запуште их обратно в нашу систему + чтобы увидеть их на сайте. Доступ к репозиторию Wiki осуществляется с теми + же правами, что и к проекту, с которым она связана. diff --git a/app/views/wiki/_gollum_includes.html.haml b/app/views/wiki/_gollum_includes.html.haml new file mode 100644 index 000000000..1e42e6d96 --- /dev/null +++ b/app/views/wiki/_gollum_includes.html.haml @@ -0,0 +1,5 @@ +- content_for :javascripts do + = javascript_include_tag 'gollum/gollum.js', 'gollum/gollum.dialog.js', 'gollum/gollum.placeholder.js' + +- content_for :stylesheets do + = stylesheet_link_tag 'gollum/gollum.css', 'gollum/dialog.css', 'gollum/ie7.css', 'gollum/template.css' diff --git a/app/views/wiki/_history.html.haml b/app/views/wiki/_history.html.haml new file mode 100644 index 000000000..a1f66a2a8 --- /dev/null +++ b/app/views/wiki/_history.html.haml @@ -0,0 +1,36 @@ +#wiki-history + %ul.actions + %li.minibutton + = link_to t("layout.wiki.compare_revisions"), "javascript:void(0);", + :class => "action-compare-revision" + + = form_tag compare_path(@project, @name), :name => "compare-versions", :id => "version-form" do + %fieldset + %table + %tbody + - @versions.each do |v| + %tr{:class => cycle("odd", "even")} + %td.checkbox + = check_box_tag "versions[]", v.id + %td.author + - user = User.where(:email => v.author.email).first + = link_to user_path_by_user(user) do + %img{:src => gravatar_url(v.author.email), + :alt => "avatar: #{v.author.name.force_encoding(Encoding.default_internal || Encoding::UTF_8)}", + :class => "mini-gravatar"} + %span.username= user.present? ? user.uname : v.author.name + %td.commit-name + %span.time-elapsed= "#{l v.committed_date.to_date, :format => :long}:" +   + = v.message.force_encoding(Encoding.default_internal) + - if @name + = raw "[#{link_to v.id[0..6], versioned_project_wiki_path(@project, escaped_name, v.id), :title => t("layout.wiki.view_commit")}]" + - else + = "[#{v.id[0..6]}]" + +#gollum-footer + %ul.actions + %li.minibutton + = link_to t("layout.wiki.compare_revisions"), "javascript:void(0);", :class => "action-compare-revision" + %li.minibutton + = link_to t("layout.wiki.back_to_top"), "#wiki", :class => "action-back-to-top" diff --git a/app/views/wiki/_navigation.html.haml b/app/views/wiki/_navigation.html.haml new file mode 100644 index 000000000..099f202c6 --- /dev/null +++ b/app/views/wiki/_navigation.html.haml @@ -0,0 +1,11 @@ +- act = action_name.intern +.secondary-navigation + %ul.wat-cf + %li.first{:class => ((act == :show and @name == 'Home') or act == :index) ? 'active' : ''} + = link_to t("layout.wiki.home"), project_wiki_index_path(@project) + %li{:class => (act == :pages) ? 'active' : ''} + = link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) + %li{:class => (act == :wiki_history or act == :compare_wiki) ? 'active' : ''} + = link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) + %li{:class => (act == :git) ? 'active' : ''} + = link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project) diff --git a/app/views/wiki/_page.html.haml b/app/views/wiki/_page.html.haml new file mode 100644 index 000000000..c6af67350 --- /dev/null +++ b/app/views/wiki/_page.html.haml @@ -0,0 +1,23 @@ +#wiki-content + .wrap{:class => "#{has_footer? ? 'has-footer' : ''} #{has_sidebar? ? 'has-rightbar' : ''}"} + #wiki-body{:class => "gollum-#{format}-content"} + #template + = raw @content + - if has_sidebar? + #wiki-rightbar{:class => "gollum-#{sidebar_format}-content"} + = raw sidebar_content + - if has_footer? + #wiki-footer{:class => "gollum-#{footer_format}-content"} + #footer-content + = raw footer_content +#gollum-footer + %p#last-edit + = t("layout.wiki.last_edited_by") + %b + = user_link_by_user User.where(:email => author_email).first + = time_ago_in_words date.to_time - 4.hours, true + = t("layout.time.ago") + - unless action_name == 'preview' or cannot? :write, @project + %p#delete-link + = link_to project_wiki_path(@project, escaped_name), :method => :delete, :confirm => t("layout.confirm") do + %span= t("layout.wiki.delete_page") diff --git a/app/views/wiki/_project_short.html.haml b/app/views/wiki/_project_short.html.haml new file mode 100644 index 000000000..4697ab479 --- /dev/null +++ b/app/views/wiki/_project_short.html.haml @@ -0,0 +1,23 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first= link_to t("layout.projects.list"), projects_path + %li= link_to t("layout.projects.new"), new_project_path + %li= link_to t("layout.projects.show"), project_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.issues"), project_issues_path(@project) + %li.active= link_to t("layout.projects.wiki"), project_wiki_index_path(@project) + + .content + .inner + %p + %b + = t("activerecord.attributes.project.name") + \: + = @project.name + %p + %b + = t("activerecord.attributes.project.owner") + \: + = link_to @project.owner.try(:name), url_for(@project.owner) diff --git a/app/views/wiki/_results.html.haml b/app/views/wiki/_results.html.haml new file mode 100644 index 000000000..97dcfb777 --- /dev/null +++ b/app/views/wiki/_results.html.haml @@ -0,0 +1,22 @@ +#results + - if @results and !@results.empty? + %ul + - @results.each do |result| + %li + - if action_name == 'search' + = link_to result[:name], project_wiki_path(@project, CGI.escape(result[:name])) + %span.count= "(#{result.count} #{t("layout.wiki.matches")})" + -else + = link_to result.name, project_wiki_path(@project, CGI.escape(result.name)) + - else + %p#no-results + - @st_ref = capture do + %strong= @ref || @query + - if action_name == 'search' + = raw t("layout.wiki.no_results_for_search", :query => @st_ref) + - else + = raw t("layout.wiki.no_pages_in", :ref => @st_ref) + +#footer + %ul.actions + %li.minibutton= link_to t("layout.wiki.back_to_top"), '#wiki' diff --git a/app/views/wiki/_searchbar.html.haml b/app/views/wiki/_searchbar.html.haml new file mode 100644 index 000000000..6d2572d09 --- /dev/null +++ b/app/views/wiki/_searchbar.html.haml @@ -0,0 +1,6 @@ +#gollum-searchbar + = form_tag search_project_wiki_index_path(@project), :method => :get, :id => "gollum-search-form" do + #gollum-searchbar-fauxtext + = text_field_tag :q, t("layout.wiki.search_and_hellip"), :id => "search-query", :autocomplete => "on" + = link_to "#", :id => "search-submit", :title => t("layout.wiki.search_popup") do + %span= t("layout.wiki.search") diff --git a/app/views/wiki/compare.html.haml b/app/views/wiki/compare.html.haml new file mode 100644 index 000000000..4ab54c5ff --- /dev/null +++ b/app/views/wiki/compare.html.haml @@ -0,0 +1,29 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + #wiki-wrapper.inner.compare + #head + %h1.title + - if @name + = t("layout.wiki.history_for") + %strong= @page.name + - else + = t("layout.wiki.wiki_history") + + %ul.actions + - if can? :read, @project + %li.minibutton= link_to t("layout.wiki.back_to_history"), + @name ? history_project_wiki_path(@project, escaped_name) : history_project_wiki_index_path(@project) + = render :partial => 'searchbar' + + #wiki-content + = render :partial => "compare" + +- content_for :sidebar do + - render :partial => 'projects/sidebar' + diff --git a/app/views/wiki/edit.html.haml b/app/views/wiki/edit.html.haml new file mode 100644 index 000000000..d2443af00 --- /dev/null +++ b/app/views/wiki/edit.html.haml @@ -0,0 +1,33 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + #wiki-wrapper.inner + #head + %h1.title + = t("layout.wiki.editing_page") + %strong= @page.name + + %ul.actions + - if can? :read, @project + %li.minibutton + = link_to t("layout.wiki.view_page"), view_path(@project, escaped_name), + :class => 'action-view-page' + %li.minibutton + = link_to t("layout.wiki.page_history"), history_project_wiki_path(@project, escaped_name), + :class => 'aciton-view-history' + + #wiki-content + = render :partial => "editor" + +:javascript + jQuery(document).ready(function() { + $.GollumEditor(); + }); + +- content_for :sidebar do + - render :partial => 'projects/sidebar' diff --git a/app/views/wiki/git.html.haml b/app/views/wiki/git.html.haml new file mode 100644 index 000000000..19f9566e0 --- /dev/null +++ b/app/views/wiki/git.html.haml @@ -0,0 +1,22 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + #wiki-wrapper.inner.compare + #head + %h1.title + = t("layout.wiki.wiki_git_access") + + #wiki-content + = render :partial => "git_access" + %br + = render :partial => "git_access_message" + +- content_for :sidebar do + - render :partial => 'projects/sidebar' + + diff --git a/app/views/wiki/history.html.haml b/app/views/wiki/history.html.haml new file mode 100644 index 000000000..11d1e0e26 --- /dev/null +++ b/app/views/wiki/history.html.haml @@ -0,0 +1,38 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + #wiki-wrapper.inner.history + #head + %h1.title + - if @name + = t("layout.wiki.history_for") + %strong= @page.name + - else + = t("layout.wiki.wiki_history") + + %ul.actions + - if @name + - if can? :read, @project + %li.minibutton + = link_to t("layout.wiki.view_page"), view_path(@project, escaped_name), + :class => 'action-view-page' + - if can? :write, @project + %li.minibutton + = link_to t("layout.wiki.edit_page"), edit_project_wiki_path(@project, escaped_name), + :class => 'aciton-edit-page' + - else + - if can? :read, @project + %li.minibutton + = link_to t("layout.wiki.view_page"), project_wiki_index_path(@project) + = render :partial => 'searchbar' + + #wiki-content + = render :partial => "history" + +- content_for :sidebar do + - render :partial => 'projects/sidebar' diff --git a/app/views/wiki/new.html.haml b/app/views/wiki/new.html.haml new file mode 100644 index 000000000..3c295d1be --- /dev/null +++ b/app/views/wiki/new.html.haml @@ -0,0 +1,24 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + #wiki-wrapper.inner + #head + %h1.title + = t("layout.wiki.create_page") + %strong= @name + + #wiki-content + = render :partial => "editor" + +:javascript + jQuery(document).ready(function() { + $.GollumEditor({ NewFile: true }); + }); + +- content_for :sidebar do + - render :partial => 'projects/sidebar' diff --git a/app/views/wiki/pages.html.haml b/app/views/wiki/pages.html.haml new file mode 100644 index 000000000..03d079b90 --- /dev/null +++ b/app/views/wiki/pages.html.haml @@ -0,0 +1,25 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + .inner + #wiki-wrapper.results + #head + - @st_ref = capture do + %strong= @ref + %h1.title= raw t("layout.wiki.all_pages_in") + %ul.actions + - if can? :read, @project + %li.minibutton + = link_to t("layout.wiki.home"), project_wiki_index_path(@project), + :class => 'action-edit-page' + = render :partial => 'searchbar' + + = render :partial => "results" + +- content_for :sidebar do + - render :partial => 'projects/sidebar' diff --git a/app/views/wiki/search.html.haml b/app/views/wiki/search.html.haml new file mode 100644 index 000000000..a1cc25ee2 --- /dev/null +++ b/app/views/wiki/search.html.haml @@ -0,0 +1,25 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + .inner + #wiki-wrapper.results + #head + - @st_query = capture do + %strong= @query + %h1.title= raw t("layout.wiki.search_results_for", :query => @st_query) + %ul.actions + - if can? :read, @project + %li.minibutton + = link_to t("layout.wiki.home"), project_wiki_index_path(@project), + :class => 'action-edit-page' + = render :partial => 'searchbar' + + = render :partial => "results" + +- content_for :sidebar do + - render :partial => 'projects/sidebar' diff --git a/app/views/wiki/show.html.haml b/app/views/wiki/show.html.haml new file mode 100644 index 000000000..a9347530b --- /dev/null +++ b/app/views/wiki/show.html.haml @@ -0,0 +1,30 @@ += render :partial => 'gollum_includes' += render :partial => 'project_short' + +%a{ :name => "wiki"} +.block + = render :partial => 'navigation' + + .content + .inner + #wiki-wrapper.page + #head + %h1.title + = @page.name + = "(#{t("layout.wiki.preview")})" if action_name == 'preview' + - unless action_name == 'preview' + %ul.actions + - if can? :write, @project + %li.minibutton.jaws + = link_to t("layout.wiki.new_page"), '#', :'data-url' => project_wiki_index_path(@project), + :id => 'minibutton-new-page' + - if @editable + %li.minibutton + = link_to t("layout.wiki.edit_page"), edit_project_wiki_path(@project, escaped_name), :class => "action-edit-page" + %li.minibutton= link_to t("layout.wiki.page_history"), history_project_wiki_path(@project, escaped_name) + = render :partial => 'searchbar' + + = render :partial => "page" + +- content_for :sidebar do + - render :partial => 'projects/sidebar' diff --git a/bin/import_srpm.sh b/bin/import_srpm.sh new file mode 100755 index 000000000..272d95721 --- /dev/null +++ b/bin/import_srpm.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# import_srpm.sh: Import SRPM packages to git repo + +# Input data +srpm_path=$1 +git_path=$2 +git_branch=$3 +name=$(rpm -q --qf '[%{Name}]' -p $srpm_path) +version=$(rpm -q --qf '[%{Version}]' -p $srpm_path) +tmp_dir=/tmp/$name-$version-$RANDOM + +# Clone destination repo +mkdir -p $tmp_dir +git clone $git_path $tmp_dir + +# Switch to import branch +cd $tmp_dir +git branch --track $git_branch origin/$git_branch # Try track remote +git branch $git_branch # Try create local +git checkout $git_branch + +# Remove all files except .git +rm -rf $tmp_dir/* +mv $tmp_dir/.git $tmp_dir/git +rm -rf $tmp_dir/.* +mv $tmp_dir/git $tmp_dir/.git + +# Unpack srpm +rpm2cpio $srpm_path > srpm.cpio +cpio -idv < srpm.cpio +rm -f srpm.cpio + +# Commit and push changes +git add -A . +git commit -m "Automatic import for version $version" +git branch $git_branch # Ensure branch exists +git push origin master $git_branch + +# Cleanup +rm -rf $tmp_dir diff --git a/bin/mount_downloads.sh b/bin/mount_downloads.sh index 13c7b8d02..11c2f45ca 100755 --- a/bin/mount_downloads.sh +++ b/bin/mount_downloads.sh @@ -3,6 +3,7 @@ for f in `ls /srv/rosa_build/shared/downloads` do if [ -d /home/share ] + then # Staging case if [ -d /home/share/platforms/$f ] then @@ -17,4 +18,4 @@ do sudo mount --bind /share/platforms/$f /srv/rosa_build/shared/downloads/$f fi fi -done \ No newline at end of file +done diff --git a/bin/xml-client-demo.rb b/bin/xml-client-demo.rb index baa02045b..af73ea16c 100755 --- a/bin/xml-client-demo.rb +++ b/bin/xml-client-demo.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- #!/usr/bin/env ruby require 'rubygems' @@ -34,4 +35,4 @@ project_id = 1 # FIXME repo_id = 1 # FIXME pp client.call("build_packet", project_id, repo_id) -puts 'DONE' \ No newline at end of file +puts 'DONE' diff --git a/config/application.rb b/config/application.rb index c9d1d710a..30807d385 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path('../boot', __FILE__) require 'rails/all' diff --git a/config/boot.rb b/config/boot.rb index 4489e5868..f488c9a44 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'rubygems' # Set up gems listed in the Gemfile. diff --git a/config/compass.rb b/config/compass.rb index 07bb179f2..d3fe0bb92 100644 --- a/config/compass.rb +++ b/config/compass.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # This configuration file works with both the Compass command line tool and within Rails. # Require any additional compass plugins here. @@ -12,4 +13,4 @@ sass_dir = "app/stylesheets" javascripts_dir = "public/javascripts" http_stylesheets_path = "/stylesheets" -http_javascripts_path = "/javascripts" \ No newline at end of file +http_javascripts_path = "/javascripts" diff --git a/config/deploy.rb b/config/deploy.rb index b03d867e4..c67c374a3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) set :rvm_type, :user @@ -27,9 +28,9 @@ set :scm, :git set :repository, "git@github.com:warpc/rosa-build.git" set :deploy_via, :remote_cache -require 'lib/recipes/nginx' -require 'lib/recipes/unicorn' -require 'lib/recipes/bluepill' +require './lib/recipes/nginx' +require './lib/recipes/unicorn' +require './lib/recipes/bluepill' namespace :deploy do task :stub_xml_rpc do diff --git a/config/deploy/application.production.yml b/config/deploy/application.production.yml index 450faf330..6992ac31f 100644 --- a/config/deploy/application.production.yml +++ b/config/deploy/application.production.yml @@ -8,7 +8,7 @@ production: build_server_port: 12555 build_server_path: /xmlrpc product_builder_ip: - mdv: 192.168.122.19 + mdv: 192.168.122.144 nau5: 192.168.122.203 product_builder_port: 12554 product_builder_path: /xmlrpc diff --git a/config/deploy/pingwinsoft.rb b/config/deploy/pingwinsoft.rb index a15b8c22a..088b5b27d 100644 --- a/config/deploy/pingwinsoft.rb +++ b/config/deploy/pingwinsoft.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- set :branch, "pingwinsoft" set :domain, "b.pingwinsoft.ru" # "195.19.76.12" diff --git a/config/environment.rb b/config/environment.rb index b35a7204e..521243091 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,8 @@ +# -*- encoding : utf-8 -*- # Load the rails application require File.expand_path('../application', __FILE__) +Encoding.default_external = Encoding::UTF_8 +Encoding.default_internal = Encoding::UTF_8 # Initialize the rails application Rosa::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 6a687d647..3e4c691ae 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- Rosa::Application.configure do # Settings specified here will take precedence over those in config/application.rb diff --git a/config/environments/production.rb b/config/environments/production.rb index 0d9247b3a..fe08b9089 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- Rosa::Application.configure do # Settings specified here will take precedence over those in config/application.rb diff --git a/config/environments/test.rb b/config/environments/test.rb index 8bff1dc49..44f17a243 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- Rosa::Application.configure do # Settings specified here will take precedence over those in config/application.rb diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf3..b5e9a55a2 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/core.rb b/config/initializers/core.rb new file mode 100644 index 000000000..fe7ee4f48 --- /dev/null +++ b/config/initializers/core.rb @@ -0,0 +1 @@ +require './lib/ext/core/string' diff --git a/config/initializers/default_product_files.rb b/config/initializers/default_product_files.rb index 6222e022c..2551ce137 100644 --- a/config/initializers/default_product_files.rb +++ b/config/initializers/default_product_files.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- DEFAULT_KS = <<-eos timezone Europe/Moscow auth --useshadow --enablemd5 diff --git a/config/initializers/generators.rb b/config/initializers/generators.rb index 2c07eb336..47fae7cb8 100644 --- a/config/initializers/generators.rb +++ b/config/initializers/generators.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- Rails.application.config.generators do |g| g.test_framework = :rspec end diff --git a/config/initializers/gollum.rb b/config/initializers/gollum.rb new file mode 100644 index 000000000..d5c28225a --- /dev/null +++ b/config/initializers/gollum.rb @@ -0,0 +1 @@ +require './lib/gollum' diff --git a/config/initializers/grit.rb b/config/initializers/grit.rb new file mode 100644 index 000000000..043d42d15 --- /dev/null +++ b/config/initializers/grit.rb @@ -0,0 +1,3 @@ +# -*- encoding : utf-8 -*- + +require './lib/grit' diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 9e8b0131f..e3c680d36 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index 70d1244b6..7dfd2abbd 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- APP_CONFIG = YAML.load_file("#{Rails.root}/config/application.yml")[Rails.env] require 'modules' diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index e9307179b..a68a2d48e 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: @@ -5,4 +6,4 @@ # Mime::Type.register_alias "text/html", :iphone Mime::Type.register "text/plain", :diff -Mime::Type.register "text/plain", :patch \ No newline at end of file +Mime::Type.register "text/plain", :patch diff --git a/config/initializers/notifications.rb b/config/initializers/notifications.rb index 965ce9dc0..75d0ebba1 100644 --- a/config/initializers/notifications.rb +++ b/config/initializers/notifications.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- Warden::Manager.after_authentication do |user,auth,opts| # after_set_user, :except => fetch ActiveSupport::Notifications.instrument("event_log.observer", :object => user) end diff --git a/config/initializers/render_errors_in_forms.rb b/config/initializers/render_errors_in_forms.rb index e1ec4a433..fb36c59ed 100644 --- a/config/initializers/render_errors_in_forms.rb +++ b/config/initializers/render_errors_in_forms.rb @@ -1,7 +1,8 @@ +# -*- encoding : utf-8 -*- ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| if html_tag =~ /