From 4606fbd8295ff028348421034ea44b98ae8cd46c Mon Sep 17 00:00:00 2001 From: Louis Jeckel Date: Thu, 13 Aug 2020 12:35:45 +0200 Subject: [PATCH] les labos --- app/Http/Controllers/ActuLabosController.php | 16 +++- .../Admin/PillBoxSpaceController.php | 19 +++++ app/Models/LaboArticle.php | 28 ++++++- app/Models/PillBoxSpace.php | 3 +- app/Repositories/PillBoxSpaceRepository.php | 7 ++ ...4135_remove_preview_from_labo_articles.php | 32 ++++++++ public/css/app.css | 81 ++++++++++++++++++- resources/sass/_colors.scss | 5 ++ resources/sass/app.scss | 36 +++++++++ resources/views/actu-labos/index.blade.php | 35 +++++++- resources/views/actu-labos/show.blade.php | 19 +++++ .../views/admin/laboArticles/form.blade.php | 9 +-- resources/views/components/back.blade.php | 1 + .../views/components/simple-preview.blade.php | 20 +++++ resources/views/podcasts/index.blade.php | 22 +++-- routes/web.php | 5 +- 16 files changed, 313 insertions(+), 25 deletions(-) create mode 100644 database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php create mode 100644 resources/views/components/back.blade.php create mode 100644 resources/views/components/simple-preview.blade.php diff --git a/app/Http/Controllers/ActuLabosController.php b/app/Http/Controllers/ActuLabosController.php index 715c1d1..be4dd5e 100644 --- a/app/Http/Controllers/ActuLabosController.php +++ b/app/Http/Controllers/ActuLabosController.php @@ -3,13 +3,27 @@ namespace App\Http\Controllers; use App\Models\LaboArticle; +use App\Repositories\LaboArticleRepository; use Illuminate\Http\Request; class ActuLabosController extends Controller { public function index() { - \View::share('actus', LaboArticle::query()->orderBy('position')->published()->take(4)->get()); + \View::share('actus', LaboArticle::query()->orderBy('position')->published()->visible()->take(4)->get()); return view('actu-labos.index'); } + + + public function show($slug, LaboArticleRepository $repository) + { + + $actu = $repository->forSlug($slug); + + + \View::share('actu', $actu); + return view('actu-labos.show'); + } } + + diff --git a/app/Http/Controllers/Admin/PillBoxSpaceController.php b/app/Http/Controllers/Admin/PillBoxSpaceController.php index 334f9bb..7f5dc68 100644 --- a/app/Http/Controllers/Admin/PillBoxSpaceController.php +++ b/app/Http/Controllers/Admin/PillBoxSpaceController.php @@ -7,4 +7,23 @@ use A17\Twill\Http\Controllers\Admin\ModuleController; class PillBoxSpaceController extends ModuleController { protected $moduleName = 'pillBoxSpaces'; + + protected $indexOptions = [ + 'publish' => false, + 'bulkPublish' => false, + ]; + + protected $indexColumns = [ + 'title' => [ + 'title' => 'Emplacement', + 'field' => 'title', + 'sort' => true, + ], + 'box_title' => [ + 'title' => "Titre de l'encadré", + 'field' => 'box_title', + + ] + + ]; } diff --git a/app/Models/LaboArticle.php b/app/Models/LaboArticle.php index 4a7edd1..210aa76 100644 --- a/app/Models/LaboArticle.php +++ b/app/Models/LaboArticle.php @@ -8,6 +8,13 @@ use A17\Twill\Models\Behaviors\HasMedias; use A17\Twill\Models\Behaviors\Sortable; use A17\Twill\Models\Model; +/** + * Class LaboArticle + * @package App\Models + * @property string $content + * @property string $link + * @property string $preview + */ class LaboArticle extends Model implements Sortable { use HasSlug, HasMedias, HasPosition; @@ -17,7 +24,6 @@ class LaboArticle extends Model implements Sortable 'publish_end_date', 'title', 'chapo', - 'preview', 'content', 'published', 'position', @@ -37,4 +43,24 @@ class LaboArticle extends Model implements Sortable ], ], ]; + + + public function getPreviewAttribute(): string + { + $line = strip_tags($this->content); + + if (preg_match('/^.{1,200}\b/s', $line, $match)) { + $line = trim($match[0]) . "…"; + } + + return $line; + } + + /** + * @return string + */ + public function getLinkAttribute(): string + { + return route('actus-labos.show', ['slug' => $this->slug]); + } } diff --git a/app/Models/PillBoxSpace.php b/app/Models/PillBoxSpace.php index 5de6418..60b8bb9 100644 --- a/app/Models/PillBoxSpace.php +++ b/app/Models/PillBoxSpace.php @@ -10,7 +10,7 @@ class PillBoxSpace extends Model use HasSlug; protected $fillable = [ - 'published', +// 'published', 'title', 'box_content', 'box_title', @@ -21,4 +21,5 @@ class PillBoxSpace extends Model 'title', ]; + } diff --git a/app/Repositories/PillBoxSpaceRepository.php b/app/Repositories/PillBoxSpaceRepository.php index a50d88e..3723da1 100644 --- a/app/Repositories/PillBoxSpaceRepository.php +++ b/app/Repositories/PillBoxSpaceRepository.php @@ -14,4 +14,11 @@ class PillBoxSpaceRepository extends ModuleRepository { $this->model = $model; } + + public function afterSave($object, $fields) + { + parent::afterSave($object, $fields); + $object->published = true; + $object->save(); + } } diff --git a/database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php b/database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php new file mode 100644 index 0000000..7babed7 --- /dev/null +++ b/database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php @@ -0,0 +1,32 @@ +dropColumn('preview'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('labo_articles', function (Blueprint $table) { + $table->text('preview')->nullable(); + }); + } +} diff --git a/public/css/app.css b/public/css/app.css index 8baa9a6..3322380 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -11050,7 +11050,8 @@ mark.mark { color: #074e9c; } -.highlight-blue { +.highlight-blue, +.btn-back { color: white; background-color: #074e9c; } @@ -11173,6 +11174,12 @@ h1 { border: 1px solid #d04d4a; } +.psq-actu .box, +.psq-actu div.pill-box div, +div.pill-box .psq-actu div { + border-radius: 5px; +} + .psq-com-campaign h1 { color: white; background-color: #AD5ED3; @@ -11182,6 +11189,12 @@ h1 { border: 1px solid #AD5ED3; } +.psq-com-campaign .box, +.psq-com-campaign div.pill-box div, +div.pill-box .psq-com-campaign div { + border-radius: 5px; +} + .psq-plus h1 { color: white; background-color: #41BD53; @@ -11191,6 +11204,12 @@ h1 { border: 1px solid #41BD53; } +.psq-plus .box, +.psq-plus div.pill-box div, +div.pill-box .psq-plus div { + border-radius: 5px; +} + .psq-mag h1 { color: white; background-color: #ce317c; @@ -11200,6 +11219,12 @@ h1 { border: 1px solid #ce317c; } +.psq-mag .box, +.psq-mag div.pill-box div, +div.pill-box .psq-mag div { + border-radius: 5px; +} + .psq-podcasts h1 { color: white; background-color: #288ed7; @@ -11209,6 +11234,12 @@ h1 { border: 1px solid #288ed7; } +.psq-podcasts .box, +.psq-podcasts div.pill-box div, +div.pill-box .psq-podcasts div { + border-radius: 5px; +} + .psq-labos h1 { color: white; background-color: #546983; @@ -11218,6 +11249,12 @@ h1 { border: 1px solid #546983; } +.psq-labos .box, +.psq-labos div.pill-box div, +div.pill-box .psq-labos div { + border-radius: 5px; +} + .psq-not-registered h1 { color: white; background-color: #e79817; @@ -11227,6 +11264,12 @@ h1 { border: 1px solid #e79817; } +.psq-not-registered .box, +.psq-not-registered div.pill-box div, +div.pill-box .psq-not-registered div { + border-radius: 5px; +} + .psq-login-logout h1 { color: white; background-color: #0c2c50; @@ -11236,6 +11279,12 @@ h1 { border: 1px solid #0c2c50; } +.psq-login-logout .box, +.psq-login-logout div.pill-box div, +div.pill-box .psq-login-logout div { + border-radius: 5px; +} + nav { margin-bottom: 0.5rem; display: flex; @@ -11491,6 +11540,36 @@ div.pill-box div > a.bottom-right { font-size: small; } +.chapo { + font-style: italic; + font-size: large; +} + +.simple-preview .chapo { + font-size: small; +} + +.btn-back { + text-transform: uppercase; + font-weight: bold; + margin-bottom: 1rem; + color: white !important; +} + +article > .content { + max-width: 800px; + font-size: larger; + margin: auto; + text-align: justify; +} + +article img.top-img { + display: block; + margin: auto; + max-width: 100%; + max-height: 350px; +} + .error-403 p { font-size: x-large; } diff --git a/resources/sass/_colors.scss b/resources/sass/_colors.scss index 8937831..50fd279 100644 --- a/resources/sass/_colors.scss +++ b/resources/sass/_colors.scss @@ -68,5 +68,10 @@ $psq_pages: ( .pill-box > div { border: 1px solid $color; } + + .box { + //border: 1px solid $color; + border-radius: 5px; + } } } diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 8773bdb..df5d069 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -80,6 +80,42 @@ a { } +.chapo { + font-style: italic; + font-size: large; +} + +.simple-preview{ + .chapo { + font-size: small; + } +} + + +.btn-back { + @extend .highlight-blue; + text-transform: uppercase; + font-weight: bold; + margin-bottom: 1rem; + color: white !important; + +} + +article { + > .content { + max-width: 800px; + font-size: larger; + margin: auto; + text-align: justify; + } + + img.top-img { + display: block; + margin: auto; + max-width: 100%; + max-height: 350px; + } +} .error-403 { p { font-size: x-large; diff --git a/resources/views/actu-labos/index.blade.php b/resources/views/actu-labos/index.blade.php index 84977a9..664c916 100644 --- a/resources/views/actu-labos/index.blade.php +++ b/resources/views/actu-labos/index.blade.php @@ -1,9 +1,36 @@ @extends('layouts.app') - +@php +@endphp @section('content') +
+

L'actu des labos

+

Une séléction de nos articles publiés cette semaine

+ + +
+
+ @component('components.simple-preview', ['actu' => $actus->shift()]) + @endcomponent +
+
+ @component('components.simple-preview', ['actu' => $actus->shift()]) + @endcomponent +
+
+ + @component('components.simple-preview', ['actu' => $actus->shift()]) + @endcomponent +
+
+ @component('components.simple-preview', ['actu' => $actus->shift()]) + @endcomponent + +
+ + + +
-@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 index e69de29..1479099 100644 --- a/resources/views/actu-labos/show.blade.php +++ b/resources/views/actu-labos/show.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.app') + +@section('content') +
+ +

{{$actu->title}}

+ +
+ +

{{$actu->chapo}}

+
+ {!! $actu->content !!} +
+
+ + + +
+@endsection diff --git a/resources/views/admin/laboArticles/form.blade.php b/resources/views/admin/laboArticles/form.blade.php index 5720aab..bf564b9 100644 --- a/resources/views/admin/laboArticles/form.blade.php +++ b/resources/views/admin/laboArticles/form.blade.php @@ -4,18 +4,11 @@ @formField('input', [ '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', diff --git a/resources/views/components/back.blade.php b/resources/views/components/back.blade.php new file mode 100644 index 0000000..aaa80e6 --- /dev/null +++ b/resources/views/components/back.blade.php @@ -0,0 +1 @@ +❮ Retour diff --git a/resources/views/components/simple-preview.blade.php b/resources/views/components/simple-preview.blade.php new file mode 100644 index 0000000..f51c839 --- /dev/null +++ b/resources/views/components/simple-preview.blade.php @@ -0,0 +1,20 @@ + +@if($actu) +
+
+ +
+ +
+
+ +

{{$actu->title}}

+
+

{{$actu->chapo}}

+ {{ $actu->preview }} + Lire la suite + +
+
+
+@endif diff --git a/resources/views/podcasts/index.blade.php b/resources/views/podcasts/index.blade.php index 71cccac..6233abe 100644 --- a/resources/views/podcasts/index.blade.php +++ b/resources/views/podcasts/index.blade.php @@ -18,7 +18,7 @@ {{-- Description + weekly sponsor --}}
-
+
{!! $podcast->description !!}
@@ -64,7 +64,7 @@

Nos rubriques du mois

-
+

Le coup de cœur

@@ -80,6 +80,8 @@
+
+

Le coup de com

@@ -96,13 +98,10 @@
-
- - Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris ter egressus Arelate Valentiam petit, in - -
-
+ + +

Le journal de la com santé

@@ -119,6 +118,13 @@
+
+ + Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris ter egressus Arelate Valentiam petit, in + + +
+
diff --git a/routes/web.php b/routes/web.php index c2b3902..cc9c3eb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -60,7 +60,10 @@ Route::domain(env('CLIENT_DOMAIN_NAME'))->group(function() { Route::get('pas-encore-inscrit', 'Auth\NotRegisteredYet@index')->name('not-registered'); - Route::get('actus-labos', 'ActuLabosController@index'); + Route::prefix('actus-labos')->group(function() { + Route::get('', 'ActuLabosController@index')->name('actus-labos.index'); + Route::get('{slug}', 'ActuLabosController@show')->name('actus-labos.show'); + }); /** Metadata */ Route::prefix('/files/{file:slug}')->group(function () { -- 2.39.5