mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Merge pull request #488 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
af5cc6e557
10 changed files with 136 additions and 36 deletions
|
@ -2,43 +2,86 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use App\Hashtag;
|
||||
use App\Profile;
|
||||
use App\Status;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function searchAPI(Request $request, $tag)
|
||||
{
|
||||
$res = Cache::remember('api:search:tag:'.$tag, 1440, function () use ($tag) {
|
||||
$res = Hashtag::where('slug', 'like', '%'.$tag.'%')->get();
|
||||
$tags = $res->map(function ($item, $key) {
|
||||
return [
|
||||
'count' => $item->posts()->count(),
|
||||
'url' => $item->url(),
|
||||
'type' => 'hashtag',
|
||||
'value' => $item->name,
|
||||
'tokens' => explode('-', $item->name),
|
||||
'name' => null,
|
||||
];
|
||||
});
|
||||
$res = Profile::where('username', 'like', '%'.$tag.'%')->get();
|
||||
$profiles = $res->map(function ($item, $key) {
|
||||
return [
|
||||
'count' => 0,
|
||||
'url' => $item->url(),
|
||||
'type' => 'profile',
|
||||
'value' => $item->username,
|
||||
'tokens' => [$item->username],
|
||||
'name' => $item->name,
|
||||
];
|
||||
});
|
||||
$tags = $tags->push($profiles[0]);
|
||||
if(mb_strlen($tag) < 3) {
|
||||
return;
|
||||
}
|
||||
$hash = hash('sha256', $tag);
|
||||
$tokens = Cache::remember('api:search:tag:'.$hash, 60, function () use ($tag) {
|
||||
$tokens = collect([]);
|
||||
$hashtags = Hashtag::select('id', 'name', 'slug')->where('slug', 'like', '%'.$tag.'%')->limit(20)->get();
|
||||
if($hashtags->count() > 0) {
|
||||
$tags = $hashtags->map(function ($item, $key) {
|
||||
return [
|
||||
'count' => $item->posts()->count(),
|
||||
'url' => $item->url(),
|
||||
'type' => 'hashtag',
|
||||
'value' => $item->name,
|
||||
'tokens' => explode('-', $item->name),
|
||||
'name' => null,
|
||||
];
|
||||
});
|
||||
$tokens->push($tags);
|
||||
}
|
||||
$users = Profile::select('username', 'name', 'id')->where('username', 'like', '%'.$tag.'%')->limit(20)->get();
|
||||
|
||||
return $tags;
|
||||
if($users->count() > 0) {
|
||||
$profiles = $users->map(function ($item, $key) {
|
||||
return [
|
||||
'count' => 0,
|
||||
'url' => $item->url(),
|
||||
'type' => 'profile',
|
||||
'value' => $item->username,
|
||||
'tokens' => [$item->username],
|
||||
'name' => $item->name,
|
||||
];
|
||||
});
|
||||
$tokens->push($profiles);
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
});
|
||||
$posts = Status::select('id', 'profile_id', 'caption', 'created_at')
|
||||
->whereHas('media')
|
||||
->whereNull('in_reply_to_id')
|
||||
->whereNull('reblog_of_id')
|
||||
->whereProfileId(Auth::user()->profile->id)
|
||||
->where('caption', 'like', '%'.$tag.'%')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
return response()->json($res);
|
||||
if($posts->count() > 0) {
|
||||
$posts = $posts->map(function($item, $key) {
|
||||
return [
|
||||
'count' => 0,
|
||||
'url' => $item->url(),
|
||||
'type' => 'status',
|
||||
'value' => 'Posted '.$item->created_at->diffForHumans(),
|
||||
'tokens' => [$item->caption],
|
||||
'name' => $item->caption,
|
||||
'thumb' => $item->thumb(),
|
||||
];
|
||||
});
|
||||
$tokens = $tokens->push($posts);
|
||||
}
|
||||
if($tokens->count() > 0) {
|
||||
$tokens = $tokens[0];
|
||||
}
|
||||
return response()->json($tokens);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,13 @@ class StatusController extends Controller
|
|||
}
|
||||
|
||||
$this->validate($request, [
|
||||
'photo.*' => 'required|mimes:jpeg,png,gif|max:'.config('pixelfed.max_photo_size'),
|
||||
'photo.*' => function() {
|
||||
return [
|
||||
'required',
|
||||
'mimes:' . config('pixelfed.media_types'),
|
||||
'max:' . config('pixelfed.max_photo_size'),
|
||||
];
|
||||
},
|
||||
'caption' => 'string|max:'.config('pixelfed.max_caption_length'),
|
||||
'cw' => 'nullable|string',
|
||||
'filter_class' => 'nullable|string',
|
||||
|
|
|
@ -196,6 +196,30 @@ class Profile extends Model
|
|||
->pluck('filterable_id');
|
||||
}
|
||||
|
||||
public function blockedIds()
|
||||
{
|
||||
return UserFilter::whereUserId($this->id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereFilterType('block')
|
||||
->pluck('filterable_id');
|
||||
}
|
||||
|
||||
public function mutedProfileUrls()
|
||||
{
|
||||
$ids = $this->mutedIds();
|
||||
return $this->whereIn('id', $ids)->get()->map(function($i) {
|
||||
return $i->url();
|
||||
});
|
||||
}
|
||||
|
||||
public function blockedProfileUrls()
|
||||
{
|
||||
$ids = $this->blockedIds();
|
||||
return $this->whereIn('id', $ids)->get()->map(function($i) {
|
||||
return $i->url();
|
||||
});
|
||||
}
|
||||
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasMany(Report::class, 'profile_id');
|
||||
|
|
BIN
public/css/app.css
vendored
BIN
public/css/app.css
vendored
Binary file not shown.
BIN
public/js/app.js
vendored
BIN
public/js/app.js
vendored
Binary file not shown.
BIN
public/js/timeline.js
vendored
BIN
public/js/timeline.js
vendored
Binary file not shown.
Binary file not shown.
30
resources/assets/js/components/searchform.js
vendored
30
resources/assets/js/components/searchform.js
vendored
|
@ -13,21 +13,21 @@ $(document).ready(function() {
|
|||
name: 'search',
|
||||
display: 'value',
|
||||
source: queryEngine,
|
||||
limit: 20,
|
||||
limit: 40,
|
||||
templates: {
|
||||
empty: [
|
||||
'<div class="alert alert-danger mb-0">',
|
||||
'unable to find any matches',
|
||||
'<div class="alert alert-info mb-0 font-weight-bold">',
|
||||
'No Results Found',
|
||||
'</div>'
|
||||
].join('\n'),
|
||||
suggestion: function(data) {
|
||||
let type = data.type;
|
||||
let res = null;
|
||||
let res = false;
|
||||
switch(type) {
|
||||
case 'hashtag':
|
||||
res = '<a href="'+data.url+'">' +
|
||||
'<div class="media d-flex align-items-center">' +
|
||||
'<div class="mr-3 h4 text-muted">#</div>' +
|
||||
'<div class="mr-3 h4 text-muted"><span class="fas fa-hashtag"></span></div>' +
|
||||
'<div class="media-body text-truncate">' +
|
||||
'<p class="mt-0 mb-0 font-weight-bold">'+data.value+'</p>' +
|
||||
'<p class="text-muted mb-0">'+data.count+' posts</p>' +
|
||||
|
@ -38,7 +38,7 @@ $(document).ready(function() {
|
|||
case 'profile':
|
||||
res = '<a href="'+data.url+'">' +
|
||||
'<div class="media d-flex align-items-center">' +
|
||||
'<div class="mr-3 h4 text-muted"><span class="icon-user"></span></div>' +
|
||||
'<div class="mr-3 h4 text-muted"><span class="far fa-user"></span></div>' +
|
||||
'<div class="media-body text-truncate">' +
|
||||
'<p class="mt-0 mb-0 font-weight-bold">'+data.name+'</p>' +
|
||||
'<p class="text-muted mb-0">'+data.value+'</p>' +
|
||||
|
@ -46,8 +46,24 @@ $(document).ready(function() {
|
|||
'</div>' +
|
||||
'</a>';
|
||||
break;
|
||||
case 'status':
|
||||
res = '<a href="'+data.url+'">' +
|
||||
'<div class="media d-flex align-items-center">' +
|
||||
'<div class="mr-3 h4 text-muted"><img src="'+data.thumb+'" width="32px"></div>' +
|
||||
'<div class="media-body text-truncate">' +
|
||||
'<p class="mt-0 mb-0 font-weight-bold">'+data.name+'</p>' +
|
||||
'<p class="text-muted mb-0">'+data.value+'</p>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</a>';
|
||||
break;
|
||||
default:
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
if(res !== false) {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
13
resources/assets/js/timeline.js
vendored
13
resources/assets/js/timeline.js
vendored
|
@ -3,7 +3,12 @@ $(document).ready(function() {
|
|||
$('.container.timeline-container').removeClass('d-none');
|
||||
let elem = document.querySelector('.timeline-feed');
|
||||
pixelfed.fetchLikes();
|
||||
|
||||
$('video').on('play', function() {
|
||||
activated = this;
|
||||
$('video').each(function() {
|
||||
if(this != activated) this.pause();
|
||||
});
|
||||
});
|
||||
let infScroll = new InfiniteScroll( elem, {
|
||||
path: '.pagination__next',
|
||||
append: '.timeline-feed',
|
||||
|
@ -19,6 +24,12 @@ $(document).ready(function() {
|
|||
$(this).addClass('d-none');
|
||||
}
|
||||
});
|
||||
$('video').on('play', function() {
|
||||
activated = this;
|
||||
$('video').each(function() {
|
||||
if(this != activated) this.pause();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div class="form-group row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<input id="code" type="code" class="form-control{{ $errors->has('code') ? ' is-invalid' : '' }}" name="code" placeholder="{{__('Two-Factor Authentication Code')}}" required autocomplete="off">
|
||||
<input id="code" type="text" class="form-control{{ $errors->has('code') ? ' is-invalid' : '' }}" name="code" placeholder="{{__('Two-Factor Authentication Code')}}" required autocomplete="off" autofocus="">
|
||||
|
||||
@if ($errors->has('code'))
|
||||
<span class="invalid-feedback">
|
||||
|
|
Loading…
Reference in a new issue