diff --git a/TODO.md b/TODO.md index afa2a9c..43f26a8 100644 --- a/TODO.md +++ b/TODO.md @@ -55,6 +55,10 @@ - [ ] Music - [ ] Announcements +- [ ] Security + - [ ] Token system for user, there should be a token that is used to consume the API and another one to use the outbox (only the server must know the one for the outbox) + - [ ] Verify the signature of the incoming activities + - [ ] Fixes - [x] Fix that weird json encoding in the object field of an activity - [x] The profile attachments are not working, they are not being federalised somehow (the interests thingy) diff --git a/app/Helpers/PaginationHelper.php b/app/Helpers/PaginationHelper.php new file mode 100644 index 0000000..a7db4c1 --- /dev/null +++ b/app/Helpers/PaginationHelper.php @@ -0,0 +1,30 @@ +count (); + + return self::paginator ($results->forPage ($page_number, $per_page), $total_page_number, $per_page, $page_number, [ + "path" => Paginator::resolveCurrentPath (), + "pageName" => $name, + ]); + } + + protected static function paginator ($items, $total, $perPage, $currentPage, $options) + { + return Container::getInstance ()->makeWith (LengthAwarePaginator::class, compact ( + "items", "total", "perPage", "currentPage", "options" + )); + } +} diff --git a/app/Models/Actor.php b/app/Models/Actor.php index e7fb312..3a3138d 100644 --- a/app/Models/Actor.php +++ b/app/Models/Actor.php @@ -6,6 +6,8 @@ use App\Models\User; use App\Models\Announcement; use App\Models\Note; +use App\Helpers\PaginationHelper; + use App\Types\TypeActor; use Illuminate\Database\Eloquent\Model; @@ -60,7 +62,7 @@ class Actor extends Model $all = $posts->merge ($announcements)->sortByDesc ("created_at"); - return $all; + return PaginationHelper::paginate ($all); } public function create_from_user (User $user) diff --git a/app/Models/User.php b/app/Models/User.php index c4f1c3a..86bdd4e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,9 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; + +use App\Helpers\PaginationHelper; + use Illuminate\Support\Facades\Cache; use Illuminate\Notifications\Notifiable; use Illuminate\Database\Eloquent\Casts\Attribute; @@ -151,7 +154,6 @@ class User extends Authenticatable $announcements = Announcement::whereIn ("actor_id", $friends_id)->orderBy ("created_at", "desc")->get (); $feed = $notes->merge ($announcements)->sortByDesc ("created_at"); - - return $feed; + return PaginationHelper::paginate ($feed, 20, "feed"); } } diff --git a/composer.json b/composer.json index 2335c0a..72112bb 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,9 @@ "phpunit/phpunit": "^11.0.1" }, "autoload": { + "files": [ + "app/Helpers/PaginationHelper.php" + ], "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", diff --git a/resources/css/style.css b/resources/css/style.css index 083ecd4..ecbcb2e 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -2989,7 +2989,7 @@ Master Container */ .master-container { margin: auto; - width: 800px; + width: 810px; background-color: white; } diff --git a/resources/views/components/comment_block.blade.php b/resources/views/components/comment_block.blade.php index 29974eb..3289804 100644 --- a/resources/views/components/comment_block.blade.php +++ b/resources/views/components/comment_block.blade.php @@ -125,6 +125,9 @@ else
Replies: {{ $display_post->get_replies ()->count () }}
++ Boosts: {{ $display_post->get_boosts ()->count () }} +
diff --git a/resources/views/home_loggedin.blade.php b/resources/views/home_loggedin.blade.php index 6ad1b2e..4ee9867 100644 --- a/resources/views/home_loggedin.blade.php +++ b/resources/views/home_loggedin.blade.php @@ -143,6 +143,8 @@ @endforeach + + {{ auth ()->user ()->feed ()->links ("pagination::default") }} diff --git a/resources/views/partials/layout.blade.php b/resources/views/partials/layout.blade.php index 5b4f9af..b59cbf9 100644 --- a/resources/views/partials/layout.blade.php +++ b/resources/views/partials/layout.blade.php @@ -12,7 +12,7 @@ -