Skip to content

feat: mentions #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4f9baad
no message
Sep 28, 2022
5c2e27b
updating main branch finally
Mar 6, 2023
90d1cd5
updating php
Mar 28, 2023
90db87c
feat: user mentions on tinymce (non functional)
ScuffedNewt Jan 21, 2025
2793418
feat(emotes): extension, squashed commit of the following:
ScuffedNewt Jan 22, 2025
73a1f1b
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt Jan 22, 2025
176bba0
chore(deps): rebuild mix assets
ScuffedNewt Jan 22, 2025
c1b20b1
refactor: fix blade formatting
ScuffedNewt Jan 22, 2025
8956266
refactor: fix PHP styling
ScuffedNewt Jan 22, 2025
6d7c235
chore(deps): rebuild mix assets
ScuffedNewt Jan 22, 2025
27e78a8
feat: emote descriptions & alt text
ScuffedNewt Jan 22, 2025
146789e
refactor: fix PHP styling
ScuffedNewt Jan 22, 2025
a9d6e81
Merge branch 'extension/emotes' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt Jan 22, 2025
883880f
refactor: fix blade formatting
ScuffedNewt Jan 22, 2025
104ff53
refactor: fix PHP styling
ScuffedNewt Jan 22, 2025
ee7d42d
feat: remove MD comments
ScuffedNewt Jan 22, 2025
8ac318b
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt Jan 22, 2025
1e08b19
refactor: fix blade formatting
ScuffedNewt Jan 22, 2025
3e6d235
feat(mentions): notifications on comments, image mentions, user / cha…
ScuffedNewt Jan 24, 2025
75946cd
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt Jan 24, 2025
77761b0
refactor: fix blade formatting
ScuffedNewt Jan 24, 2025
5056d01
refactor: fix PHP styling
ScuffedNewt Jan 24, 2025
ed8b5a8
feat: regenerating broken images / tags, mentions on news and sales
ScuffedNewt Jan 24, 2025
7af1b8e
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt Jan 24, 2025
d67346f
refactor: fix blade formatting
ScuffedNewt Jan 24, 2025
2e47125
refactor: fix PHP styling
ScuffedNewt Jan 24, 2025
b1b9495
feat: update mention information & gallery submission mentions
ScuffedNewt Jan 24, 2025
30c8cf5
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt Jan 24, 2025
efefd80
chore(deps): rebuild mix assets
ScuffedNewt Jan 24, 2025
16b865e
refactor: fix blade formatting
ScuffedNewt Jan 24, 2025
4b01fbd
feat: update all tinymce JS
ScuffedNewt Jan 24, 2025
8e3c407
Merge branch 'feature/mentions' of https://github.com/Ne-wt/lorekeepe…
ScuffedNewt Jan 24, 2025
d10a832
refactor: fix PHP styling
ScuffedNewt Jan 24, 2025
dd4c91e
feat(mentions command): command to convert prior mentions to new format
ScuffedNewt Jan 24, 2025
76a3c63
refactor: fix PHP styling
ScuffedNewt Jan 24, 2025
f6e89dd
fix: user av + name
ScuffedNewt Jan 25, 2025
485fb09
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt Apr 4, 2025
dc3b114
refactor: fix blade formatting
ScuffedNewt Apr 4, 2025
eda8264
fix: conflicts
ScuffedNewt Apr 4, 2025
31fd3ca
fix: fix tinymce init and change # delimiter to %
ScuffedNewt May 26, 2025
e2a50d8
refactor: fix blade formatting
ScuffedNewt May 26, 2025
d001ceb
fix: loading
ScuffedNewt May 26, 2025
b7da706
Merge branch 'feature/mentions' of https://github.com/scuffednewt/lor…
ScuffedNewt May 26, 2025
3a11810
fix: restore extension config
ScuffedNewt May 27, 2025
01addfc
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt May 29, 2025
a46b303
fix: allow pings in comments
ScuffedNewt May 29, 2025
aacac2c
refactor: fix blade formatting
ScuffedNewt May 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions app/Console/Commands/ConvertExtendedMentions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace App\Console\Commands;

use App\Models\Character\CharacterProfile;
use App\Models\Gallery\GallerySubmission;
use App\Models\News;
use App\Models\Sales\Sales;
use App\Models\SitePage;
use App\Models\Users\UserProfile;
use Illuminate\Console\Command;

