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

Frontend ui refactor
This commit is contained in:
daniel 2018-08-22 22:34:44 -06:00 committed by GitHub
commit a157edc7b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 141 additions and 24 deletions

View file

@ -6,10 +6,21 @@ use Illuminate\Http\Request;
use Carbon\Carbon; use Carbon\Carbon;
use App\Mail\ConfirmEmail; use App\Mail\ConfirmEmail;
use Auth, DB, Cache, Mail, Redis; use Auth, DB, Cache, Mail, Redis;
use App\{EmailVerification, Notification, Profile, User}; use App\{
EmailVerification,
Notification,
Profile,
User,
UserFilter
};
class AccountController extends Controller class AccountController extends Controller
{ {
protected $filters = [
'user.mute',
'user.block'
];
public function __construct() public function __construct()
{ {
$this->middleware('auth'); $this->middleware('auth');
@ -134,4 +145,97 @@ class AccountController extends Controller
return $notifications; return $notifications;
} }
public function messages()
{
return view('account.messages');
}
public function showMessage(Request $request, $id)
{
return view('account.message');
}
public function mute(Request $request)
{
$this->validate($request, [
'type' => 'required|string',
'item' => 'required|integer|min:1'
]);
$user = Auth::user()->profile;
$type = $request->input('type');
$item = $request->input('item');
$action = "{$type}.mute";
if(!in_array($action, $this->filters)) {
return abort(406);
}
$filterable = [];
switch ($type) {
case 'user':
$profile = Profile::findOrFail($item);
if($profile->id == $user->id) {
return abort(403);
}
$class = get_class($profile);
$filterable['id'] = $profile->id;
$filterable['type'] = $class;
break;
default:
# code...
break;
}
$filter = UserFilter::firstOrCreate([
'user_id' => $user->id,
'filterable_id' => $filterable['id'],
'filterable_type' => $filterable['type'],
'filter_type' => 'mute'
]);
return redirect()->back();
}
public function block(Request $request)
{
$this->validate($request, [
'type' => 'required|string',
'item' => 'required|integer|min:1'
]);
$user = Auth::user()->profile;
$type = $request->input('type');
$item = $request->input('item');
$action = "{$type}.block";
if(!in_array($action, $this->filters)) {
return abort(406);
}
$filterable = [];
switch ($type) {
case 'user':
$profile = Profile::findOrFail($item);
$class = get_class($profile);
$filterable['id'] = $profile->id;
$filterable['type'] = $class;
break;
default:
# code...
break;
}
$filter = UserFilter::firstOrCreate([
'user_id' => $user->id,
'filterable_id' => $filterable['id'],
'filterable_type' => $filterable['type'],
'filter_type' => 'block'
]);
return redirect()->back();
}
} }

View file

@ -6,5 +6,10 @@ use Illuminate\Database\Eloquent\Model;
class UserFilter extends Model class UserFilter extends Model
{ {
// protected $fillable = [
'user_id',
'filterable_id',
'filterable_type',
'filter_type'
];
} }

View file

@ -30,7 +30,7 @@
<li class="nav-item px-2"> <li class="nav-item px-2">
<div title="Create new post" data-toggle="tooltip" data-placement="bottom"> <div title="Create new post" data-toggle="tooltip" data-placement="bottom">
<a href="{{route('compose')}}" class="nav-link" data-toggle="modal" data-target="#composeModal"> <a href="{{route('compose')}}" class="nav-link" data-toggle="modal" data-target="#composeModal">
<i class="far fa-plus-square fa-lg text-primary"></i> <i class="fas fa-camera-retro fa-lg text-primary"></i>
</a> </a>
</div> </div>
</li> </li>

View file

@ -1,21 +0,0 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class InstalledTest extends TestCase
{
public function testLandingTest()
{
$response = $this->get('/');
$response
->assertStatus(200)
->assertSeeText('Image Sharing for Everyone');
}
public function testNodeinfoTest()
{
$response = $this->get('/.well-known/nodeinfo');
$response
->assertStatus(200)
->assertJson([
"links" => [
["rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0"]
]]);
}
}