diff --git a/Gemfile b/Gemfile index c4e9780d0..ccbac6cce 100644 --- a/Gemfile +++ b/Gemfile @@ -1,56 +1,66 @@ source 'http://rubygems.org' -gem 'rails', '3.0.5' +gem 'rails', '3.0.10' #, :git => 'git://github.com/rails/rails.git' -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' +gem 'pg', '~> 0.11.0' +gem 'silent-postgres', '~> 0.1.1' -gem 'pg' +gem 'devise', '~> 1.4.8' +gem 'omniauth', '~> 0.3.0' +gem 'oa-openid', '~> 0.3.0', :require => 'omniauth/openid' +gem 'cancan', '~> 1.6.7' -# Use unicorn as the web server -# gem 'unicorn' +gem "haml-rails", '~> 0.3.4' +gem "compass", '~> 0.11.5' +gem 'jammit' +gem "yui-compressor", "0.9.5" # Higher versions depends on Platform gem which conflicts with Platform model -# Deploy with Capistrano -# gem 'capistrano' +gem 'paperclip', "~> 2.3" +gem "will_paginate", "~> 3.0.2" +gem "russian" -# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+) -# gem 'ruby-debug' -# gem 'ruby-debug19', :require => 'ruby-debug' +gem "grit" +gem 'delayed_job' +gem 'unicorn' -# Bundle the extra gems: -# gem 'bj' -# gem 'nokogiri' -# gem 'sqlite3-ruby', :require => 'sqlite3' -# gem 'aws-s3', :require => 'aws/s3' - -# Bundle gems for the local environment. Make sure to -# put test-only gems in this group so their generators -# and rake tasks are available in development mode: -# group :development, :test do -# gem 'webrat' -# end - -group :development, :test do - gem "rspec-rails", ">= 2.0.1" - gem 'factory_girl_rails' - gem 'web-app-theme', '>= 0.6.2' - gem 'hpricot' - gem 'ruby_parser' +group :production do + gem "airbrake" + # gem 'newrelic_rpm', '~> 3.1.1' end -gem "devise" -gem "haml", ">= 3.0.0" -gem "haml-rails" -gem "compass", ">= 0.10.6" -gem "capistrano" -gem "capistrano-ext" -gem "will_paginate", "~> 3.0.pre2" -gem 'factory_girl_rails' -gem "airbrake" -gem "russian" -gem "grit" -gem 'unicorn' -gem 'delayed_job' -gem 'paperclip', "~> 2.3" +group :development do + # gem 'letter_opener' + gem 'rails3-generators' + gem 'web-app-theme' + gem 'hpricot' + gem 'ruby_parser' -gem 'jammit' + # 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 'capistrano-exts', :require => false #, :git => 'git://github.com/chipiga/capistrano-exts.git' + # gem 'capistrano-recipes', :require => false + gem 'capistrano_colors', :require => false +end + +group :test do + gem 'rspec-rails', '~> 2.6.1' + gem 'factory_girl_rails', '~> 1.2.0' + # gem 'spork', '>= 0.9.0.rc9' + # gem 'guard-spork', '~> 0.3.1' + # gem 'guard-rspec', '~> 0.5.0' + # gem 'guard-bundler', '~> 0.1.3' + # + # gem 'rb-fsevent', '>= 0.4.3', :require => false + # gem 'growl', '~> 1.0.3', :require => false + # gem 'rb-inotify', '>= 0.8.6', :require => false + # gem 'libnotify', '~> 0.5.7', :require => false +end diff --git a/Gemfile.lock b/Gemfile.lock index 5582f021e..e06fd22da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,145 +1,242 @@ GEM remote: http://rubygems.org/ specs: + XMLCanonicalizer (1.0.1) + log4r (>= 1.0.4) abstract (1.0.0) - actionmailer (3.0.5) - actionpack (= 3.0.5) - mail (~> 2.2.15) - actionpack (3.0.5) - activemodel (= 3.0.5) - activesupport (= 3.0.5) + actionmailer (3.0.10) + actionpack (= 3.0.10) + mail (~> 2.2.19) + actionpack (3.0.10) + activemodel (= 3.0.10) + activesupport (= 3.0.10) builder (~> 2.1.2) erubis (~> 2.6.6) - i18n (~> 0.4) + i18n (~> 0.5.0) rack (~> 1.2.1) - rack-mount (~> 0.6.13) + rack-mount (~> 0.6.14) rack-test (~> 0.5.7) tzinfo (~> 0.3.23) - activemodel (3.0.5) - activesupport (= 3.0.5) + activemodel (3.0.10) + activesupport (= 3.0.10) builder (~> 2.1.2) - i18n (~> 0.4) - activerecord (3.0.5) - activemodel (= 3.0.5) - activesupport (= 3.0.5) - arel (~> 2.0.2) + i18n (~> 0.5.0) + activerecord (3.0.10) + activemodel (= 3.0.10) + activesupport (= 3.0.10) + arel (~> 2.0.10) tzinfo (~> 0.3.23) - activeresource (3.0.5) - activemodel (= 3.0.5) - activesupport (= 3.0.5) - activesupport (3.0.5) + activeresource (3.0.10) + activemodel (= 3.0.10) + activesupport (= 3.0.10) + activesupport (3.0.10) + addressable (2.2.6) airbrake (3.0.4) activesupport builder - arel (2.0.9) - bcrypt-ruby (2.1.4) + arel (2.0.10) + bcrypt-ruby (3.0.1) builder (2.1.2) - capistrano (2.5.19) + cancan (1.6.7) + capistrano (2.9.0) highline net-scp (>= 1.0.0) net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.0.0) + net-ssh-gateway (>= 1.1.0) capistrano-ext (1.2.1) capistrano (>= 1.0.0) - closure-compiler (1.1.1) - compass (0.10.6) - haml (>= 3.0.4) - daemons (1.1.0) + capistrano_colors (0.5.5) + chunky_png (1.2.5) + cocaine (0.2.0) + columnize (0.3.4) + compass (0.11.5) + chunky_png (~> 1.2) + fssm (>= 0.2.7) + sass (~> 3.1) + daemons (1.1.4) delayed_job (2.1.4) activesupport (~> 3.0) daemons - devise (1.1.7) - bcrypt-ruby (~> 2.1.2) - warden (~> 1.0.2) - diff-lcs (1.1.2) + devise (1.4.8) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + warden (~> 1.0.3) + diff-lcs (1.1.3) erubis (2.6.6) abstract (>= 1.0.0) - factory_girl (1.3.3) - factory_girl_rails (1.0.1) - factory_girl (~> 1.3) + factory_girl (2.1.2) + activesupport + factory_girl_rails (1.2.0) + factory_girl (~> 2.1.0) railties (>= 3.0.0) + faraday (0.7.5) + addressable (~> 2.2.6) + multipart-post (~> 1.1.3) + rack (>= 1.1.0, < 2) + fssm (0.2.7) grit (2.4.1) diff-lcs (~> 1.1) mime-types (~> 1.15) - haml (3.0.25) + haml (3.1.3) haml-rails (0.3.4) actionpack (~> 3.0) activesupport (~> 3.0) haml (~> 3.0) railties (~> 3.0) - highline (1.6.1) + highline (1.6.2) hpricot (0.8.4) i18n (0.5.0) - jammit (0.6.0) - closure-compiler (>= 0.1.0) - yui-compressor (>= 0.9.1) - kgio (2.3.3) - mail (2.2.15) + jammit (0.6.3) + yui-compressor (>= 0.9.3) + json (1.6.1) + kgio (2.6.0) + linecache (0.46) + rbx-require-relative (> 0.0.4) + log4r (1.1.9) + macaddr (1.4.0) + systemu (~> 2.2.0) + mail (2.2.19) activesupport (>= 2.3.6) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.16) + multi_json (1.0.3) + multi_xml (0.4.1) + multipart-post (1.1.3) + net-ldap (0.2.2) net-scp (1.0.4) net-ssh (>= 1.99.1) net-sftp (2.0.5) net-ssh (>= 2.0.9) - net-ssh (2.1.3) - net-ssh-gateway (1.0.1) + net-ssh (2.2.1) + net-ssh-gateway (1.1.0) net-ssh (>= 1.99.1) - paperclip (2.3.8) - activerecord - activesupport - pg (0.10.1) - polyglot (0.3.1) - rack (1.2.1) - rack-mount (0.6.13) + nokogiri (1.5.0) + oa-basic (0.3.0) + oa-core (= 0.3.0) + rest-client (~> 1.6.0) + oa-core (0.3.0) + oa-enterprise (0.3.0) + XMLCanonicalizer (~> 1.0.1) + addressable (~> 2.2.6) + net-ldap (~> 0.2.2) + nokogiri (~> 1.5.0) + oa-core (= 0.3.0) + pyu-ruby-sasl (~> 0.0.3.1) + rubyntlm (~> 0.1.1) + uuid + oa-more (0.3.0) + multi_json (~> 1.0.0) + oa-core (= 0.3.0) + rest-client (~> 1.6.0) + oa-oauth (0.3.0) + faraday (~> 0.7.3) + multi_json (~> 1.0.0) + multi_xml (~> 0.4.0) + oa-core (= 0.3.0) + oauth (~> 0.4.0) + oauth2 (~> 0.5.0) + oa-openid (0.3.0) + oa-core (= 0.3.0) + rack-openid (~> 1.3.1) + ruby-openid-apps-discovery (~> 1.2.0) + oauth (0.4.5) + oauth2 (0.5.1) + faraday (~> 0.7.4) + multi_json (~> 1.0.3) + omniauth (0.3.0) + oa-basic (= 0.3.0) + oa-core (= 0.3.0) + oa-enterprise (= 0.3.0) + oa-more (= 0.3.0) + oa-oauth (= 0.3.0) + oa-openid (= 0.3.0) + orm_adapter (0.0.5) + paperclip (2.4.3) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) + cocaine (>= 0.0.2) + mime-types + pg (0.11.0) + polyglot (0.3.2) + pyu-ruby-sasl (0.0.3.3) + rack (1.2.4) + rack-mount (0.6.14) rack (>= 1.0.0) + rack-openid (1.3.1) + rack (>= 1.1.0) + ruby-openid (>= 2.1.8) rack-test (0.5.7) rack (>= 1.0) - rails (3.0.5) - actionmailer (= 3.0.5) - actionpack (= 3.0.5) - activerecord (= 3.0.5) - activeresource (= 3.0.5) - activesupport (= 3.0.5) + rails (3.0.10) + actionmailer (= 3.0.10) + actionpack (= 3.0.10) + activerecord (= 3.0.10) + activeresource (= 3.0.10) + activesupport (= 3.0.10) bundler (~> 1.0) - railties (= 3.0.5) - railties (3.0.5) - actionpack (= 3.0.5) - activesupport (= 3.0.5) + railties (= 3.0.10) + rails3-generators (0.17.4) + railties (>= 3.0.0) + railties (3.0.10) + actionpack (= 3.0.10) + activesupport (= 3.0.10) rake (>= 0.8.7) + rdoc (~> 3.4) thor (~> 0.14.4) - rake (0.8.7) - rspec (2.5.0) - rspec-core (~> 2.5.0) - rspec-expectations (~> 2.5.0) - rspec-mocks (~> 2.5.0) - rspec-core (2.5.1) - rspec-expectations (2.5.0) + raindrops (0.7.0) + rake (0.9.2) + rbx-require-relative (0.0.5) + rdoc (3.10) + json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) diff-lcs (~> 1.1.2) - rspec-mocks (2.5.0) - rspec-rails (2.5.0) + rspec-mocks (2.6.0) + rspec-rails (2.6.1) actionpack (~> 3.0) activesupport (~> 3.0) railties (~> 3.0) - rspec (~> 2.5.0) - ruby_parser (2.0.6) + rspec (~> 2.6.0) + ruby-debug (0.10.4) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.4.0) + ruby-debug-base (0.10.4) + linecache (>= 0.3) + ruby-openid (2.1.8) + ruby-openid-apps-discovery (1.2.0) + ruby-openid (>= 2.1.7) + ruby_parser (2.3.1) sexp_processor (~> 3.0) + rubyntlm (0.1.1) russian (0.2.7) - sexp_processor (3.0.5) + sass (3.1.10) + sexp_processor (3.0.7) + silent-postgres (0.1.1) + systemu (2.2.0) thor (0.14.6) - treetop (1.4.9) + treetop (1.4.10) + polyglot polyglot (>= 0.3.1) - tzinfo (0.3.24) - unicorn (3.5.0) - kgio (~> 2.3) + tzinfo (0.3.30) + unicorn (4.1.1) + kgio (~> 2.4) rack - warden (1.0.3) - rack (>= 1.0.0) - web-app-theme (0.6.3) - will_paginate (3.0.pre2) + raindrops (~> 0.6) + uuid (2.3.4) + macaddr (~> 1.0) + warden (1.0.6) + rack (>= 1.0) + web-app-theme (0.7.0) + will_paginate (3.0.2) yui-compressor (0.9.5) PLATFORMS @@ -147,23 +244,30 @@ PLATFORMS DEPENDENCIES airbrake + cancan (~> 1.6.7) capistrano capistrano-ext - compass (>= 0.10.6) + capistrano_colors + compass (~> 0.11.5) delayed_job - devise - factory_girl_rails + devise (~> 1.4.8) + factory_girl_rails (~> 1.2.0) grit - haml (>= 3.0.0) - haml-rails + haml-rails (~> 0.3.4) hpricot jammit + oa-openid (~> 0.3.0) + omniauth (~> 0.3.0) paperclip (~> 2.3) - pg - rails (= 3.0.5) - rspec-rails (>= 2.0.1) + pg (~> 0.11.0) + rails (= 3.0.10) + rails3-generators + rspec-rails (~> 2.6.1) + ruby-debug ruby_parser russian + silent-postgres (~> 0.1.1) unicorn - web-app-theme (>= 0.6.2) - will_paginate (~> 3.0.pre2) + web-app-theme + will_paginate (~> 3.0.2) + yui-compressor (= 0.9.5) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb new file mode 100644 index 000000000..fc0b2e243 --- /dev/null +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -0,0 +1,45 @@ +class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController + def open_id + generic + end + + def passthru + render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false + end + + protected + + def generic + authentication = Authentication.find_or_initialize_by_provider_and_uid(env['omniauth.auth']['provider'], env['omniauth.auth']['uid']) + if authentication.new_record? + if user_signed_in? # New authentication method for current_user + authentication.user = current_user + authentication.save + else # Register new user + session["devise.omniauth_data"] = env["omniauth.auth"] + redirect_to new_user_registration_url + end + else + flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => action_name.classify + sign_in_and_redirect authentication.user, :event => :authentication + end + + # @authentication = Authentication.find_or_initialize_by_provider_and_uid(env['omniauth.auth']['provider'], env['omniauth.auth']['uid']) + # if @authentication.new_record? + # if user_signed_in? # New authentication method for current_user + # user = current_user + # else # Register new user + # user = User.new(:password => Devise.friendly_token[0,20]) # Stub password + # user.init_from env['omniauth.auth'], action_name + # user. + # end + # extra = env['omniauth.auth']['extra']['user_hash'] rescue {} + # @authentication.user_info = env['omniauth.auth']['user_info'].merge extra + # # Assign authentication to user + # @authentication.user = user + # @authentication.save + # end + # flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => action_name.classify + # sign_in_and_redirect @authentication.user, :event => :authentication + end +end diff --git a/app/models/authentication.rb b/app/models/authentication.rb new file mode 100644 index 000000000..26ba03317 --- /dev/null +++ b/app/models/authentication.rb @@ -0,0 +1,6 @@ +class Authentication < ActiveRecord::Base + belongs_to :user + + validates :provider, :uid, :presence => true + validates :uid, :uniqueness => {:scope => :provider, :case_sensitive => false} +end diff --git a/app/models/user.rb b/app/models/user.rb index 37d2e86bb..c992d89a6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,22 +1,50 @@ -require 'digest/md5' class User < ActiveRecord::Base - devise :database_authenticatable, - :recoverable, :rememberable, :validatable + has_many :authentications, :dependent => :destroy - attr_accessible :email, :password, :password_confirmation, :remember_me, :name + devise :database_authenticatable, :registerable, :omniauthable, # :token_authenticatable, :encryptable, :timeoutable + :recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable - before_validation :generate_password, :on => :create - after_create :send_notification_email + validates :nickname, :presence => true, :uniqueness => {:case_sensitive => false}, + :format => {:with => /[\w]+/i} #, :exclusion => {:in => %w(superuser moderator')} - protected + attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :nickname, :name, :ssh_key - def generate_password - if self.password.blank? - self.password = self.password_confirmation = Digest::MD5.hexdigest(Date.today.to_s)[0..6] + attr_accessor :login + + before_validation(:on => :update) { raise "Can't change nickname" if nickname_changed? } # disable edit username + # after_create() { UserMailer.new_user_notification(self).deliver } + + class << self + def find_for_database_authentication(warden_conditions) + conditions = warden_conditions.dup + login = conditions.delete(:login) + where(conditions).where(["lower(nickname) = :value OR lower(email) = :value", { :value => login.downcase }]).first + end + + def new_with_session(params, session) + super.tap do |user| + if data = session["devise.omniauth_data"] + if info = data['user_info'] and info.present? + user.email ||= info['email'].presence + user.nickname ||= info['nickname'].presence || info['username'].presence + user.name ||= info['name'].presence || [info['first_name'], info['last_name']].join(' ').strip + end + user.password = Devise.friendly_token[0,20] # stub password + user.authentications.build :uid => data['uid'], :provider => data['provider'] + end end end + end - def send_notification_email - UserMailer.new_user_notification(self).deliver + def update_with_password(params={}) + params.delete(:current_password) + # self.update_without_password(params) # Don't allow password update + if params[:password].blank? + params.delete(:password) + params.delete(:password_confirmation) if params[:password_confirmation].blank? end + result = update_attributes(params) + clean_up_passwords + result + end end diff --git a/app/stylesheets/ie.scss b/app/stylesheets/ie.scss new file mode 100644 index 000000000..5cd5b6c5b --- /dev/null +++ b/app/stylesheets/ie.scss @@ -0,0 +1,5 @@ +/* Welcome to Compass. Use this file to write IE specific override styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/app/stylesheets/print.scss b/app/stylesheets/print.scss new file mode 100644 index 000000000..b0e9e456f --- /dev/null +++ b/app/stylesheets/print.scss @@ -0,0 +1,3 @@ +/* Welcome to Compass. Use this file to define print styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/app/stylesheets/screen.scss b/app/stylesheets/screen.scss new file mode 100644 index 000000000..81de84703 --- /dev/null +++ b/app/stylesheets/screen.scss @@ -0,0 +1,6 @@ +/* Welcome to Compass. + * In this file you should write your main styles. (or centralize your imports) + * Import this file using the following HTML or equivalent: + * */ + +@import "compass/reset"; diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 8857fe42a..78969c1a1 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -23,4 +23,5 @@ .group.navform.wat-cf %button.button{ :tyle => "submit" } #{image_tag("web-app-theme/icons/application_edit.png", :alt => t("devise.passwords.edit_button"))} #{t("devise.passwords.edit_button")} - + %span.text_button_padding + = render :partial => "devise/shared/links" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index b440c0144..b25bb7320 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -16,4 +16,6 @@ .group.navform.wat-cf %button.button{ :tyle => "submit" } - #{image_tag("web-app-theme/icons/tick.png", :alt => t("devise.passwords.button"))} #{t("devise.passwords.button")} \ No newline at end of file + #{image_tag("web-app-theme/icons/tick.png", :alt => t("devise.passwords.button"))} #{t("devise.passwords.button")} + %span.text_button_padding + = render :partial => "devise/shared/links" \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index ce7201d56..91449ae86 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -1,45 +1,63 @@ #block-signup.block %h2 #{t("devise.registrations.edit")} #{resource_name.to_s.humanize} - .content - = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "form" }) do |f| - - if resource.errors.present? - .flash - .message.error - - messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg) }.join.html_safe - = messages + .content + = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "form" }) do |f| + - if resource.errors.present? + .flash + .message.error + - messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg) }.join.html_safe + = messages - .group.wat-cf - .left - = f.label :email, :class => "label" - .right - = f.text_field :email, :class => "text_field" + / .group.wat-cf + / .left + / = f.label :nickname, :class => "label" + / .right + / = f.text_field :nickname, :class => "text_field" - .group.wat-cf - .left - = f.label :current_password, :class => "label" - .right - = f.password_field :current_password, :class => "text_field" - %span.description= t("devise.registrations.current_password_description") + .group.wat-cf + .left + = f.label :email, :class => "label" + .right + = f.text_field :email, :class => "text_field" - .group.wat-cf - .left - = f.label :password, :class => "label" - .right - = f.password_field :password, :class => "text_field" - %span.description= t("devise.registrations.edit_password_description") + .group.wat-cf + .left + = f.label :name, :class => "label" + .right + = f.text_field :name, :class => "text_field" - .group.wat-cf - .left - = f.label :password_confirmation, :class => "label" - .right - = f.password_field :password_confirmation, :class => "text_field" + .group.wat-cf + .left + = f.label :ssh_key, :class => "label" + .right + = f.text_area :ssh_key, :class => "text_area" - .group.navform.wat-cf - %button.button{ :type => "submit" } - #{image_tag("web-app-theme/icons/tick.png", :alt => t("devise.registrations.signed_up"))} #{t("devise.registrations.signed_up")} + / .group.wat-cf + / .left + / = f.label :current_password, :class => "label" + / .right + / = f.password_field :current_password, :class => "text_field" + / %span.description= t("devise.registrations.current_password_description") - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("devise.registrations.cancel")) + " " + t("devise.registrations.cancel"), registration_path(resource_name), :method => "delete", :class => "button", :confirm => t("devise.registrations.cancel_confirmation") + .group.wat-cf + .left + = f.label :password, :class => "label" + .right + = f.password_field :password, :class => "text_field" + %span.description= t("devise.registrations.edit_password_description") - %span.text_button_padding - = link_to t('layout.back'), :back, :class => "text_button_padding link_button" + .group.wat-cf + .left + = f.label :password_confirmation, :class => "label" + .right + = f.password_field :password_confirmation, :class => "text_field" + + .group.navform.wat-cf + %button.button{ :type => "submit" } + #{image_tag("web-app-theme/icons/tick.png", :alt => t("devise.registrations.signed_up"))} #{t("layout.save")} + + = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("devise.registrations.cancel")) + " " + t("devise.registrations.cancel"), registration_path(resource_name), :method => :delete, :class => "button", :confirm => t("devise.registrations.cancel_confirmation") + + %span.text_button_padding + = link_to t('layout.back'), :back, :class => "text_button_padding link_button" diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index d68795e70..66fd0a0a9 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,19 +1,32 @@ #block-signup.block %h2= t("devise.registrations.sign_up_header") - .content - = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form" }) do |f| - - if resource.errors.present? - .flash - .message.error - - messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg) }.join.html_safe - = messages + .content + = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form" }) do |f| + - if resource.errors.present? + .flash + .message.error + - messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg) }.join.html_safe + = messages - .group.wat-cf - .left - = f.label :email, :class => "label" - .right - = f.text_field :email, :class => "text_field" + .group.wat-cf + .left + = f.label :nickname, :class => "label" + .right + = f.text_field :nickname, :class => "text_field" + .group.wat-cf + .left + = f.label :email, :class => "label" + .right + = f.text_field :email, :class => "text_field" + + .group.wat-cf + .left + = f.label :name, :class => "label" + .right + = f.text_field :name, :class => "text_field" + + - if resource.authentications.blank? .group.wat-cf .left = f.label :password, :class => "label" @@ -26,8 +39,8 @@ .right = f.password_field :password_confirmation, :class => "text_field" - .group.navform.wat-cf - %button.button{ :type => "submit" } - #{image_tag("web-app-theme/icons/tick.png", :alt => t("devise.registrations.signed_up"))} #{t("devise.registrations.signed_up")} - %span.text_button_padding - = render :partial => "devise/shared/links" + .group.navform.wat-cf + %button.button{ :type => "submit" } + #{image_tag("web-app-theme/icons/tick.png", :alt => t("devise.registrations.sign_up_header"))} #{t("devise.registrations.sign_up_header")} + %span.text_button_padding + = render :partial => "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index d3caed1c2..7605731e2 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -9,9 +9,9 @@ - form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "form login" }) do |f| .group.wat-cf .left - = f.label :email, :class => "label right" + = f.label :login, :class => "label right" .right - = f.text_field :email, :class => "text_field" + = f.text_field :login, :class => "text_field" .group.wat-cf .left = f.label :password, :class => "label right" @@ -22,4 +22,4 @@ %button.button{ :type => "submit" } %img{ :src => "/images/web-app-theme/icons/key.png", :alt => "Save" }= t("layout.login") %span.text_button_padding - = link_to t('devise.passwords.link'), new_password_path(resource_name), :class => "text_button_padding link_button" \ No newline at end of file + = render :partial => "devise/shared/links" diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index f34d98813..f3c6883ac 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -1,2 +1,13 @@ +- if controller_name != 'sessions' + = link_to "Войти", 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" - if devise_mapping.recoverable? && controller_name != 'passwords' - = link_to t('devise.passwords.link'), new_password_path(resource_name), :class => "text_button_padding link_button" + = link_to "Забыли пароль?", 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" +- 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" +- 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 diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 5f3ed52f2..752f0ad37 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -12,8 +12,8 @@ %a{:href => "/"}= t("layout.global_header") #user-navigation %ul.wat-cf - %li - = link_to t('layout.logout'), destroy_user_session_path, :class => "logout" + %li= link_to current_user.nickname, edit_user_registration_path + %li= link_to t('layout.logout'), destroy_user_session_path, :method => :delete, :class => "logout" #main-navigation %ul.wat-cf %li{:class => controller.controller_path == 'users' ? 'active' : '' } diff --git a/app/views/layouts/sessions.html.haml b/app/views/layouts/sessions.html.haml index be5bfb52f..e4d4c4026 100644 --- a/app/views/layouts/sessions.html.haml +++ b/app/views/layouts/sessions.html.haml @@ -2,6 +2,7 @@ %html %head %title= t("layout.global_header") + = render :partial => "layouts/javascripts" -#= include_stylesheets :sessions = stylesheet_link_tag "web-app-theme/base.css", "web-app-theme/themes/default/style.css", "web-app-theme/override.css" diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index 3ff7ed8c5..66eb1d72d 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -1,9 +1,15 @@ .group = f.label :name, t("activerecord.attributes.user.name"), :class => :label = f.text_field :name, :class => 'text_field' +/ .group +/ = f.label :nickname, t("activerecord.attributes.user.nickname"), :class => :label +/ = f.text_field :nickname, :class => 'text_field' .group = f.label :email, t("activerecord.attributes.user.email"), :class => :label = f.text_field :email, :class => 'text_field' +.group + = f.label :ssh_key, t("activerecord.attributes.user.ssh_key"), :class => :label + = f.text_area :ssh_key, :class => 'text_area' .group.navform.wat-cf %button.button{:type => "submit"} diff --git a/config/initializers/compass.rb b/config/initializers/compass.rb deleted file mode 100644 index 6811b3267..000000000 --- a/config/initializers/compass.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'compass' -require 'compass/app_integration/rails' -Compass::AppIntegration::Rails.initialize! diff --git a/config/locales/devise.ru.yml b/config/locales/devise.ru.yml index 3c8afa0bd..4d25e93cd 100644 --- a/config/locales/devise.ru.yml +++ b/config/locales/devise.ru.yml @@ -1,6 +1,19 @@ ru: + errors: + messages: + expired: "устарела. Пожалуйста, запросите новую" + not_found: "не найдена" + already_confirmed: "уже подтверждена. Пожалуйста, попробуйте войти в систему" + not_locked: "не заблокирована" + not_saved: + one: "%{resource}: сохранение не удалось из-за %{count} ошибки" + few: "%{resource}: сохранение не удалось из-за %{count} ошибок" + many: "%{resource}: сохранение не удалось из-за %{count} ошибок" + other: "%{resource}: сохранение не удалось из-за %{count} ошибки" + devise: failure: + already_authenticated: "Вы уже вошли в систему." unauthenticated: 'Вы должны войти или зарегистрироваться, прежде чем сможете продолжить.' unconfirmed: 'Вы должны подтвердить вашу учетную запись, прежде чем сможете продолжить.' locked: 'Ваша учетная запись заблокирована.' @@ -16,18 +29,21 @@ ru: link: 'Забыли пароль?' button: 'Восстановить' send_instructions: 'Вы получите письмо с инструкциями о том, как сбросить ваш пароль, через несколько минут.' + send_paranoid_instructions: "Если ваш адрес e-mail есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по восстановлению вашего пароля." updated: 'Ваш пароль изменен. Теперь вы можете войти.' edit: 'Изменение пароля' edit_button: 'Изменить пароль' confirmations: link: "Не получили инструкции для подтверждения учетной записи?" send_instructions: 'Вы получите письмо с инструкциями о том, как подтвердить вашу учетную запись.' + send_paranoid_instructions: "Если ваш адрес e-mail есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи." confirmed: 'Ваша учетная запись успешно подтверждена. Добро пожаловать.' resend_header: 'Повторная отправка инструкций для подтверждения учетной записи' send: "Отправить" registrations: link: 'Регистрация' signed_up: 'Вы успешно зарегистрировались.' + inactive_signed_up: "Добро пожаловать! Вы успешно зарегистрировались. Но пока вы не можете войти в систему, т.к. ваша учётная запись %{reason}." updated: 'Ваша учетная запись изменена.' destroyed: 'До свидания! Ваша учетная запись удалена. Надеемся вскоре снова вас увидеть.' sign_up_header: 'Регистрация' @@ -39,9 +55,15 @@ ru: unlocks: link: "Не получили инструкции для разблокировки учетной записи?" send_instructions: 'Вы получите письмо с инструкциями о том, как разблокировать вашу учетную запись, через несколько минут.' + send_paranoid_instructions: "Если ваша учётная запись существует, то в течение нескольких минут вы получите письмо с инструкциями по её разблокировке." unlocked: 'Ваша учетная запись разблокирована. Вы вошли.' + omniauth_callbacks: + success: "Вход в систему выполнен с учётной записью из %{kind}." + failure: "Вы не можете войти в систему с учётной записью из %{kind}, т.к. \"%{reason}\"." mailer: - confirmation_instructions: 'Инструкции для подтверждения' - reset_password_instructions: 'Инструкции для сброса пароля' - unlock_instructions: 'Инструкции для разблокировки' - + confirmation_instructions: + subject: "Инструкции по подтверждению учётной записи" + reset_password_instructions: + subject: "Инструкции по восстановлению пароля" + unlock_instructions: + subject: "Инструкции по разблокировке учётной записи" diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 69248a18c..6711ed015 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -297,7 +297,11 @@ ru: user: name: Имя + login: Никнейм или Email email: Email + nickname: Никнейм + ssh_key: SSH ключ + current_password: Текущий пароль created_at: Создан updated_at: Обновлен diff --git a/config/routes.rb b/config/routes.rb index 151faf1b1..fe44ff666 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,8 @@ Rosa::Application.routes.draw do - devise_for :users + devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'} do + get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' + end + resources :users resources :platforms do member do @@ -36,8 +39,6 @@ Rosa::Application.routes.draw do end end end - - resources :users match 'build_lists/status_build', :to => "build_lists#status_build" match 'build_lists/post_build', :to => "build_lists#post_build" diff --git a/db/migrate/20111011182847_add_extra_fields_to_users.rb b/db/migrate/20111011182847_add_extra_fields_to_users.rb new file mode 100644 index 000000000..052ba39db --- /dev/null +++ b/db/migrate/20111011182847_add_extra_fields_to_users.rb @@ -0,0 +1,13 @@ +class AddExtraFieldsToUsers < ActiveRecord::Migration + def self.up + add_column :users, :nickname, :string + add_column :users, :ssh_key, :text + add_index :users, :nickname, :unique => true + User.all.each {|u| u.update_attribute :nickname, u.email.split('@').first} + end + + def self.down + remove_column :users, :ssh_key + remove_column :users, :nickname + end +end diff --git a/db/migrate/20111011200645_create_authentications.rb b/db/migrate/20111011200645_create_authentications.rb new file mode 100644 index 000000000..068a5c180 --- /dev/null +++ b/db/migrate/20111011200645_create_authentications.rb @@ -0,0 +1,18 @@ +class CreateAuthentications < ActiveRecord::Migration + def self.up + create_table :authentications do |t| + t.references :user + t.string :provider + t.string :uid + + t.timestamps + end + + add_index :authentications, :user_id + add_index :authentications, [:provider, :uid], :unique => true + end + + def self.down + drop_table :authentications + end +end diff --git a/db/schema.rb b/db/schema.rb index 727a3cb43..0e1886e2d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110428140753) do +ActiveRecord::Schema.define(:version => 20111011200645) do create_table "arches", :force => true do |t| t.string "name", :null => false @@ -20,6 +20,17 @@ ActiveRecord::Schema.define(:version => 20110428140753) do add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true + create_table "authentications", :force => true do |t| + t.integer "user_id" + t.string "provider" + t.string "uid" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true + add_index "authentications", ["user_id"], :name => "index_authentications_on_user_id" + create_table "build_list_items", :force => true do |t| t.string "name" t.integer "level" @@ -140,9 +151,12 @@ ActiveRecord::Schema.define(:version => 20110428140753) do t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" + t.string "nickname" + t.text "ssh_key" end add_index "users", ["email"], :name => "index_users_on_email", :unique => true + add_index "users", ["nickname"], :name => "index_users_on_nickname", :unique => true add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true end