-
Notifications
You must be signed in to change notification settings - Fork 164
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
ScuffedNewt
wants to merge
47
commits into
lk-arpg:develop
Choose a base branch
from
ScuffedNewt:feature/mentions
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: mentions #1205
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
4f9baad
no message
5c2e27b
updating main branch finally
90d1cd5
updating php
90db87c
feat: user mentions on tinymce (non functional)
ScuffedNewt 2793418
feat(emotes): extension, squashed commit of the following:
ScuffedNewt 73a1f1b
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt 176bba0
chore(deps): rebuild mix assets
ScuffedNewt c1b20b1
refactor: fix blade formatting
ScuffedNewt 8956266
refactor: fix PHP styling
ScuffedNewt 6d7c235
chore(deps): rebuild mix assets
ScuffedNewt 27e78a8
feat: emote descriptions & alt text
ScuffedNewt 146789e
refactor: fix PHP styling
ScuffedNewt a9d6e81
Merge branch 'extension/emotes' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt 883880f
refactor: fix blade formatting
ScuffedNewt 104ff53
refactor: fix PHP styling
ScuffedNewt ee7d42d
feat: remove MD comments
ScuffedNewt 8ac318b
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt 1e08b19
refactor: fix blade formatting
ScuffedNewt 3e6d235
feat(mentions): notifications on comments, image mentions, user / cha…
ScuffedNewt 75946cd
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt 77761b0
refactor: fix blade formatting
ScuffedNewt 5056d01
refactor: fix PHP styling
ScuffedNewt ed8b5a8
feat: regenerating broken images / tags, mentions on news and sales
ScuffedNewt 7af1b8e
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt d67346f
refactor: fix blade formatting
ScuffedNewt 2e47125
refactor: fix PHP styling
ScuffedNewt b1b9495
feat: update mention information & gallery submission mentions
ScuffedNewt 30c8cf5
Merge branch 'feature/mentions' of https://github.com/Ne-wt/LK-privat…
ScuffedNewt efefd80
chore(deps): rebuild mix assets
ScuffedNewt 16b865e
refactor: fix blade formatting
ScuffedNewt 4b01fbd
feat: update all tinymce JS
ScuffedNewt 8e3c407
Merge branch 'feature/mentions' of https://github.com/Ne-wt/lorekeepe…
ScuffedNewt d10a832
refactor: fix PHP styling
ScuffedNewt dd4c91e
feat(mentions command): command to convert prior mentions to new format
ScuffedNewt 76a3c63
refactor: fix PHP styling
ScuffedNewt f6e89dd
fix: user av + name
ScuffedNewt 485fb09
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt dc3b114
refactor: fix blade formatting
ScuffedNewt eda8264
fix: conflicts
ScuffedNewt 31fd3ca
fix: fix tinymce init and change # delimiter to %
ScuffedNewt e2a50d8
refactor: fix blade formatting
ScuffedNewt d001ceb
fix: loading
ScuffedNewt b7da706
Merge branch 'feature/mentions' of https://github.com/scuffednewt/lor…
ScuffedNewt 3a11810
fix: restore extension config
ScuffedNewt 01addfc
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt a46b303
fix: allow pings in comments
ScuffedNewt aacac2c
refactor: fix blade formatting
ScuffedNewt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my god I'm re-reviewing this code and the sudden realization hits me here: all the extensions for images are
.jpg. I do not know how I missed this prior but that is definitely not going to fly for a lot of images.