diff --git a/app/Http/Livewire/BbcodeInput.php b/app/Http/Livewire/BbcodeInput.php index 2340f840f..e858e7786 100644 --- a/app/Http/Livewire/BbcodeInput.php +++ b/app/Http/Livewire/BbcodeInput.php @@ -16,7 +16,6 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Helpers\Bbcode; use Livewire\Component; class BbcodeInput extends Component @@ -41,18 +40,11 @@ class BbcodeInput extends Component $this->contentBbcode = $content ?? old($name) ?? ''; } - final public function updatedIsPreviewEnabled(): void - { - if ($this->isPreviewEnabled) { - $this->contentHtml = (new Bbcode())->parse($this->contentBbcode); - } - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.bbcode-input', [ - 'contentHtml' => $this->contentHtml, - 'label' => $this->label, + 'contentBbcode' => $this->contentBbcode, + 'label' => $this->label, ]); } } diff --git a/app/Models/Article.php b/app/Models/Article.php index 1423f235a..168e487b1 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -67,14 +65,4 @@ class Article extends Model { return $this->morphMany(Comment::class, 'commentable'); } - - /** - * Parse Content And Return Valid HTML. - */ - public function getContentHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->content)); - } } diff --git a/app/Models/Comment.php b/app/Models/Comment.php index 5dd9e3e17..9278f3023 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -17,8 +17,6 @@ declare(strict_types=1); namespace App\Models; use App\Events\TicketWentStale; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -110,16 +108,6 @@ class Comment extends Model $builder->whereNull('parent_id'); } - /** - * Parse Content And Return Valid HTML. - */ - public function getContentHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->content)); - } - /** * Notify Staff There Is Stale Tickets. */ diff --git a/app/Models/Message.php b/app/Models/Message.php index b78a1481b..914fe5661 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -16,7 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -89,12 +88,4 @@ class Message extends Model { return $this->belongsTo(Chatroom::class); } - - /** - * Parse Content And Return Valid HTML. - */ - public static function getMessageHtml(string $message): string - { - return (new Bbcode())->parse($message); - } } diff --git a/app/Models/Note.php b/app/Models/Note.php index 6ab03f11b..261045df1 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -16,7 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Linkify; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -77,12 +76,4 @@ class Note extends Model 'id' => User::SYSTEM_USER_ID, ]); } - - /** - * Parse Message And Return Valid HTML. - */ - public function getMessageHtml(): string - { - return (new Linkify())->linky($this->message); - } } diff --git a/app/Models/Playlist.php b/app/Models/Playlist.php index 9348ecc26..ddbc051d7 100644 --- a/app/Models/Playlist.php +++ b/app/Models/Playlist.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -76,14 +74,4 @@ class Playlist extends Model { return $this->morphMany(Comment::class, 'commentable'); } - - /** - * Parse Description And Return Valid HTML. - */ - public function getDescriptionHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->description)); - } } diff --git a/app/Models/Post.php b/app/Models/Post.php index 1fde47741..e99162d8e 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -154,14 +152,4 @@ class Post extends Model ->select('id') ); } - - /** - * Parse Content And Return Valid HTML. - */ - public function getContentHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->content)); - } } diff --git a/app/Models/PrivateMessage.php b/app/Models/PrivateMessage.php index ece0f05ed..bb9240974 100644 --- a/app/Models/PrivateMessage.php +++ b/app/Models/PrivateMessage.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -62,14 +60,4 @@ class PrivateMessage extends Model { return $this->belongsTo(Conversation::class); } - - /** - * Parse Content And Return Valid HTML. - */ - public function getMessageHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->message)); - } } diff --git a/app/Models/TicketNote.php b/app/Models/TicketNote.php index 6014cf38c..bd4a0ab9e 100644 --- a/app/Models/TicketNote.php +++ b/app/Models/TicketNote.php @@ -16,7 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Linkify; use Illuminate\Database\Eloquent\Model; /** @@ -57,12 +56,4 @@ class TicketNote extends Model { return $this->belongsTo(Ticket::class); } - - /** - * Parse Message And Return Valid HTML. - */ - public function getMessageHtml(): string - { - return (new Linkify())->linky($this->message); - } } diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index 1b6f73368..a73c63c51 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Helpers\StringHelper; use App\Models\Scopes\ApprovedScope; use App\Notifications\NewComment; @@ -750,16 +748,6 @@ class Torrent extends Model return $this->hasOne(TorrentTrump::class); } - /** - * Parse Description And Return Valid HTML. - */ - public function getDescriptionHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->description)); - } - /** * Set The Torrents MediaInfo After Its Been Purified. */ diff --git a/app/Models/TorrentRequest.php b/app/Models/TorrentRequest.php index 4eda9aae1..d48c1d726 100644 --- a/app/Models/TorrentRequest.php +++ b/app/Models/TorrentRequest.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -213,14 +211,4 @@ class TorrentRequest extends Model { return $this->hasOne(TorrentRequestClaim::class, 'request_id'); } - - /** - * Parse Description And Return Valid HTML. - */ - public function getDescriptionHtml(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->description)); - } } diff --git a/app/Models/User.php b/app/Models/User.php index 9b04ac00f..7ff608210 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -16,8 +16,6 @@ declare(strict_types=1); namespace App\Models; -use App\Helpers\Bbcode; -use App\Helpers\Linkify; use App\Helpers\StringHelper; use App\Traits\UsersOnlineTrait; use Assada\Achievements\Achiever; @@ -1154,30 +1152,6 @@ class User extends Authenticatable implements MustVerifyEmail return StringHelper::formatBytes($bytes); } - /** - * Returns the HTML of the user's signature. - */ - public function getSignatureHtmlAttribute(): string - { - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->signature)); - } - - /** - * Parse About Me And Return Valid HTML. - */ - public function getAboutHtmlAttribute(): string - { - if (empty($this->about)) { - return 'N/A'; - } - - $bbcode = new Bbcode(); - - return (new Linkify())->linky($bbcode->parse($this->about)); - } - /** * Formats the seed bonus points of the User. */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index d20984aa1..eeabe8917 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -54,6 +54,12 @@ class AppServiceProvider extends ServiceProvider // Hidden Captcha Blade::directive('hiddencaptcha', fn ($mustBeEmptyField = '_username') => \sprintf('= App\Helpers\HiddenCaptcha::render(%s); ?>', $mustBeEmptyField)); + // BBcode + Blade::directive('bbcode', fn (?string $bbcodeString) => "toImage((new \App\Helpers\Linkify())->linky((new \App\Helpers\Bbcode())->parse({$bbcodeString}))); ?>"); + + // Linkify + Blade::directive('linkify', fn (?string $contentString) => "linky(e({$contentString})); ?>"); + $this->app['validator']->extendImplicit( 'hiddencaptcha', function ($attribute, $value, $parameters, $validator) { diff --git a/resources/views/article/index.blade.php b/resources/views/article/index.blade.php index e8b6b7ab1..64b533f99 100644 --- a/resources/views/article/index.blade.php +++ b/resources/views/article/index.blade.php @@ -42,7 +42,7 @@ />
- @joypixels(preg_replace('#\[[^\]]+\]#', '', Str::limit($article->content, 500, '...'), 150)) + @joypixels(preg_replace('#\[[^\]]+\]#', '', Str::limit(e($article->content), 500, '...'), 150))
- @joypixels(preg_replace('#\[[^\]]+\]#', '', Str::limit($article->content, 500, '...'), 150)) + @joypixels(preg_replace('#\[[^\]]+\]#', '', Str::limit(e($article->content), 500, '...'), 150))
- @joypixels($post->getContentHtml()) + @bbcode($post->content) @if (! empty($post->user->signature)) @endif diff --git a/resources/views/components/torrent/comment-listing.blade.php b/resources/views/components/torrent/comment-listing.blade.php index 8d7247818..c95e66fe5 100644 --- a/resources/views/components/torrent/comment-listing.blade.php +++ b/resources/views/components/torrent/comment-listing.blade.php @@ -65,6 +65,6 @@ @endif