Update Collections, add custom limit

This commit is contained in:
Daniel Supernault 2020-12-10 01:02:56 -07:00
parent 2f7d369ec8
commit 048642bead
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
6 changed files with 13 additions and 7 deletions

View File

@ -121,8 +121,9 @@ class CollectionController extends Controller
$collection = Collection::whereProfileId($profileId)->findOrFail($collectionId); $collection = Collection::whereProfileId($profileId)->findOrFail($collectionId);
$count = $collection->items()->count(); $count = $collection->items()->count();
if($count >= 50) { $max = config('pixelfed.max_collection_length');
abort(400, 'You can only add 50 posts per collection'); if($count >= $max) {
abort(400, 'You can only add '.$max.' posts per collection');
} }
$status = Status::whereScope('public') $status = Status::whereScope('public')
@ -165,7 +166,7 @@ class CollectionController extends Controller
if($collection->visibility !== 'public') { if($collection->visibility !== 'public') {
abort_if(!Auth::check() || Auth::user()->profile_id != $collection->profile_id, 404); abort_if(!Auth::check() || Auth::user()->profile_id != $collection->profile_id, 404);
} }
$posts = $collection->posts()->orderBy('order', 'asc')->paginate(18); $posts = $collection->posts()->orderBy('order', 'asc')->get();
$fractal = new Fractal\Manager(); $fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer()); $fractal->setSerializer(new ArraySerializer());

View File

@ -8,7 +8,7 @@ use Illuminate\Support\Str;
class Config { class Config {
public static function get() { public static function get() {
return Cache::remember('api:site:configuration', now()->addMinutes(30), function() { return Cache::remember('api:site:configuration:_v0', now()->addHours(30), function() {
return [ return [
'open_registration' => config('pixelfed.open_registration'), 'open_registration' => config('pixelfed.open_registration'),
'uploader' => [ 'uploader' => [
@ -17,6 +17,8 @@ class Config {
'album_limit' => config('pixelfed.max_album_length'), 'album_limit' => config('pixelfed.max_album_length'),
'image_quality' => config('pixelfed.image_quality'), 'image_quality' => config('pixelfed.image_quality'),
'max_collection_length' => config('pixelfed.max_collection_length', 18),
'optimize_image' => config('pixelfed.optimize_image'), 'optimize_image' => config('pixelfed.optimize_image'),
'optimize_video' => config('pixelfed.optimize_video'), 'optimize_video' => config('pixelfed.optimize_video'),

View File

@ -239,6 +239,7 @@ return [
] ]
], ],
'max_collection_length' => (int) env('PF_MAX_COLLECTION_LENGTH', 18),
'media_types' => env('MEDIA_TYPES', 'image/jpeg,image/png,image/gif'), 'media_types' => env('MEDIA_TYPES', 'image/jpeg,image/png,image/gif'),

View File

@ -161,6 +161,7 @@ export default {
data() { data() {
return { return {
config: window.App.config,
loaded: false, loaded: false,
posts: [], posts: [],
ids: [], ids: [],
@ -243,7 +244,7 @@ export default {
}, },
pushId() { pushId() {
let max = 18; let max = this.config.uploader.max_collection_length;
let addingPostToCollection = true; let addingPostToCollection = true;
let self = this; let self = this;
if(this.posts.length >= max) { if(this.posts.length >= max) {

View File

@ -113,6 +113,7 @@ export default {
props: ['collection-id', 'profile-id'], props: ['collection-id', 'profile-id'],
data() { data() {
return { return {
config: window.App.config,
loaded: false, loaded: false,
limit: 8, limit: 8,
step: 1, step: 1,
@ -175,7 +176,7 @@ export default {
}, },
addId() { addId() {
let max = 18; let max = this.config.uploader.max_collection_length;
if(this.posts.length >= max) { if(this.posts.length >= max) {
swal('Error', 'You can only add ' + max + ' posts per collection', 'error'); swal('Error', 'You can only add ' + max + ' posts per collection', 'error');
return; return;

View File

@ -345,7 +345,7 @@
<footer> <footer>
<div class="container pb-5"> <div class="container pb-5">
<p class="mb-0 text-uppercase font-weight-bold text-muted small"> <p class="mb-0 text-uppercase font-weight-bold text-muted small">
<a href="/site/about" class="text-dark pr-2">About Us</a> <a href="/site/about" class="text-dark pr-2">About</a>
<a href="/site/help" class="text-dark pr-2">Help</a> <a href="/site/help" class="text-dark pr-2">Help</a>
<a href="/site/language" class="text-dark pr-2">Language</a> <a href="/site/language" class="text-dark pr-2">Language</a>
<a href="/discover/profiles" class="text-dark pr-2">Profiles</a> <a href="/discover/profiles" class="text-dark pr-2">Profiles</a>