mirror of
https://github.com/YunoHost-Apps/pixelfed_ynh.git
synced 2024-09-03 20:06:04 +02:00
Merge pull request #488 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
af5cc6e557
10 changed files with 144 additions and 44 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');
|
||||
|
|
4
public/css/app.css
vendored
4
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
2
public/js/app.js
vendored
2
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/timeline.js
vendored
2
public/js/timeline.js
vendored
|
@ -1 +1 @@
|
|||
!function(e){var n={};function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=2)}({2:function(e,n,t){e.exports=t("uOOV")},uOOV:function(e,n){$(document).ready(function(){$(".pagination").hide(),$(".container.timeline-container").removeClass("d-none");var e=document.querySelector(".timeline-feed");pixelfed.fetchLikes(),new InfiniteScroll(e,{path:".pagination__next",append:".timeline-feed",status:".page-load-status",history:!1}).on("append",function(e,n,t){pixelfed.hydrateLikes(),$(".status-card > .card-footer").each(function(){var e=$(this);e.hasClass("d-none")||e.find('input[name="comment"]').val()||$(this).addClass("d-none")})})}),$(document).on("DOMContentLoaded",function(){var e=!1,n=function(){if(!1===e){e=!0;var n=[].slice.call(document.querySelectorAll("img.lazy"));n.forEach(function(e){e.getBoundingClientRect().top<=window.innerHeight&&e.getBoundingClientRect().bottom>=0&&"none"!==getComputedStyle(e).display&&(e.src=e.dataset.src,e.srcset=e.dataset.srcset,e.classList.remove("lazy"),n=n.filter(function(n){return n!==e}))}),e=!1}};document.addEventListener("scroll",n),window.addEventListener("resize",n),window.addEventListener("orientationchange",n)})}});
|
||||
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=2)}({2:function(e,t,n){e.exports=n("uOOV")},uOOV:function(e,t){$(document).ready(function(){$(".pagination").hide(),$(".container.timeline-container").removeClass("d-none");var e=document.querySelector(".timeline-feed");pixelfed.fetchLikes(),$("video").on("play",function(){activated=this,$("video").each(function(){this!=activated&&this.pause()})}),new InfiniteScroll(e,{path:".pagination__next",append:".timeline-feed",status:".page-load-status",history:!1}).on("append",function(e,t,n){pixelfed.hydrateLikes(),$(".status-card > .card-footer").each(function(){var e=$(this);e.hasClass("d-none")||e.find('input[name="comment"]').val()||$(this).addClass("d-none")}),$("video").on("play",function(){activated=this,$("video").each(function(){this!=activated&&this.pause()})})})}),$(document).on("DOMContentLoaded",function(){var e=!1,t=function(){if(!1===e){e=!0;var t=[].slice.call(document.querySelectorAll("img.lazy"));t.forEach(function(e){e.getBoundingClientRect().top<=window.innerHeight&&e.getBoundingClientRect().bottom>=0&&"none"!==getComputedStyle(e).display&&(e.src=e.dataset.src,e.srcset=e.dataset.srcset,e.classList.remove("lazy"),t=t.filter(function(t){return t!==e}))}),e=!1}};document.addEventListener("scroll",t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t)})}});
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"/js/app.js": "/js/app.js?id=670b2543dcb79503ba92",
|
||||
"/css/app.css": "/css/app.css?id=909c2fa80940ca721877",
|
||||
"/js/timeline.js": "/js/timeline.js?id=74c2181f0fcd6fe6933c",
|
||||
"/js/app.js": "/js/app.js?id=0b1af34f5d9ca22177fc",
|
||||
"/css/app.css": "/css/app.css?id=3f55b1817ba401d96621",
|
||||
"/js/timeline.js": "/js/timeline.js?id=7c7cbb3c0a644e2d14d8",
|
||||
"/js/activity.js": "/js/activity.js?id=723dfb98bbbc96a9d39f"
|
||||
}
|
||||
}
|
||||
|
|
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…
Add table
Reference in a new issue