Skip to content

Commit

Permalink
Update Collections, add custom limit
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Dec 10, 2020
1 parent 2f7d369 commit 048642b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/CollectionController.php
Expand Up @@ -121,8 +121,9 @@ public function storeId(Request $request)
$collection = Collection::whereProfileId($profileId)->findOrFail($collectionId);
$count = $collection->items()->count();

if($count >= 50) {
abort(400, 'You can only add 50 posts per collection');
$max = config('pixelfed.max_collection_length');
if($count >= $max) {
abort(400, 'You can only add '.$max.' posts per collection');
}

$status = Status::whereScope('public')
Expand Down Expand Up @@ -165,7 +166,7 @@ public function getItems(Request $request, int $id)
if($collection->visibility !== 'public') {
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->setSerializer(new ArraySerializer());
Expand Down
4 changes: 3 additions & 1 deletion app/Util/Site/Config.php
Expand Up @@ -8,7 +8,7 @@
class Config {

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 [
'open_registration' => config('pixelfed.open_registration'),
'uploader' => [
Expand All @@ -17,6 +17,8 @@ public static function get() {
'album_limit' => config('pixelfed.max_album_length'),
'image_quality' => config('pixelfed.image_quality'),

'max_collection_length' => config('pixelfed.max_collection_length', 18),

'optimize_image' => config('pixelfed.optimize_image'),
'optimize_video' => config('pixelfed.optimize_video'),

Expand Down
1 change: 1 addition & 0 deletions config/pixelfed.php
Expand Up @@ -239,6 +239,7 @@
]
],

'max_collection_length' => (int) env('PF_MAX_COLLECTION_LENGTH', 18),

'media_types' => env('MEDIA_TYPES', 'image/jpeg,image/png,image/gif'),

Expand Down
3 changes: 2 additions & 1 deletion resources/assets/js/components/CollectionComponent.vue
Expand Up @@ -161,6 +161,7 @@ export default {
data() {
return {
config: window.App.config,
loaded: false,
posts: [],
ids: [],
Expand Down Expand Up @@ -243,7 +244,7 @@ export default {
},
pushId() {
let max = 18;
let max = this.config.uploader.max_collection_length;
let addingPostToCollection = true;
let self = this;
if(this.posts.length >= max) {
Expand Down
3 changes: 2 additions & 1 deletion resources/assets/js/components/CollectionCompose.vue
Expand Up @@ -113,6 +113,7 @@ export default {
props: ['collection-id', 'profile-id'],
data() {
return {
config: window.App.config,
loaded: false,
limit: 8,
step: 1,
Expand Down Expand Up @@ -175,7 +176,7 @@ export default {
},
addId() {
let max = 18;
let max = this.config.uploader.max_collection_length;
if(this.posts.length >= max) {
swal('Error', 'You can only add ' + max + ' posts per collection', 'error');
return;
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/components/Timeline.vue
Expand Up @@ -345,7 +345,7 @@
<footer>
<div class="container pb-5">
<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/language" class="text-dark pr-2">Language</a>
<a href="/discover/profiles" class="text-dark pr-2">Profiles</a>
Expand Down

0 comments on commit 048642b

Please sign in to comment.