Don’t use NotePrep for retreiving tags from a note
This commit is contained in:
parent
cac29bbb63
commit
58c060ad27
1 changed files with 7 additions and 5 deletions
|
@ -5,7 +5,6 @@ namespace App\Providers;
|
||||||
use App\Tag;
|
use App\Tag;
|
||||||
use App\Note;
|
use App\Note;
|
||||||
use Validator;
|
use Validator;
|
||||||
use Jonnybarnes\IndieWeb\NotePrep;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
@ -32,11 +31,14 @@ class AppServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
//Add tags for notes
|
//Add tags for notes
|
||||||
Note::created(function ($note) {
|
Note::created(function ($note) {
|
||||||
$noteprep = new NotePrep();
|
|
||||||
$tagsToAdd = [];
|
$tagsToAdd = [];
|
||||||
$tags = $noteprep->getTags($note->note);
|
preg_match_all('/#([^\s<>]+)\b/', $note, $tags);
|
||||||
foreach ($tags as $text) {
|
foreach ($tags[1] as $tag) {
|
||||||
$tag = Tag::firstOrCreate(['tag' => $text]);
|
$tag = Tag::normalizeTag($tag);
|
||||||
|
}
|
||||||
|
$tags = array_unique($tags[1]);
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
$tag = Tag::firstOrCreate(['tag' => $tag]);
|
||||||
$tagsToAdd[] = $tag->id;
|
$tagsToAdd[] = $tag->id;
|
||||||
}
|
}
|
||||||
if (count($tagsToAdd > 0)) {
|
if (count($tagsToAdd > 0)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue