1
0
Fork 0

Merge pull request #422 from pixelfed/frontend-ui-refactor

Frontend ui refactor
This commit is contained in:
daniel 2018-08-30 22:32:54 -06:00 committed by GitHub
commit d0b4c4f765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 202 additions and 2 deletions

View File

@ -6,6 +6,7 @@ use App\Follower;
use App\Hashtag;
use App\Profile;
use App\Status;
use App\UserFilter;
use Auth;
use Illuminate\Http\Request;
@ -23,6 +24,13 @@ class DiscoverController extends Controller
$following = Follower::whereProfileId($pid)
->pluck('following_id');
$filtered = UserFilter::whereUserId($pid)
->whereFilterableType('App\Profile')
->whereIn('filter_type', ['mute', 'block'])
->pluck('filterable_id');
$following = $following->push($filtered);
$people = Profile::inRandomOrder()
->where('id', '!=', $pid)
->whereNotIn('id', $following)

View File

@ -7,6 +7,7 @@ use App\EmailVerification;
use App\Media;
use App\Profile;
use App\User;
use App\UserFilter;
use App\Util\Lexer\PrettyNumber;
use Auth;
use DB;
@ -254,4 +255,64 @@ class SettingsController extends Controller
{
return view('settings.developers');
}
public function mutedUsers()
{
$pid = Auth::user()->profile->id;
$ids = (new UserFilter())->mutedUserIds($pid);
$users = Profile::whereIn('id', $ids)->simplePaginate(15);
return view('settings.privacy.muted', compact('users'));
}
public function mutedUsersUpdate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|integer|min:1'
]);
$fid = $request->input('profile_id');
$pid = Auth::user()->profile->id;
DB::transaction(function () use ($fid, $pid) {
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterType('mute')
->firstOrFail();
$filter->delete();
});
return redirect()->back();
}
public function blockedUsers()
{
$pid = Auth::user()->profile->id;
$ids = (new UserFilter())->blockedUserIds($pid);
$users = Profile::whereIn('id', $ids)->simplePaginate(15);
return view('settings.privacy.blocked', compact('users'));
}
public function blockedUsersUpdate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|integer|min:1'
]);
$fid = $request->input('profile_id');
$pid = Auth::user()->profile->id;
DB::transaction(function () use ($fid, $pid) {
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterType('block')
->firstOrFail();
$filter->delete();
});
return redirect()->back();
}
public function blockedInstances()
{
$settings = Auth::user()->settings;
return view('settings.privacy.blocked-instances');
}
}

View File

@ -7,6 +7,7 @@ use App\Follower;
use App\Profile;
use App\Status;
use App\User;
use App\UserFilter;
use App\Util\Lexer\PrettyNumber;
use Auth;
use Cache;
@ -30,10 +31,16 @@ class SiteController extends Controller
public function homeTimeline()
{
$pid = Auth::user()->profile->id;
// TODO: Use redis for timelines
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
$following->push(Auth::user()->profile->id);
$filtered = UserFilter::whereUserId($pid)
->whereFilterableType('App\Profile')
->whereIn('filter_type', ['mute', 'block'])
->pluck('filterable_id');
$timeline = Status::whereIn('profile_id', $following)
->whereNotIn('profile_id', $filtered)
->whereHas('media')
->orderBy('id', 'desc')
->withCount(['comments', 'likes', 'shares'])

View File

@ -12,4 +12,21 @@ class UserFilter extends Model
'filterable_type',
'filter_type',
];
public function mutedUserIds($profile_id)
{
return $this->whereUserId($profile_id)
->whereFilterableType('App\Profile')
->whereFilterType('mute')
->pluck('filterable_id');
}
public function blockedUserIds($profile_id)
{
return $this->whereUserId($profile_id)
->whereFilterableType('App\Profile')
->whereFilterType('block')
->pluck('filterable_id');
}
}

View File

