Merge pull request #1725 from opf/fix/use_default_avatar_lib
Fix/use default avatar libpull/1719/merge
commit
02a556b71f
@ -1,53 +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; } |
@ -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 |
@ -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 |
@ -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. |
@ -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 |
@ -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 |
@ -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+ |
@ -1,3 +0,0 @@ |
||||
#-- encoding: UTF-8 |
||||
require 'gravatar' |
||||
ActionView::Base.send :include, GravatarHelper::PublicMethods |
@ -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 |
@ -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 |
Loading…
Reference in new issue