mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 17:53:16 +00:00
Merge pull request #2799 from pixelfed/staging
Update Profile, add linkified bio, joined date, follows you label and improved website handling
This commit is contained in:
commit
ed3ba496dc
7 changed files with 2237 additions and 2211 deletions
|
@ -11,6 +11,7 @@
|
||||||
- Updated Timeline, implement suggested post opt out. ([66750d34](https://github.com/pixelfed/pixelfed/commit/66750d34))
|
- Updated Timeline, implement suggested post opt out. ([66750d34](https://github.com/pixelfed/pixelfed/commit/66750d34))
|
||||||
- Updated Notification component, add at (@) symbol for remote profiles and local urls for remote posts and profile. ([aafd6a21](https://github.com/pixelfed/pixelfed/commit/aafd6a21))
|
- Updated Notification component, add at (@) symbol for remote profiles and local urls for remote posts and profile. ([aafd6a21](https://github.com/pixelfed/pixelfed/commit/aafd6a21))
|
||||||
- Updated Activity component, add at (@) symbol for remote profiles and local urls for remote posts and profile. ([a2211815](https://github.com/pixelfed/pixelfed/commit/a2211815))
|
- Updated Activity component, add at (@) symbol for remote profiles and local urls for remote posts and profile. ([a2211815](https://github.com/pixelfed/pixelfed/commit/a2211815))
|
||||||
|
- Updated Profile, add linkified bio, joined date, follows you label and improved website handling. ([8ee10436](https://github.com/pixelfed/pixelfed/commit/8ee10436))
|
||||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.11.0 (2021-06-01)](https://github.com/pixelfed/pixelfed/compare/v0.10.10...v0.11.0)
|
## [v0.11.0 (2021-06-01)](https://github.com/pixelfed/pixelfed/compare/v0.10.10...v0.11.0)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,7 @@ use App\Media;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\User;
|
use App\User;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
|
use App\Util\Lexer\Autolink;
|
||||||
use App\Util\Lexer\PrettyNumber;
|
use App\Util\Lexer\PrettyNumber;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Cache;
|
use Cache;
|
||||||
|
@ -21,23 +22,23 @@ use App\Services\PronounService;
|
||||||
trait HomeSettings
|
trait HomeSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public function home()
|
public function home()
|
||||||
{
|
{
|
||||||
$id = Auth::user()->profile->id;
|
$id = Auth::user()->profile->id;
|
||||||
$storage = [];
|
$storage = [];
|
||||||
$used = Media::whereProfileId($id)->sum('size');
|
$used = Media::whereProfileId($id)->sum('size');
|
||||||
$storage['limit'] = config_cache('pixelfed.max_account_size') * 1024;
|
$storage['limit'] = config_cache('pixelfed.max_account_size') * 1024;
|
||||||
$storage['used'] = $used;
|
$storage['used'] = $used;
|
||||||
$storage['percentUsed'] = ceil($storage['used'] / $storage['limit'] * 100);
|
$storage['percentUsed'] = ceil($storage['used'] / $storage['limit'] * 100);
|
||||||
$storage['limitPretty'] = PrettyNumber::size($storage['limit']);
|
$storage['limitPretty'] = PrettyNumber::size($storage['limit']);
|
||||||
$storage['usedPretty'] = PrettyNumber::size($storage['used']);
|
$storage['usedPretty'] = PrettyNumber::size($storage['used']);
|
||||||
$pronouns = PronounService::get($id);
|
$pronouns = PronounService::get($id);
|
||||||
|
|
||||||
return view('settings.home', compact('storage', 'pronouns'));
|
return view('settings.home', compact('storage', 'pronouns'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function homeUpdate(Request $request)
|
public function homeUpdate(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'name' => 'required|string|max:'.config('pixelfed.max_name_length'),
|
'name' => 'required|string|max:'.config('pixelfed.max_name_length'),
|
||||||
'bio' => 'nullable|string|max:'.config('pixelfed.max_bio_length'),
|
'bio' => 'nullable|string|max:'.config('pixelfed.max_bio_length'),
|
||||||
|
@ -46,164 +47,164 @@ trait HomeSettings
|
||||||
'pronouns' => 'nullable|array|max:4'
|
'pronouns' => 'nullable|array|max:4'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$changes = false;
|
$changes = false;
|
||||||
$name = strip_tags(Purify::clean($request->input('name')));
|
$name = strip_tags(Purify::clean($request->input('name')));
|
||||||
$bio = $request->filled('bio') ? strip_tags(Purify::clean($request->input('bio'))) : null;
|
$bio = $request->filled('bio') ? strip_tags(Purify::clean($request->input('bio'))) : null;
|
||||||
$website = $request->input('website');
|
$website = $request->input('website');
|
||||||
$language = $request->input('language');
|
$language = $request->input('language');
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
$pronouns = $request->input('pronouns');
|
$pronouns = $request->input('pronouns');
|
||||||
$existingPronouns = PronounService::get($profile->id);
|
$existingPronouns = PronounService::get($profile->id);
|
||||||
$layout = $request->input('profile_layout');
|
$layout = $request->input('profile_layout');
|
||||||
if($layout) {
|
if($layout) {
|
||||||
$layout = !in_array($layout, ['metro', 'moment']) ? 'metro' : $layout;
|
$layout = !in_array($layout, ['metro', 'moment']) ? 'metro' : $layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
$enforceEmailVerification = config_cache('pixelfed.enforce_email_verification');
|
$enforceEmailVerification = config_cache('pixelfed.enforce_email_verification');
|
||||||
|
|
||||||
// Only allow email to be updated if not yet verified
|
// Only allow email to be updated if not yet verified
|
||||||
if (!$enforceEmailVerification || !$changes && $user->email_verified_at) {
|
if (!$enforceEmailVerification || !$changes && $user->email_verified_at) {
|
||||||
if ($profile->name != $name) {
|
if ($profile->name != $name) {
|
||||||
$changes = true;
|
$changes = true;
|
||||||
$user->name = $name;
|
$user->name = $name;
|
||||||
$profile->name = $name;
|
$profile->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($profile->website != $website) {
|
if ($profile->website != $website) {
|
||||||
$changes = true;
|
$changes = true;
|
||||||
$profile->website = $website;
|
$profile->website = $website;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($profile->bio != $bio) {
|
if (strip_tags($profile->bio) != $bio) {
|
||||||
$changes = true;
|
$changes = true;
|
||||||
$profile->bio = $bio;
|
$profile->bio = Autolink::create()->autolink($bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($user->language != $language &&
|
if($user->language != $language &&
|
||||||
in_array($language, \App\Util\Localization\Localization::languages())
|
in_array($language, \App\Util\Localization\Localization::languages())
|
||||||
) {
|
) {
|
||||||
$changes = true;
|
$changes = true;
|
||||||
$user->language = $language;
|
$user->language = $language;
|
||||||
session()->put('locale', $language);
|
session()->put('locale', $language);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($existingPronouns != $pronouns) {
|
if($existingPronouns != $pronouns) {
|
||||||
if($pronouns && in_array('Select Pronoun(s)', $pronouns)) {
|
if($pronouns && in_array('Select Pronoun(s)', $pronouns)) {
|
||||||
PronounService::clear($profile->id);
|
PronounService::clear($profile->id);
|
||||||
} else {
|
} else {
|
||||||
PronounService::put($profile->id, $pronouns);
|
PronounService::put($profile->id, $pronouns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($changes === true) {
|
if ($changes === true) {
|
||||||
Cache::forget('user:account:id:'.$user->id);
|
Cache::forget('user:account:id:'.$user->id);
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
|
|
||||||
return redirect('/settings/home')->with('status', 'Profile successfully updated!');
|
return redirect('/settings/home')->with('status', 'Profile successfully updated!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect('/settings/home');
|
return redirect('/settings/home');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function password()
|
public function password()
|
||||||
{
|
{
|
||||||
return view('settings.password');
|
return view('settings.password');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function passwordUpdate(Request $request)
|
public function passwordUpdate(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'current' => 'required|string',
|
'current' => 'required|string',
|
||||||
'password' => 'required|string',
|
'password' => 'required|string',
|
||||||
'password_confirmation' => 'required|string',
|
'password_confirmation' => 'required|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$current = $request->input('current');
|
$current = $request->input('current');
|
||||||
$new = $request->input('password');
|
$new = $request->input('password');
|
||||||
$confirm = $request->input('password_confirmation');
|
$confirm = $request->input('password_confirmation');
|
||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
if (password_verify($current, $user->password) && $new === $confirm) {
|
if (password_verify($current, $user->password) && $new === $confirm) {
|
||||||
$user->password = bcrypt($new);
|
$user->password = bcrypt($new);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$log = new AccountLog();
|
$log = new AccountLog();
|
||||||
$log->user_id = $user->id;
|
$log->user_id = $user->id;
|
||||||
$log->item_id = $user->id;
|
$log->item_id = $user->id;
|
||||||
$log->item_type = 'App\User';
|
$log->item_type = 'App\User';
|
||||||
$log->action = 'account.edit.password';
|
$log->action = 'account.edit.password';
|
||||||
$log->message = 'Password changed';
|
$log->message = 'Password changed';
|
||||||
$log->link = null;
|
$log->link = null;
|
||||||
$log->ip_address = $request->ip();
|
$log->ip_address = $request->ip();
|
||||||
$log->user_agent = $request->userAgent();
|
$log->user_agent = $request->userAgent();
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
Mail::to($request->user())->send(new PasswordChange($user));
|
Mail::to($request->user())->send(new PasswordChange($user));
|
||||||
return redirect('/settings/home')->with('status', 'Password successfully updated!');
|
return redirect('/settings/home')->with('status', 'Password successfully updated!');
|
||||||
} else {
|
} else {
|
||||||
return redirect()->back()->with('error', 'There was an error with your request! Please try again.');
|
return redirect()->back()->with('error', 'There was an error with your request! Please try again.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function email()
|
public function email()
|
||||||
{
|
{
|
||||||
return view('settings.email');
|
return view('settings.email');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function emailUpdate(Request $request)
|
public function emailUpdate(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
]);
|
]);
|
||||||
$changes = false;
|
$changes = false;
|
||||||
$email = $request->input('email');
|
$email = $request->input('email');
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
|
|
||||||
$validate = config_cache('pixelfed.enforce_email_verification');
|
$validate = config_cache('pixelfed.enforce_email_verification');
|
||||||
|
|
||||||
if ($user->email != $email) {
|
if ($user->email != $email) {
|
||||||
$changes = true;
|
$changes = true;
|
||||||
$user->email = $email;
|
$user->email = $email;
|
||||||
|
|
||||||
if ($validate) {
|
if ($validate) {
|
||||||
$user->email_verified_at = null;
|
$user->email_verified_at = null;
|
||||||
// Prevent old verifications from working
|
// Prevent old verifications from working
|
||||||
EmailVerification::whereUserId($user->id)->delete();
|
EmailVerification::whereUserId($user->id)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = new AccountLog();
|
$log = new AccountLog();
|
||||||
$log->user_id = $user->id;
|
$log->user_id = $user->id;
|
||||||
$log->item_id = $user->id;
|
$log->item_id = $user->id;
|
||||||
$log->item_type = 'App\User';
|
$log->item_type = 'App\User';
|
||||||
$log->action = 'account.edit.email';
|
$log->action = 'account.edit.email';
|
||||||
$log->message = 'Email changed';
|
$log->message = 'Email changed';
|
||||||
$log->link = null;
|
$log->link = null;
|
||||||
$log->ip_address = $request->ip();
|
$log->ip_address = $request->ip();
|
||||||
$log->user_agent = $request->userAgent();
|
$log->user_agent = $request->userAgent();
|
||||||
$log->save();
|
$log->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($changes === true) {
|
if ($changes === true) {
|
||||||
Cache::forget('user:account:id:'.$user->id);
|
Cache::forget('user:account:id:'.$user->id);
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
|
|
||||||
return redirect('/settings/home')->with('status', 'Email successfully updated!');
|
return redirect('/settings/home')->with('status', 'Email successfully updated!');
|
||||||
} else {
|
} else {
|
||||||
return redirect('/settings/email');
|
return redirect('/settings/email');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function avatar()
|
public function avatar()
|
||||||
{
|
{
|
||||||
return view('settings.avatar');
|
return view('settings.avatar');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
BIN
public/js/profile.js
vendored
BIN
public/js/profile.js
vendored
Binary file not shown.
Binary file not shown.
|
@ -103,10 +103,6 @@
|
||||||
<div class="profile-details">
|
<div class="profile-details">
|
||||||
<div class="d-none d-md-flex username-bar pb-3 align-items-center">
|
<div class="d-none d-md-flex username-bar pb-3 align-items-center">
|
||||||
<span class="font-weight-ultralight h3 mb-0">{{profile.username}}</span>
|
<span class="font-weight-ultralight h3 mb-0">{{profile.username}}</span>
|
||||||
<span class="pl-1 pb-2 fa-stack" v-if="profile.is_admin" title="Admin Account" data-toggle="tooltip">
|
|
||||||
<i class="fas fa-certificate fa-lg text-danger fa-stack-1x"></i>
|
|
||||||
<i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:9px;"></i>
|
|
||||||
</span>
|
|
||||||
<span v-if="profile.id != user.id && user.hasOwnProperty('id')">
|
<span v-if="profile.id != user.id && user.hasOwnProperty('id')">
|
||||||
<span class="pl-4" v-if="relationship.following == true">
|
<span class="pl-4" v-if="relationship.following == true">
|
||||||
<a :href="'/account/direct/t/'+profile.id" class="btn btn-outline-secondary font-weight-bold btn-sm py-1 text-dark mr-2 px-3 btn-sec-alt" style="border:1px solid #dbdbdb;" data-toggle="tooltip" title="Message">Message</a>
|
<a :href="'/account/direct/t/'+profile.id" class="btn btn-outline-secondary font-weight-bold btn-sm py-1 text-dark mr-2 px-3 btn-sec-alt" style="border:1px solid #dbdbdb;" data-toggle="tooltip" title="Message">Message</a>
|
||||||
|
@ -144,12 +140,21 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="mb-0 d-flex align-items-center">
|
<p class="d-flex align-items-center mb-1">
|
||||||
<span class="font-weight-bold mr-1">{{profile.display_name}}</span>
|
<span class="font-weight-bold mr-1">{{profile.display_name}}</span>
|
||||||
<span v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</span>
|
<span v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</span>
|
||||||
</p>
|
</p>
|
||||||
<div v-if="profile.note" class="mb-0" v-html="profile.note"></div>
|
<p v-if="profile.note" class="mb-0" v-html="profile.note"></p>
|
||||||
<p v-if="profile.website" class=""><a :href="profile.website" class="profile-website" rel="me external nofollow noopener" target="_blank" @click.prevent="remoteRedirect(profile.website)">{{truncate(profile.website,24)}}</a></p>
|
<p v-if="profile.website"><a :href="profile.website" class="profile-website small" rel="me external nofollow noopener" target="_blank" @click.prevent="remoteRedirect(profile.website)">{{formatWebsite(profile.website)}}</a></p>
|
||||||
|
<p class="d-flex small text-muted align-items-center">
|
||||||
|
<span v-if="profile.is_admin" class="btn btn-outline-danger btn-sm py-0 mr-3" title="Admin Account" data-toggle="tooltip">
|
||||||
|
Admin
|
||||||
|
</span>
|
||||||
|
<span v-if="relationship && relationship.followed_by" class="btn btn-outline-muted btn-sm py-0 mr-3">Follows You</span>
|
||||||
|
<span>
|
||||||
|
Joined {{joinedAtFormat(profile.created_at)}}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1316,6 +1321,24 @@
|
||||||
return _.truncate(str, {
|
return _.truncate(str, {
|
||||||
length: len
|
length: len
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
formatWebsite(site) {
|
||||||
|
if(site.slice(0, 8) === 'https://') {
|
||||||
|
site = site.substr(8);
|
||||||
|
} else if(site.slice(0, 7) === 'http://') {
|
||||||
|
site = site.substr(7);
|
||||||
|
} else {
|
||||||
|
this.profile.website = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.truncate(site, 60);
|
||||||
|
},
|
||||||
|
|
||||||
|
joinedAtFormat(created) {
|
||||||
|
let d = new Date(created);
|
||||||
|
return d.toDateString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="bio" class="col-sm-3 col-form-label font-weight-bold">Bio</label>
|
<label for="bio" class="col-sm-3 col-form-label font-weight-bold">Bio</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<textarea class="form-control" id="bio" name="bio" placeholder="Add a bio here" rows="2" data-max-length="{{config('pixelfed.max_bio_length')}}" v-pre>{{Auth::user()->profile->bio}}</textarea>
|
<textarea class="form-control" id="bio" name="bio" placeholder="Add a bio here" rows="2" data-max-length="{{config('pixelfed.max_bio_length')}}" v-pre>{{strip_tags(Auth::user()->profile->bio)}}</textarea>
|
||||||
<p class="form-text">
|
<p class="form-text">
|
||||||
<span class="bio-counter float-right small text-muted">0/{{config('pixelfed.max_bio_length')}}</span>
|
<span class="bio-counter float-right small text-muted">0/{{config('pixelfed.max_bio_length')}}</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in a new issue