added a page to show a single post
This commit is contained in:
parent
dcfa475a01
commit
fdb9d09f0d
10
README.md
10
README.md
@ -14,8 +14,8 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about
|
||||
- [-] Activitypub
|
||||
- [x] Accounts
|
||||
- [-] Posts
|
||||
- [ ] Local posts should be federated
|
||||
- [ ] Local posts should be deleted
|
||||
- [x] Local posts should be federated
|
||||
- [x] Local posts should be deleted
|
||||
- [x] Remote posts should be fetched
|
||||
- [x] Remote posts should be deleted
|
||||
- [x] Follows
|
||||
@ -28,7 +28,7 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about
|
||||
- [x] Profile
|
||||
- [ ] Show when the user is online
|
||||
- [ ] Set mood
|
||||
- [ ] Set interests
|
||||
- [x] Set interests
|
||||
- [x] Update profile picture
|
||||
- [ ] Mark account as private (in federation manual approval is needed)
|
||||
- [ ] Allow custom CSS
|
||||
@ -36,8 +36,8 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about
|
||||
- [x] Friends (they are known as follows in the activitypub protocol)
|
||||
- [x] Add friends
|
||||
- [x] Remove friends
|
||||
- [ ] Posts (everything should be federated)
|
||||
- [ ] Create posts
|
||||
- [x] Posts (everything should be federated)
|
||||
- [x] Create posts
|
||||
- [ ] Delete posts
|
||||
- [ ] Like posts
|
||||
- [ ] Comment posts
|
||||
|
@ -95,6 +95,15 @@ class APInstanceInboxController extends Controller
|
||||
case "Person":
|
||||
return $this->handle_update_person ($object);
|
||||
break;
|
||||
|
||||
case "Note":
|
||||
return $this->handle_update_note ($object);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log::info ("APInstanceInboxController:handle_update");
|
||||
Log::info (json_encode ($activity));
|
||||
break;
|
||||
}
|
||||
|
||||
return response ()->json (["status" => "ok"]);
|
||||
@ -127,4 +136,16 @@ class APInstanceInboxController extends Controller
|
||||
|
||||
return response ()->json (["status" => "ok"]);
|
||||
}
|
||||
|
||||
public function handle_update_note ($object)
|
||||
{
|
||||
$note = TypeNote::note_exists ($object ["id"]);
|
||||
if (!$note)
|
||||
return response ()->json (["status" => "ok"]);
|
||||
|
||||
TypeNote::update_from_request ($note, $object, $note->get_activity ()->first (), $note->get_actor ()->first ());
|
||||
$note->save ();
|
||||
|
||||
return response ()->json (["status" => "ok"]);
|
||||
}
|
||||
}
|
||||
|
17
app/Http/Controllers/PostController.php
Normal file
17
app/Http/Controllers/PostController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Note;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PostController extends Controller
|
||||
{
|
||||
public function show (Note $note)
|
||||
{
|
||||
$actor = $note->get_actor ()->first ();
|
||||
|
||||
return view ("posts.show", compact ("note", "actor"));
|
||||
}
|
||||
}
|
@ -92,4 +92,21 @@ class User extends Authenticatable
|
||||
|
||||
return array_diff ($followers, $following);
|
||||
}
|
||||
|
||||
public function feed ()
|
||||
{
|
||||
$mutual_friends = $this->mutual_friends ();
|
||||
$friends_id = [
|
||||
$this->actor ()->first ()->id
|
||||
];
|
||||
|
||||
foreach ($mutual_friends as $friend)
|
||||
{
|
||||
$friends_id[] = Actor::where ("actor_id", $friend)->first ()->id;
|
||||
}
|
||||
|
||||
$notes = Note::whereIn ("actor_id", $friends_id)->orderBy ("created_at", "desc")->get ();
|
||||
|
||||
return $notes;
|
||||
}
|
||||
}
|
||||
|
@ -76,14 +76,22 @@ class TypeNote
|
||||
$note->content = $request["content"] ?? null;
|
||||
$note->tag = $request["tag"] ?? null;
|
||||
|
||||
$attachments = $note->attachments ()->get ();
|
||||
foreach ($attachments as $attachment)
|
||||
$attachment->delete ();
|
||||
|
||||
if ($request ["attachment"])
|
||||
{
|
||||
|
||||
foreach ($request ["attachment"] as $attachment)
|
||||
{
|
||||
$note_attachment = NoteAttachment::create ([
|
||||
"note_id" => $note->id,
|
||||
"url" => $attachment ["url"]
|
||||
]);
|
||||
$attachment_url = $attachment ["url"];
|
||||
$exists = NoteAttachment::where ("url", $attachment_url)->first ();
|
||||
if (!$exists)
|
||||
$note_attachment = NoteAttachment::create ([
|
||||
"note_id" => $note->id,
|
||||
"url" => $attachment ["url"]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,16 +27,34 @@ else
|
||||
<td>
|
||||
<p>
|
||||
<b>
|
||||
<time>{{ Carbon\Carbon::parse ($post->created_at)->diffForHumans () }}</time>
|
||||
<time>{{ $post->created_at->diffForHumans () }}</time>
|
||||
</b>
|
||||
</p>
|
||||
<p>
|
||||
{!! $post->content !!}
|
||||
</p>
|
||||
|
||||
{!! $post->content !!}
|
||||
|
||||
<p>
|
||||
@foreach ($post->attachments as $attachment)
|
||||
<img loading="lazy" src="{{ $attachment->url }}" alt="{{ $attachment->name }}" width="100">
|
||||
@endforeach
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<hr>
|
||||
|
||||
<a href="{{ route ('posts.show', [ 'note' => $post ]) }}">
|
||||
<button type="button">View</button>
|
||||
</a>
|
||||
@if ($actor->user && auth ()->check () && auth ()->user ()->is ($actor->user))
|
||||
<form action="#" method="POST" style="display: inline">
|
||||
@csrf
|
||||
<a href="#">
|
||||
<button type="button">
|
||||
Edit
|
||||
</button>
|
||||
</a>
|
||||
<input type="submit" value="Delete">
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -87,7 +87,7 @@
|
||||
Joined:
|
||||
<br>
|
||||
<span class="count">
|
||||
<i>{{ Carbon\Carbon::parse (auth ()->user ()->created_at)->diffForHumans () }}</i>
|
||||
<i>{{ auth ()->user ()->created_at->diffForHumans () }}</i>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
@ -121,7 +121,13 @@
|
||||
</div>
|
||||
|
||||
<div class="inner">
|
||||
Feed goes here
|
||||
<table class="comments-table" cellspacing="0" cellpadding="3" bordercollor="#ffffff" border="1">
|
||||
<tbody>
|
||||
@foreach (auth ()->user ()->feed () as $post)
|
||||
<x-comment_block :actor="$post->get_actor ()->first ()" :post="$post" />
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
77
resources/views/posts/show.blade.php
Normal file
77
resources/views/posts/show.blade.php
Normal file
@ -0,0 +1,77 @@
|
||||
@extends("partials.layout")
|
||||
|
||||
@section ("title", "View Post")
|
||||
|
||||
@section ("content")
|
||||
<div class="row article blog-entry">
|
||||
<div class="col w-20 left">
|
||||
<div class="edit-info">
|
||||
<div class="profile-pic">
|
||||
<img loading="lazy" src="{{ $actor->user ? $actor->user->avatar : $actor->icon }}" class="pfp-fallback">
|
||||
</div>
|
||||
|
||||
<div class="author-details">
|
||||
<h4>
|
||||
Published by
|
||||
<span>
|
||||
<a href="{{ route ('users.show', [ 'user_name' => $actor->user ? $actor->user->name : $actor->local_actor_id ]) }}">
|
||||
{{ $actor->name }}
|
||||
</a>
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<p class="publish-date">
|
||||
published <time class="ago">
|
||||
{{ $note->created_at->diffForHumans() }}
|
||||
</time>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
<p class="links">
|
||||
<a href="{{ route ('users.show', [ 'user_name' => $actor->user ? $actor->user->name : $actor->local_actor_id ]) }}">
|
||||
<img loading="lazy" src="/resources/icons/user.png" class="icon">
|
||||
<span class="m-hide">View</span> Profile
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col right">
|
||||
<h1 class="title">{{ $actor->name }}'s Post</h1>
|
||||
@if (auth ()->check () && auth ()->user ()->is ($actor->user))
|
||||
<form action="#" method="POST">
|
||||
@csrf
|
||||
<a href="#">
|
||||
<button type="button">Edit</button>
|
||||
</a>
|
||||
<button type="submit">Delete</button>
|
||||
</form>
|
||||
@endif
|
||||
<div class="content">
|
||||
{!! $note->content !!}
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="comments" id="comments">
|
||||
<div class="heading">
|
||||
<h4>Comments</h4>
|
||||
</div>
|
||||
|
||||
<div class="inner">
|
||||
<p>
|
||||
<b>Displaying <span class="count">0</span> of <span class="count">0</span> comments</b>
|
||||
</p>
|
||||
|
||||
<table class="comments-table" cellspacing="0" cellpadding="3" bordercolor="ffffff" border="1">
|
||||
<tbody>
|
||||
<!-- TODO: Comments -->
|
||||
Comments go here
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -3,6 +3,7 @@
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
use App\Http\Controllers\HomeController;
|
||||
use App\Http\Controllers\PostController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Http\Controllers\UserActionController;
|
||||
@ -26,6 +27,9 @@ Route::get ("/user/edit", [ ProfileController::class, "edit" ])->name ("users.ed
|
||||
Route::post ("/user/edit", [ ProfileController::class, "update" ])->middleware ("auth");
|
||||
Route::get ("/user/{user_name}", [ ProfileController::class, "show" ])->name ("users.show");
|
||||
|
||||
// posts routes
|
||||
Route::get ("/post/{note}", [ PostController::class, "show" ])->name ("posts.show");
|
||||
|
||||
// other routes
|
||||
Route::get ("/search", [ HomeController::class, "search" ])->name ("search");
|
||||
Route::get ("/requests", [ HomeController::class, "requests" ])->name ("requests")->middleware ("auth");
|
||||
|
Loading…
x
Reference in New Issue
Block a user