]> _ Git - psq.git/commitdiff
actus labos, file show, 403 error
authorLouis Jeckel <louis.jeckel@outlook.cm>
Wed, 12 Aug 2020 17:22:01 +0000 (19:22 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Wed, 12 Aug 2020 17:22:01 +0000 (19:22 +0200)
22 files changed:
app/Helpers/Fields.php [new file with mode: 0644]
app/Http/Controllers/ActuLabosController.php [new file with mode: 0644]
app/Http/Controllers/Admin/LaboArticleController.php
app/Http/Controllers/FileController.php
app/Http/Controllers/FlowpaperController.php
app/Models/LaboArticle.php
app/PdfFile.php
app/Policies/PdfFilePolicy.php
app/View/Components/Cover.php
database/migrations/2020_08_11_092617_create_labo_articles_tables.php
public/css/app.css
resources/sass/_pill_boxes.scss
resources/sass/app.scss
resources/views/actu-labos/index.blade.php [new file with mode: 0644]
resources/views/actu-labos/show.blade.php [new file with mode: 0644]
resources/views/admin/laboArticles/form.blade.php
resources/views/admin/settings/strings.blade.php
resources/views/components/cover.blade.php
resources/views/components/nav.blade.php
resources/views/errors/403.blade.php
resources/views/file/show.blade.php [new file with mode: 0644]
routes/web.php

diff --git a/app/Helpers/Fields.php b/app/Helpers/Fields.php
new file mode 100644 (file)
index 0000000..65dffb2
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+
+namespace App\Helpers;
+
+
+class Fields
+{
+
+    public static function fullToolbar(): array
+    {
+        return [
+            [ 'header' => [2, 3, false] ],
+            'link',
+            'bold',
+            'italic',
+            'underline',
+            'strike',
+            'list-ordered',
+            'list-unordered',
+            [ 'indent' => '-1'],
+            [ 'indent' => '+1' ]
+        ];
+
+    }
+
+}
diff --git a/app/Http/Controllers/ActuLabosController.php b/app/Http/Controllers/ActuLabosController.php
new file mode 100644 (file)
index 0000000..715c1d1
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\LaboArticle;
+use Illuminate\Http\Request;
+
+class ActuLabosController extends Controller
+{
+    public function index()
+    {
+        \View::share('actus', LaboArticle::query()->orderBy('position')->published()->take(4)->get());
+        return view('actu-labos.index');
+    }
+}
index fe2929aff9713918ecd8029cad5bcbb38e4f5e8f..287ec187ea18908acaaa432b6adb1771b085049a 100644 (file)
@@ -7,4 +7,10 @@ use A17\Twill\Http\Controllers\Admin\ModuleController;
 class LaboArticleController extends ModuleController
 {
     protected $moduleName = 'laboArticles';
+
+
+    protected $indexOptions = [
+        'reorder' => true,
+    ];
 }
+
index 94e832e1c8834cd80f52cafa41ecbededf441cd9..addbad87ac35dc628142e9fd7b606b8c6ee11134 100644 (file)
@@ -31,6 +31,12 @@ class FileController extends Controller
     }
 
 
+    public function show(PdfFile $file)
+    {
+        \View::share('file', $file);
+        return view('file.show');
+    }
+
 }
 
 
index b415b9cb7768aa5c3c5b07a35886a579a16a1909..bfb0d163dce53cc28a004af15fdedd43090bf41f 100644 (file)
@@ -23,6 +23,7 @@ class FlowpaperController extends Controller
     public function view(PdfFile $file, Request $request): View
     {
         $this->authorize('view', $file);
+
         AccessLog::log($request, $file);
         return $file->view();
     }
index ef9d7bc2aea7cbe5e02125ef5f67cf4f15c0b3a1..4a7edd17ed1ad77078a0ce0627e20b5683eea41e 100644 (file)
@@ -2,51 +2,38 @@
 
 namespace App\Models;
 
+use A17\Twill\Models\Behaviors\HasPosition;
 use A17\Twill\Models\Behaviors\HasSlug;
 use A17\Twill\Models\Behaviors\HasMedias;
+use A17\Twill\Models\Behaviors\Sortable;
 use A17\Twill\Models\Model;
 
