From f2c5dc468c9bdb86e096565e9306f53eb1876ce0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 12:43:15 +0900 Subject: [PATCH] Extract user's profile --- src/api/endpoints/i/update.js | 24 +++++------ src/api/private/signup.ts | 16 ++++++-- src/web/app/desktop/tags/list-user.tag | 50 +++++++++++------------ src/web/app/desktop/tags/user-header.tag | 2 +- src/web/app/desktop/tags/user-preview.tag | 4 +- src/web/app/desktop/tags/user-profile.tag | 8 ++-- src/web/app/mobile/tags/user-preview.tag | 14 +++++-- src/web/app/mobile/tags/user.tag | 12 +++--- test/api.js | 23 +++++++---- tools/migration/user-profile.js | 18 ++++++++ 10 files changed, 102 insertions(+), 69 deletions(-) create mode 100644 tools/migration/user-profile.js diff --git a/src/api/endpoints/i/update.js b/src/api/endpoints/i/update.js index 13b5c523e0..5aeafa60c8 100644 --- a/src/api/endpoints/i/update.js +++ b/src/api/endpoints/i/update.js @@ -39,7 +39,7 @@ module.exports = async (params, user, _, isSecure) => return rej('too long location'); } - user.location = location; + user.profile.location = location; } // Get 'bio' parameter @@ -49,21 +49,19 @@ module.exports = async (params, user, _, isSecure) => return rej('too long bio'); } - user.bio = bio; + user.profile.bio = bio; } // Get 'birthday' parameter const birthday = params.birthday; if (birthday != null) { - if (birthday != '') { - if (!isValidBirthday(birthday)) { - return rej('invalid birthday'); - } - - user.birthday = birthday; - } else { - user.birthday = null; + if (!isValidBirthday(birthday)) { + return rej('invalid birthday'); } + + user.profile.birthday = birthday; + } else { + user.profile.birthday = null; } // Get 'avatar_id' parameter @@ -81,11 +79,9 @@ module.exports = async (params, user, _, isSecure) => await User.update(user._id, { $set: { name: user.name, - location: user.location, - bio: user.bio, - birthday: user.birthday, avatar_id: user.avatar_id, - banner_id: user.banner_id + banner_id: user.banner_id, + profile: user.profile } }); diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index 2b679b914c..73e04f8b37 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -65,14 +65,12 @@ export default async (req: express.Request, res: express.Response) => { token: secret, avatar_id: null, banner_id: null, - birthday: null, created_at: new Date(), - bio: null, + description: null, email: null, followers_count: 0, following_count: 0, links: null, - location: null, name: name, password: hash, posts_count: 0, @@ -80,7 +78,17 @@ export default async (req: express.Request, res: express.Response) => { liked_count: 0, drive_capacity: 1073741824, // 1GB username: username, - username_lower: username.toLowerCase() + username_lower: username.toLowerCase(), + profile: { + bio: null, + birthday: null, + blood: null, + gender: null, + handedness: null, + height: null, + location: null, + weight: null + } }); // Response diff --git a/src/web/app/desktop/tags/list-user.tag b/src/web/app/desktop/tags/list-user.tag index 133efd2d1e..e709d8d708 100644 --- a/src/web/app/desktop/tags/list-user.tag +++ b/src/web/app/desktop/tags/list-user.tag @@ -1,11 +1,15 @@ -avatar + + + avatar +
-
{ user.name }@{ user.username }
+ { user.name } + @{ user.username }

フォローされています

-
{ user.bio }
+
{ user.description }
@@ -41,31 +45,23 @@ > header margin-bottom 2px - &:after - content "" - display block - clear both + > .name + display inline + margin 0 + padding 0 + color #777 + font-size 1em + font-weight 700 + text-align left + text-decoration none - > .left - float left + &:hover + text-decoration underline - > .name - display inline - margin 0 - padding 0 - color #777 - font-size 1em - font-weight 700 - text-align left - text-decoration none - - &:hover - text-decoration underline - - > .username - text-align left - margin 0 0 0 8px - color #ccc + > .username + text-align left + margin 0 0 0 8px + color #ccc > .body > .followed @@ -78,7 +74,7 @@ background #eefaff border-radius 4px - > .bio + > .description cursor default display block margin 0 diff --git a/src/web/app/desktop/tags/user-header.tag b/src/web/app/desktop/tags/user-header.tag index c265357169..c7ebaff446 100644 --- a/src/web/app/desktop/tags/user-header.tag +++ b/src/web/app/desktop/tags/user-header.tag @@ -3,7 +3,7 @@

{ user.name }

@{ user.username }

-

{ user.location }

+

{ user.profile.location }