diff --git a/README.md b/README.md index 9716858..179bc3a 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about - [ ] Check when waiting for approval - [ ] Handle Rejection - [x] Likes - - [ ] Comments + - [x] Comments - [ ] Boosts - - [ ] Tags + - [x] Tags - [ ] Pinned Posts - [-] Social features @@ -37,6 +37,7 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about - [ ] Mark account as private (in federation manual approval is needed) - [ ] Allow custom CSS - [ ] Profile audio + - [ ] Top 8 friends - [x] Friends (they are known as follows in the activitypub protocol) - [x] Add friends - [x] Remove friends @@ -44,9 +45,9 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about - [x] Create posts - [x] Delete posts - [x] Like posts - - [ ] Comment posts + - [x] Comment posts - [ ] Boost posts - - [ ] Post tags + - [x] Post tags - [ ] Blog - [ ] Bulletin - [ ] Groups diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index d3b99dd..8ce4f8c 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -7,6 +7,8 @@ use App\Actions\ActionsFriends; use App\Models\User; use App\Models\Actor; +use App\Models\Note; +use App\Models\Hashtag; use GuzzleHttp\Client; @@ -21,6 +23,22 @@ class HomeController extends Controller return view ("home", compact ("latest_users")); } + public function browse () + { + $latest_users = User::latest ()->take (8)->get (); + $popular_hashtags = Hashtag::withCount ("get_notes")->orderBy ("get_notes_count", "desc")->take (16)->get ()->shuffle (); + $popular_notes = Note::withCount ([ "get_likes" => function ($query) { + $query->where ("created_at", ">=", now ()->subDay ()); + }])->where ("in_reply_to", null)->orderBy ("get_likes_count", "desc")->take (8)->get (); + + return view ("browse", compact ("latest_users", "popular_hashtags", "popular_notes")); + } + + public function tag ($tag) + { + dd ($tag); + } + public function search () { $query = request ()->get ("query"); diff --git a/app/Models/User.php b/app/Models/User.php index 1d42cac..dd457a2 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -134,7 +134,7 @@ class User extends Authenticatable $friends_id[] = Actor::where ("actor_id", $friend)->first ()->id; } - $notes = Note::whereIn ("actor_id", $friends_id)->where ("in_reply_to", null)->orderBy ("created_at", "desc")->get (); + $notes = Note::whereIn ("actor_id", $friends_id)->orderBy ("created_at", "desc")->get (); return $notes; } diff --git a/resources/css/style.css b/resources/css/style.css index 2cf73c6..57d87da 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -3730,3 +3730,20 @@ audio { width: 80px; transition: 0.5s width; } + +ul.cloud { + list-style: none; + padding-left: 0; + + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; +} + +ul.cloud a { + display: block; + padding: 0.125rem 0.25rem; + text-decoration: none; + position: relative; +} diff --git a/resources/views/browse.blade.php b/resources/views/browse.blade.php new file mode 100644 index 0000000..c39eea3 --- /dev/null +++ b/resources/views/browse.blade.php @@ -0,0 +1,76 @@ +@extends ("partials.layout") + +@section ("title", "Explore") + +@section ("content") +
+

Browse Users

+ +
+
+

Active Users

+ [random] +
+ +
+ @foreach ($latest_users as $user) + + @endforeach +
+
+ +

Popular Hashtags

+ +
+
+

Hashtags

+
+ +
+ +
+
+ +

Trending Posts

+ The posts with the most likes in the last 24 hours + + + + @foreach ($popular_notes as $post) + + @endforeach + +
+
+ + +@endsection diff --git a/resources/views/components/comment_block.blade.php b/resources/views/components/comment_block.blade.php index 213f93f..9c3ce9c 100644 --- a/resources/views/components/comment_block.blade.php +++ b/resources/views/components/comment_block.blade.php @@ -83,7 +83,7 @@ else

Tags: @foreach ($post->get_hashtags ()->get () as $hashtag) - + {{ $hashtag->name }} @endforeach diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index 0a33975..d73423f 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -39,7 +39,7 @@

  • -  Browse +  Browse
  • diff --git a/resources/views/users/profile.blade.php b/resources/views/users/profile.blade.php index 4f9e4ac..feaedc8 100644 --- a/resources/views/users/profile.blade.php +++ b/resources/views/users/profile.blade.php @@ -33,6 +33,7 @@ online ONLINE!

    @endif +

    Joined: {{ $user->created_at->diffForHumans () }}

    @endif @@ -277,7 +278,16 @@

    -
    +
    + @foreach ($user->mutual_friends () as $key => $friend) + @if ($key > 8) + @break + @endif + + @php $friend = \App\Models\Actor::where ('actor_id', $friend)->first (); @endphp + + @endforeach +
    diff --git a/routes/web.php b/routes/web.php index 15bdd97..de94391 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,7 +36,7 @@ Route::get ("/post/{note}", [ PostController::class, "show" ])->name ("posts.sho Route::delete ("/post/{note}", [ PostController::class, "delete" ])->name ("posts.delete")->middleware ("auth"); // other routes -Route::get ("/browse", [ HomeController::class, "browse" ])->name ("browse"); // TODO: This +Route::get ("/browse", [ HomeController::class, "browse" ])->name ("browse"); Route::get ("/tags/{tag}", [ HomeController::class, "tag" ])->name ("tags"); // TODO: This Route::get ("/search", [ HomeController::class, "search" ])->name ("search"); Route::get ("/requests", [ HomeController::class, "requests" ])->name ("requests")->middleware ("auth");