mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 00:28:29 +08:00
Remove user bio feature (#1214)
The feature is very limited in scope, and we hope for community extensions to take over this feature and make it much better.
This commit is contained in:
parent
a18088f385
commit
6614fddbcd
4
framework/core/js/admin/dist/app.js
vendored
4
framework/core/js/admin/dist/app.js
vendored
|
@ -22451,10 +22451,6 @@ System.register('flarum/models/User', ['flarum/Model', 'flarum/utils/stringToCol
|
|||
password: Model.attribute('password'),
|
||||
|
||||
avatarUrl: Model.attribute('avatarUrl'),
|
||||
bio: Model.attribute('bio'),
|
||||
bioHtml: computed('bio', function (bio) {
|
||||
return bio ? '<p>' + $('<div/>').text(bio).html().replace(/\n/g, '<br>').autoLink({ rel: 'nofollow' }) + '</p>' : '';
|
||||
}),
|
||||
preferences: Model.attribute('preferences'),
|
||||
groups: Model.hasMany('groups'),
|
||||
|
||||
|
|
148
framework/core/js/forum/dist/app.js
vendored
148
framework/core/js/forum/dist/app.js
vendored
|
@ -28478,143 +28478,10 @@ System.register('flarum/components/TextEditor', ['flarum/Component', 'flarum/uti
|
|||
});;
|
||||
'use strict';
|
||||
|
||||
System.register('flarum/components/UserBio', ['flarum/Component', 'flarum/components/LoadingIndicator', 'flarum/utils/classList', 'flarum/utils/extractText'], function (_export, _context) {
|
||||
System.register('flarum/components/UserCard', ['flarum/Component', 'flarum/utils/humanTime', 'flarum/utils/ItemList', 'flarum/utils/UserControls', 'flarum/helpers/avatar', 'flarum/helpers/username', 'flarum/helpers/icon', 'flarum/components/Dropdown', 'flarum/components/AvatarEditor', 'flarum/helpers/listItems'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var Component, LoadingIndicator, classList, extractText, UserBio;
|
||||
return {
|
||||
setters: [function (_flarumComponent) {
|
||||
Component = _flarumComponent.default;
|
||||
}, function (_flarumComponentsLoadingIndicator) {
|
||||
LoadingIndicator = _flarumComponentsLoadingIndicator.default;
|
||||
}, function (_flarumUtilsClassList) {
|
||||
classList = _flarumUtilsClassList.default;
|
||||
}, function (_flarumUtilsExtractText) {
|
||||
extractText = _flarumUtilsExtractText.default;
|
||||
}],
|
||||
execute: function () {
|
||||
UserBio = function (_Component) {
|
||||
babelHelpers.inherits(UserBio, _Component);
|
||||
|
||||
function UserBio() {
|
||||
babelHelpers.classCallCheck(this, UserBio);
|
||||
return babelHelpers.possibleConstructorReturn(this, (UserBio.__proto__ || Object.getPrototypeOf(UserBio)).apply(this, arguments));
|
||||
}
|
||||
|
||||
babelHelpers.createClass(UserBio, [{
|
||||
key: 'init',
|
||||
value: function init() {
|
||||
/**
|
||||
* Whether or not the bio is currently being edited.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.editing = false;
|
||||
|
||||
/**
|
||||
* Whether or not the bio is currently being saved.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.loading = false;
|
||||
}
|
||||
}, {
|
||||
key: 'view',
|
||||
value: function view() {
|
||||
var user = this.props.user;
|
||||
var content = void 0;
|
||||
|
||||
if (this.editing) {
|
||||
content = m('textarea', { className: 'FormControl', placeholder: extractText(app.translator.trans('core.forum.user.bio_placeholder')), rows: '3', value: user.bio() });
|
||||
} else {
|
||||
var subContent = void 0;
|
||||
|
||||
if (this.loading) {
|
||||
subContent = m(
|
||||
'p',
|
||||
{ className: 'UserBio-placeholder' },
|
||||
LoadingIndicator.component({ size: 'tiny' })
|
||||
);
|
||||
} else {
|
||||
var bioHtml = user.bioHtml();
|
||||
|
||||
if (bioHtml) {
|
||||
subContent = m.trust(bioHtml);
|
||||
} else if (this.props.editable) {
|
||||
subContent = m(
|
||||
'p',
|
||||
{ className: 'UserBio-placeholder' },
|
||||
app.translator.trans('core.forum.user.bio_placeholder')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
content = m(
|
||||
'div',
|
||||
{ className: 'UserBio-content', onclick: this.edit.bind(this) },
|
||||
subContent
|
||||
);
|
||||
}
|
||||
|
||||
return m(
|
||||
'div',
|
||||
{ className: 'UserBio ' + classList({
|
||||
editable: this.props.editable,
|
||||
editing: this.editing
|
||||
}) },
|
||||
content
|
||||
);
|
||||
}
|
||||
}, {
|
||||
key: 'edit',
|
||||
value: function edit() {
|
||||
if (!this.props.editable) return;
|
||||
|
||||
this.editing = true;
|
||||
m.redraw();
|
||||
|
||||
var bio = this;
|
||||
var save = function save(e) {
|
||||
if (e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
bio.save($(this).val());
|
||||
};
|
||||
|
||||
this.$('textarea').focus().bind('blur', save).bind('keydown', 'return', save);
|
||||
}
|
||||
}, {
|
||||
key: 'save',
|
||||
value: function save(value) {
|
||||
var _this2 = this;
|
||||
|
||||
var user = this.props.user;
|
||||
|
||||
if (user.bio() !== value) {
|
||||
this.loading = true;
|
||||
|
||||
user.save({ bio: value }).catch(function () {}).then(function () {
|
||||
_this2.loading = false;
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
|
||||
this.editing = false;
|
||||
m.redraw();
|
||||
}
|
||||
}]);
|
||||
return UserBio;
|
||||
}(Component);
|
||||
|
||||
_export('default', UserBio);
|
||||
}
|
||||
};
|
||||
});;
|
||||
'use strict';
|
||||
|
||||
System.register('flarum/components/UserCard', ['flarum/Component', 'flarum/utils/humanTime', 'flarum/utils/ItemList', 'flarum/utils/UserControls', 'flarum/helpers/avatar', 'flarum/helpers/username', 'flarum/helpers/icon', 'flarum/components/Dropdown', 'flarum/components/UserBio', 'flarum/components/AvatarEditor', 'flarum/helpers/listItems'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var Component, humanTime, ItemList, UserControls, avatar, username, icon, Dropdown, UserBio, AvatarEditor, listItems, UserCard;
|
||||
var Component, humanTime, ItemList, UserControls, avatar, username, icon, Dropdown, AvatarEditor, listItems, UserCard;
|
||||
return {
|
||||
setters: [function (_flarumComponent) {
|
||||
Component = _flarumComponent.default;
|
||||
|
@ -28632,8 +28499,6 @@ System.register('flarum/components/UserCard', ['flarum/Component', 'flarum/utils
|
|||
icon = _flarumHelpersIcon.default;
|
||||
}, function (_flarumComponentsDropdown) {
|
||||
Dropdown = _flarumComponentsDropdown.default;
|
||||
}, function (_flarumComponentsUserBio) {
|
||||
UserBio = _flarumComponentsUserBio.default;
|
||||
}, function (_flarumComponentsAvatarEditor) {
|
||||
AvatarEditor = _flarumComponentsAvatarEditor.default;
|
||||
}, function (_flarumHelpersListItems) {
|
||||
|
@ -28713,11 +28578,6 @@ System.register('flarum/components/UserCard', ['flarum/Component', 'flarum/utils
|
|||
var user = this.props.user;
|
||||
var lastSeenTime = user.lastSeenTime();
|
||||
|
||||
items.add('bio', UserBio.component({
|
||||
user: user,
|
||||
editable: this.props.editable
|
||||
}));
|
||||
|
||||
if (lastSeenTime) {
|
||||
var online = user.isOnline();
|
||||
|
||||
|
@ -30541,10 +30401,6 @@ System.register('flarum/models/User', ['flarum/Model', 'flarum/utils/stringToCol
|
|||
password: Model.attribute('password'),
|
||||
|
||||
avatarUrl: Model.attribute('avatarUrl'),
|
||||
bio: Model.attribute('bio'),
|
||||
bioHtml: computed('bio', function (bio) {
|
||||
return bio ? '<p>' + $('<div/>').text(bio).html().replace(/\n/g, '<br>').autoLink({ rel: 'nofollow' }) + '</p>' : '';
|
||||
}),
|
||||
preferences: Model.attribute('preferences'),
|
||||
groups: Model.hasMany('groups'),
|
||||
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
import Component from 'flarum/Component';
|
||||
import LoadingIndicator from 'flarum/components/LoadingIndicator';
|
||||
import classList from 'flarum/utils/classList';
|
||||
import extractText from 'flarum/utils/extractText';
|
||||
|
||||
/**
|
||||
* The `UserBio` component displays a user's bio, optionally letting the user
|
||||
* edit it.
|
||||
*/
|
||||
export default class UserBio extends Component {
|
||||
init() {
|
||||
/**
|
||||
* Whether or not the bio is currently being edited.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.editing = false;
|
||||
|
||||
/**
|
||||
* Whether or not the bio is currently being saved.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
view() {
|
||||
const user = this.props.user;
|
||||
let content;
|
||||
|
||||
if (this.editing) {
|
||||
content = <textarea className="FormControl" placeholder={extractText(app.translator.trans('core.forum.user.bio_placeholder'))} rows="3" value={user.bio()}/>;
|
||||
} else {
|
||||
let subContent;
|
||||
|
||||
if (this.loading) {
|
||||
subContent = <p className="UserBio-placeholder">{LoadingIndicator.component({size: 'tiny'})}</p>;
|
||||
} else {
|
||||
const bioHtml = user.bioHtml();
|
||||
|
||||
if (bioHtml) {
|
||||
subContent = m.trust(bioHtml);
|
||||
} else if (this.props.editable) {
|
||||
subContent = <p className="UserBio-placeholder">{app.translator.trans('core.forum.user.bio_placeholder')}</p>;
|
||||
}
|
||||
}
|
||||
|
||||
content = <div className="UserBio-content" onclick={this.edit.bind(this)}>{subContent}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={'UserBio ' + classList({
|
||||
editable: this.props.editable,
|
||||
editing: this.editing
|
||||
})}>
|
||||
{content}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the bio.
|
||||
*/
|
||||
edit() {
|
||||
if (!this.props.editable) return;
|
||||
|
||||
this.editing = true;
|
||||
m.redraw();
|
||||
|
||||
const bio = this;
|
||||
const save = function(e) {
|
||||
if (e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
bio.save($(this).val());
|
||||
};
|
||||
|
||||
this.$('textarea').focus()
|
||||
.bind('blur', save)
|
||||
.bind('keydown', 'return', save);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the bio.
|
||||
*
|
||||
* @param {String} value
|
||||
*/
|
||||
save(value) {
|
||||
const user = this.props.user;
|
||||
|
||||
if (user.bio() !== value) {
|
||||
this.loading = true;
|
||||
|
||||
user.save({bio: value})
|
||||
.catch(() => {})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
|
||||
this.editing = false;
|
||||
m.redraw();
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import avatar from 'flarum/helpers/avatar';
|
|||
import username from 'flarum/helpers/username';
|
||||
import icon from 'flarum/helpers/icon';
|
||||
import Dropdown from 'flarum/components/Dropdown';
|
||||
import UserBio from 'flarum/components/UserBio';
|
||||
import AvatarEditor from 'flarum/components/AvatarEditor';
|
||||
import listItems from 'flarum/helpers/listItems';
|
||||
|
||||
|
@ -82,13 +81,6 @@ export default class UserCard extends Component {
|
|||
const user = this.props.user;
|
||||
const lastSeenTime = user.lastSeenTime();
|
||||
|
||||
items.add('bio',
|
||||
UserBio.component({
|
||||
user,
|
||||
editable: this.props.editable
|
||||
})
|
||||
);
|
||||
|
||||
if (lastSeenTime) {
|
||||
const online = user.isOnline();
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ Object.assign(User.prototype, {
|
|||
password: Model.attribute('password'),
|
||||
|
||||
avatarUrl: Model.attribute('avatarUrl'),
|
||||
bio: Model.attribute('bio'),
|
||||
bioHtml: computed('bio', bio => bio ? '<p>' + $('<div/>').text(bio).html().replace(/\n/g, '<br>').autoLink({rel: 'nofollow'}) + '</p>' : ''),
|
||||
preferences: Model.attribute('preferences'),
|
||||
groups: Model.hasMany('groups'),
|
||||
|
||||
|
|
|
@ -90,37 +90,6 @@
|
|||
display: inline-block;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.item-bio {
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
.UserBio {
|
||||
margin: -10px -10px 10px;
|
||||
border: 1px dashed transparent;
|
||||
border-radius: @border-radius;
|
||||
|
||||
&.editable:not(.editing) {
|
||||
cursor: text;
|
||||
|
||||
&:hover {
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
&, textarea {
|
||||
font-size: 14px;
|
||||
}
|
||||
textarea {
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
resize: none;
|
||||
}
|
||||
}
|
||||
.UserBio-content {
|
||||
padding: 10px 10px 1px;
|
||||
}
|
||||
.UserBio-placeholder {
|
||||
opacity: 0.3;
|
||||
}
|
||||
.UserCard-lastSeen {
|
||||
& .icon {
|
||||
|
|
|
@ -40,7 +40,6 @@ class UserSerializer extends UserBasicSerializer
|
|||
$canEdit = $gate->allows('edit', $user);
|
||||
|
||||
$attributes += [
|
||||
'bio' => $user->bio,
|
||||
'joinTime' => $this->formatDate($user->join_time),
|
||||
'discussionsCount' => (int) $user->discussions_count,
|
||||
'commentsCount' => (int) $user->comments_count,
|
||||
|
|
|
@ -114,14 +114,6 @@ class EditUserHandler
|
|||
$validate['password'] = $attributes['password'];
|
||||
}
|
||||
|
||||
if (isset($attributes['bio'])) {
|
||||
if (! $isSelf) {
|
||||
$this->assertPermission($canEdit);
|
||||
}
|
||||
|
||||
$user->changeBio($attributes['bio']);
|
||||
}
|
||||
|
||||
if (! empty($attributes['readTime'])) {
|
||||
$this->assertPermission($isSelf);
|
||||
$user->markAllAsRead();
|
||||
|
|
|
@ -22,7 +22,6 @@ use Flarum\Event\GetDisplayName;
|
|||
use Flarum\Event\PostWasDeleted;
|
||||
use Flarum\Event\PrepareUserGroups;
|
||||
use Flarum\Event\UserAvatarWasChanged;
|
||||
use Flarum\Event\UserBioWasChanged;
|
||||
use Flarum\Event\UserEmailChangeWasRequested;
|
||||
use Flarum\Event\UserEmailWasChanged;
|
||||
use Flarum\Event\UserPasswordWasChanged;
|
||||
|
@ -42,7 +41,6 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|||
* @property bool $is_activated
|
||||
* @property string $password
|
||||
* @property string $locale
|
||||
* @property string $bio
|
||||
* @property string|null $avatar_path
|
||||
* @property string $avatar_url
|
||||
* @property array $preferences
|
||||
|
@ -263,21 +261,6 @@ class User extends AbstractModel
|
|||
$this->attributes['password'] = $value ? static::$hasher->make($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the user's bio.
|
||||
*
|
||||
* @param string $bio
|
||||
* @return $this
|
||||
*/
|
||||
public function changeBio($bio)
|
||||
{
|
||||
$this->bio = $bio;
|
||||
|
||||
$this->raise(new UserBioWasChanged($this));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark all discussions as read.
|
||||
*
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
|
||||
use Flarum\Core\User;
|
||||
|
||||
class UserBioWasChanged
|
||||
{
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $actor;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User $actor
|
||||
*/
|
||||
public function __construct(User $user, User $actor = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->actor = $actor;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user