From: Louis Jeckel Date: Wed, 12 Aug 2020 17:22:01 +0000 (+0200) Subject: actus labos, file show, 403 error X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9f3bedda7c7d08b590f5fc5876716c72bb65f28b;p=psq.git actus labos, file show, 403 error --- diff --git a/app/Helpers/Fields.php b/app/Helpers/Fields.php new file mode 100644 index 0000000..65dffb2 --- /dev/null +++ b/app/Helpers/Fields.php @@ -0,0 +1,27 @@ + [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 index 0000000..715c1d1 --- /dev/null +++ b/app/Http/Controllers/ActuLabosController.php @@ -0,0 +1,15 @@ +orderBy('position')->published()->take(4)->get()); + return view('actu-labos.index'); + } +} diff --git a/app/Http/Controllers/Admin/LaboArticleController.php b/app/Http/Controllers/Admin/LaboArticleController.php index fe2929a..287ec18 100644 --- a/app/Http/Controllers/Admin/LaboArticleController.php +++ b/app/Http/Controllers/Admin/LaboArticleController.php @@ -7,4 +7,10 @@ use A17\Twill\Http\Controllers\Admin\ModuleController; class LaboArticleController extends ModuleController { protected $moduleName = 'laboArticles'; + + + protected $indexOptions = [ + 'reorder' => true, + ]; } + diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php index 94e832e..addbad8 100644 --- a/app/Http/Controllers/FileController.php +++ b/app/Http/Controllers/FileController.php @@ -31,6 +31,12 @@ class FileController extends Controller } + public function show(PdfFile $file) + { + \View::share('file', $file); + return view('file.show'); + } + } diff --git a/app/Http/Controllers/FlowpaperController.php b/app/Http/Controllers/FlowpaperController.php index b415b9c..bfb0d16 100644 --- a/app/Http/Controllers/FlowpaperController.php +++ b/app/Http/Controllers/FlowpaperController.php @@ -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(); } diff --git a/app/Models/LaboArticle.php b/app/Models/LaboArticle.php index ef9d7bc..4a7edd1 100644 --- a/app/Models/LaboArticle.php +++ b/app/Models/LaboArticle.php @@ -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, - ], ], ], ]; diff --git a/app/PdfFile.php b/app/PdfFile.php index 5901a77..667e8f2 100644 --- a/app/PdfFile.php +++ b/app/PdfFile.php @@ -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'; + } } diff --git a/app/Policies/PdfFilePolicy.php b/app/Policies/PdfFilePolicy.php index 8848d77..20a94c5 100644 --- a/app/Policies/PdfFilePolicy.php +++ b/app/Policies/PdfFilePolicy.php @@ -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()]) +// ); } diff --git a/app/View/Components/Cover.php b/app/View/Components/Cover.php index 8970795..58e1401 100644 --- a/app/View/Components/Cover.php +++ b/app/View/Components/Cover.php @@ -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; + } diff --git a/database/migrations/2020_08_11_092617_create_labo_articles_tables.php b/database/migrations/2020_08_11_092617_create_labo_articles_tables.php index a289469..d0a03d6 100644 --- a/database/migrations/2020_08_11_092617_create_labo_articles_tables.php +++ b/database/migrations/2020_08_11_092617_create_labo_articles_tables.php @@ -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'); } diff --git a/public/css/app.css b/public/css/app.css index cbd0e1e..8baa9a6 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -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; +} + diff --git a/resources/sass/_pill_boxes.scss b/resources/sass/_pill_boxes.scss index 9627d56..6c5f4b3 100644 --- a/resources/sass/_pill_boxes.scss +++ b/resources/sass/_pill_boxes.scss @@ -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; diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 1db74ab..8773bdb 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -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 index 0000000..84977a9 --- /dev/null +++ b/resources/views/actu-labos/index.blade.php @@ -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 index 0000000..e69de29 diff --git a/resources/views/admin/laboArticles/form.blade.php b/resources/views/admin/laboArticles/form.blade.php index 2a22637..5720aab 100644 --- a/resources/views/admin/laboArticles/form.blade.php +++ b/resources/views/admin/laboArticles/form.blade.php @@ -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 diff --git a/resources/views/admin/settings/strings.blade.php b/resources/views/admin/settings/strings.blade.php index 874cc88..fa8595a 100644 --- a/resources/views/admin/settings/strings.blade.php +++ b/resources/views/admin/settings/strings.blade.php @@ -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 diff --git a/resources/views/components/cover.blade.php b/resources/views/components/cover.blade.php index c38e436..94996ad 100644 --- a/resources/views/components/cover.blade.php +++ b/resources/views/components/cover.blade.php @@ -1,6 +1,6 @@
- +
diff --git a/resources/views/components/nav.blade.php b/resources/views/components/nav.blade.php index b31afcf..122fa82 100644 --- a/resources/views/components/nav.blade.php +++ b/resources/views/components/nav.blade.php @@ -34,7 +34,7 @@
- + Pill Icon

Les labo­ratoires

diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php index 362d10e..08d28d8 100644 --- a/resources/views/errors/403.blade.php +++ b/resources/views/errors/403.blade.php @@ -2,15 +2,15 @@ @section('content') -
+

Vous ne pouvez pas accéder à cette page !

- @auth + @guest +

Si vous possédez un compte, cliquez ici pour vous connecter

+

Sinon, cliquez ici pour découvrir nos formules d'abonnement !

+ @elseguest

Il semblerait que votre abonnement n'est plus actif...

- @elseauth -

Vous n'êtes pas connecté, cliquez ici pour vous connecter

- - @endauth + @endguest
@endsection diff --git a/resources/views/file/show.blade.php b/resources/views/file/show.blade.php new file mode 100644 index 0000000..841671a --- /dev/null +++ b/resources/views/file/show.blade.php @@ -0,0 +1,25 @@ +@extends('layouts.app') + +@section('content') + + @can('view', $file) + + + @endcan + +
+ + +

{{$file->isLast() ? "L'édition du jour" : $file->title}}

+
+ +

Cliquez sur l’image pour télécharger cette édition de notre quotidien

+
+ + + 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 + + +
+ +@endsection diff --git a/routes/web.php b/routes/web.php index c230a02..c2b3902 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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 () {