-class LaboArticle extends Model 
+class LaboArticle extends Model implements Sortable
 {
-    use HasSlug, HasMedias;
+    use HasSlug, HasMedias, HasPosition;
 
     protected $fillable = [
-        'published',
+        'publish_start_date',
+        'publish_end_date',
         'title',
-        'description',
+        'chapo',
+        'preview',
+        'content',
+        'published',
+        'position',
     ];
-    
+
     public $slugAttributes = [
         'title',
     ];
-    
+
     public $mediasParams = [
-        'cover' => [
-            'desktop' => [
-                [
-                    'name' => 'desktop',
-                    'ratio' => 16 / 9,
-                ],
-            ],
-            'mobile' => [
+        'image' => [
+            'default' => [
                 [
-                    'name' => 'mobile',
-                    'ratio' => 1,
-                ],
-            ],
-            'flexible' => [
-                [
-                    'name' => 'free',
+                    'name' => 'default',
                     'ratio' => 0,
                 ],
-                [
-                    'name' => 'landscape',
-                    'ratio' => 16 / 9,
-                ],
-                [
-                    'name' => 'portrait',
-                    'ratio' => 3 / 5,
-                ],
             ],
         ],
     ];
index 5901a773d0c7e9a96f1d236ed509ab815d558eb7..667e8f2131214c7df1d3192a6f3dc6346a259f9c 100644 (file)
@@ -41,6 +41,7 @@ use Vaites\ApacheTika\Client as TikaClient;
  * @property string $absoluteCoverPath
  * @property string $coverUrl
  * @property string $directory
+ * @property string $title
  * @property bool $is_free
  * @property Collection $accessLogs
  * @property-read int $accessCount
@@ -353,7 +354,6 @@ class PdfFile extends TwillModel implements Sortable
 
 
 
-
     /**
      * Processes pdf to json conversion for in-file search
      */
@@ -466,7 +466,7 @@ class PdfFile extends TwillModel implements Sortable
         return view('flowpaper.view', [
             'pdfPath' => $this->binUrl,
             'jsonPath' => $this->jsonUrl,
-            'title' => 'La Lettre Pharma',
+            'title' => (string)$this,
         ]);
 
     }
@@ -498,8 +498,24 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
+    /**
+     * @return Builder
+     */
+    public static function last(): Builder
+    {
+        return self::query()->orderByDesc('id');
+    }
 
-
+    /**
+     * @return bool
+     */
+    public function isLast(): bool
+    {
+        return self::last()
+            ->select('id')
+            ->firstOrFail()
+            ->is($this);
+    }
 
 
     /** Scopes */
@@ -512,6 +528,13 @@ class PdfFile extends TwillModel implements Sortable
         $builder->where('is_free', true);
     }
 
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return $this->title ?? 'PSQ';
+    }
 }
 
 
index 8848d77e485ca9335c56a09d74e90536a27a014a..20a94c54ddb405197de28271dd624175bba457bb 100644 (file)
@@ -54,11 +54,13 @@ class PdfFilePolicy
             return true;
         }
 
-        throw new AuthenticationException(
-            'Unauthenticated.',
-            ['web'],
-            route('login', ['redirect_to' => request()->getUri()])
-        );
+        return false;
+
+//        throw new AuthenticationException(
+//            'Unauthenticated.',
+//            ['web'],
+//            route('login', ['redirect_to' => request()->getUri()])
+//        );
 
     }
 
index 897079543a796ba3de9585bb2f6e62c3ccd44775..58e140148490fd0ceadd5487bf079a567534878e 100644 (file)
@@ -11,20 +11,28 @@ class Cover extends Component
     public string $type;
     public string $class;
     public string $file;
+    public string $link;
+    public string $target;
 
     /**
      * Create a new component instance.
      *
      * @param $pdf
      * @param $type
+     * @param string $linkTo edition or read
+     * @param string $target
      */
-    public function __construct($pdf, $type)
+    public function __construct($pdf, $type, $linkTo = 'edition', $target = '_self')
     {
-        //
         $this->pdf = $pdf;
         $this->type = $type;
         $this->class = "cover-pile-$type";
         $this->file = asset("img/cover-bg/pile-mag-$type.png");
+        $this->link = $linkTo === 'edition' ?
+            action('FileController@show', ['file' => $pdf]) :
+            $this->pdf->getUrl();
+        $this->target = $target;
+
 
     }
 
index a289469082e3892f16ecf13d8fd1a5fa8248c026..d0a03d654a7ec8cd20c9da129c3f3537c5c35db2 100644 (file)
@@ -15,7 +15,9 @@ class CreateLaboArticlesTables extends Migration
             $table->string('title', 200)->nullable();
 
             $table->string('chapo')->nullable();
+            $table->text('preview')->nullable();
             $table->text('content')->nullable();
+            $table->integer('position')->nullable();
 
             // add those 2 columns to enable publication timeframe fields (you can use publish_start_date only if you don't need to provide the ability to specify an end date)
              $table->timestamp('publish_start_date')->nullable();
@@ -31,7 +33,6 @@ class CreateLaboArticlesTables extends Migration
 
     public function down()
     {
-
         Schema::dropIfExists('labo_article_slugs');
         Schema::dropIfExists('labo_articles');
     }
