From ae069d09be61f18e42e3ccdab7081e631d880e11 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 21 May 2009 19:35:53 -0300 Subject: [PATCH] ActionItem1044: better profile page --- app/helpers/profile_helper.rb | 12 ++++++++++++ app/helpers/tags_helper.rb | 8 ++++---- app/views/profile/_organization.rhtml | 16 ++++++++++++++++ app/views/profile/_person.rhtml | 38 ++++++++++++++++++++++++++++++++++++++ app/views/profile/index.rhtml | 64 +++++++++++++++++++++++++--------------------------------------- public/stylesheets/common.css | 19 +++++++++++++++++++ 6 files changed, 114 insertions(+), 43 deletions(-) create mode 100644 app/views/profile/_organization.rhtml create mode 100644 app/views/profile/_person.rhtml diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index f0678df..f1fe755 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -1,3 +1,15 @@ module ProfileHelper + def display_field(title, object, field) + value = object.send(field) + if !value.blank? + if block_given? + value = yield(value) + end + content_tag('tr', content_tag('td', title, :class => 'field-name') + content_tag('td', value)) + else + '' + end + end + end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 3f112a1..82cc8be 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -30,10 +30,10 @@ module TagsHelper def tag_cloud(tags, tagname_option, url, options = {}) - return _('No tags yet.') + '
' + - '' + - _('What are tags?') + '' if tags.empty? + return content_tag('em', _('No tags yet.')) + + ' (' + + _('What are tags?') + ')' if tags.empty? max_size = options[:max_size] || Cloud::MAX_SIZE min_size = options[:min_size] || Cloud::MIN_SIZE diff --git a/app/views/profile/_organization.rhtml b/app/views/profile/_organization.rhtml new file mode 100644 index 0000000..cbeb29e --- /dev/null +++ b/app/views/profile/_organization.rhtml @@ -0,0 +1,16 @@ + + <%= _('Basic information')%> + +<%= display_field(_('Name:'), profile, :name) { |name| link_to name, profile.url } %> + + + <%= link_to _('Members'), :action => 'members' %> + + +<% if profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises') %> + + + <%= link_to _('Products/Services'), :controller => 'catalog', :action => 'index' %> + + +<% end %> diff --git a/app/views/profile/_person.rhtml b/app/views/profile/_person.rhtml new file mode 100644 index 0000000..b868823 --- /dev/null +++ b/app/views/profile/_person.rhtml @@ -0,0 +1,38 @@ + + <%= _('Basic information')%> + +<%= display_field(_('Name:'), profile, :name) { |name| link_to name, profile.url } %> +<%= display_field(_('Gender:'), profile, :sex) { |gender| { 'male' => _('Male'), 'female' => _('Female') }[gender] } %> +<%= display_field(_('Date of birth:'), profile, :birth_date) { |date| show_date(date) }%> + + + <%= _('Contact')%> + +<% if profile == user || profile.friends.include?(user) %> + <%= display_field(_('Address:'), profile, :address) %> + <%= display_field(_('ZIP code:'), profile, :zip_code) %> + <%= display_field(_('Contact phone:'), profile, :contact_phone) %> + <%= display_field(_('e-Mail:'), profile, :email) { |email| link_to email, 'mailto:'+email } %> +<% end %> +<%= display_field(_('Location:'), profile, :location) %> + + + <%= _('Work')%> + +<%= display_field(_('Organization:'), profile, :organization) %> +<%= display_field(_('Organization website:'), profile, :organization_website) { |url| link_to(url, url) }%> + + + + <%= _('Network')%> + + + + <%= link_to __('Friends'), :action => 'friends' %> + — <%= link_to __('Communities'), :action => 'communities' %> + <% if !environment.enabled?('disable_asset_enterprises') %> + — <%= link_to __('Enterprises'), :action => 'enterprises' %> + <% end %> + + + diff --git a/app/views/profile/index.rhtml b/app/views/profile/index.rhtml index 4579e21..30c3337 100644 --- a/app/views/profile/index.rhtml +++ b/app/views/profile/index.rhtml @@ -4,43 +4,29 @@ <% end %> -

<%= _("%s's profile") % profile.identifier %>

+

<%= _("%s's profile") % profile.identifier %>

- + + <%= render :partial => partial_for_class(profile.class) %> + + + + + + + + + + + +
+ <%= _('Content') %> +
+ <%= _('Content published:') %> + + <%= link_to _('Site map'), :action => 'sitemap' %> +
+ <%= _('Tags:') %> + + <%= tag_cloud @tags, :id, { :action => 'tag' }, :max_size => 18, :min_size => 10%> +
diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index 3327969..adc1508 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -276,6 +276,25 @@ td .button { background-color: transparent; } +td.field-name { + color: #888; + width: 150px; + text-align: left; +} + +table.profile th { + border-bottom: 2px solid #eeeeec; + padding: 10px 0px 0px 0px; +} +table.profile td { + border: none; + padding-left: 0px; +} +table.profile tr:hover td { + background: none; +} + + /* for fields with auto-completion */ div.auto-complete { display: block; -- libgit2 0.21.2