From: Louis Jeckel Date: Wed, 20 Jan 2021 10:42:37 +0000 (+0100) Subject: removed chapo from social article X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=908b9bdd5f8e5d9ad76120720dfc3783fb59ec6c;p=psq.git removed chapo from social article --- diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php new file mode 100644 index 0000000..da3be1f --- /dev/null +++ b/app/Helpers/Helpers.php @@ -0,0 +1,29 @@ +getText(); + + if (preg_match("/^.{1,$size}\b/s", $line, $match)) { + $line = trim($match[0]) . "…"; + } + + return $line; + } + +} diff --git a/app/Helpers/SimpleTemplateEngine.php b/app/Helpers/SimpleTemplateEngine.php index bde7ac6..3e83c5d 100644 --- a/app/Helpers/SimpleTemplateEngine.php +++ b/app/Helpers/SimpleTemplateEngine.php @@ -7,6 +7,11 @@ namespace App\Helpers; use Illuminate\Support\Arr; use Illuminate\Support\Str; +/** + * Class SimpleTemplateEngine + * @package App\Helpers + * @deprecated + */ class SimpleTemplateEngine { public static function renderWithModel($template, $model) diff --git a/app/Models/LaboArticle.php b/app/Models/LaboArticle.php index 60bde42..1358119 100644 --- a/app/Models/LaboArticle.php +++ b/app/Models/LaboArticle.php @@ -7,6 +7,7 @@ use A17\Twill\Models\Behaviors\HasSlug; use A17\Twill\Models\Behaviors\HasMedias; use A17\Twill\Models\Behaviors\Sortable; use A17\Twill\Models\Model; +use App\Helpers\Helpers; use App\IsStripeUnlockable; use App\StripePaymentContract; use Laravel\Scout\Searchable; @@ -63,13 +64,7 @@ class LaboArticle extends Model implements Sortable, PillBoxContract, HasUrl, St public function getPreviewAttribute(): string { - $line = (new \Html2Text\Html2Text($this->content))->getText(); - - if (preg_match('/^.{1,200}\b/s', $line, $match)) { - $line = trim($match[0]) . "…"; - } - - return $line; + return Helpers::htmlTrimMaker($this->content, 200); } /** diff --git a/app/Models/SocialArticle.php b/app/Models/SocialArticle.php index 44c221b..7c55b23 100644 --- a/app/Models/SocialArticle.php +++ b/app/Models/SocialArticle.php @@ -11,6 +11,7 @@ use A17\Twill\Models\Behaviors\HasRevisions; use A17\Twill\Models\Behaviors\HasPosition; use A17\Twill\Models\Behaviors\Sortable; use A17\Twill\Models\Model; +use App\Helpers\Helpers; use App\IsStripeUnlockable; use App\StripePaymentContract; @@ -19,7 +20,7 @@ use App\StripePaymentContract; * @package App\Models * @property string $content * @property string $title - * @property string $chapo + * @property string $chapo depreciated * @property int $count */ class SocialArticle extends Model implements PillBoxContract, HasUrl, StripePaymentContract @@ -75,4 +76,12 @@ class SocialArticle extends Model implements PillBoxContract, HasUrl, StripePaym { return route('social-article.show', ['slug' => $this->slug]); } + + /** + * @return string + */ + protected function getMetaDescription(): string + { + return Helpers::htmlTrimMaker($this->content, 200); + } } diff --git a/resources/views/admin/socialArticles/form.blade.php b/resources/views/admin/socialArticles/form.blade.php index a08d799..d631f20 100644 --- a/resources/views/admin/socialArticles/form.blade.php +++ b/resources/views/admin/socialArticles/form.blade.php @@ -13,10 +13,10 @@ 'max' => 1, ]) - @formField('wysiwyg', [ - 'name' => 'chapo', - 'label' => 'Chapô', - ]) +{{-- @formField('wysiwyg', [--}} +{{-- 'name' => 'chapo',--}} +{{-- 'label' => 'Chapô',--}} +{{-- ])--}} @formField('radios', [ 'name' => 'subscriber_only', 'label' => 'Article réservé aux abonnés', diff --git a/resources/views/social-articles/show.blade.php b/resources/views/social-articles/show.blade.php index 6568cad..b2c5a4c 100644 --- a/resources/views/social-articles/show.blade.php +++ b/resources/views/social-articles/show.blade.php @@ -11,8 +11,8 @@
-

{{$article->title}}

-
{!! $article->chapo !!}
+{{--

{{$article->title}}

--}} +{{--
{!! $article->chapo !!}
--}}