@ -23,7 +23,7 @@ return [
| This value is the version of your PixelFed instance.
|
*/
'version' => '0.1.7',
'version' => '0.1.8',
/*
|--------------------------------------------------------------------------

View File

@ -16,7 +16,7 @@
<a class="nav-link font-weight-light text-muted" href="{{route('settings.notifications')}}">Notifications</a>
</li>
--}}
<li class="nav-item pl-3 {{request()->is('settings/privacy')?'active':''}}">
<li class="nav-item pl-3 {{request()->is('settings/privacy*')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.privacy')}}">Privacy</a>
</li>
{{-- <li class="nav-item pl-3 {{request()->is('settings/security')?'active':''}}">

View File

@ -6,6 +6,12 @@
<h3 class="font-weight-bold">Privacy Settings</h3>
</div>
<hr>
<div class="form-group pb-1">
<p>
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.muted-users')}}">Muted Users</a>
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-users')}}">Blocked Users</a>
</p>
</div>
<form method="post">
@csrf
<div class="form-check pb-3">

View File

@ -0,0 +1,39 @@
@extends('settings.template')
@section('section')
<div class="title">
<h3 class="font-weight-bold">Blocked Users</h3>
</div>
<hr>
<div class="form-group pb-1">
<p>
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.muted-users')}}">Muted Users</a>
<a class="btn btn-outline-primary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-users')}}">Blocked Users</a>
</p>
</div>
@if($users->count() > 0)
<ul class="list-group list-group-flush">
@foreach($users as $user)
<li class="list-group-item">
<div class="d-flex justify-content-between align-items-center font-weight-bold">
<span><img class="rounded-circle mr-3" src="{{$user->avatarUrl()}}" width="32px">{{$user->emailUrl()}}</span>
<span class="btn-group">
<form method="post">
@csrf
<input type="hidden" name="profile_id" value="{{$user->id}}">
<button type="submit" class="btn btn-outline-secondary btn-sm px-3 font-weight-bold">Unblock</button>
</form>
</span>
</div>
</li>
@endforeach
</ul>
<div class="d-flex justify-content-center mt-3 font-weight-bold">
{{$users->links()}}
</div>
@else
<p class="lead">You are not blocking any accounts.</p>
@endif
@endsection

View File

@ -0,0 +1,39 @@
@extends('settings.template')
@section('section')
<div class="title">
<h3 class="font-weight-bold">Muted Users</h3>
</div>
<hr>
<div class="form-group pb-1">
<p>
<a class="btn btn-outline-primary py-0 font-weight-bold" href="{{route('settings.privacy.muted-users')}}">Muted Users</a>
<a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-users')}}">Blocked Users</a>
</p>
</div>
@if($users->count() > 0)
<ul class="list-group list-group-flush">
@foreach($users as $user)
<li class="list-group-item">
<div class="d-flex justify-content-between align-items-center font-weight-bold">
<span><img class="rounded-circle mr-3" src="{{$user->avatarUrl()}}" width="32px">{{$user->emailUrl()}}</span>
<span class="btn-group">
<form method="post">
@csrf
<input type="hidden" name="profile_id" value="{{$user->id}}">
<button type="submit" class="btn btn-outline-secondary btn-sm px-3 font-weight-bold">Unmute</button>
</form>
</span>
</div>
</li>
@endforeach
</ul>
<div class="d-flex justify-content-center mt-3 font-weight-bold">
{{$users->links()}}
</div>
@else
<p class="lead">You are not muting any accounts.</p>
@endif
@endsection

View File

@ -14,7 +14,23 @@
<a class="dropdown-item font-weight-bold" href="{{route('report.form')}}?type=post&id={{$item->id}}">Report</a>
<a class="dropdown-item font-weight-bold" href="#">Embed</a>
@if(Auth::check())
@if(Auth::user()->profile->id !== $item->profile->id)
<div class="dropdown-divider"></div>
<form method="post" action="/i/mute">
@csrf
<input type="hidden" name="type" value="user">
<input type="hidden" name="item" value="{{$item->profile_id}}">
<button type="submit" class="dropdown-item btn btn-link font-weight-bold">Mute this user</button>
</form>
<form method="post" action="/i/block">
@csrf
<input type="hidden" name="type" value="user">
<input type="hidden" name="item" value="{{$item->profile_id}}">
<button type="submit" class="dropdown-item btn btn-link font-weight-bold">Block this user</button>
</form>
@endif
@if(Auth::user()->profile->id === $item->profile->id || Auth::user()->is_admin == true)
<div class="dropdown-divider"></div>
<a class="dropdown-item font-weight-bold" href="{{$item->editUrl()}}">Edit</a>
<form method="post" action="/i/delete">
@csrf

View File

@ -54,6 +54,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu
Route::post('remote-follow', 'FederationController@remoteFollowStore');
Route::post('comment', 'CommentController@store');
Route::post('delete', 'StatusController@delete');
Route::post('mute', 'AccountController@mute');
Route::post('block', 'AccountController@block');
Route::post('like', 'LikeController@store');
Route::post('share', 'StatusController@storeShare');
Route::post('follow', 'FollowerController@store');
@ -97,6 +99,11 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu
Route::get('notifications', 'SettingsController@notifications')->name('settings.notifications');
Route::get('privacy', 'SettingsController@privacy')->name('settings.privacy');
Route::post('privacy', 'SettingsController@privacyStore');
Route::get('privacy/muted-users', 'SettingsController@mutedUsers')->name('settings.privacy.muted-users');
Route::post('privacy/muted-users', 'SettingsController@mutedUsersUpdate');
Route::get('privacy/blocked-users', 'SettingsController@blockedUsers')->name('settings.privacy.blocked-users');
Route::post('privacy/blocked-users', 'SettingsController@blockedUsersUpdate');
Route::get('privacy/blocked-instances', 'SettingsController@blockedInstances')->name('settings.privacy.blocked-instances');
Route::get('security', 'SettingsController@security')->name('settings.security');
Route::get('applications', 'SettingsController@applications')->name('settings.applications');
Route::get('data-export', 'SettingsController@dataExport')->name('settings.dataexport');