Commit ae069d09be61f18e42e3ccdab7081e631d880e11
1 parent
e8085d8d
Exists in
master
and in
28 other branches
ActionItem1044: better profile page
Showing
6 changed files
with
114 additions
and
43 deletions
Show diff stats
app/helpers/profile_helper.rb
1 | module ProfileHelper | 1 | module ProfileHelper |
2 | 2 | ||
3 | + def display_field(title, object, field) | ||
4 | + value = object.send(field) | ||
5 | + if !value.blank? | ||
6 | + if block_given? | ||
7 | + value = yield(value) | ||
8 | + end | ||
9 | + content_tag('tr', content_tag('td', title, :class => 'field-name') + content_tag('td', value)) | ||
10 | + else | ||
11 | + '' | ||
12 | + end | ||
13 | + end | ||
14 | + | ||
3 | end | 15 | end |
app/helpers/tags_helper.rb
@@ -30,10 +30,10 @@ module TagsHelper | @@ -30,10 +30,10 @@ module TagsHelper | ||
30 | def tag_cloud(tags, tagname_option, url, options = {}) | 30 | def tag_cloud(tags, tagname_option, url, options = {}) |
31 | 31 | ||
32 | 32 | ||
33 | - return _('No tags yet.') + '<br/>' + | ||
34 | - '<a href="' + _('http://en.wikipedia.org/wiki/Tag_%28metadata%29') + | ||
35 | - '" class="button with-text icon-help" target="wptags"><span>' + | ||
36 | - _('What are tags?') + '</span></a>' if tags.empty? | 33 | + return content_tag('em', _('No tags yet.')) + |
34 | + ' <a href="' + _('http://en.wikipedia.org/wiki/Tag_%28metadata%29') + | ||
35 | + '" target="wptags"><span>(' + | ||
36 | + _('What are tags?') + ')</span></a>' if tags.empty? | ||
37 | 37 | ||
38 | max_size = options[:max_size] || Cloud::MAX_SIZE | 38 | max_size = options[:max_size] || Cloud::MAX_SIZE |
39 | min_size = options[:min_size] || Cloud::MIN_SIZE | 39 | min_size = options[:min_size] || Cloud::MIN_SIZE |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<tr> | ||
2 | + <th colspan='2'><%= _('Basic information')%></th> | ||
3 | +</tr> | ||
4 | +<%= display_field(_('Name:'), profile, :name) { |name| link_to name, profile.url } %> | ||
5 | +<tr> | ||
6 | + <td colspan='2'> | ||
7 | + <%= link_to _('Members'), :action => 'members' %></li> | ||
8 | + </td> | ||
9 | +</tr> | ||
10 | +<% if profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises') %> | ||
11 | + <tr> | ||
12 | + <td colspan='2'> | ||
13 | + <%= link_to _('Products/Services'), :controller => 'catalog', :action => 'index' %> | ||
14 | + </td> | ||
15 | + </tr> | ||
16 | +<% end %> |
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +<tr> | ||
2 | + <th colspan='2'><%= _('Basic information')%></th> | ||
3 | +</tr> | ||
4 | +<%= display_field(_('Name:'), profile, :name) { |name| link_to name, profile.url } %> | ||
5 | +<%= display_field(_('Gender:'), profile, :sex) { |gender| { 'male' => _('Male'), 'female' => _('Female') }[gender] } %> | ||
6 | +<%= display_field(_('Date of birth:'), profile, :birth_date) { |date| show_date(date) }%> | ||
7 | + | ||
8 | +<tr> | ||
9 | + <th colspan='2'><%= _('Contact')%></th> | ||
10 | +</tr> | ||
11 | +<% if profile == user || profile.friends.include?(user) %> | ||
12 | + <%= display_field(_('Address:'), profile, :address) %> | ||
13 | + <%= display_field(_('ZIP code:'), profile, :zip_code) %> | ||
14 | + <%= display_field(_('Contact phone:'), profile, :contact_phone) %> | ||
15 | + <%= display_field(_('e-Mail:'), profile, :email) { |email| link_to email, 'mailto:'+email } %> | ||
16 | +<% end %> | ||
17 | +<%= display_field(_('Location:'), profile, :location) %> | ||
18 | + | ||
19 | +<tr> | ||
20 | + <th colspan='2'><%= _('Work')%></th> | ||
21 | +</tr> | ||
22 | +<%= display_field(_('Organization:'), profile, :organization) %> | ||
23 | +<%= display_field(_('Organization website:'), profile, :organization_website) { |url| link_to(url, url) }%> | ||
24 | +</tr> | ||
25 | + | ||
26 | +<tr> | ||
27 | + <th colspan='2'><%= _('Network')%></th> | ||
28 | +</tr> | ||
29 | +<tr> | ||
30 | + <td colspan='2'> | ||
31 | + <%= link_to __('Friends'), :action => 'friends' %> | ||
32 | + — <%= link_to __('Communities'), :action => 'communities' %> | ||
33 | + <% if !environment.enabled?('disable_asset_enterprises') %> | ||
34 | + — <%= link_to __('Enterprises'), :action => 'enterprises' %> | ||
35 | + <% end %> | ||
36 | + </td> | ||
37 | +</tr> | ||
38 | + |
app/views/profile/index.rhtml
@@ -4,43 +4,29 @@ | @@ -4,43 +4,29 @@ | ||
4 | </div> | 4 | </div> |
5 | <% end %> | 5 | <% end %> |
6 | 6 | ||
7 | -<h2><%= _("%s's profile") % profile.identifier %></h2> | 7 | +<h1><%= _("%s's profile") % profile.identifier %></h1> |
8 | 8 | ||
9 | -<ul> | ||
10 | - <li> | ||
11 | - <strong><%= _('Name:') %></strong> | ||
12 | - <%= profile.name %> | ||
13 | - </li> | ||
14 | - <li> | ||
15 | - <strong><%= _('Homepage:') %></strong> | ||
16 | - <%= link_to url_for(profile.url), profile.url %> | ||
17 | - </li> | ||
18 | - | ||
19 | - <%# FIXME %> | ||
20 | - <% if profile.kind_of? Person %> | ||
21 | - <% if profile.friends.include?(user) %> | ||
22 | - <li> | ||
23 | - <strong><%= _('e-Mail:') %></strong> | ||
24 | - <%= content_tag 'a', profile.email, :href => 'mailto:'+profile.email %> | ||
25 | - </li> | ||
26 | - <% end %> | ||
27 | - <li><%= link_to __('Friends'), :action => 'friends' %></li> | ||
28 | - <li><%= link_to __('Communities'), :action => 'communities' %></li> | ||
29 | - <li><%= link_to __('Enterprises'), :action => 'enterprises' %></li> | ||
30 | - <% end %> | ||
31 | - <% if profile.kind_of? Organization %> | ||
32 | - <li><%= link_to _('Members'), :action => 'members' %></li> | ||
33 | - <% end %> | ||
34 | - <% if profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises') %> | ||
35 | - <li><%= link_to _('Products/Services'), :controller => 'catalog', :action => 'index' %></li> | ||
36 | - <% end %> | ||
37 | - | ||
38 | - <li> | ||
39 | - <%= link_to _('Site map'), :action => 'sitemap' %> | ||
40 | - </li> | ||
41 | - | ||
42 | - <li> | ||
43 | - <%= _('Tags:') %> | ||
44 | - <%= tag_cloud @tags, :id, { :action => 'tag' }, :max_size => 18, :min_size => 10%> | ||
45 | - </li> | ||
46 | -</ul> | 9 | +<table class='profile'> |
10 | + <%= render :partial => partial_for_class(profile.class) %> | ||
11 | + <tr> | ||
12 | + <th colspan='2'> | ||
13 | + <%= _('Content') %> | ||
14 | + </th> | ||
15 | + </tr> | ||
16 | + <tr> | ||
17 | + <td> | ||
18 | + <%= _('Content published:') %> | ||
19 | + </td> | ||
20 | + <td> | ||
21 | + <%= link_to _('Site map'), :action => 'sitemap' %> | ||
22 | + </td> | ||
23 | + </tr> | ||
24 | + <tr> | ||
25 | + <td> | ||
26 | + <%= _('Tags:') %> | ||
27 | + </td> | ||
28 | + <td> | ||
29 | + <%= tag_cloud @tags, :id, { :action => 'tag' }, :max_size => 18, :min_size => 10%> | ||
30 | + </td> | ||
31 | + </tr> | ||
32 | +</table> |
public/stylesheets/common.css
@@ -276,6 +276,25 @@ td .button { | @@ -276,6 +276,25 @@ td .button { | ||
276 | background-color: transparent; | 276 | background-color: transparent; |
277 | } | 277 | } |
278 | 278 | ||
279 | +td.field-name { | ||
280 | + color: #888; | ||
281 | + width: 150px; | ||
282 | + text-align: left; | ||
283 | +} | ||
284 | + | ||
285 | +table.profile th { | ||
286 | + border-bottom: 2px solid #eeeeec; | ||
287 | + padding: 10px 0px 0px 0px; | ||
288 | +} | ||
289 | +table.profile td { | ||
290 | + border: none; | ||
291 | + padding-left: 0px; | ||
292 | +} | ||
293 | +table.profile tr:hover td { | ||
294 | + background: none; | ||
295 | +} | ||
296 | + | ||
297 | + | ||
279 | /* for fields with auto-completion */ | 298 | /* for fields with auto-completion */ |
280 | div.auto-complete { | 299 | div.auto-complete { |
281 | display: block; | 300 | display: block; |