From f758aabfb101c3ecd3d3b662f2ebc19bb66e5c3e Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 5 Aug 2014 23:44:51 +0200 Subject: [PATCH 1/9] uses gravatar_image_tag gem as standard avatar lib --- Gemfile | 2 +- Gemfile.lock | 2 +- app/helpers/avatar_helper.rb | 74 +++++++++-- lib/api/v3/activities/activity_model.rb | 1 - lib/api/v3/users/user_model.rb | 1 - lib/api/v3/users/user_representer.rb | 5 +- .../v3/work_packages/work_package_model.rb | 1 - lib/plugins/gravatar/MIT-LICENSE | 20 --- lib/plugins/gravatar/README.rdoc | 55 -------- lib/plugins/gravatar/Rakefile | 32 ----- lib/plugins/gravatar/about.yml | 35 ------ lib/plugins/gravatar/init.rb | 3 - lib/plugins/gravatar/lib/gravatar.rb | 88 ------------- lib/plugins/gravatar/spec/gravatar_spec.rb | 44 ------- spec/helpers/avatar_helper_spec.rb | 118 +++++++++++++----- .../lib/api/v3/users/user_representer_spec.rb | 35 +++++- 16 files changed, 195 insertions(+), 321 deletions(-) delete mode 100644 lib/plugins/gravatar/MIT-LICENSE delete mode 100644 lib/plugins/gravatar/README.rdoc delete mode 100644 lib/plugins/gravatar/Rakefile delete mode 100644 lib/plugins/gravatar/about.yml delete mode 100644 lib/plugins/gravatar/init.rb delete mode 100644 lib/plugins/gravatar/lib/gravatar.rb delete mode 100644 lib/plugins/gravatar/spec/gravatar_spec.rb diff --git a/Gemfile b/Gemfile index 60062f50c8..905ae63c81 100644 --- a/Gemfile +++ b/Gemfile @@ -52,7 +52,7 @@ gem "rdoc", ">= 2.4.2" gem 'globalize' gem 'omniauth' gem 'request_store' -gem 'gravatar_image_tag' +gem 'gravatar_image_tag', '~> 1.2.0' # TODO: adds #auto_link which was deprecated in rails 3.1 gem 'rails_autolink' diff --git a/Gemfile.lock b/Gemfile.lock index b52ed1446a..f3aa3e97b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -469,7 +469,7 @@ DEPENDENCIES globalize gon (~> 4.0) grape (~> 0.7.0) - gravatar_image_tag + gravatar_image_tag (~> 1.2.0) htmldiff i18n (>= 0.6.8) i18n-js! diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index b100f5db21..02ee4f3096 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -27,25 +27,81 @@ # See doc/COPYRIGHT.rdoc for more details. #++ +require 'gravatar_image_tag' + module AvatarHelper - include GravatarHelper::PublicMethods + include GravatarImageTag + + GravatarImageTag.configure do |c| + c.include_size_attributes = false + c.secure = Setting.protocol == 'https' + c.default_image = Setting.gravatar_default.blank? ? nil : Setting.gravatar_default + end + + Setting.register_callback(:protocol) do |values| + GravatarImageTag.configure do |c| + c.secure = values[:value] == 'https' + end + end + + Setting.register_callback(:gravatar_default) do |values| + GravatarImageTag.configure do |c| + c.default_image = values[:value].blank? ? nil : values[:value] + end + end + + def self.secure? + GravatarImageTag.configuration.secure + end + + def self.default + GravatarImageTag.configuration.default_image + end # Returns the avatar image tag for the given +user+ if avatars are enabled # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe ') def avatar(user, options = { }) - avatar = if Setting.gravatar_enabled? && (email = extract_email_address(user)).present? - options.merge!({ :ssl => (defined?(request) && request.ssl?), - :default => Setting.gravatar_default }) - - gravatar(email.to_s.downcase, options) - end - ensure - # return is actually needed here + avatar = with_default_avatar_options(user, options) do |email, opts| + tag_options = merge_image_options(user, opts) + + gravatar_image_tag(email, tag_options) + end + ensure # return is actually needed here return (avatar || ''.html_safe) end + def avatar_url(user, options = {}) + url = with_default_avatar_options(user, options) do |email, opts| + gravatar_image_url(email, opts) + end + ensure # return is actually needed here + return (url || ''.html_safe) + end + private + def merge_image_options(user, options) + default_options = { class: 'avatar' } + default_options[:title] = user.name if user.respond_to?(:name) + + options.reverse_merge(default_options) + end + + def with_default_avatar_options(user, options, &block) + if options.delete(:size) + warn <<-DOC + + [DEPRECATION] The :size option is no longer supported for #avatar. + Use css styling (:class attribute). The classes '.avatar', '.gravatar', and '.avatar-mini' are provided for this + Called from #{caller[1]} + DOC + end + + if Setting.gravatar_enabled? && (email = extract_email_address(user)).present? + block.call(email.to_s.downcase, options) + end + end + def extract_email_address(object) if object.respond_to?(:mail) object.mail diff --git a/lib/api/v3/activities/activity_model.rb b/lib/api/v3/activities/activity_model.rb index 899d1e257b..c8a528d1ef 100644 --- a/lib/api/v3/activities/activity_model.rb +++ b/lib/api/v3/activities/activity_model.rb @@ -39,7 +39,6 @@ module API include OpenProject::TextFormatting include OpenProject::StaticRouting::UrlHelpers include WorkPackagesHelper - include GravatarImageTag # N.B. required by ActionView::Helpers::UrlHelper def controller; nil; end diff --git a/lib/api/v3/users/user_model.rb b/lib/api/v3/users/user_model.rb index 657e44d4b4..fcdac5e707 100644 --- a/lib/api/v3/users/user_model.rb +++ b/lib/api/v3/users/user_model.rb @@ -35,7 +35,6 @@ module API module Users class UserModel < Reform::Form include Coercion - include GravatarImageTag property :login, type: String property :firstname, type: String diff --git a/lib/api/v3/users/user_representer.rb b/lib/api/v3/users/user_representer.rb index 8cee40a8c0..698f9cb62d 100644 --- a/lib/api/v3/users/user_representer.rb +++ b/lib/api/v3/users/user_representer.rb @@ -37,6 +37,7 @@ module API include Roar::Representer::JSON::HAL include Roar::Representer::Feature::Hypermedia include OpenProject::StaticRouting::UrlHelpers + include AvatarHelper self.as_strategy = API::Utilities::CamelCasingStrategy.new @@ -68,7 +69,9 @@ module API property :lastname, as: :lastName, render_nil: true property :name, getter: -> (*) { model.try(:name) }, render_nil: true property :mail, render_nil: true - property :avatar, getter: ->(*) { gravatar_image_url(mail) }, render_nil: true + property :avatar, getter: -> (*) { avatar_url(represented) }, + render_nil: true, + exec_context: :decorator property :created_at, getter: -> (*) { model.created_on.utc.iso8601 }, render_nil: true property :updated_at, getter: -> (*) { model.updated_on.utc.iso8601 }, render_nil: true property :status, getter: -> (*) { model.status }, render_nil: true diff --git a/lib/api/v3/work_packages/work_package_model.rb b/lib/api/v3/work_packages/work_package_model.rb index 39d3e83b64..9cb8061fa5 100644 --- a/lib/api/v3/work_packages/work_package_model.rb +++ b/lib/api/v3/work_packages/work_package_model.rb @@ -40,7 +40,6 @@ module API include OpenProject::TextFormatting include OpenProject::StaticRouting::UrlHelpers include WorkPackagesHelper - include GravatarImageTag # N.B. required by ActionView::Helpers::UrlHelper def controller; nil; end diff --git a/lib/plugins/gravatar/MIT-LICENSE b/lib/plugins/gravatar/MIT-LICENSE deleted file mode 100644 index 6a222ac4d9..0000000000 --- a/lib/plugins/gravatar/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2007 West Arete Computing, Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/lib/plugins/gravatar/README.rdoc b/lib/plugins/gravatar/README.rdoc deleted file mode 100644 index 0b95e85e8e..0000000000 --- a/lib/plugins/gravatar/README.rdoc +++ /dev/null @@ -1,55 +0,0 @@ -== Gravatar Plugin - -This plugin provides a handful of view helpers for displaying gravatars -(globally-recognized avatars). - -Gravatars allow users to configure an avatar to go with their email address at -a central location: http://gravatar.com. Gravatar-aware websites (such -as yours) can then look up and display each user's preferred avatar, without -having to handle avatar management. The user gets the benefit of not having to -set up an avatar for each site that they post on. - -== Installation - - cd ~/myapp - ruby script/plugin install git://github.com/woods/gravatar-plugin.git - -or, if you're using piston[http://piston.rubyforge.org] (worth it!): - - cd ~/myapp/vendor/plugins - piston import git://github.com/woods/gravatar-plugin.git - -== Example - -If you represent your users with a model that has an +email+ method (typical -for most rails authentication setups), then you can simply use this method -in your views: - - <%= gravatar_for @user %> - -This will be replaced with the full HTML +img+ tag necessary for displaying -that user's gravatar. - -Other helpers are documented under GravatarHelper::PublicMethods. - -== Acknowledgments - -Thanks to Magnus Bergmark (http://github.com/Mange), who contributed the SSL -support in this plugin, as well as a few minor fixes. - -The following people have also written gravatar-related Ruby libraries: -* Seth Rasmussen created the gravatar gem[http://gravatar.rubyforge.org] -* Matt McCray has also created a gravatar - plugin[http://mattmccray.com/svn/rails/plugins/gravatar_helper] - -== Author - - Scott A. Woods - West Arete Computing, Inc. - http://westarete.com - scott at westarete dot com - -== TODO - -* Add specs for ssl support -* Finish rdoc documentation \ No newline at end of file diff --git a/lib/plugins/gravatar/Rakefile b/lib/plugins/gravatar/Rakefile deleted file mode 100644 index 3b10b6d3dd..0000000000 --- a/lib/plugins/gravatar/Rakefile +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec/rake/spectask' -require 'rake/rdoctask' - -desc 'Default: run all specs' -task :default => :spec - -desc 'Run all application-specific specs' -RSpec::Rake::SpecTask.new(:spec) do |t| - # t.rcov = true -end - -desc "Report code statistics (KLOCs, etc) from the application" -task :stats do - RAILS_ROOT = File.dirname(__FILE__) - STATS_DIRECTORIES = [ - %w(Libraries lib/), - %w(Specs spec/), - ].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } - require 'code_statistics' - CodeStatistics.new(*STATS_DIRECTORIES).to_s -end - -namespace :doc do - desc 'Generate documentation for the assert_request plugin.' - Rake::RDocTask.new(:plugin) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Gravatar Rails Plugin' - rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=rw' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') - end -end diff --git a/lib/plugins/gravatar/about.yml b/lib/plugins/gravatar/about.yml deleted file mode 100644 index d43542210e..0000000000 --- a/lib/plugins/gravatar/about.yml +++ /dev/null @@ -1,35 +0,0 @@ -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ - -author: Scott Woods, West Arete Computing -summary: View helpers for displaying gravatars. -homepage: http://github.com/woods/gravatar-plugin/ -plugin: git://github.com/woods/gravatar-plugin.git -license: MIT -version: 0.1 -rails_version: 1.0+ diff --git a/lib/plugins/gravatar/init.rb b/lib/plugins/gravatar/init.rb deleted file mode 100644 index 3336c81c2e..0000000000 --- a/lib/plugins/gravatar/init.rb +++ /dev/null @@ -1,3 +0,0 @@ -#-- encoding: UTF-8 -require 'gravatar' -ActionView::Base.send :include, GravatarHelper::PublicMethods diff --git a/lib/plugins/gravatar/lib/gravatar.rb b/lib/plugins/gravatar/lib/gravatar.rb deleted file mode 100644 index 66c564e522..0000000000 --- a/lib/plugins/gravatar/lib/gravatar.rb +++ /dev/null @@ -1,88 +0,0 @@ -#-- encoding: UTF-8 -require 'digest/md5' -require 'cgi' - -module GravatarHelper - - # These are the options that control the default behavior of the public - # methods. They can be overridden during the actual call to the helper, - # or you can set them in your environment.rb as such: - # - # # Allow racier gravatars - # GravatarHelper::DEFAULT_OPTIONS[:rating] = 'R' - # - DEFAULT_OPTIONS = { - # The URL of a default image to display if the given email address does - # not have a gravatar. - :default => nil, - - # The default size in pixels for the gravatar image (they're square). - :size => 50, - - # The maximum allowed MPAA rating for gravatars. This allows you to - # exclude gravatars that may be out of character for your site. - :rating => 'PG', - - # The alt text to use in the img tag for the gravatar. Since it's a - # decorational picture, the alt text should be empty according to the - # XHTML specs. - :alt => '', - - # The title text to use for the img tag for the gravatar. - :title => '', - - # The class to assign to the img tag for the gravatar. - :class => 'gravatar', - - # Whether or not to display the gravatars using HTTPS instead of HTTP - :ssl => false, - } - - # The methods that will be made available to your views. - module PublicMethods - # Return the HTML img tag for the given user's gravatar. Presumes that - # the given user object will respond_to "email", and return the user's - # email address. - def gravatar_for(user, options={}) - gravatar(user.email, options) - end - - # Return the HTML img tag for the given email address's gravatar. - def gravatar(email, options={}) - src = h(gravatar_url(email, options)) - options = DEFAULT_OPTIONS.merge(options) - [:class, :alt, :size, :title].each { |opt| options[opt] = h(options[opt]) } - image_tag src, options - end - - # Returns the base Gravatar URL for the given email hash. If ssl evaluates to true, - # a secure URL will be used instead. This is required when the gravatar is to be - # displayed on a HTTPS site. - def gravatar_api_url(hash, ssl=false) - if ssl - "https://secure.gravatar.com/avatar/#{hash}" - else - "http://www.gravatar.com/avatar/#{hash}" - end - end - - # Return the gravatar URL for the given email address. - def gravatar_url(email, options={}) - email_hash = Digest::MD5.hexdigest(email) - options = DEFAULT_OPTIONS.merge(options) - options[:default] = CGI::escape(options[:default]) unless options[:default].nil? - gravatar_api_url(email_hash, options.delete(:ssl)).tap do |url| - opts = [] - [:rating, :size, :default].each do |opt| - unless options[opt].nil? - value = h(options[opt]) - opts << [opt, value].join('=') - end - end - url << "?#{opts.join('&')}" unless opts.empty? - end - end - - end - -end diff --git a/lib/plugins/gravatar/spec/gravatar_spec.rb b/lib/plugins/gravatar/spec/gravatar_spec.rb deleted file mode 100644 index 5e6af43f10..0000000000 --- a/lib/plugins/gravatar/spec/gravatar_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -#-- encoding: UTF-8 -require 'rubygems' -require 'erb' # to get "h" -require 'active_support' # to get "returning" -require File.dirname(__FILE__) + '/../lib/gravatar' -include GravatarHelper, GravatarHelper::PublicMethods, ERB::Util - -describe "gravatar_url with a custom default URL" do - before(:each) do - @original_options = DEFAULT_OPTIONS.dup - DEFAULT_OPTIONS[:default] = "no_avatar.png" - @url = gravatar_url("somewhere") - end - - it "should include the \"default\" argument in the result" do - expect(@url).to match(/&default=no_avatar.png/) - end - - after(:each) do - DEFAULT_OPTIONS.merge!(@original_options) - end - -end - -describe "gravatar_url with default settings" do - before(:each) do - @url = gravatar_url("somewhere") - end - - it "should have a nil default URL" do - expect(DEFAULT_OPTIONS[:default]).to be_nil - end - - it "should not include the \"default\" argument in the result" do - expect(@url).not_to match(/&default=/) - end - -end - -describe "gravatar with a custom title option" do - it "should include the title in the result" do - expect(gravatar('example@example.com', :title => "This is a title attribute")).to match(/This is a title attribute/) - end -end diff --git a/spec/helpers/avatar_helper_spec.rb b/spec/helpers/avatar_helper_spec.rb index a414df8ea8..028621df3b 100644 --- a/spec/helpers/avatar_helper_spec.rb +++ b/spec/helpers/avatar_helper_spec.rb @@ -33,52 +33,68 @@ describe AvatarHelper, :type => :helper do let(:user) { FactoryGirl.build_stubbed(:user) } def expected_image_tag(digest, options = {}) - # there are some attributes in here that are wrong but are returned by the - # bundled plugin. I will not fix the lib at the given moment. I would rather, we - # remove the bundled gem and reference one in the Gemfile or - # implement the thing ourselves. + tag_options = options.reverse_merge(title: user.name, + alt: 'Gravatar', + class: 'avatar').delete_if { |key, value| value.nil? || key == :ssl} - host = options[:ssl] ? + image_tag expected_url(digest, options), tag_options + end + + def expected_url(digest, options = {}) + ssl = !!options[:ssl] + + host = ssl ? "https://secure.gravatar.com" : - "http://www.gravatar.com" + "http://gravatar.com" - expected_src = "#{host}/avatar/#{digest}?rating=PG&size=50&default=" + "#{host}/avatar/#{digest}?secure=#{ssl}" + end + + describe 'ssl dependent on protocol settings' do + it "should be set to secure if protocol is 'https'" do + with_settings protocol: 'https' do + expect(described_class.secure?).to be true + end + end - image_tag expected_src, :class => "gravatar", - :title => '', - :ssl => options[:ssl] || false, - :alt => '', - :default => '', - :rating => 'PG' + it "should be set to unsecure if protocol is 'http'" do + with_settings protocol: 'http' do + expect(described_class.secure?).to be false + end + end + end + + describe 'default avatar dependent on settings' do + it "should be set to value of setting" do + with_settings gravatar_default: 'Wavatars' do + expect(described_class.default).to eq 'Wavatars' + end + end + + it "should be set to unsecure if protocol is 'http'" do + with_settings gravatar_default: '' do + expect(described_class.default).to be_nil + end + end end describe :avatar do it "should return a gravatar image tag if a user is provided" do digest = Digest::MD5.hexdigest(user.mail) - with_settings :gravatar_enabled => '1' do + with_settings gravatar_enabled: '1', protocol: 'http' do expect(helper.avatar(user)).to eq(expected_image_tag(digest)) end end it "should return a gravatar image tag with ssl if the request was ssl required" do digest = Digest::MD5.hexdigest(user.mail) - allow(helper.request).to receive(:ssl?).and_return(true) - with_settings :gravatar_enabled => '1' do + with_settings :gravatar_enabled => '1', protocol: 'https' do expect(helper.avatar(user)).to eq(expected_image_tag(digest, :ssl => true)) end end - it "should return a gravatar image tag if a parsable e-mail string is provided" do - with_settings :gravatar_enabled => '1' do - mail = "" - digest = Digest::MD5.hexdigest("e-mail@mail.de") - - expect(helper.avatar(mail)).to eq(expected_image_tag(digest)) - end - end - it "should return an empty string if a non parsable (e-mail) string is provided" do with_settings :gravatar_enabled => '1' do expect(helper.avatar('just the name')).to eq('') @@ -97,12 +113,58 @@ describe AvatarHelper, :type => :helper do end end - it "should return an empty string if any error is produced in the lib" do - allow(helper).to receive(:gravatar).and_raise(ArgumentError) + it "should return a gravatar image tag if a parsable e-mail string is provided" do + with_settings :gravatar_enabled => '1' do + mail = "" + digest = Digest::MD5.hexdigest("e-mail@mail.de") + + expect(helper.avatar(mail)).to eq(expected_image_tag(digest, title: nil)) + end + end + end + describe :avatar_url do + it "should return a gravatar url if a user is provided" do + digest = Digest::MD5.hexdigest(user.mail) + + with_settings gravatar_enabled: '1', protocol: 'http' do + expect(helper.avatar_url(user)).to eq(expected_url(digest)) + end + end + + it "should return a gravatar image tag with ssl if the request was ssl required" do + digest = Digest::MD5.hexdigest(user.mail) + + with_settings :gravatar_enabled => '1', protocol: 'https' do + expect(helper.avatar_url(user)).to eq(expected_url(digest, :ssl => true)) + end + end + + it "should return an empty string if a non parsable (e-mail) string is provided" do with_settings :gravatar_enabled => '1' do - expect(helper.avatar(user)).to eq('') + expect(helper.avatar_url('just the name')).to eq('') end end + + it "should return an empty string if nil is provided" do + with_settings :gravatar_enabled => '1' do + expect(helper.avatar_url(nil)).to eq('') + end + end + + it "should return an empty string if gravatar is disabled" do + with_settings :gravatar_enabled => '0' do + expect(helper.avatar_url(user)).to eq('') + end + end + + it "should return a gravatar image tag if a parsable e-mail string is provided" do + with_settings :gravatar_enabled => '1' do + mail = "" + digest = Digest::MD5.hexdigest("e-mail@mail.de") + + expect(helper.avatar_url(mail)).to eq(expected_url(digest)) + end + end end end diff --git a/spec/lib/api/v3/users/user_representer_spec.rb b/spec/lib/api/v3/users/user_representer_spec.rb index 99e5286804..79bbcdb602 100644 --- a/spec/lib/api/v3/users/user_representer_spec.rb +++ b/spec/lib/api/v3/users/user_representer_spec.rb @@ -29,7 +29,9 @@ require 'spec_helper' describe ::API::V3::Users::UserRepresenter do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryGirl.build_stubbed(:user, + created_on: Time.now, + updated_on: Time.now) } let(:model) { ::API::V3::Users::UserModel.new(user) } let(:representer) { described_class.new(model) } @@ -49,6 +51,7 @@ describe ::API::V3::Users::UserRepresenter do it { is_expected.to have_json_path('createdAt') } it { is_expected.to have_json_path('updatedAt') } it { is_expected.to have_json_path('status') } + it { is_expected.to have_json_path('avatar') } end describe '_links' do @@ -56,5 +59,35 @@ describe ::API::V3::Users::UserRepresenter do expect(subject).to have_json_path('_links/self/href') end end + + describe 'avatar' do + before do + user.mail = 'foo@bar.com' + Setting.stub(:gravatar_enabled?).and_return(true) + end + + it 'should have an url to gravatar if settings permit and mail is set' do + expect(parse_json(subject, 'avatar')).to start_with('http://gravatar.com/avatar') + end + + it 'should be blank if gravatar is disabled' do + Setting.stub(:gravatar_enabled?).and_return(false) + + expect(parse_json(subject, 'avatar')).to be_blank + end + + it 'should be blank if email is missing (e.g. anonymous)' do + user.mail = nil + + expect(parse_json(subject, 'avatar')).to be_blank + end + + it 'should be https if setting set to https' do + # have to actually set the setting for the lib to pick up the change + with_settings protocol: 'https' do + expect(parse_json(subject, 'avatar')).to start_with('https://secure.gravatar.com/avatar') + end + end + end end end From a12e61db518233ca317fee8f2422f03b3b266911 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 10:19:24 +0200 Subject: [PATCH 2/9] fixes % sign on progress bar --- app/helpers/application_helper.rb | 2 +- features/work_packages/work_package_show.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6111c71472..6b1506a080 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -470,7 +470,7 @@ module ApplicationHelper end number = content_tag 'p', :class => 'pourcent' do - legend + " " + l(:total_progress) + legend + '% ' + l(:total_progress) end bar + number diff --git a/features/work_packages/work_package_show.feature b/features/work_packages/work_package_show.feature index 196bd2ac3f..9b7edf13bb 100644 --- a/features/work_packages/work_package_show.feature +++ b/features/work_packages/work_package_show.feature @@ -87,7 +87,7 @@ Feature: Viewing a work package When I go to the page of the work package "issue1" Then I should see "Bug #1: issue1" Then I should see "Bug #2: issue2" within ".idnt-1" - And I should see "0 Total progress" + And I should see "0% Total progress" Scenario: View work package with issue done ratio disabled Given the "work_package_done_ratio" setting is set to disabled From ad8f19f030cfec3b373e32aa29078df0bb058ccc Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 10:22:57 +0200 Subject: [PATCH 3/9] styles work_package#show based on changes to avatar --- app/assets/stylesheets/_work_packages.scss | 20 +++++++++++++++++++ app/assets/stylesheets/default/main.css.erb | 5 +---- app/helpers/journals_helper.rb | 2 +- app/helpers/watchers_helper.rb | 3 +-- app/helpers/work_packages_helper.rb | 4 ++-- .../work_packages/_show_attributes.html.erb | 2 +- app/views/work_packages/show.html.erb | 2 +- 7 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/_work_packages.scss b/app/assets/stylesheets/_work_packages.scss index 6d54ae7210..c554639b18 100644 --- a/app/assets/stylesheets/_work_packages.scss +++ b/app/assets/stylesheets/_work_packages.scss @@ -51,3 +51,23 @@ select.to-validate.ng-dirty.ng-valid, input.to-validate.ng-dirty.ng-valid { bord select.to-validate.ng-dirty.ng-invalid, input.to-validate.ng-dirty.ng-invalid { border:1px solid Red; } select.to-validate.ng-dirty.ng-valid ~ span.ok, input.to-validate.ng-dirty.ng-valid ~ span.ok { color:green; display:inline; } select.to-validate.ng-dirty.ng-invalid ~ span.ko, input.to-validate.ng-dirty.ng-invalid ~ span.ko { color:red; display:inline; } + +.controller-work_packages.action-show .work_package tr { + line-height: 20px; +} + +.controller-work_packages.action-show .avatar-mini { + float: left; +} + +.controller-work_packages.action-show .avatar-mini + a { + padding-left: 3px; + line-height: 20px; + vertical-align: sub; +} + +.controller-work_packages.action-show #watchers .delete { + padding-left: 3px; + line-height: 20px; + vertical-align: sub; +} diff --git a/app/assets/stylesheets/default/main.css.erb b/app/assets/stylesheets/default/main.css.erb index 3c1fcc9d65..82a6c7f20c 100644 --- a/app/assets/stylesheets/default/main.css.erb +++ b/app/assets/stylesheets/default/main.css.erb @@ -534,7 +534,7 @@ div.tooltip:hover span.tip, div.tooltip.hover span.tip { empty-cells: show; text-align: center; float: left; - margin: 1px 6px 1px 0px; + margin: 3px 6px 1px 0px; border: 1px solid #BBBBBB; border-collapse: separate; -moz-border-radius: 3px; @@ -953,9 +953,6 @@ div.issue hr { #content div.issue table th { font-weight: bold; } -.issue p { - margin-bottom: 5px; -} .attachments h4 { margin-bottom: 6px; background: url(<%= asset_path 'files-showhide.png' %>) no-repeat right bottom; diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 81d6e3bc8b..115152b872 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -51,7 +51,7 @@ module JournalsHelper def render_journal_details(journal, header_label = :label_updated_time_by, model=nil, options={}) header = <<-HTML
- #{avatar(journal.user, :size => "40")} + #{avatar(journal.user)}

diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index c4caf5bd71..03b6400647 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -63,7 +63,7 @@ module WatchersHelper lis = object.watcher_users.sort.collect do |user| watcher = object.watchers(true).find{|u| u.user_id == user.id } content_tag :li do - avatar(user, :size => "16") + + avatar(user, :class => 'avatar-mini') + link_to_user(user, :class => 'user') + if remove_allowed ' '.html_safe + link_to(icon_wrapper('icon-context icon-close delete-ctrl', @@ -71,7 +71,6 @@ module WatchersHelper watcher_path(watcher), :method => :delete, :remote => true, - :style => "vertical-align: middle", :title => l(:button_delete_watcher, name: user.name), :class => "delete no-decoration-on-hover") else diff --git a/app/helpers/work_packages_helper.rb b/app/helpers/work_packages_helper.rb index 62a81210f8..de090d03bd 100644 --- a/app/helpers/work_packages_helper.rb +++ b/app/helpers/work_packages_helper.rb @@ -373,7 +373,7 @@ module WorkPackagesHelper def work_package_show_assigned_to_attribute(work_package) work_package_show_table_row(:assigned_to) do - content = avatar(work_package.assigned_to, :size => "14").html_safe + content = avatar(work_package.assigned_to, class: 'avatar-mini').html_safe content << (work_package.assigned_to ? link_to_user(work_package.assigned_to) : empty_element_tag) content end @@ -381,7 +381,7 @@ module WorkPackagesHelper def work_package_show_responsible_attribute(work_package) work_package_show_table_row(:responsible) do - content = avatar(work_package.responsible, :size => "14").html_safe + content = avatar(work_package.responsible, class: 'avatar-mini').html_safe content << (work_package.responsible ? link_to_user(work_package.responsible) : empty_element_tag) content end diff --git a/app/views/work_packages/_show_attributes.html.erb b/app/views/work_packages/_show_attributes.html.erb index 7500e06de7..ec9003153f 100644 --- a/app/views/work_packages/_show_attributes.html.erb +++ b/app/views/work_packages/_show_attributes.html.erb @@ -27,7 +27,7 @@ See doc/COPYRIGHT.rdoc for more details. ++#%> -
+
<% attributes = work_package_show_attributes(work_package) %>
diff --git a/app/views/work_packages/show.html.erb b/app/views/work_packages/show.html.erb index 199a1e1fb2..fb079c4cd5 100644 --- a/app/views/work_packages/show.html.erb +++ b/app/views/work_packages/show.html.erb @@ -39,7 +39,7 @@ See doc/COPYRIGHT.rdoc for more details.
- <%= avatar(work_package.author, :size => "40") %> + <%= avatar(work_package.author) %>

From e1bd40da8b02f58bfabfeea8a17d59f5698b06d8 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 10:24:25 +0200 Subject: [PATCH 4/9] uses default avatar on activities --- app/views/activities/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index 27b00cbf0c..6d663d5482 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -41,7 +41,7 @@ See doc/COPYRIGHT.rdoc for more details. <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>

<%= icon_wrapper("icon-context icon-#{e.event_type}", e.event_name) %> - <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> + <%= avatar(e.event_author) if e.respond_to?(:event_author) %> <%= format_time(e.event_datetime.to_time, false) %> <%= content_tag('span', link_to(e.project.name, e.project), :class => 'project') if (@project.nil? || @project != e.project) && e.project %> <%= link_to format_activity_title(e.event_title), e.event_path%> From 8b0b0c7912a4a44124110bc5a9e93aed0986de7f Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 18:13:12 +0200 Subject: [PATCH 5/9] removes duplicate avatar stylings and scopes them to wp split_view --- .../stylesheets/layout/_split_view.sass | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/layout/_split_view.sass b/app/assets/stylesheets/layout/_split_view.sass index 7495e26c3a..e5c0482d07 100644 --- a/app/assets/stylesheets/layout/_split_view.sass +++ b/app/assets/stylesheets/layout/_split_view.sass @@ -104,9 +104,8 @@ div list-style-type: none li clear: both - height: 36px margin-bottom: 10px - + .user-field-user-link float: left .detail-panel-watchers-delete-watcher-icon @@ -170,15 +169,14 @@ div.detail-panel-latest-activity margin: 0 0 20px 0 padding: 0 -img - &.avatar - width: 36px - float: left - margin: -2px 10px 0 0 - &.avatar-small - width: 16px - float: left - margin: 0 7px 0 0 +div.work-package-details-tab + img + &.avatar + float: left + margin: -2px 10px 0 0 + &.avatar-mini + float: left + margin: -3px 7px 0 0 span &.user From 874b08c194d681b56f7456adabbb5f3d13a3eef4 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 18:15:32 +0200 Subject: [PATCH 6/9] consolidates avatar css --- app/assets/stylesheets/_work_packages.scss | 12 ---- .../stylesheets/content/_journal.css.sass | 4 -- .../stylesheets/content/_user_avatars.sass | 5 ++ app/assets/stylesheets/content/_watchers.sass | 14 +++++ app/assets/stylesheets/default.css.sass | 1 + app/assets/stylesheets/default/main.css.erb | 62 +------------------ 6 files changed, 23 insertions(+), 75 deletions(-) create mode 100644 app/assets/stylesheets/content/_watchers.sass diff --git a/app/assets/stylesheets/_work_packages.scss b/app/assets/stylesheets/_work_packages.scss index c554639b18..9e2f360873 100644 --- a/app/assets/stylesheets/_work_packages.scss +++ b/app/assets/stylesheets/_work_packages.scss @@ -59,15 +59,3 @@ select.to-validate.ng-dirty.ng-invalid ~ span.ko, input.to-validate.ng-dirty.ng- .controller-work_packages.action-show .avatar-mini { float: left; } - -.controller-work_packages.action-show .avatar-mini + a { - padding-left: 3px; - line-height: 20px; - vertical-align: sub; -} - -.controller-work_packages.action-show #watchers .delete { - padding-left: 3px; - line-height: 20px; - vertical-align: sub; -} diff --git a/app/assets/stylesheets/content/_journal.css.sass b/app/assets/stylesheets/content/_journal.css.sass index 14c188a76c..d231d203b5 100644 --- a/app/assets/stylesheets/content/_journal.css.sass +++ b/app/assets/stylesheets/content/_journal.css.sass @@ -44,10 +44,6 @@ bottom: 20px left: 3px clear: left - img.gravatar - float: none - margin: 0 - padding: 0 .journal width: 700px diff --git a/app/assets/stylesheets/content/_user_avatars.sass b/app/assets/stylesheets/content/_user_avatars.sass index 9834cecf22..d5d1a8a9fd 100644 --- a/app/assets/stylesheets/content/_user_avatars.sass +++ b/app/assets/stylesheets/content/_user_avatars.sass @@ -5,3 +5,8 @@ .avatar-mini border-radius: $user_avatar_mini_border_radius width: $user_avatar_mini_width + +h1, h2, h3, h4, tr + .avatar, .avatar-mini + vertical-align: middle + margin-right: 7px diff --git a/app/assets/stylesheets/content/_watchers.sass b/app/assets/stylesheets/content/_watchers.sass new file mode 100644 index 0000000000..29ac984256 --- /dev/null +++ b/app/assets/stylesheets/content/_watchers.sass @@ -0,0 +1,14 @@ +#watchers + img + vertical-align: middle + margin-right: 7px + + .delete + vertical-align: sub + + li + list-style-type: none + margin: 0px 10px 0px 0px + padding: 0px 0px 0px 0px + float: left + line-height: $user_avatar_mini_width diff --git a/app/assets/stylesheets/default.css.sass b/app/assets/stylesheets/default.css.sass index b5cc22353f..051ab14961 100644 --- a/app/assets/stylesheets/default.css.sass +++ b/app/assets/stylesheets/default.css.sass @@ -53,6 +53,7 @@ @import content/buttons @import content/boxes @import content/tabular +@import content/watchers @import content/work_packages @import content/work_packages_filters @import content/work_packages_relations diff --git a/app/assets/stylesheets/default/main.css.erb b/app/assets/stylesheets/default/main.css.erb index 82a6c7f20c..e64462636e 100644 --- a/app/assets/stylesheets/default/main.css.erb +++ b/app/assets/stylesheets/default/main.css.erb @@ -122,9 +122,8 @@ tr.version td.name { padding-left: 20px; } tr.version.shared td.name { background: url(<%= asset_path 'link.png' %>) no-repeat 0% 70%; } tr.version td.date, tr.version td.status, tr.version td.sharing { text-align: left; white-space: nowrap; } -tr.user td { width: 13%; } +tr.user td { width: 13%; white-space: nowrap; } tr.user td.email { width: 18%; } -tr.user td { white-space: nowrap; } tr.user.locked, tr.user.registered { color: #aaa; } tr.user.locked a, tr.user.registered a { color: #aaa; } @@ -159,11 +158,9 @@ table.attributes td { vertical-align: top; } td.center, th.center {text-align: center;} #watchers ul {margin: 0; padding: 0;} -#watchers li {list-style-type: none;margin: 0px 10px 0px 0px; padding: 0px 0px 0px 0px;float: left;} #watchers select {width: 200px; display: block;float: left;margin-right: 10px;} #watchers a.delete {opacity: 0.4;} #watchers a.delete:hover {opacity: 1;} -#watchers img.gravatar {vertical-align: middle;margin: 0 10px 0px 0;} .highlight { background-color: #FCFD8D;} .highlight.token-1 { background-color: #faa;} @@ -691,50 +688,6 @@ ins.diffmod, ins.diffins { background: #cfc; } } /***** My page layout *****/ -img.gravatar { - background: #fff; -} - -div.issue img.gravatar { - float: right; - margin: 0 0 0 1em; - padding: 5px; -} - -div.issue table img.gravatar { - height: 14px; - width: 14px; - padding: 2px; - float: left; - margin: 0 0.5em 0 0; -} - -h2 img.gravatar { - margin: -2px 4px -4px 0; - vertical-align: top; -} - -h4 img.gravatar { - margin: -6px 0 -4px 0; - vertical-align: top; -} - -td.username img.gravatar { - margin: 0 0.5em 0 0; - vertical-align: top; -} - -#activity dt img.gravatar { - float: left; - margin: 0 1em 1em 0; -} - -/* Used on 12px Gravatar img tags without the icon background */ -.icon-gravatar { - float: left; - margin-right: 4px; -} - #activity dt { clear: left; } @@ -1106,11 +1059,6 @@ ul.projects li div.root { .profile-box ul li:last-child { border-bottom: 0; } -.profile-box .gravatar { - border: 0; - float: left; - margin-right: 6px; -} /* file table hovers */ a.has-thumb img { @@ -1303,14 +1251,10 @@ div.issue hr { #content h2 + h3 { margin-top: 12px; } -div.issue img.gravatar { - float: none; - margin: 0; - padding: 0; -} p.author { - margin-bottom: 15px; font-style: italic; + /* to accomodate the .profile-wrap class */ + height: 42px; } /* add filter select box on non-issue pages */ fieldset#filters div.add-filter { From 7c7c99daa2c540420fbba58afa73881762f62fc8 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 18:16:49 +0200 Subject: [PATCH 7/9] removes stylesheet import - included two times otherwise --- app/assets/stylesheets/layout/all.sass | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/layout/all.sass b/app/assets/stylesheets/layout/all.sass index 6253033099..1a242e1c70 100644 --- a/app/assets/stylesheets/layout/all.sass +++ b/app/assets/stylesheets/layout/all.sass @@ -33,4 +33,3 @@ @import layout/footer @import layout/drop_down @import layout/toolbar -@import layout/split_view From 62a834f04320c2fe11597659764d6dd5351757f7 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 18:17:59 +0200 Subject: [PATCH 8/9] corrects usage of avatar throughout the application --- app/views/messages/show.html.erb | 4 ++-- app/views/news/index.html.erb | 2 +- app/views/news/show.html.erb | 4 ++-- app/views/project_associations/index.html.erb | 2 +- app/views/users/edit.html.erb | 2 +- app/views/users/index.html.erb | 2 +- app/views/users/show.html.erb | 2 +- public/templates/work_packages/tabs/_user_field.html | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index bc585de28f..98ef79013c 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -52,7 +52,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= render :partial => 'layouts/action_menu_specific' %> -

<%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %>

+

<%= avatar(@topic.author) %><%=h @topic.subject %>

@@ -69,7 +69,7 @@ See doc/COPYRIGHT.rdoc for more details. <% @replies.each do |message| %>
">

- <%= avatar(message.author, :size => "24") %> + <%= avatar(message.author) %> <%= link_to h(message.subject), topic_path(@topic, :r => message, :anchor => "message-#{message.id}") %> diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 2288027249..c5caf0628b 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -33,7 +33,7 @@ See doc/COPYRIGHT.rdoc for more details.

<%= l(:label_no_data) %>

<% else %> <% @newss.each do |news| %> -

<%= avatar(news.author, :size => "24") %><%= link_to_project(news.project) + ': ' unless news.project == @project %> +

<%= avatar(news.author) %><%= link_to_project(news.project) + ': ' unless news.project == @project %> <%= link_to h(news.title), news_path(news) %> <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>

<%= authoring news.created_on, news.author %>

diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index 8378cfff2f..25ecdb939f 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -43,7 +43,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= render :partial => 'layouts/action_menu_specific' %> -

<%= avatar(@news.author, :size => "24") %><%=h @news.title %>

+

<%= avatar(@news.author) %><%=h @news.title %>

<% if authorize_for('news', 'edit') %> @@ -78,7 +78,7 @@ See doc/COPYRIGHT.rdoc for more details. :title => l(:button_delete), :alt => l(:button_delete) %>
-

<%= avatar(comment.author, :size => "24") %><%= authoring comment.created_on, comment.author %>

+

<%= avatar(comment.author) %><%= authoring comment.created_on, comment.author %>

<%= format_text(comment.comments, :object => comment) %> <% end %>
diff --git a/app/views/project_associations/index.html.erb b/app/views/project_associations/index.html.erb index 3adb14eb08..14710ce2d4 100644 --- a/app/views/project_associations/index.html.erb +++ b/app/views/project_associations/index.html.erb @@ -89,7 +89,7 @@ See doc/COPYRIGHT.rdoc for more details. <% if other.responsible.present? %> - <%= avatar(other.responsible, :size => "14") %> + <%= avatar(other.responsible, class: 'avatar-mini') %> <%= link_to_user(other.responsible) %> <% else %> - diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 85a394d4a1..3799aa5727 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -36,7 +36,7 @@ See doc/COPYRIGHT.rdoc for more details. <% html_title(l(:label_administration), "#{l(:label_edit)} #{User.model_name.human} #{h(@user.login)}") -%> -

<%= link_to l(:label_user_plural), :controller => '/users', :action => 'index' %> » <%=h @user.login %>

+

<%= link_to l(:label_user_plural), :controller => '/users', :action => 'index' %> » <%= avatar(@user) %> <%=h @user.login %>

<%= render :partial => 'layouts/action_menu_specific' %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 4fb295798e..7339de0a19 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -81,7 +81,7 @@ See doc/COPYRIGHT.rdoc for more details. <% for user in @users -%> <%= %w(anon active registered locked)[user.status] %> <%= 'blocked' if user.failed_too_many_recent_login_attempts? %>"> - <%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %> + <%= avatar(user, class: 'avatar-mini') %><%= link_to h(user.login), edit_user_path(user) %> <%= h(user.firstname) %> <%= h(user.lastname) %> <%= mail_to(h(user.mail)) %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index fc6c7376ff..993b396d99 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -38,7 +38,7 @@ See doc/COPYRIGHT.rdoc for more details. accesskey: accesskey(:edit)) if User.current.admin? %> <% end %> -

<%= avatar @user, :size => "50" %> <%=h @user.name %>

+

<%= avatar @user %> <%=h @user.name %>

<%= render :partial => 'layouts/action_menu_specific' %> diff --git a/public/templates/work_packages/tabs/_user_field.html b/public/templates/work_packages/tabs/_user_field.html index cee96e048c..4aa50469e3 100644 --- a/public/templates/work_packages/tabs/_user_field.html +++ b/public/templates/work_packages/tabs/_user_field.html @@ -1,6 +1,6 @@

- From 144255c75ee2a5ffdf16c2a29868be35d613193d Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 7 Aug 2014 18:46:10 +0200 Subject: [PATCH 9/9] rewrites scss as sass to use variables --- app/assets/stylesheets/_work_packages.scss | 61 ------------------- app/assets/stylesheets/default.css.sass | 1 - .../stylesheets/layout/_work_package.sass | 58 ++++++++++++++++++ app/assets/stylesheets/layout/all.sass | 1 + 4 files changed, 59 insertions(+), 62 deletions(-) delete mode 100644 app/assets/stylesheets/_work_packages.scss create mode 100644 app/assets/stylesheets/layout/_work_package.sass diff --git a/app/assets/stylesheets/_work_packages.scss b/app/assets/stylesheets/_work_packages.scss deleted file mode 100644 index 9e2f360873..0000000000 --- a/app/assets/stylesheets/_work_packages.scss +++ /dev/null @@ -1,61 +0,0 @@ -/*-- copyright -OpenProject is a project management system. -Copyright (C) 2012-2014 the OpenProject Foundation (OPF) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 3. - -OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -Copyright (C) 2006-2013 Jean-Philippe Lang -Copyright (C) 2010-2013 the ChiliProject Team - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -See doc/COPYRIGHT.rdoc for more details. - -++*/ - -#work-packages-query-selection .select2-container { - margin-left: 5px; -} - -.issue .attributes td.work_package_attribute_header { - font-weight: bold; -} - -.icon-button { - cursor: pointer; -} - -.sort-header { - cursor: pointer; -} - -.action-icon { - cursor: pointer; -} - -select.to-validate.ng-dirty.ng-valid, input.to-validate.ng-dirty.ng-valid { border:1px solid Green; } -select.to-validate.ng-dirty.ng-invalid, input.to-validate.ng-dirty.ng-invalid { border:1px solid Red; } -select.to-validate.ng-dirty.ng-valid ~ span.ok, input.to-validate.ng-dirty.ng-valid ~ span.ok { color:green; display:inline; } -select.to-validate.ng-dirty.ng-invalid ~ span.ko, input.to-validate.ng-dirty.ng-invalid ~ span.ko { color:red; display:inline; } - -.controller-work_packages.action-show .work_package tr { - line-height: 20px; -} - -.controller-work_packages.action-show .avatar-mini { - float: left; -} diff --git a/app/assets/stylesheets/default.css.sass b/app/assets/stylesheets/default.css.sass index 051ab14961..af809e690b 100644 --- a/app/assets/stylesheets/default.css.sass +++ b/app/assets/stylesheets/default.css.sass @@ -38,7 +38,6 @@ @import print @import scm @import top-shelf -@import work_packages @import openproject_plugins @import layout/all @import content/accounts diff --git a/app/assets/stylesheets/layout/_work_package.sass b/app/assets/stylesheets/layout/_work_package.sass new file mode 100644 index 0000000000..2de0c21e35 --- /dev/null +++ b/app/assets/stylesheets/layout/_work_package.sass @@ -0,0 +1,58 @@ +/*-- copyright + * OpenProject is a project management system. + * Copyright (C) 2012-2014 the OpenProject Foundation (OPF) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 3. + * + * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: + * Copyright (C) 2006-2013 Jean-Philippe Lang + * Copyright (C) 2010-2013 the ChiliProject Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * See doc/COPYRIGHT.rdoc for more details. + * + */ + +.controller-work_packages + #work-packages-query-selection + .select2-container + margin-left: 5px + + .issue + .attributes + td.work_package_attribute_header + font-weight: bold + .icon-button, .sort-header, .action-icon + cursor: pointer + + select, input + &.to-validate.ng-dirty.ng-valid + border: 1px solid Green + &.to-validate.ng-dirty.ng-valid ~ span.ok + color: green + display: inline + &.to-validate.ng-dirty.ng-invalid + border: 1px solid Red + &.to-validate.ng-dirty.ng-invalid ~ span.ok + color: red + display: inline + + .work_package + tr + line-height: $user_avatar_mini_width + .avatar-mini + float: left diff --git a/app/assets/stylesheets/layout/all.sass b/app/assets/stylesheets/layout/all.sass index 1a242e1c70..340a1fd6a4 100644 --- a/app/assets/stylesheets/layout/all.sass +++ b/app/assets/stylesheets/layout/all.sass @@ -33,3 +33,4 @@ @import layout/footer @import layout/drop_down @import layout/toolbar +@import layout/work_package