Merge pull request #2744 from pixelfed/staging

Staging
This commit is contained in:
daniel 2021-04-30 23:50:40 -06:00 committed by GitHub
commit 2e2078a2fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 367 additions and 484 deletions

View file

@ -75,6 +75,7 @@
- Updated StoryController, fix cache crop bug. ([c2f8faae](https://github.com/pixelfed/pixelfed/commit/c2f8faae)) - Updated StoryController, fix cache crop bug. ([c2f8faae](https://github.com/pixelfed/pixelfed/commit/c2f8faae))
- Updated StoryController, optimize photo size by resizing to 9:16 aspect. ([e66ed9a2](https://github.com/pixelfed/pixelfed/commit/e66ed9a2)) - Updated StoryController, optimize photo size by resizing to 9:16 aspect. ([e66ed9a2](https://github.com/pixelfed/pixelfed/commit/e66ed9a2))
- Updated StoryCompose crop logic. ([2ead622c](https://github.com/pixelfed/pixelfed/commit/2ead622c)) - Updated StoryCompose crop logic. ([2ead622c](https://github.com/pixelfed/pixelfed/commit/2ead622c))
- Updated StatusController, allow license edits without 24 hour limit. ([c799a01a](https://github.com/pixelfed/pixelfed/commit/c799a01a))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10) ## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)

View file

@ -21,422 +21,398 @@ use App\Util\Media\Filter;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Services\HashidService; use App\Services\HashidService;
use App\Services\StatusService; use App\Services\StatusService;
use App\Util\Media\License;
class StatusController extends Controller class StatusController extends Controller
{ {
public function show(Request $request, $username, int $id) public function show(Request $request, $username, int $id)
{ {
$user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail(); $user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
if($user->status != null) { if($user->status != null) {
return ProfileController::accountCheck($user); return ProfileController::accountCheck($user);
} }
$status = Status::whereProfileId($user->id) $status = Status::whereProfileId($user->id)
->whereNull('reblog_of_id') ->whereNull('reblog_of_id')
->whereIn('scope', ['public','unlisted', 'private']) ->whereIn('scope', ['public','unlisted', 'private'])
->findOrFail($id); ->findOrFail($id);
if($status->uri || $status->url) { if($status->uri || $status->url) {
$url = $status->uri ?? $status->url; $url = $status->uri ?? $status->url;
if(ends_with($url, '/activity')) { if(ends_with($url, '/activity')) {
$url = str_replace('/activity', '', $url); $url = str_replace('/activity', '', $url);
} }
return redirect($url); return redirect($url);
} }
if($status->visibility == 'private' || $user->is_private) { if($status->visibility == 'private' || $user->is_private) {
if(!Auth::check()) { if(!Auth::check()) {
abort(404); abort(404);
} }
$pid = Auth::user()->profile; $pid = Auth::user()->profile;
if($user->followedBy($pid) == false && $user->id !== $pid->id && Auth::user()->is_admin == false) { if($user->followedBy($pid) == false && $user->id !== $pid->id && Auth::user()->is_admin == false) {
abort(404); abort(404);
} }
} }
if($status->type == 'archived') { if($status->type == 'archived') {
if(Auth::user()->profile_id !== $status->profile_id) { if(Auth::user()->profile_id !== $status->profile_id) {
abort(404); abort(404);
} }
} }
if($request->user() && $request->user()->profile_id != $status->profile_id) { if($request->user() && $request->user()->profile_id != $status->profile_id) {
StatusView::firstOrCreate([ StatusView::firstOrCreate([
'status_id' => $status->id, 'status_id' => $status->id,
'status_profile_id' => $status->profile_id, 'status_profile_id' => $status->profile_id,
'profile_id' => $request->user()->profile_id 'profile_id' => $request->user()->profile_id
]); ]);
} }
if ($request->wantsJson() && config('federation.activitypub.enabled')) { if ($request->wantsJson() && config('federation.activitypub.enabled')) {
return $this->showActivityPub($request, $status); return $this->showActivityPub($request, $status);
} }
$template = $status->in_reply_to_id ? 'status.reply' : 'status.show'; $template = $status->in_reply_to_id ? 'status.reply' : 'status.show';
// $template = $status->type === 'video' &&
// $request->has('video_beta') && return view($template, compact('user', 'status'));
// $request->video_beta == 1 && }
// $request->user() ?
// 'status.show_video' : 'status.show'; public function shortcodeRedirect(Request $request, $id)
{
return view($template, compact('user', 'status')); abort_if(strlen($id) < 5, 404);
} if(!Auth::check()) {
return redirect('/login?next='.urlencode('/' . $request->path()));
public function shortcodeRedirect(Request $request, $id) }
{ $id = HashidService::decode($id);
abort_if(strlen($id) < 5, 404); $status = Status::find($id);
if(!Auth::check()) { if(!$status) {
return redirect('/login?next='.urlencode('/' . $request->path())); return redirect('/404');
} }
$id = HashidService::decode($id); return redirect($status->url());
$status = Status::find($id); }
if(!$status) {
return redirect('/404'); public function showId(int $id)
} {
return redirect($status->url()); abort(404);
} $status = Status::whereNull('reblog_of_id')
->whereIn('scope', ['public', 'unlisted'])
public function showId(int $id) ->findOrFail($id);
{ return redirect($status->url());
abort(404); }
$status = Status::whereNull('reblog_of_id')
->whereIn('scope', ['public', 'unlisted']) public function showEmbed(Request $request, $username, int $id)
->findOrFail($id); {
return redirect($status->url()); $profile = Profile::whereNull(['domain','status'])
} ->whereIsPrivate(false)
->whereUsername($username)
public function showEmbed(Request $request, $username, int $id) ->first();
{ if(!$profile) {
$profile = Profile::whereNull(['domain','status']) $content = view('status.embed-removed');
->whereIsPrivate(false) return response($content)->header('X-Frame-Options', 'ALLOWALL');
->whereUsername($username) }
->first(); $status = Status::whereProfileId($profile->id)
if(!$profile) { ->whereNull('uri')
$content = view('status.embed-removed'); ->whereScope('public')
return response($content)->header('X-Frame-Options', 'ALLOWALL'); ->whereIsNsfw(false)
} ->whereIn('type', ['photo', 'video','photo:album'])
$status = Status::whereProfileId($profile->id) ->find($id);
->whereNull('uri') if(!$status) {
->whereScope('public') $content = view('status.embed-removed');
->whereIsNsfw(false) return response($content)->header('X-Frame-Options', 'ALLOWALL');
->whereIn('type', ['photo', 'video','photo:album']) }
->find($id); $showLikes = $request->filled('likes') && $request->likes == true;
if(!$status) { $showCaption = $request->filled('caption') && $request->caption !== false;
$content = view('status.embed-removed'); $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full';
return response($content)->header('X-Frame-Options', 'ALLOWALL'); $content = view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout'));
} return response($content)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
$showLikes = $request->filled('likes') && $request->likes == true; }
$showCaption = $request->filled('caption') && $request->caption !== false;
$layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; public function showObject(Request $request, $username, int $id)
$content = view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); {
return response($content)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); $user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
}
if($user->status != null) {
public function showObject(Request $request, $username, int $id) return ProfileController::accountCheck($user);
{ }
$user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
$status = Status::whereProfileId($user->id)
if($user->status != null) { ->whereNotIn('visibility',['draft','direct'])
return ProfileController::accountCheck($user); ->findOrFail($id);
}
abort_if($status->uri, 404);
$status = Status::whereProfileId($user->id)
->whereNotIn('visibility',['draft','direct']) if($status->visibility == 'private' || $user->is_private) {
->findOrFail($id); if(!Auth::check()) {
abort(403);
abort_if($status->uri, 404); }
$pid = Auth::user()->profile;
if($status->visibility == 'private' || $user->is_private) { if($user->followedBy($pid) == false && $user->id !== $pid->id) {
if(!Auth::check()) { abort(403);
abort(403); }
} }
$pid = Auth::user()->profile;
if($user->followedBy($pid) == false && $user->id !== $pid->id) { return $this->showActivityPub($request, $status);
abort(403); }
}
} public function compose()
{
return $this->showActivityPub($request, $status); $this->authCheck();
}
return view('status.compose');
public function compose() }
{
$this->authCheck(); public function store(Request $request)
{
return view('status.compose'); return;
} }
public function store(Request $request) public function delete(Request $request)
{ {
return; $this->authCheck();
}
$this->validate($request, [
public function delete(Request $request) 'item' => 'required|integer|min:1',
{ ]);
$this->authCheck();
$status = Status::findOrFail($request->input('item'));
$this->validate($request, [
'item' => 'required|integer|min:1', $user = Auth::user();
]);
if($status->profile_id != $user->profile->id &&
$status = Status::findOrFail($request->input('item')); $user->is_admin == true &&
$status->uri == null
$user = Auth::user(); ) {
$media = $status->media;
if($status->profile_id != $user->profile->id &&
$user->is_admin == true && $ai = new AccountInterstitial;
$status->uri == null $ai->user_id = $status->profile->user_id;
) { $ai->type = 'post.removed';
$media = $status->media; $ai->view = 'account.moderation.post.removed';
$ai->item_type = 'App\Status';
$ai = new AccountInterstitial; $ai->item_id = $status->id;
$ai->user_id = $status->profile->user_id; $ai->has_media = (bool) $media->count();
$ai->type = 'post.removed'; $ai->blurhash = $media->count() ? $media->first()->blurhash : null;
$ai->view = 'account.moderation.post.removed'; $ai->meta = json_encode([
$ai->item_type = 'App\Status'; 'caption' => $status->caption,
$ai->item_id = $status->id; 'created_at' => $status->created_at,
$ai->has_media = (bool) $media->count(); 'type' => $status->type,
$ai->blurhash = $media->count() ? $media->first()->blurhash : null; 'url' => $status->url(),
$ai->meta = json_encode([ 'is_nsfw' => $status->is_nsfw,
'caption' => $status->caption, 'scope' => $status->scope,
'created_at' => $status->created_at, 'reblog' => $status->reblog_of_id,
'type' => $status->type, 'likes_count' => $status->likes_count,
'url' => $status->url(), 'reblogs_count' => $status->reblogs_count,
'is_nsfw' => $status->is_nsfw, ]);
'scope' => $status->scope, $ai->save();
'reblog' => $status->reblog_of_id,
'likes_count' => $status->likes_count, $u = $status->profile->user;
'reblogs_count' => $status->reblogs_count, $u->has_interstitial = true;
]); $u->save();
$ai->save(); }
$u = $status->profile->user; Cache::forget('_api:statuses:recent_9:' . $status->profile_id);
$u->has_interstitial = true; Cache::forget('profile:status_count:' . $status->profile_id);
$u->save(); Cache::forget('profile:embed:' . $status->profile_id);
} StatusService::del($status->id);
if ($status->profile_id == $user->profile->id || $user->is_admin == true) {
Cache::forget('_api:statuses:recent_9:' . $status->profile_id); Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id); StatusDelete::dispatch($status);
Cache::forget('profile:embed:' . $status->profile_id); }
StatusService::del($status->id);
if ($status->profile_id == $user->profile->id || $user->is_admin == true) { if($request->wantsJson()) {
Cache::forget('profile:status_count:'.$status->profile_id); return response()->json(['Status successfully deleted.']);
StatusDelete::dispatch($status); } else {
} return redirect($user->url());
}
if($request->wantsJson()) { }
return response()->json(['Status successfully deleted.']);
} else { public function storeShare(Request $request)
return redirect($user->url()); {
} $this->authCheck();
}
$this->validate($request, [
public function storeShare(Request $request) 'item' => 'required|integer|min:1',
{ ]);
$this->authCheck();
$user = Auth::user();
$this->validate($request, [ $profile = $user->profile;
'item' => 'required|integer|min:1', $status = Status::withCount('shares')
]); ->whereIn('scope', ['public', 'unlisted'])
->findOrFail($request->input('item'));
$user = Auth::user();
$profile = $user->profile; $count = $status->shares()->count();
$status = Status::withCount('shares')
->whereIn('scope', ['public', 'unlisted']) $exists = Status::whereProfileId(Auth::user()->profile->id)
->findOrFail($request->input('item')); ->whereReblogOfId($status->id)
->count();
$count = $status->shares()->count(); if ($exists !== 0) {
$shares = Status::whereProfileId(Auth::user()->profile->id)
$exists = Status::whereProfileId(Auth::user()->profile->id) ->whereReblogOfId($status->id)
->whereReblogOfId($status->id) ->get();
->count(); foreach ($shares as $share) {
if ($exists !== 0) { $share->delete();
$shares = Status::whereProfileId(Auth::user()->profile->id) $count--;
->whereReblogOfId($status->id) }
->get(); } else {
foreach ($shares as $share) { $share = new Status();
$share->delete(); $share->profile_id = $profile->id;
$count--; $share->reblog_of_id = $status->id;
} $share->in_reply_to_profile_id = $status->profile_id;
} else { $share->save();
$share = new Status(); $count++;
$share->profile_id = $profile->id; SharePipeline::dispatch($share);
$share->reblog_of_id = $status->id; }
$share->in_reply_to_profile_id = $status->profile_id;
$share->save(); if($count >= 0) {
$count++; $status->reblogs_count = $count;
SharePipeline::dispatch($share); $status->save();
} }
if($count >= 0) { Cache::forget('status:'.$status->id.':sharedby:userid:'.$user->id);
$status->reblogs_count = $count; StatusService::del($status->id);
$status->save();
} if ($request->ajax()) {
$response = ['code' => 200, 'msg' => 'Share saved', 'count' => $count];
Cache::forget('status:'.$status->id.':sharedby:userid:'.$user->id); } else {
StatusService::del($status->id); $response = redirect($status->url());
}
if ($request->ajax()) {
$response = ['code' => 200, 'msg' => 'Share saved', 'count' => $count]; return $response;
} else { }
$response = redirect($status->url());
} public function showActivityPub(Request $request, $status)
{
return $response; $fractal = new Fractal\Manager();
} $resource = new Fractal\Resource\Item($status, new Note());
$res = $fractal->createData($resource)->toArray();
public function showActivityPub(Request $request, $status)
{ return response()->json($res['data'], 200, ['Content-Type' => 'application/activity+json'], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
$fractal = new Fractal\Manager(); }
$resource = new Fractal\Resource\Item($status, new Note());
$res = $fractal->createData($resource)->toArray(); public function edit(Request $request, $username, $id)
{
return response()->json($res['data'], 200, ['Content-Type' => 'application/activity+json'], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); $this->authCheck();
} $user = Auth::user()->profile;
$status = Status::whereProfileId($user->id)
public function edit(Request $request, $username, $id) ->with(['media'])
{ ->findOrFail($id);
$this->authCheck(); $licenses = License::get();
$user = Auth::user()->profile; return view('status.edit', compact('user', 'status', 'licenses'));
$status = Status::whereProfileId($user->id) }
->with(['media'])
->where('created_at', '>', now()->subHours(24)) public function editStore(Request $request, $username, $id)
->findOrFail($id); {
return view('status.edit', compact('user', 'status')); $this->authCheck();
} $user = Auth::user()->profile;
$status = Status::whereProfileId($user->id)
public function editStore(Request $request, $username, $id) ->with(['media'])
{ ->findOrFail($id);
$this->authCheck();
$user = Auth::user()->profile; $this->validate($request, [
$status = Status::whereProfileId($user->id) 'license' => 'nullable|integer|min:1|max:16',
->with(['media']) ]);
->where('created_at', '>', now()->subHours(24))
->findOrFail($id); $licenseId = $request->input('license');
$this->validate($request, [ $status->media->each(function($media) use($licenseId) {
'id' => 'required|integer|min:1', $media->license = $licenseId;
'caption' => 'nullable', $media->save();
'filter' => 'nullable|alpha_dash|max:30', Cache::forget('status:transformer:media:attachments:'.$media->status_id);
]); });
$id = $request->input('id'); return redirect($status->url());
$caption = $request->input('caption'); }
$filter = $request->input('filter');
protected function authCheck()
$media = Media::whereProfileId($user->id) {
->whereStatusId($status->id) if (Auth::check() == false) {
->findOrFail($id); abort(403);
}
$changed = false; }
if ($media->caption != $caption) { protected function validateVisibility($visibility)
$media->caption = $caption; {
$changed = true; $allowed = ['public', 'unlisted', 'private'];
} return in_array($visibility, $allowed) ? $visibility : 'public';
}
if ($media->filter_class != $filter && in_array($filter, Filter::classes())) {
$media->filter_class = $filter; public static function mimeTypeCheck($mimes)
$changed = true; {
} $allowed = explode(',', config('pixelfed.media_types'));
$count = count($mimes);
if ($changed === true) { $photos = 0;
$media->save(); $videos = 0;
Cache::forget('status:transformer:media:attachments:'.$media->status_id); foreach($mimes as $mime) {
} if(in_array($mime, $allowed) == false && $mime !== 'video/mp4') {
continue;
return response()->json([], 200); }
} if(str_contains($mime, 'image/')) {
$photos++;
protected function authCheck() }
{ if(str_contains($mime, 'video/')) {
if (Auth::check() == false) { $videos++;
abort(403); }
} }
} if($photos == 1 && $videos == 0) {
return 'photo';
protected function validateVisibility($visibility) }
{ if($videos == 1 && $photos == 0) {
$allowed = ['public', 'unlisted', 'private']; return 'video';
return in_array($visibility, $allowed) ? $visibility : 'public'; }
} if($photos > 1 && $videos == 0) {
return 'photo:album';
public static function mimeTypeCheck($mimes) }
{ if($videos > 1 && $photos == 0) {
$allowed = explode(',', config('pixelfed.media_types')); return 'video:album';
$count = count($mimes); }
$photos = 0; if($photos >= 1 && $videos >= 1) {
$videos = 0; return 'photo:video:album';
foreach($mimes as $mime) { }
if(in_array($mime, $allowed) == false && $mime !== 'video/mp4') { }
continue;
} public function toggleVisibility(Request $request) {
if(str_contains($mime, 'image/')) { $this->authCheck();
$photos++; $this->validate($request, [
} 'item' => 'required|string|min:1|max:20',
if(str_contains($mime, 'video/')) { 'disableComments' => 'required|boolean'
$videos++; ]);
}
} $user = Auth::user();
if($photos == 1 && $videos == 0) { $id = $request->input('item');
return 'photo'; $state = $request->input('disableComments');
}
if($videos == 1 && $photos == 0) { $status = Status::findOrFail($id);
return 'video';
} if($status->profile_id != $user->profile->id && $user->is_admin == false) {
if($photos > 1 && $videos == 0) { abort(403);
return 'photo:album'; }
}
if($videos > 1 && $photos == 0) { $status->comments_disabled = $status->comments_disabled == true ? false : true;
return 'video:album'; $status->save();
}
if($photos >= 1 && $videos >= 1) { return response()->json([200]);
return 'photo:video:album'; }
}
} public function storeView(Request $request)
{
public function toggleVisibility(Request $request) { abort_if(!$request->user(), 403);
$this->authCheck();
$this->validate($request, [ $this->validate($request, [
'item' => 'required|string|min:1|max:20', 'status_id' => 'required|integer|exists:statuses,id',
'disableComments' => 'required|boolean' 'profile_id' => 'required|integer|exists:profiles,id'
]); ]);
$user = Auth::user(); $sid = (int) $request->input('status_id');
$id = $request->input('item'); $pid = (int) $request->input('profile_id');
$state = $request->input('disableComments');
StatusView::firstOrCreate([
$status = Status::findOrFail($id); 'status_id' => $sid,
'status_profile_id' => $pid,
if($status->profile_id != $user->profile->id && $user->is_admin == false) { 'profile_id' => $request->user()->profile_id
abort(403); ]);
}
return response()->json(1);
$status->comments_disabled = $status->comments_disabled == true ? false : true; }
$status->save();
return response()->json([200]);
}
public function storeView(Request $request)
{
abort_if(!$request->user(), 403);
$this->validate($request, [
'status_id' => 'required|integer|exists:statuses,id',
'profile_id' => 'required|integer|exists:profiles,id'
]);
$sid = (int) $request->input('status_id');
$pid = (int) $request->input('profile_id');
StatusView::firstOrCreate([
'status_id' => $sid,
'status_profile_id' => $pid,
'profile_id' => $request->user()->profile_id
]);
return response()->json(1);
}
} }

BIN
public/js/discover.js vendored

Binary file not shown.

BIN
public/js/hashtag.js vendored

Binary file not shown.

BIN
public/js/profile.js vendored

Binary file not shown.

Binary file not shown.

View file

@ -54,10 +54,6 @@
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span> <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
<div class="info-overlay-text"> <div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold"> <h5 class="text-white m-auto font-weight-bold">
<span>
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
</span>
<span> <span>
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span> <span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span> <span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
@ -119,10 +115,6 @@
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span> <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
<div class="info-overlay-text"> <div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold"> <h5 class="text-white m-auto font-weight-bold">
<span>
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
</span>
<span> <span>
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span> <span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span> <span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>

View file

@ -48,9 +48,6 @@
<div v-else class="square-content" :style="'background-image: url('+tag.status.media_attachments[0].preview_url+')'"></div> <div v-else class="square-content" :style="'background-image: url('+tag.status.media_attachments[0].preview_url+')'"></div>
<div class="info-overlay-text"> <div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold"> <h5 class="text-white m-auto font-weight-bold">
<span class="pr-4">
<span class="far fa-heart fa-lg pr-1"></span> {{tag.status.like_count}}
</span>
<span> <span>
<span class="fas fa-retweet fa-lg pr-1"></span> {{tag.status.share_count}} <span class="fas fa-retweet fa-lg pr-1"></span> {{tag.status.share_count}}
</span> </span>
@ -92,9 +89,6 @@
<span v-if="tag.status.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span> <span v-if="tag.status.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
<div class="info-overlay-text"> <div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold"> <h5 class="text-white m-auto font-weight-bold">
<span class="pr-4">
<span class="far fa-heart fa-lg pr-1"></span> {{tag.status.favourites_count}}
</span>
<span> <span>
<span class="far fa-comment fa-lg pr-1"></span> {{tag.status.reply_count}} <span class="far fa-comment fa-lg pr-1"></span> {{tag.status.reply_count}}
</span> </span>

View file

@ -212,10 +212,6 @@
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span> <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
<div class="info-overlay-text"> <div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold"> <h5 class="text-white m-auto font-weight-bold">
<span>
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
</span>
<span> <span>
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span> <span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span> <span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
@ -260,10 +256,6 @@
</div> </div>
<div class="info-overlay-text"> <div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold"> <h5 class="text-white m-auto font-weight-bold">
<span>
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{s.favourites_count}}</span>
</span>
<span> <span>
<span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span> <span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span>
<span class="d-flex-inline">{{s.reblogs_count}}</span> <span class="d-flex-inline">{{s.reblogs_count}}</span>

View file

@ -5,99 +5,27 @@
<div class="container"> <div class="container">
<div class="col-12 col-md-8 offset-md-2 pt-4"> <div class="col-12 col-md-8 offset-md-2 pt-4">
<div class="card"> <div class="card shadow-none border">
<div class="card-header bg-white font-weight-bold d-flex justify-content-between align-items-center"> <div class="card-header bg-white font-weight-bold d-flex justify-content-between align-items-center">
<span>Edit Status</span> <span>Edit Status</span>
<a class="btn btn-outline-primary btn-sm font-weight-bold" href="{{$status->url()}}">Back to post</a> <a class="btn btn-outline-primary btn-sm font-weight-bold" href="{{$status->url()}}">Back to post</a>
</div> </div>
<div class="card-body"> <div class="card-body">
@csrf <form method="post">
<div class="form-group mb-0"> @csrf
<label class="font-weight-bold text-muted small">CW/NSFW</label> <div class="form-group">
<div class="switch switch-sm"> <label class="font-weight-bold text-muted small">License</label>
<input type="checkbox" class="switch" id="cw-switch" name="cw" {{$status->is_nsfw==true?'checked=""':''}} disabled=""> <select class="form-control" name="license">
<label for="cw-switch" class="small font-weight-bold">(Default off)</label> @foreach($licenses as $license)
<option value="{{$license['id']}}" {{$status->firstMedia()->license == $license['id'] ? 'selected' : ''}}>{{$license['title']}}</option>
@endforeach
</select>
</div> </div>
</div> <hr>
<button class="btn btn-primary btn-block font-weight-bold">Save</button>
</form>
</div> </div>
</div> </div>
<div class="accordion" id="accordionWrapper">
@foreach($status->media()->orderBy('order')->get() as $media)
<div class="card mt-4 media-card">
<div class="card-header bg-white font-weight-bold" data-toggle="collapse" href="#collapseMedia{{$loop->iteration}}">
Media #{{$media->order + 1}}
<span class="float-right">
<span class="badge badge-primary">
{{$media->mime}}
</span>
</span>
</div>
<div class="collapse {{$loop->iteration==1?'show':''}}" id="collapseMedia{{$loop->iteration}}" data-parent="#accordionWrapper">
<div class="card-body p-0">
<form method="post" enctype="multipart/form-data" class="media-form">
@csrf
<input type="hidden" name="media_id" value="{{$media->id}}">
<div class="filter-wrapper {{$media->filter_class}}" data-filter="{{$media->filter_class}}">
<img class="img-fluid" src="{{$media->url()}}" width="100%">
</div>
<div class="p-3">
<div class="form-group">
<label class="font-weight-bold text-muted small">Description</label>
<input class="form-control" name="media_caption" value="{{$media->caption}}" placeholder="Add a descriptive caption for screenreaders" autocomplete="off">
</div>
@if($media->activityVerb() == 'Image')
<div class="form-group form-filters" data-filter="{{$media->filter_class}}">
<label for="filterSelectDropdown" class="font-weight-bold text-muted small">Select Filter</label>
<select class="form-control filter-dropdown" name="media_filter"><option value="" selected="">No Filter</option><option value="filter-1977">1977</option><option value="filter-aden">Aden</option><option value="filter-amaro">Amaro</option><option value="filter-ashby">Ashby</option><option value="filter-brannan">Brannan</option><option value="filter-brooklyn">Brooklyn</option><option value="filter-charmes">Charmes</option><option value="filter-clarendon">Clarendon</option><option value="filter-crema">Crema</option><option value="filter-dogpatch">Dogpatch</option><option value="filter-earlybird">Earlybird</option><option value="filter-gingham">Gingham</option><option value="filter-ginza">Ginza</option><option value="filter-hefe">Hefe</option><option value="filter-helena">Helena</option><option value="filter-hudson">Hudson</option><option value="filter-inkwell">Inkwell</option><option value="filter-kelvin">Kelvin</option><option value="filter-juno">Kuno</option><option value="filter-lark">Lark</option><option value="filter-lofi">Lo-Fi</option><option value="filter-ludwig">Ludwig</option><option value="filter-maven">Maven</option><option value="filter-mayfair">Mayfair</option><option value="filter-moon">Moon</option><option value="filter-nashville">Nashville</option><option value="filter-perpetua">Perpetua</option><option value="filter-poprocket">Poprocket</option><option value="filter-reyes">Reyes</option><option value="filter-rise">Rise</option><option value="filter-sierra">Sierra</option><option value="filter-skyline">Skyline</option><option value="filter-slumber">Slumber</option><option value="filter-stinson">Stinson</option><option value="filter-sutro">Sutro</option><option value="filter-toaster">Toaster</option><option value="filter-valencia">Valencia</option><option value="filter-vesper">Vesper</option><option value="filter-walden">Walden</option><option value="filter-willow">Willow</option><option value="filter-xpro-ii">X-Pro II</option></select>
</div>
@endif
<hr>
<div class="form-group d-flex justify-content-between align-items-center mb-0">
<p class="text-muted font-weight-bold mb-0 small">Last Updated: {{$media->updated_at->diffForHumans()}}</p>
<button type="submit" class="btn btn-primary btn-sm font-weight-bold px-4">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endforeach
</div>
</div> </div>
</div> </div>
@endsection @endsection
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
App.boot();
$('.form-filters').each(function(i,d) {
let el = $(d);
let filter = el.data('filter');
if(filter) {
var opt = el.find('option[value='+filter+']')[0];
$(opt).attr('selected','');
}
});
$('.media-form').on('submit', function(e){
e.preventDefault();
let el = $(this);
let id = el.find('input[name=media_id]').val();
let caption = el.find('input[name=media_caption]').val();
let filter = el.find('.filter-dropdown option:selected').val();
axios.post(window.location.href, {
'id': id,
'caption': caption,
'filter': filter
}).then((res) => {
window.location.href = '{{$status->url()}}';
}).catch((err) => {
swal('Something went wrong', 'An error occurred, please try again later', 'error');
});
});
});
</script>
@endpush

View file

@ -190,7 +190,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('loops', 'DiscoverController@loopsApi'); Route::get('loops', 'DiscoverController@loopsApi');
Route::post('loops/watch', 'DiscoverController@loopWatch'); Route::post('loops/watch', 'DiscoverController@loopWatch');
Route::get('discover/tag', 'DiscoverController@getHashtags'); Route::get('discover/tag', 'DiscoverController@getHashtags');
Route::post('status/compose', 'InternalApiController@composePost')->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440'); Route::post('status/compose', 'InternalApiController@composePost');
Route::get('discover/posts/trending', 'DiscoverController@trendingApi'); Route::get('discover/posts/trending', 'DiscoverController@trendingApi');
Route::get('discover/posts/hashtags', 'DiscoverController@trendingHashtags'); Route::get('discover/posts/hashtags', 'DiscoverController@trendingHashtags');
Route::get('discover/posts/places', 'DiscoverController@trendingPlaces'); Route::get('discover/posts/places', 'DiscoverController@trendingPlaces');
@ -202,7 +202,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::group(['prefix' => 'local'], function () { Route::group(['prefix' => 'local'], function () {
// Route::post('status/compose', 'InternalApiController@composePost')->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440'); // Route::post('status/compose', 'InternalApiController@composePost')->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440');
Route::get('exp/rec', 'ApiController@userRecommendations'); Route::get('exp/rec', 'ApiController@userRecommendations');
Route::post('discover/tag/subscribe', 'HashtagFollowController@store')->middleware('throttle:maxHashtagFollowsPerHour,60')->middleware('throttle:maxHashtagFollowsPerDay,1440'); Route::post('discover/tag/subscribe', 'HashtagFollowController@store');
Route::get('discover/tag/list', 'HashtagFollowController@getTags'); Route::get('discover/tag/list', 'HashtagFollowController@getTags');
// Route::get('profile/sponsor/{id}', 'ProfileSponsorController@get'); // Route::get('profile/sponsor/{id}', 'ProfileSponsorController@get');
Route::get('bookmarks', 'InternalApiController@bookmarks'); Route::get('bookmarks', 'InternalApiController@bookmarks');
@ -211,8 +211,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::delete('collection/item', 'CollectionController@deleteId'); Route::delete('collection/item', 'CollectionController@deleteId');
Route::get('collection/{id}', 'CollectionController@get'); Route::get('collection/{id}', 'CollectionController@get');
Route::post('collection/{id}', 'CollectionController@store'); Route::post('collection/{id}', 'CollectionController@store');
Route::delete('collection/{id}', 'CollectionController@delete')->middleware('throttle:maxCollectionsPerHour,60')->middleware('throttle:maxCollectionsPerDay,1440')->middleware('throttle:maxCollectionsPerMonth,43800'); Route::delete('collection/{id}', 'CollectionController@delete');
Route::post('collection/{id}/publish', 'CollectionController@publish')->middleware('throttle:maxCollectionsPerHour,60')->middleware('throttle:maxCollectionsPerDay,1440')->middleware('throttle:maxCollectionsPerMonth,43800'); Route::post('collection/{id}/publish', 'CollectionController@publish');
Route::get('profile/collections/{id}', 'CollectionController@getUserCollections'); Route::get('profile/collections/{id}', 'CollectionController@getUserCollections');
Route::get('compose/location/search', 'ApiController@composeLocationSearch'); Route::get('compose/location/search', 'ApiController@composeLocationSearch');
@ -223,11 +223,11 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
}); });
Route::group(['prefix' => 'stories'], function () { Route::group(['prefix' => 'stories'], function () {
Route::get('v0/recent', 'StoryController@apiV1Recent'); Route::get('v0/recent', 'StoryController@apiV1Recent');
Route::post('v0/add', 'StoryController@apiV1Add')->middleware('throttle:maxStoriesPerDay,1440'); Route::post('v0/add', 'StoryController@apiV1Add');
Route::get('v0/fetch/{id}', 'StoryController@apiV1Fetch'); Route::get('v0/fetch/{id}', 'StoryController@apiV1Fetch');
Route::get('v0/profile/{id}', 'StoryController@apiV1Profile'); Route::get('v0/profile/{id}', 'StoryController@apiV1Profile');
Route::get('v0/exists/{id}', 'StoryController@apiV1Exists'); Route::get('v0/exists/{id}', 'StoryController@apiV1Exists');
Route::delete('v0/delete/{id}', 'StoryController@apiV1Delete')->middleware('throttle:maxStoryDeletePerDay,1440'); Route::delete('v0/delete/{id}', 'StoryController@apiV1Delete');
Route::get('v0/me', 'StoryController@apiV1Me'); Route::get('v0/me', 'StoryController@apiV1Me');
Route::get('v0/item/{id}', 'StoryController@apiV1Item'); Route::get('v0/item/{id}', 'StoryController@apiV1Item');
Route::post('v0/crop', 'StoryController@cropPhoto'); Route::post('v0/crop', 'StoryController@cropPhoto');
@ -244,14 +244,14 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::group(['prefix' => 'i'], function () { Route::group(['prefix' => 'i'], function () {
Route::redirect('/', '/'); Route::redirect('/', '/');
Route::get('compose', 'StatusController@compose')->name('compose'); Route::get('compose', 'StatusController@compose')->name('compose');
Route::post('comment', 'CommentController@store')->middleware('throttle:maxCommentsPerDay,1440'); Route::post('comment', 'CommentController@store');
Route::post('delete', 'StatusController@delete'); Route::post('delete', 'StatusController@delete');
Route::post('mute', 'AccountController@mute'); Route::post('mute', 'AccountController@mute');
Route::post('unmute', 'AccountController@unmute'); Route::post('unmute', 'AccountController@unmute');
Route::post('block', 'AccountController@block'); Route::post('block', 'AccountController@block');
Route::post('unblock', 'AccountController@unblock'); Route::post('unblock', 'AccountController@unblock');
Route::post('like', 'LikeController@store')->middleware('throttle:maxLikesPerDay,1440'); Route::post('like', 'LikeController@store');
Route::post('share', 'StatusController@storeShare')->middleware('throttle:maxSharesPerHour,60')->middleware('throttle:maxSharesPerDay,1440'); Route::post('share', 'StatusController@storeShare');
Route::post('follow', 'FollowerController@store'); Route::post('follow', 'FollowerController@store');
Route::post('bookmark', 'BookmarkController@store'); Route::post('bookmark', 'BookmarkController@store');
Route::get('lang/{locale}', 'SiteController@changeLocale'); Route::get('lang/{locale}', 'SiteController@changeLocale');
@ -347,7 +347,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('privacy/blocked-users', 'SettingsController@blockedUsers')->name('settings.privacy.blocked-users'); Route::get('privacy/blocked-users', 'SettingsController@blockedUsers')->name('settings.privacy.blocked-users');
Route::post('privacy/blocked-users', 'SettingsController@blockedUsersUpdate'); Route::post('privacy/blocked-users', 'SettingsController@blockedUsersUpdate');
Route::get('privacy/blocked-instances', 'SettingsController@blockedInstances')->name('settings.privacy.blocked-instances'); Route::get('privacy/blocked-instances', 'SettingsController@blockedInstances')->name('settings.privacy.blocked-instances');
Route::post('privacy/blocked-instances', 'SettingsController@blockedInstanceStore')->middleware('throttle:maxInstanceBansPerDay,1440'); Route::post('privacy/blocked-instances', 'SettingsController@blockedInstanceStore');
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock'); Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords'); Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account'); Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
@ -489,7 +489,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('p/{username}/{id}/c', 'CommentController@showAll'); Route::get('p/{username}/{id}/c', 'CommentController@showAll');
Route::get('p/{username}/{id}/embed', 'StatusController@showEmbed'); Route::get('p/{username}/{id}/embed', 'StatusController@showEmbed');
Route::get('p/{username}/{id}/edit', 'StatusController@edit'); Route::get('p/{username}/{id}/edit', 'StatusController@edit');
Route::post('p/{username}/{id}/edit', 'StatusController@editStore')->middleware('throttle:maxPostEditsPerHour,60')->middleware('throttle:maxPostEditsPerDay,1440'); Route::post('p/{username}/{id}/edit', 'StatusController@editStore');
Route::get('p/{username}/{id}.json', 'StatusController@showObject'); Route::get('p/{username}/{id}.json', 'StatusController@showObject');
Route::get('p/{username}/{id}', 'StatusController@show'); Route::get('p/{username}/{id}', 'StatusController@show');
Route::get('{username}/embed', 'ProfileController@embed'); Route::get('{username}/embed', 'ProfileController@embed');