Skip to content

Commit

Permalink
feat(users): add optional alias display on user profiles (#583)
Browse files Browse the repository at this point in the history
* feat(user): Added aliases on userprofile feature

* refactor: fix blade formatting

* space fixing, very minor

* refactor: fix PHP styling

---------

Co-authored-by: SpeedyD <SpeedyD@users.noreply.github.com>
  • Loading branch information
SpeedyD and SpeedyD committed Apr 28, 2023
1 parent d631f04 commit 90d3841
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/Http/Controllers/Users/UserController.php
Expand Up @@ -59,10 +59,16 @@ public function getUser($name) {
$characters->visible();
}

$aliases = $this->user->aliases();
if (!Auth::check() || !(Auth::check() && Auth::user()->hasPower('edit_user_info'))) {
$aliases->visible();
}

return view('user.profile', [
'user' => $this->user,
'items' => $this->user->items()->where('count', '>', 0)->orderBy('user_items.updated_at', 'DESC')->take(4)->get(),
'characters' => $characters,
'aliases' => $aliases->orderBy('is_primary_alias', 'DESC')->orderBy('site')->get(),
]);
}

Expand Down
4 changes: 4 additions & 0 deletions config/lorekeeper/extensions.php
Expand Up @@ -80,4 +80,8 @@
'display' => 0,
'reverse' => 0, // By default, 0 has the lower number on the 'Next' side and the higher number on the 'Previous' side, reflecting the default masterlist order. Setting this to 1 reverses this.
],

// Aliases on Userpage - Speedy
'aliases_on_userpage' => 0, // By default, does not display the aliases on userpage. Enable to add a small arrow to display these underneath the primary alias.

];
3 changes: 3 additions & 0 deletions resources/views/pages/credits.blade.php
Expand Up @@ -72,6 +72,9 @@
<a href="http://wiki.lorekeeper.me/index.php?title=Extensions:90_Percent_Watermark"><strong>Watermark Resizing</strong></a> by <a href="https://github.com/SpeedyD">Speedy</a>
</p>

<p class="mb-0 col-md-4">
<strong>Aliases on Userpage</strong> by <a href="https://github.com/SpeedyD">Speedy</a> ({{ Config::get('lorekeeper.extensions.aliases_on_userpage') ? 'Enabled' : 'Disabled' }})
</p>
<p class="mb-0 col-md-4">
<strong>Auto-populate New Image Traits</strong> by <a href="https://github.com/itinerare">itinerare</a> ({{ Config::get('lorekeeper.extensions.autopopulate_image_features') ? 'Enabled' : 'Disabled' }})
</p>
Expand Down
14 changes: 13 additions & 1 deletion resources/views/user/_profile_content.blade.php
Expand Up @@ -16,7 +16,19 @@
<div class="col-md-2 col-4">
<h5>Alias</h5>
</div>
<div class="col-md-10 col-8">{!! $user->displayAlias !!}</div>
<div class="col-md-10 col-8">
{!! $user->displayAlias !!}
@if (count($aliases) > 1 && Config::get('lorekeeper.extensions.aliases_on_userpage'))
<a class="small collapse-toggle collapsed" href="#otherUserAliases" data-toggle="collapse">&nbsp;</a>
<p class="collapse mb-0" id="otherUserAliases">
@foreach ($aliases as $alias)
@if ($alias != $user->primaryAlias)
<a href="{{ $alias->url }}"><i class="{{ $alias->config['icon'] }} fa-fw mr-1" data-toggle="tooltip" title="{{ $alias->alias . '@' . $alias->siteDisplayName }}"></i></a>
@endif
@endforeach
</p>
@endif
</div>
</div>
<div class="row col-md-6">
<div class="col-md-2 col-4">
Expand Down

0 comments on commit 90d3841

Please sign in to comment.