Rename "User Expansion" to the much clearer "User Card"

This commit is contained in:
Robin Ward 2014-10-20 12:11:36 -04:00
parent 10094a0bcd
commit 1cf4a0d604
27 changed files with 76 additions and 71 deletions

View File

@ -32,7 +32,7 @@ export default Em.Component.extend({
if (c.get('usersExpanded')) {
var postUrl;
c.get('users').forEach(function(u) {
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + u.get('username_lower') + "\" data-user-expand=\"" + u.get('username_lower') + "\">";
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + u.get('username_lower') + "\" data-user-card=\"" + u.get('username_lower') + "\">";
if (u.post_url) {
postUrl = postUrl || u.post_url;
}

View File

@ -1,7 +1,7 @@
export default Ember.Component.extend({
tagName: 'a',
attributeBindings: ['href'],
classNames: ['trigger-expansion'],
classNames: ['trigger-user-card'],
href: Em.computed.alias('post.usernameUrl'),
click: function(e) {

View File

@ -1,5 +1,5 @@
var PosterNameComponent = Em.Component.extend({
classNames: ['names', 'trigger-expansion'],
classNames: ['names', 'trigger-user-card'],
displayNameOnPosts: Discourse.computed.setting('display_name_on_posts'),
// sanitize name for comparison

View File

@ -18,7 +18,7 @@ export default {
$currentTarget.data('ember-action') ||
$currentTarget.data('auto-route') ||
$currentTarget.data('share-url') ||
$currentTarget.data('user-expand') ||
$currentTarget.data('user-card') ||
$currentTarget.hasClass('mention') ||
$currentTarget.hasClass('ember-view') ||
$currentTarget.hasClass('lightbox') ||

View File

@ -20,7 +20,7 @@ var ApplicationRoute = Discourse.Route.extend({
},
expandUser: function(user) {
this.controllerFor('user-expansion').show(user.get('username'), user.get('uploaded_avatar_id'));
this.controllerFor('user-card').show(user.get('username'), user.get('uploaded_avatar_id'));
return true;
},

View File

@ -27,13 +27,13 @@ Discourse.TopicRoute = Discourse.Route.extend({
// Modals that can pop up within a topic
expandPostUser: function(post) {
this.controllerFor('user-expansion').show(post.get('username'), post.get('uploaded_avatar_id'));
this.controllerFor('user-card').show(post.get('username'), post.get('uploaded_avatar_id'));
},
expandPostUsername: function(username) {
username = username.replace(/^@/, '');
if (!Em.isEmpty(username)) {
this.controllerFor('user-expansion').show(username);
this.controllerFor('user-card').show(username);
}
},
@ -172,7 +172,7 @@ Discourse.TopicRoute = Discourse.Route.extend({
// Clear the search context
this.controllerFor('search').set('searchContext', null);
this.controllerFor('user-expansion').set('visible', false);
this.controllerFor('user-card').set('visible', false);
var topicController = this.controllerFor('topic'),
postStream = topicController.get('postStream');

View File

@ -2,7 +2,7 @@
<div id='main-outlet' {{bind-attr class=backgroundClass}}>
{{outlet}}
{{render "user-expansion"}}
{{render "user-card"}}
</div>
{{render "modal"}}

View File

@ -111,15 +111,15 @@
</div>
<div class="control-group pref-profile-bg">
<label class="control-label">{{i18n user.change_expansion_background.title}}</label>
<label class="control-label">{{i18n user.change_card_background.title}}</label>
<div class="controls">
{{image-uploader uploadUrl=imageUploadUrl
imageUrl=expansion_background
imageUrl=card_background
instantDelete="true"
type="expansion_background"}}
type="card_background"}}
</div>
<div class='instructions'>
{{i18n user.change_expansion_background.instructions}}
{{i18n user.change_card_background.instructions}}
</div>
</div>
{{/if}}

View File

@ -1,7 +1,7 @@
{{#grouped-each model.content}}
<div {{bind-attr class=":item hidden deleted moderator_action"}}>
<div class='clearfix info'>
<a href="{{unbound userUrl}}" data-user-expand="{{unbound username}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div></a>
<a href="{{unbound userUrl}}" data-user-card="{{unbound username}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div></a>
<span class='time'>{{format-date path="created_at" leaveAgo="true"}}</span>
<span class="title">
<a href="{{unbound postUrl}}">{{unbound title}}</a>
@ -19,7 +19,7 @@
{{i18n "bookmarks.remove"}}
</button>
{{/if}}
<a href="{{unbound userUrl}}" data-user-expand="{{unbound username}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="tiny" extraClasses="actor" ignoreTitle="true"}}</div></a>
<a href="{{unbound userUrl}}" data-user-card="{{unbound username}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="tiny" extraClasses="actor" ignoreTitle="true"}}</div></a>
{{#if edit_reason}} &mdash; <span class="edit-reason">{{unbound edit_reason}}</span>{{/if}}
{{/grouped-each}}
</div>

View File

@ -2,13 +2,13 @@ import { renderAvatar } from 'discourse/helpers/user-avatar';
export default Ember.View.extend({
tagName: 'a',
attributeBindings: ['href', 'data-user-expand'],
attributeBindings: ['href', 'data-user-card'],
classNameBindings: ['content.extras'],
user: Em.computed.alias('content.user'),
href: Em.computed.alias('user.path'),
'data-user-expand': Em.computed.alias('user.username'),
'data-user-card': Em.computed.alias('user.username'),
render: function(buffer) {
var av = renderAvatar(this.get('content'), {usernamePath: 'user.username', imageSize: 'small'});

View File

@ -1,16 +1,16 @@
import CleansUp from 'discourse/mixins/cleans-up';
var clickOutsideEventName = "mousedown.outside-user-expansion",
clickDataExpand = "click.discourse-user-expand",
var clickOutsideEventName = "mousedown.outside-user-card",
clickDataExpand = "click.discourse-user-card",
clickMention = "click.discourse-user-mention";
export default Discourse.View.extend(CleansUp, {
elementId: 'user-expansion',
elementId: 'user-card',
classNameBindings: ['controller.visible::hidden', 'controller.showBadges'],
allowBackgrounds: Discourse.computed.setting('allow_profile_backgrounds'),
addBackground: function() {
var url = this.get('controller.user.expansion_background');
var url = this.get('controller.user.card_background');
if (!this.get('allowBackgrounds')) { return; }
var $this = this.$();
@ -21,7 +21,7 @@ export default Discourse.View.extend(CleansUp, {
} else {
$this.css('background-image', "url(" + url + ")");
}
}.observes('controller.user.expansion_background'),
}.observes('controller.user.card_background'),
_setup: function() {
var self = this;
@ -30,7 +30,7 @@ export default Discourse.View.extend(CleansUp, {
$('html').off(clickOutsideEventName).on(clickOutsideEventName, function(e) {
if (self.get('controller.visible')) {
var $target = $(e.target);
if ($target.closest('.trigger-expansion').length > 0) { return; }
if ($target.closest('.trigger-user-card').length > 0) { return; }
if (self.$().has(e.target).length !== 0) { return; }
self.get('controller').close();
@ -39,10 +39,10 @@ export default Discourse.View.extend(CleansUp, {
return true;
});
$('#main-outlet').on(clickDataExpand, '[data-user-expand]', function(e) {
$('#main-outlet').on(clickDataExpand, '[data-user-card]', function(e) {
var $target = $(e.currentTarget);
self._posterExpand($target);
self.get('controller').show($target.data('user-expand'));
self.get('controller').show($target.data('user-card'));
return false;
});

View File

@ -9,7 +9,7 @@
@import "desktop/header";
@import "desktop/login";
@import "desktop/modal";
@import "desktop/poster_expansion";
@import "desktop/user-card";
@import "desktop/topic-list";
@import "desktop/topic-post";
@import "desktop/topic";

View File

@ -1,6 +1,6 @@
// styles that apply to the "share" popup when sharing a link to a post or topic
#user-expansion {
#user-card {
position: absolute;
width: 460px;
left: 20px;

View File

@ -461,8 +461,8 @@ class UsersController < ApplicationController
upload_avatar_for(user, upload)
when "profile_background"
upload_profile_background_for(user.user_profile, upload)
when "expansion_background"
upload_expansion_background_for(user.user_profile, upload)
when "card_background"
upload_card_background_for(user.user_profile, upload)
end
else
render status: 422, text: upload.errors.full_messages
@ -492,8 +492,8 @@ class UsersController < ApplicationController
image_type = params.require(:image_type)
if image_type == 'profile_background'
user.user_profile.clear_profile_background
elsif image_type == 'expansion_background'
user.user_profile.clear_expansion_background
elsif image_type == 'card_background'
user.user_profile.clear_card_background
else
raise Discourse::InvalidParameters.new(:image_type)
end
@ -554,8 +554,8 @@ class UsersController < ApplicationController
render json: { url: upload.url, width: upload.width, height: upload.height }
end
def upload_expansion_background_for(user_profile, upload)
user_profile.upload_expansion_background(upload)
def upload_card_background_for(user_profile, upload)
user_profile.upload_card_background(upload)
render json: { url: upload.url, width: upload.width, height: upload.height }
end

View File

@ -8,7 +8,7 @@ module Jobs
ignore_urls = []
ignore_urls << UserProfile.uniq.where("profile_background IS NOT NULL AND profile_background != ''").pluck(:profile_background)
ignore_urls << UserProfile.uniq.where("expansion_background IS NOT NULL AND expansion_background != ''").pluck(:expansion_background)
ignore_urls << UserProfile.uniq.where("card_background IS NOT NULL AND card_background != ''").pluck(:card_background)
ignore_urls << Category.uniq.where("logo_url IS NOT NULL AND logo_url != ''").pluck(:logo_url)
ignore_urls << Category.uniq.where("background_url IS NOT NULL AND background_url != ''").pluck(:background_url)
ignore_urls.flatten!

View File

@ -29,13 +29,13 @@ class UserProfile < ActiveRecord::Base
cook
end
def upload_expansion_background(upload)
self.expansion_background = upload.url
def upload_card_background(upload)
self.card_background = upload.url
self.save!
end
def clear_expansion_background
self.expansion_background = ""
def clear_card_background
self.card_background = ""
self.save!
end
@ -106,7 +106,7 @@ end
# bio_cooked :text
# dismissed_banner_key :integer
# profile_background :string(255)
# expansion_background :string(255)
# card_background :string(255)
# bio_cooked_version :integer
#
# Indexes

View File

@ -27,7 +27,7 @@ class UserSerializer < BasicUserSerializer
:created_at,
:website,
:profile_background,
:expansion_background,
:card_background,
:location,
:can_edit,
:can_edit_username,
@ -118,12 +118,12 @@ class UserSerializer < BasicUserSerializer
profile_background.present?
end
def expansion_background
object.user_profile.expansion_background
def card_background
object.user_profile.card_background
end
def include_expansion_background?
expansion_background.present?
def include_card_background?
card_background.present?
end
def location

View File

@ -373,9 +373,9 @@ en:
title: "Profile Background"
instructions: "Profile backgrounds will be centered and have a default width of 850px."
change_expansion_background:
title: "User Expansion Background"
instructions: "Expansion images will be centered and have a default width of 590px."
change_card_background:
title: "User Card Background"
instructions: "Background images will be centered and have a default width of 590px."
email:
title: "Email"

View File

@ -330,7 +330,7 @@ pt_BR:
change_profile_background:
title: "Fundo do perfil"
instructions: "Fundos do perfil será centralizado e tera uma largura padrão de 850px."
change_expansion_background:
change_card_background:
title: "Fundo de Expansão do Usuário"
instructions: "Imagens de Expansão será centralizado e tera uma largura padrão de 590px."
email:

View File

@ -0,0 +1,5 @@
class RenameExpansionToCard < ActiveRecord::Migration
def change
rename_column :user_profiles, :expansion_background, :card_background
end
end

View File

@ -1156,13 +1156,13 @@ describe UsersController do
json['height'].should == 200
end
it 'is successful for expansion backgrounds' do
it 'is successful for card backgrounds' do
upload = Fabricate(:upload)
Upload.expects(:create_for).returns(upload)
xhr :post, :upload_user_image, username: user.username, file: user_image, image_type: "expansion_background"
xhr :post, :upload_user_image, username: user.username, file: user_image, image_type: "card_background"
user.reload
user.user_profile.expansion_background.should == "/uploads/default/1/1234567890123456.png"
user.user_profile.card_background.should == "/uploads/default/1/1234567890123456.png"
# returns the url, width and height of the uploaded image
json = JSON.parse(response.body)
@ -1220,12 +1220,12 @@ describe UsersController do
json['height'].should == 200
end
it 'is successful for expansion backgrounds' do
it 'is successful for card backgrounds' do
upload = Fabricate(:upload)
Upload.expects(:create_for).returns(upload)
xhr :post, :upload_user_image, username: user.username, file: user_image_url, image_type: "expansion_background"
xhr :post, :upload_user_image, username: user.username, file: user_image_url, image_type: "card_background"
user.reload
user.user_profile.expansion_background.should == "/uploads/default/1/1234567890123456.png"
user.user_profile.card_background.should == "/uploads/default/1/1234567890123456.png"
# returns the url, width and height of the uploaded image
json = JSON.parse(response.body)

View File

@ -126,7 +126,7 @@ page.runTests = function(){
});
test("has details",function(){
return $('#user-expansion .names').length === 1;
return $('#user-card .names').length === 1;
});
run();

View File

@ -32,13 +32,13 @@ describe UserSerializer do
end
end
context "with filled out expansion background" do
context "with filled out card background" do
before do
user.user_profile.expansion_background = 'http://expansion.com'
user.user_profile.card_background = 'http://card.com'
end
it "has a profile background" do
expect(json[:expansion_background]).to eq 'http://expansion.com'
expect(json[:card_background]).to eq 'http://card.com'
end
end

View File

@ -0,0 +1,13 @@
integration("User Card");
test("card", function() {
visit('/');
ok(find('#user-card:visible').length === 0, 'user card is invisible by default');
click('a[data-user-card=eviltrout]:first');
andThen(function() {
ok(find('#user-card:visible').length === 1, 'card should appear');
});
});

View File

@ -1,13 +0,0 @@
integration("User Expansion");
test("expansion", function() {
visit('/');
ok(find('#user-expansion:visible').length === 0, 'user expansion is invisible by default');
click('a[data-user-expand=eviltrout]:first');
andThen(function() {
ok(find('#user-expansion:visible').length === 1, 'expansion should appear');
});
});