class ConvertExtendedMentions extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:convert-extended-mentions';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Converts the unparsed text of extended mentions to follow the new format, and also reparsing to update the parsed text.';

/**
* Execute the console command.
*/
public function handle() {
//
$this->info('Converting extended mentions...');
$this->info('Converting News...');
foreach (News::all() as $news) {
$newText = $this->convertText($news->text);
$news->text = $newText;
$news->parsed_text = parse($newText);
$news->save();
}

$this->info('Converting Site Pages...');
foreach (SitePage::all() as $page) {
$newText = $this->convertText($page->text);
$page->text = $newText;
$page->parsed_text = parse($newText);
$page->save();
}

$this->info('Converting Sales...');
foreach (Sales::all() as $sale) {
$newText = $this->convertText($sale->description);
$sale->description = $newText;
$sale->parsed_description = parse($newText);
$sale->save();
}

$this->info('Converting Character Profiles...');
foreach (CharacterProfile::all() as $profile) {
$newText = $this->convertText($profile->description);
$profile->description = $newText;
$profile->parsed_description = parse($newText);
$profile->save();
}

$this->info('Converting User Profiles...');
foreach (UserProfile::all() as $profile) {
$newText = $this->convertText($profile->bio);
$profile->bio = $newText;
$profile->parsed_bio = parse($newText);
$profile->save();
}

$this->info('Converting Gallery Submissions...');
foreach (GallerySubmission::all() as $submission) {
$newText = $this->convertText($submission->description);
$submission->description = $newText;
$submission->parsed_description = parse($newText);
$submission->save();
}

$this->info('Conversion complete.');
}

private function convertText($text) {
$toMatch = [
'/\B@([A-Za-z0-9_-]+)/', // matches @mentions
'/\B%([A-Za-z0-9_-]+)/', // matches %mentions
'/\[user=([^\[\]&<>?"\']+)\]/', // matches [user=username]
'/\[userav=([^\[\]&<>?"\']+)\]/', // matches [userav=username]
'/\[character=([^\[\]&<>?"\']+)\]/', // matches [character=name]
'/\[charthumb=([^\[\]&<>?"\']+)\]/', // matches [charthumb=name]
'/\[thumb=([^\[\]&<>?"\']+)\]/', // matches [thumb=name]
];

$replacements = [
'<span class="data-mention" data-mention-type="user" data-id="$1">@$1</span>',
'<span class="data-mention" data-mention-type="user" data-id="$1"><img src="/avatars/$1.jpg"></span><span class="data-mention" data-mention-type="user" data-id="$1">@$1</span>',
'<span class="data-mention" data-mention-type="user" data-id="$1">@$1</span>',
'<span class="data-mention" data-mention-type="user" data-id="$1"><img src="/avatars/$1.jpg"></span>',
'<span class="data-mention" data-mention-type="character" data-id="$1">@$1</span>',
'<span class="data-mention" data-mention-type="character" data-id="$1"><img src="/character_thumbs/$1.jpg"></span>',
'<span class="data-mention" data-mention-type="gallery_submission" data-id="$1"><img class="img-fluid rounded" src="/gallery_thumbs/$1.jpg"></span>',
];

foreach ($toMatch as $index => $pattern) {
$text = preg_replace($pattern, $replacements[$index], $text);
}

return $text;
}
}
26 changes: 25 additions & 1 deletion app/Helpers/AssetHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ function getAssetModelString($type, $namespaced = true) {
}
break;

case 'users': case 'user': // users aren't really assets, but it's convenient to be able to get the user model
if ($namespaced) {
return '\App\Models\User\User';
} else {
return 'User';
}
break;

case 'user_items':
if ($namespaced) {
return '\App\Models\User\UserItem';
Expand All @@ -129,7 +137,7 @@ function getAssetModelString($type, $namespaced = true) {
}
break;

case 'characters':
case 'characters': case 'character':
if ($namespaced) {
return '\App\Models\Character\Character';
} else {
Expand All @@ -144,6 +152,22 @@ function getAssetModelString($type, $namespaced = true) {
return 'CharacterItem';
}
break;

case 'emotes': case 'emote':
if ($namespaced) {
return '\App\Models\Emote';
} else {
return 'Emote';
}
break;

case 'gallery_submissions': case 'gallery_submission':
if ($namespaced) {
return '\App\Models\Gallery\GallerySubmission';
} else {
return 'GallerySubmission';
}
break;
}

return null;
Expand Down
Loading