avatari 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +14 -14
- data/app/helpers/avatari/avatar_helper.rb +2 -11
- data/app/views/mozaic/avatari/_avatar.html.erb +7 -0
- data/lib/avatari/railtie.rb +8 -0
- data/lib/avatari/version.rb +1 -1
- metadata +46 -5
- data/app/views/avatari/_avatar.html.erb +0 -3
- data/vendor/assets/stylesheets/avatari.min.css +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac5e9557a3f84fe6a8a4fc9db838efe98f4a596c971f60225264bc6cfb3217d0
|
4
|
+
data.tar.gz: d1ca7db7614794fcae4be3c3d4e7c3e8763ef9d771a6cc38abc0c1fc366e99a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb91bb0abd69bf78b6d7ab1aaaa627982793fb8a68cb1b91ae8045575258cf6038235cd8b4a8e5b2a78b2e71e7e9499149eaa390d91fe77d6b23c7bda2c5be30
|
7
|
+
data.tar.gz: 50fbc9e0f7a822b08ef104f30852baf709aacea1d92d5b01cd8be88ab48ef11ca40a4e6a4b269d1c7b1a119e3bceaffa631ec84aba7a14a19947d4191d31747f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -10,7 +10,6 @@ Avatari extends [CarrierWave](https://github.com/carrierwaveuploader/carrierwave
|
|
10
10
|
|
11
11
|
* [Installation](#installation)
|
12
12
|
* [Usage](#usage)
|
13
|
-
* [Assets](#assets)
|
14
13
|
* [CarrierWave](#carrierwave)
|
15
14
|
* [Models](#models)
|
16
15
|
* [Views](#views)
|
@@ -49,23 +48,17 @@ Now run the generator:
|
|
49
48
|
|
50
49
|
$ rails g avatari
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
### Assets
|
55
|
-
|
56
|
-
To render Avatari avatars, you have to require the necessary assets to be added to your asset pipeline:
|
51
|
+
Add the stylesheet to the asset pipeline:
|
57
52
|
|
58
|
-
```js
|
59
|
-
//= require avitari
|
60
53
|
```
|
61
|
-
|
62
|
-
```css
|
63
54
|
/*
|
64
|
-
*= require
|
55
|
+
*= require avatari
|
65
56
|
*/
|
66
57
|
```
|
67
58
|
|
68
|
-
|
59
|
+
---
|
60
|
+
|
61
|
+
## Usage
|
69
62
|
|
70
63
|
### CarrierWave
|
71
64
|
|
@@ -151,13 +144,20 @@ end
|
|
151
144
|
To render an avatar in your view, utilize the `avatari` helper method:
|
152
145
|
|
153
146
|
```haml
|
154
|
-
= avatari current_user
|
147
|
+
= component 'avatari/avatar', object: current_user
|
155
148
|
```
|
156
149
|
|
157
150
|
You can also specify a size:
|
158
151
|
|
159
152
|
```haml
|
160
|
-
= avatari current_user, :tiny
|
153
|
+
= component 'avatari/avatar', object: current_user, version: :tiny
|
154
|
+
```
|
155
|
+
|
156
|
+
You are able to check whether or not an avatar can be rendered:
|
157
|
+
|
158
|
+
```haml
|
159
|
+
- if avatari?
|
160
|
+
= component 'avatari/avatar', object: current_user
|
161
161
|
```
|
162
162
|
|
163
163
|
---
|
@@ -1,17 +1,8 @@
|
|
1
1
|
module Avatari
|
2
2
|
module AvatarHelper
|
3
3
|
|
4
|
-
def avatari
|
5
|
-
|
6
|
-
version = version.to_s
|
7
|
-
|
8
|
-
if object.avatar?
|
9
|
-
image_tag object.avatar.url, class: 'avatari avatari--' + version
|
10
|
-
elsif !object.class.avatari_instance.initials(object).nil?
|
11
|
-
render partial: 'avatari/avatar', locals: { object: object, version: version }
|
12
|
-
else
|
13
|
-
false
|
14
|
-
end
|
4
|
+
def avatari?
|
5
|
+
object.avatar? || !object.class.avatari_instance.initials(object).nil?
|
15
6
|
end
|
16
7
|
|
17
8
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<% if options[:object].avatar? %>
|
2
|
+
<%= image_tag options[:object].avatar.url, class: "avatari avatari--#{options[:version]}" %>
|
3
|
+
<% elsif !options[:object].class.avatari_instance.initials(options[:object]).nil? %>
|
4
|
+
<div class="<%= "avatari avatari--#{options[:version]}" %>" style="width: <%= options[:object].class.avatari_instance.versions[options[:version].to_sym].first / 16 %>rem; height: <%= options[:object].class.avatari_instance.versions[options[:version].to_sym].last / 16 %>rem; background: <%= options[:object].avatari_color %>;">
|
5
|
+
<span class="initials" style="font-size: <%= options[:object].class.avatari_instance.versions[options[:version].to_sym].first / 50 %>rem;"><%= options[:object].class.avatari_instance.initials(options[:object]) %></span>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
data/lib/avatari/railtie.rb
CHANGED
@@ -9,5 +9,13 @@ module Avatari
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
initializer 'avatari.mozaic' do
|
13
|
+
Mozaic.configure do |config|
|
14
|
+
config.define_component 'avatari/avatar' do |options|
|
15
|
+
options[:version] ||= options[:object].class.avatari_instance.default_version || ::Avatari.configuration.default_version
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
12
20
|
end
|
13
21
|
end
|
data/lib/avatari/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avatari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -24,6 +24,48 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mozaic
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: carrierwave
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +134,7 @@ files:
|
|
92
134
|
- app/helpers/avatari/avatar_helper.rb
|
93
135
|
- app/models/concerns/avatari/model.rb
|
94
136
|
- app/uploaders/avatari/avatar_uploader.rb
|
95
|
-
- app/views/avatari/_avatar.html.erb
|
137
|
+
- app/views/mozaic/avatari/_avatar.html.erb
|
96
138
|
- lib/avatari.rb
|
97
139
|
- lib/avatari/avatar.rb
|
98
140
|
- lib/avatari/configuration.rb
|
@@ -101,7 +143,6 @@ files:
|
|
101
143
|
- lib/avatari/version.rb
|
102
144
|
- lib/generators/avatari_generator.rb
|
103
145
|
- lib/generators/templates/initializer.rb
|
104
|
-
- vendor/assets/stylesheets/avatari.min.css
|
105
146
|
- vendor/assets/stylesheets/avatari.sass
|
106
147
|
homepage: https://github.com/jonhue/avatari
|
107
148
|
licenses:
|
@@ -1,3 +0,0 @@
|
|
1
|
-
<div class="<%= 'avatari avatari--' + version %>" style="width: <%= object.class.avatari_instance.versions[version.to_sym].first / 16 %>rem; height: <%= object.class.avatari_instance.versions[version.to_sym].last / 16 %>rem; background: <%= object.avatari_color %>;">
|
2
|
-
<span class="initials" style="font-size: <%= object.class.avatari_instance.versions[version.to_sym].first / 50 %>rem;"><%= object.class.avatari_instance.initials(object) %></span>
|
3
|
-
</div>
|
@@ -1 +0,0 @@
|
|
1
|
-
.avatari{display:flex;justify-content:center;align-items:center;border-radius:50%;-webkit-border-radius:50%;-moz-border-radius:50%}.avatari>.initials{line-height:1;color:white;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";font-weight:600}
|