]> _ Git - psq.git/commitdiff
removed chapo from social article
authorLouis Jeckel <louis.jeckel@outlook.com>
Wed, 20 Jan 2021 10:42:37 +0000 (11:42 +0100)
committerLouis Jeckel <louis.jeckel@outlook.com>
Wed, 20 Jan 2021 10:42:37 +0000 (11:42 +0100)
app/Helpers/Helpers.php [new file with mode: 0644]
app/Helpers/SimpleTemplateEngine.php
app/Models/LaboArticle.php
app/Models/SocialArticle.php
resources/views/admin/socialArticles/form.blade.php
resources/views/social-articles/show.blade.php

diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php
new file mode 100644 (file)
index 0000000..da3be1f
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+
+namespace App\Helpers;
+
+
+use Html2Text\Html2Text;
+
+class Helpers
+{
+
+    /**
+     * @param $string
+     * @param $size
+     * @return string
+     * Trims HTML to specified size
+     */
+    public static function htmlTrimMaker($string, $size): string
+    {
+        $line = (new Html2Text($string))->getText();
+
+        if (preg_match("/^.{1,$size}\b/s", $line, $match)) {
+            $line = trim($match[0]) . "…";
+        }
+
+        return $line;
+    }
+
+}
index bde7ac681696618fe47a4530773c5e689ddfb795..3e83c5d3cd72c6cae3e1c10a9c0192c810d36440 100644 (file)
@@ -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)
index 60bde42f4c653c1d3e8b03c760478ba7dbe8d341..1358119bbc587b982917612e2d136eb901766bdc 100644 (file)
@@ -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);
     }
 
     /**
index 44c221b3c1a5f121dbdb76c04123bdfa18d432d7..7c55b23140e427f8d483dc821ffac3a478b492c9 100644 (file)
@@ -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);
+    }
 }
index a08d799790b1b96f57fac8e1657aa4cca6ecaed8..d631f2016943c5f55e2b3a340aa7189ca9ece433 100644 (file)
         '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',
index 6568cad9d24e425f0a7360b5cd334f711b09f302..b2c5a4c68b27718ff9208ad8ed1646fbd934fdc2 100644 (file)
@@ -11,8 +11,8 @@
             <article class="col-sm-8">
                         <x-unlocked-article-alerts :article="$article"></x-unlocked-article-alerts>
 
-                <h2>{{$article->title}}</h2>
-                <div class="chapo">{!! $article->chapo !!}</div>
+{{--                <h2>{{$article->title}}</h2>--}}
+{{--                <div class="chapo">{!! $article->chapo !!}</div>--}}
 
                 <div class="content ck-content mt-5">
                     <x-subscriber-only-content :article="$article"></x-subscriber-only-content>