1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2025-03-13 23:49:13 +00:00

Update Profile, add linkified bio, joined date, follows you label and improved website handling

This commit is contained in:
Daniel Supernault 2021-06-10 22:54:31 -06:00
parent fbd77f4410
commit 8ee104363a
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 2236 additions and 2211 deletions

View file

@ -55,6 +55,7 @@ use App\Services\{
StatusService,
MediaBlocklistService
};
use App\Util\Lexer\Autolink;
class ApiV1Controller extends Controller
{
@ -192,8 +193,8 @@ class ApiV1Controller extends Controller
$changes = true;
}
if($note !== $profile->bio) {
$profile->bio = e($note);
if($note !== strip_tags($profile->bio)) {
$profile->bio = Autolink::create()->autolink(strip_tags($note));
$changes = true;
}

View file

@ -8,6 +8,7 @@ use App\Media;
use App\Profile;
use App\User;
use App\UserFilter;
use App\Util\Lexer\Autolink;
use App\Util\Lexer\PrettyNumber;
use Auth;
use Cache;
@ -75,9 +76,9 @@ trait HomeSettings
$profile->website = $website;
}
if ($profile->bio != $bio) {
if (strip_tags($profile->bio) != $bio) {
$changes = true;
$profile->bio = $bio;
$profile->bio = Autolink::create()->autolink($bio);
}
if($user->language != $language &&

View file

@ -103,10 +103,6 @@
<div class="profile-details">
<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="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 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>
@ -144,12 +140,21 @@
</a>
</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 v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</span>
</p>
<div v-if="profile.note" class="mb-0" v-html="profile.note"></div>
<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.note" class="mb-0" v-html="profile.note"></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>
@ -1316,6 +1321,24 @@
return _.truncate(str, {
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();
}
}
}

View file

@ -51,7 +51,7 @@
<div class="form-group row">
<label for="bio" class="col-sm-3 col-form-label font-weight-bold">Bio</label>
<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">
<span class="bio-counter float-right small text-muted">0/{{config('pixelfed.max_bio_length')}}</span>
</p>