index cbd0e1e8417050777a20ba3f8246cc788ec45fc0..8baa9a6aad953b8bd3d84a5de37d6769a14ec7e8 100644 (file)
@@ -11384,7 +11384,7 @@ div.pill-box div {
 
 div.pill-box div h2 {
   padding: 2px 10px 1px 50px;
-  margin: 0 -6px;
+  margin: 0 -6px 10px;
   background-color: #074e9c;
   color: white;
   text-align: center;
@@ -11491,3 +11491,11 @@ div.pill-box div > a.bottom-right {
   font-size: small;
 }
 
+.error-403 p {
+  font-size: x-large;
+}
+
+.error-403 a {
+  color: inherit !important;
+}
+
index 9627d56c129fd959bbd3a7663e38ca48766e7126..6c5f4b39edd3285f4c96d41a0d6010e7dc05e8bb 100644 (file)
@@ -21,7 +21,7 @@ div.pill-box {
 
         h2 {
             padding: 2px 10px 1px 50px;
-            margin: 0 -6px;
+            margin: 0 -6px 10px;
             background-color: $psq_blue;
             color: white;
             text-align: center;
index 1db74ab8e89a8c1edc42ff8e03592db759559596..8773bdbac06541d71709936b9168943704dbf94c 100644 (file)
@@ -79,3 +79,13 @@ a {
     }
 }
 
+
+.error-403 {
+    p {
+        font-size: x-large;
+    }
+    a {
+        color: inherit !important;
+
+    }
+}
diff --git a/resources/views/actu-labos/index.blade.php b/resources/views/actu-labos/index.blade.php
new file mode 100644 (file)
index 0000000..84977a9
--- /dev/null
@@ -0,0 +1,9 @@
+@extends('layouts.app')
+
+@section('content')
+
+@foreach($actus as $actu)
+    {{$actu->title}}
+@endforeach
+
+@endsection
diff --git a/resources/views/actu-labos/show.blade.php b/resources/views/actu-labos/show.blade.php
new file mode 100644 (file)
index 0000000..e69de29
index 2a22637c029db1d44025e06d69d1560a8b162105..5720aab595c7c04dce20d8f3cef5bea922a3220c 100644 (file)
@@ -2,8 +2,31 @@
 
 @section('contentFields')
     @formField('input', [
-        'name' => 'description',
-        'label' => 'Description',
-        'maxlength' => 100
+        'name' => 'chapo',
+        'label' => 'Chapô',
+        'maxlength' => 200,
+        'required' => true,
+
+    ])
+    @formField('input', [
+        'name' => 'preview',
+        'label' => 'Extrait',
+        'maxlength' => 250,
+        'type' => 'textarea',
+        'required' => true,
+
+    ])
+    @formField('wysiwyg', [
+        'label' => 'Article complet',
+        'name' => 'content',
+        'required' => true,
+        'toolbarOptions' => \App\Helpers\Fields::fullToolbar(),
+        'rows' => 8
+    ])
+
+    @formField('medias', [
+        'name' => 'image',
+        'label' => 'Image',
+        'max' => 1,
     ])
 @stop
index 874cc88ef3bd68827dd6d6d60ec00afdcafd94ea..fa8595a841b48b7cee2f5633b00daba7317e062e 100644 (file)
@@ -6,20 +6,20 @@
         'name' => 'not_registered_text',
         'maxlength' => 1000,
         'required' => true,
-        'toolbarOptions' => [ [ 'header' => [2, 3, false] ], 'link', 'bold', 'italic', 'underline', 'strike', 'list-ordered', 'list-unordered', [ 'indent' => '-1'], [ 'indent' => '+1' ] ],
+        'toolbarOptions' => \App\Helpers\Fields::fullToolbar(),
     ])
     @formField('wysiwyg', [
         'label' => 'Texte page pas encore abonné bas gauche',
         'name' => 'not_registered_text_left',
         'maxlength' => 1000,
         'required' => true,
-        'toolbarOptions' => [ [ 'header' => [2, 3, false] ], 'link', 'bold', 'italic', 'underline', 'strike', 'list-ordered', 'list-unordered', [ 'indent' => '-1'], [ 'indent' => '+1' ] ],
+        'toolbarOptions' => \App\Helpers\Fields::fullToolbar(),
     ])
     @formField('wysiwyg', [
         'label' => 'Texte page pas encore abonné bas droite',
         'name' => 'not_registered_text_right',
         'maxlength' => 1000,
         'required' => true,
-        'toolbarOptions' => [ [ 'header' => [2, 3, false] ], 'link', 'bold', 'italic', 'underline', 'strike', 'list-ordered', 'list-unordered', [ 'indent' => '-1'], [ 'indent' => '+1' ] ],
+        'toolbarOptions' => \App\Helpers\Fields::fullToolbar(),
     ])
 @stop
index c38e4364298ea13bd28e38ff629d22daabb50437..94996ad76d6f21c7a4ffe125aa829e5884f91a24 100644 (file)
@@ -1,6 +1,6 @@
 <div class="cover {{$class}}">
 
-    <a href="{{$pdf->getUrl()}}" target="_blank">
+    <a href="{{$link}}" target="{{$target}}">
         <img class="cover-bg" src="{{$file}}" alt="">
         <img class="cover-over" src="{{$pdf->coverUrl}}" alt="">
         <div class="cover-title">
index b31afcf70fe60efcf43723ee9eeadd9e7f6aa57b..122fa822f42ce9274ab59edabc4ca80d5095610a 100644 (file)
@@ -34,7 +34,7 @@
     </div>
 
     <div>
-        <a href="#">
+        <a href="{{action('ActuLabosController@index')}}">
             <img src="{{asset('img/nav/6-leslabos.svg')}}" alt="Pill Icon">
             <p>Les labo&shy;ratoires</p>
         </a>
index 362d10e94570bac7eda85e79fa2990cad1b162e2..08d28d8e285462759f1a3b47a54bde2a0469bc5f 100644 (file)
@@ -2,15 +2,15 @@
 
 @section('content')
 
-    <div class="container">
+    <div class="container error-403">
         <h1>Vous ne pouvez pas accéder à cette page !</h1>
 
 
-        @auth
+        @guest
+            <p class="denim">Si vous possédez un compte, <a href="{{route('login', ['redirect_to' => request()->getUri()])}}">cliquez ici pour vous connecter</a></p>
+            <p class="orange">Sinon, <a href="{{route('not-registered')}}">cliquez ici pour découvrir nos formules d'abonnement !</a></p>
+        @elseguest
             <h2>Il semblerait que votre abonnement n'est plus actif...</h2>
-        @elseauth
-            <p>Vous n'êtes pas connecté, <a href="{{route('login')}}">cliquez ici pour vous connecter</a></p>
-
-        @endauth
+        @endguest
     </div>
 @endsection
diff --git a/resources/views/file/show.blade.php b/resources/views/file/show.blade.php
new file mode 100644 (file)
index 0000000..841671a
--- /dev/null
@@ -0,0 +1,25 @@
+@extends('layouts.app')
+
+@section('content')
+
+    @can('view', $file)
+
+
+    @endcan
+
+    <div class="container psq-mag">
+
+
+        <h1>{{$file->isLast() ? "L'édition du jour" : $file->title}}</h1>
+        <div class="mx-auto mb-4" style="max-width: 500px;">
+            <x-cover :pdf="$file" type="3" linkTo="read" target="_blank"></x-cover>
+            <h2 class="text-center">Cliquez sur l’image pour télécharger cette édition de notre quotidien</h2>
+        </div>
+
+        <x-pill-box title="Archives" :link="route('archives')">
+            Vous pouvez accéder aux archives de Prescription Santé Quotidien et aux 300 derniers numéros. Vous pouvez également effectuer des recherches par mots clefs
+        </x-pill-box>
+
+    </div>
+
+@endsection
index c230a0284b86b60b5119f5b3bc9567a67bf95ab2..c2b390237e4f0243493311900b41bf57fe4bbfc1 100644 (file)
@@ -48,15 +48,19 @@ Route::domain(env('CLIENT_DOMAIN_NAME'))->group(function() {
         ->get('/view/{file:slug}', 'FlowpaperController@view')
         ->name('flowpaper.view');
 
+    Route::get('edition/{file:slug}', 'FileController@show');
 
-    Route::get('/search', 'FileController@search');
 
-    Route::get('/campagnes-et-communication', 'AdCampaignController@index');
-    Route::get('/campagnes-et-communication/archives', 'AdCampaignController@search');
+    Route::get('search', 'FileController@search')->name('archives');
 
-    Route::get('/podcasts', 'PodcastController@index');
+    Route::get('campagnes-et-communication', 'AdCampaignController@index');
+    Route::get('campagnes-et-communication/archives', 'AdCampaignController@search');
 
-    Route::get('/pas-encore-inscrit', 'Auth\NotRegisteredYet@index');
+    Route::get('podcasts', 'PodcastController@index');
+
+    Route::get('pas-encore-inscrit', 'Auth\NotRegisteredYet@index')->name('not-registered');
+
+    Route::get('actus-labos', 'ActuLabosController@index');
 
     /** Metadata */
     Route::prefix('/files/{file:slug}')->group(function () {