From a0e7eca4eb9c6373a9320fea18a23c4736ac2d6c Mon Sep 17 00:00:00 2001 From: Louis Jeckel Date: Fri, 31 Jul 2020 01:12:12 +0200 Subject: [PATCH] publish errors, campagines search + index, headlines --- app/Http/Controllers/AdCampaignController.php | 10 +- app/Jobs/ProcessEmailBatch.php | 1 + app/Models/AdCampaign.php | 13 + app/PdfFile.php | 18 +- app/Policies/PdfFilePolicy.php | 3 + app/View/Components/Headline.php | 33 ++ config/twill-navigation.php | 6 +- public/admin/js/admin.js | 64 ++- public/css/app.css | 25 +- public/img/blue-pill.svg | 1 + public/img/{pill-icon.svg => red-pill.svg} | 0 public/js/app.js | 64 ++- .../js/components/AdCampaign/CampaignHit.vue | 10 +- .../components/Publish/HeadlineRepeater.vue | 26 +- resources/sass/_variables.scss | 2 + resources/sass/app.scss | 40 +- resources/views/adCampaigns/index.blade.php | 38 ++ resources/views/adCampaigns/search.blade.php | 10 + resources/views/ad_campaigns.blade.php | 13 - resources/views/components/cover.blade.php | 12 +- ...ight-news.blade.php => headline.blade.php} | 2 +- resources/views/components/pill-box.blade.php | 5 +- resources/views/errors/401.blade.php | 5 + resources/views/errors/403.blade.php | 16 + resources/views/errors/404.blade.php | 5 + resources/views/errors/419.blade.php | 5 + resources/views/errors/429.blade.php | 5 + resources/views/errors/500.blade.php | 5 + resources/views/errors/503.blade.php | 5 + .../views/errors/illustrated-layout.blade.php | 486 ++++++++++++++++++ resources/views/errors/layout.blade.php | 57 ++ resources/views/errors/minimal.blade.php | 62 +++ resources/views/home/index.blade.php | 12 +- resources/views/layouts/app.blade.php | 40 +- routes/web.php | 2 + 35 files changed, 1025 insertions(+), 76 deletions(-) create mode 100644 app/View/Components/Headline.php create mode 100644 public/img/blue-pill.svg rename public/img/{pill-icon.svg => red-pill.svg} (100%) create mode 100644 resources/views/adCampaigns/index.blade.php create mode 100644 resources/views/adCampaigns/search.blade.php delete mode 100644 resources/views/ad_campaigns.blade.php rename resources/views/components/{spotlight-news.blade.php => headline.blade.php} (81%) create mode 100644 resources/views/errors/401.blade.php create mode 100644 resources/views/errors/403.blade.php create mode 100644 resources/views/errors/404.blade.php create mode 100644 resources/views/errors/419.blade.php create mode 100644 resources/views/errors/429.blade.php create mode 100644 resources/views/errors/500.blade.php create mode 100644 resources/views/errors/503.blade.php create mode 100644 resources/views/errors/illustrated-layout.blade.php create mode 100644 resources/views/errors/layout.blade.php create mode 100644 resources/views/errors/minimal.blade.php diff --git a/app/Http/Controllers/AdCampaignController.php b/app/Http/Controllers/AdCampaignController.php index 2aa2e62..e591cac 100644 --- a/app/Http/Controllers/AdCampaignController.php +++ b/app/Http/Controllers/AdCampaignController.php @@ -2,15 +2,23 @@ namespace App\Http\Controllers; +use App\Models\AdCampaign; use Illuminate\Http\Request; class AdCampaignController extends Controller { + public function search() + { + return view('adCampaigns.search'); + } + public function index() { - return view('ad_campaigns'); + \View::share('campaigns', AdCampaign::query()->orderByDesc('id')->take(3)->get()); + return view('adCampaigns.index'); } + } diff --git a/app/Jobs/ProcessEmailBatch.php b/app/Jobs/ProcessEmailBatch.php index 6eec3b4..c8e9d80 100644 --- a/app/Jobs/ProcessEmailBatch.php +++ b/app/Jobs/ProcessEmailBatch.php @@ -64,6 +64,7 @@ class ProcessEmailBatch implements ShouldQueue 'current' => 0 ]); $i = 0; + $this->batch->file->publish(); foreach($chunks as $chunk) { diff --git a/app/Models/AdCampaign.php b/app/Models/AdCampaign.php index 2f3f3dc..eafe3e6 100644 --- a/app/Models/AdCampaign.php +++ b/app/Models/AdCampaign.php @@ -25,6 +25,10 @@ class AdCampaign extends Model implements Sortable 'organization' ]; + public $appends = [ + 'image' + ]; + public $slugAttributes = [ 'title', ]; @@ -55,4 +59,13 @@ class AdCampaign extends Model implements Sortable 'organization' => $this->organization, ]; } + + + /** + * @return string|null + */ + public function getImageAttribute(): ?string + { + return $this->image('image', 'preview'); + } } diff --git a/app/PdfFile.php b/app/PdfFile.php index 9baf96d..5901a77 100644 --- a/app/PdfFile.php +++ b/app/PdfFile.php @@ -97,6 +97,7 @@ class PdfFile extends TwillModel implements Sortable 'slug' => Str::slug("{$collection->slug}_{$ref}"), 'title' => "{$collection->short_name} - $ref", 'headlines' => $headlines, + 'published' => 0, ]); @@ -130,6 +131,14 @@ class PdfFile extends TwillModel implements Sortable } + /** + * Sets published to true + */ + public function publish(): void + { + $this->update(['published' => true]); + } + @@ -325,12 +334,17 @@ class PdfFile extends TwillModel implements Sortable /** * @return string */ - public function getUrl() + public function getUrl(): string { return route('flowpaper.view', ['file' => $this->slug]); } - public function getUrlWithToken(User $user) + /** + * @param User $user + * @return string + * Returns an URL with an auth token (for emails) + */ + public function getUrlWithToken(User $user): string { return $user->routeWithToken('flowpaper.view', ['file' => $this->slug]); } diff --git a/app/Policies/PdfFilePolicy.php b/app/Policies/PdfFilePolicy.php index 4166222..8848d77 100644 --- a/app/Policies/PdfFilePolicy.php +++ b/app/Policies/PdfFilePolicy.php @@ -40,13 +40,16 @@ class PdfFilePolicy * @param \App\PdfFile $pdfFile * @return mixed * @throws AuthenticationException + * @todo Redirect with proper error message */ public function view($user = null, PdfFile $pdfFile) { + if($user instanceof TwillUser) { return true; } + if($pdfFile->is_free || ($user instanceof \App\User ? $user->isSubscribed : false)) { return true; } diff --git a/app/View/Components/Headline.php b/app/View/Components/Headline.php new file mode 100644 index 0000000..60b20eb --- /dev/null +++ b/app/View/Components/Headline.php @@ -0,0 +1,33 @@ +title = $headline['headline'] ?? ''; + $this->content = nl2br($headline['content'] ?? ''); + + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\View\View|string + */ + public function render() + { + return view('components.headline'); + } +} diff --git a/config/twill-navigation.php b/config/twill-navigation.php index e258762..89e30f5 100644 --- a/config/twill-navigation.php +++ b/config/twill-navigation.php @@ -3,16 +3,16 @@ return [ 'nova' => [ - 'title' => 'CRM', + 'title' => 'Clients (CRM)', 'route' => '/crm', 'raw' => true, ], 'publish' => [ - 'title' => 'Publier', + 'title' => 'Publier une lettre', 'route' => 'admin.publish', ], 'content' => [ - 'title' => 'Contenu', + 'title' => 'Gestion du Contenu', 'route' => 'admin.content.homepage', 'primary_navigation' => [ 'homepage' => [ diff --git a/public/admin/js/admin.js b/public/admin/js/admin.js index 8802048..616dd2e 100644 --- a/public/admin/js/admin.js +++ b/public/admin/js/admin.js @@ -2166,6 +2166,12 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// +// +// +// +// /* harmony default export */ __webpack_exports__["default"] = ({ name: "CampaignHit", props: ['hit'] @@ -2535,23 +2541,38 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// /* harmony default export */ __webpack_exports__["default"] = ({ name: "HeadlineRepeater", props: { value: { - type: String, required: true } }, + data: function data() { + return { + headline: '', + content: '' + }; + }, computed: { - headline: { + val: { get: function get() { - return this.value; + return { + headline: this.headline, + content: this.content + }; }, set: function set(v) { this.$emit('input', v); } } + }, + watch: { + val: function val(value) { + this.$emit('input', value); + } } }); @@ -49654,16 +49675,26 @@ var render = function() { _c( "h3", [ - _c("ais-highlight", { - attrs: { attribute: "organization", hit: _vm.hit } - }) + _vm.hit._highlightResult === undefined + ? _c("span", { + domProps: { innerHTML: _vm._s(_vm.hit.organization) } + }) + : _c("ais-highlight", { + attrs: { attribute: "organization", hit: _vm.hit } + }) ], 1 ), _vm._v(" "), _c( "h4", - [_c("ais-highlight", { attrs: { attribute: "title", hit: _vm.hit } })], + [ + _vm.hit._highlightResult === undefined + ? _c("span", { domProps: { innerHTML: _vm._s(_vm.hit.title) } }) + : _vm._e(), + _vm._v(" "), + _c("ais-highlight", { attrs: { attribute: "title", hit: _vm.hit } }) + ], 1 ), _vm._v(" "), @@ -50150,8 +50181,25 @@ var render = function() { }), _vm._v(" "), _c("textarea", { + directives: [ + { + name: "model", + rawName: "v-model", + value: _vm.content, + expression: "content" + } + ], staticClass: "form-control mt-1", - attrs: { placeholder: "Description rapide", rows: "4" } + attrs: { placeholder: "Description rapide", rows: "4" }, + domProps: { value: _vm.content }, + on: { + input: function($event) { + if ($event.target.composing) { + return + } + _vm.content = $event.target.value + } + } }) ]) } diff --git a/public/css/app.css b/public/css/app.css index fbdb95f..3a4ca33 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -11205,20 +11205,41 @@ div.cover img.cover-over { position: absolute; } -div.cover p { +div.cover .cover-title { + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; + margin: auto; + position: relative; + height: 30px; +} + +div.cover .cover-title img { + position: absolute; + width: 50px; + z-index: 5; + top: -12px; + left: -30px; +} + +div.cover .cover-title p { text-transform: uppercase; color: #074e9c; - background-color: rgba(7, 78, 156, 0.3); + background-color: #cddceb; text-align: center; font-weight: 900; display: table; margin: auto; padding: 0 6px; font-size: small; + z-index: 10; + position: relative; } div.pill-box { position: relative; + margin-top: 2rem; + margin-bottom: 2rem; } div.pill-box img { diff --git a/public/img/blue-pill.svg b/public/img/blue-pill.svg new file mode 100644 index 0000000..6b8e410 --- /dev/null +++ b/public/img/blue-pill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/pill-icon.svg b/public/img/red-pill.svg similarity index 100% rename from public/img/pill-icon.svg rename to public/img/red-pill.svg diff --git a/public/js/app.js b/public/js/app.js index 4212acd..f6c1f3b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -7361,6 +7361,12 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// +// +// +// +// /* harmony default export */ __webpack_exports__["default"] = ({ name: "CampaignHit", props: ['hit'] @@ -7730,23 +7736,38 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// /* harmony default export */ __webpack_exports__["default"] = ({ name: "HeadlineRepeater", props: { value: { - type: String, required: true } }, + data: function data() { + return { + headline: '', + content: '' + }; + }, computed: { - headline: { + val: { get: function get() { - return this.value; + return { + headline: this.headline, + content: this.content + }; }, set: function set(v) { this.$emit('input', v); } } + }, + watch: { + val: function val(value) { + this.$emit('input', value); + } } }); @@ -79134,16 +79155,26 @@ var render = function() { _c( "h3", [ - _c("ais-highlight", { - attrs: { attribute: "organization", hit: _vm.hit } - }) + _vm.hit._highlightResult === undefined + ? _c("span", { + domProps: { innerHTML: _vm._s(_vm.hit.organization) } + }) + : _c("ais-highlight", { + attrs: { attribute: "organization", hit: _vm.hit } + }) ], 1 ), _vm._v(" "), _c( "h4", - [_c("ais-highlight", { attrs: { attribute: "title", hit: _vm.hit } })], + [ + _vm.hit._highlightResult === undefined + ? _c("span", { domProps: { innerHTML: _vm._s(_vm.hit.title) } }) + : _vm._e(), + _vm._v(" "), + _c("ais-highlight", { attrs: { attribute: "title", hit: _vm.hit } }) + ], 1 ), _vm._v(" "), @@ -79630,8 +79661,25 @@ var render = function() { }), _vm._v(" "), _c("textarea", { + directives: [ + { + name: "model", + rawName: "v-model", + value: _vm.content, + expression: "content" + } + ], staticClass: "form-control mt-1", - attrs: { placeholder: "Description rapide", rows: "4" } + attrs: { placeholder: "Description rapide", rows: "4" }, + domProps: { value: _vm.content }, + on: { + input: function($event) { + if ($event.target.composing) { + return + } + _vm.content = $event.target.value + } + } }) ]) } diff --git a/resources/js/components/AdCampaign/CampaignHit.vue b/resources/js/components/AdCampaign/CampaignHit.vue index b0b98c7..2d8273b 100644 --- a/resources/js/components/AdCampaign/CampaignHit.vue +++ b/resources/js/components/AdCampaign/CampaignHit.vue @@ -5,8 +5,14 @@
-

-

+

+ + +

+

+ + +

diff --git a/resources/js/components/Publish/HeadlineRepeater.vue b/resources/js/components/Publish/HeadlineRepeater.vue index b9c7b8d..15e56d9 100644 --- a/resources/js/components/Publish/HeadlineRepeater.vue +++ b/resources/js/components/Publish/HeadlineRepeater.vue @@ -1,7 +1,9 @@ + + @@ -10,15 +12,31 @@ name: "HeadlineRepeater", props: { value: { - type: String, required: true } }, + data() { + return { + headline: '', + content : '' + } + + }, computed: { - headline: { - get() { return this.value }, + val: { + get() { + return { + headline: this.headline, + content : this.content + } + }, set(v) { this.$emit('input', v) } } + }, + watch: { + val: function(value) { + this.$emit('input', value) + } } } diff --git a/resources/sass/_variables.scss b/resources/sass/_variables.scss index 8be5f0d..3d518e3 100644 --- a/resources/sass/_variables.scss +++ b/resources/sass/_variables.scss @@ -26,9 +26,11 @@ $cyan: #6cb2eb; $psq_red: #d04d4a; $psq_blue: #074e9c; +$psq_light_blue: #cddceb; //$psq_blue, opacity 0.3 white bg $psq_purple: #AD5ED3; + $blue: $psq_blue; $red: $psq_red; diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 23d93b0..98da316 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -152,16 +152,35 @@ div.cover { position: absolute; } - p { - text-transform: uppercase; - color: $psq_blue; - background-color: rgba($psq_blue, 0.3); - text-align: center; - font-weight: 900; - display: table; + .cover-title { + + width: fit-content; margin: auto; - padding: 0 6px; - font-size: small; + position: relative; + height: 30px; + + img { + position: absolute; + width: 50px; + z-index: 5; + top: -12px; + left: -30px; + + } + + p { + text-transform: uppercase; + color: $psq_blue; + background-color: $psq_light_blue; + text-align: center; + font-weight: 900; + display: table; + margin: auto; + padding: 0 6px; + font-size: small; + z-index: 10; + position: relative; + } } } @@ -171,6 +190,9 @@ div.cover { div.pill-box { position: relative; + margin-top: 2rem; + margin-bottom: 2rem; + img { width: 50px; diff --git a/resources/views/adCampaigns/index.blade.php b/resources/views/adCampaigns/index.blade.php new file mode 100644 index 0000000..55e6faf --- /dev/null +++ b/resources/views/adCampaigns/index.blade.php @@ -0,0 +1,38 @@ +@extends('layouts.app') + +@section('content') +
+

CAMPAGNES & COMMUNICATION DES ACTEURS DE LA SANTÉ

+ + + +
+ @foreach($campaigns as $campaign) +
+ +
+ + @endforeach +
+ + +
+@endsection + diff --git a/resources/views/adCampaigns/search.blade.php b/resources/views/adCampaigns/search.blade.php new file mode 100644 index 0000000..b48dc87 --- /dev/null +++ b/resources/views/adCampaigns/search.blade.php @@ -0,0 +1,10 @@ +@extends('layouts.app') + +@section('content') +
+

ARCHIVES : CAMPAGNES & COMMUNICATION DES ACTEURS DE LA SANTÉ

+ + + +
+@endsection diff --git a/resources/views/ad_campaigns.blade.php b/resources/views/ad_campaigns.blade.php deleted file mode 100644 index 8a5806a..0000000 --- a/resources/views/ad_campaigns.blade.php +++ /dev/null @@ -1,13 +0,0 @@ -@extends('layouts.app') - -@section('content') -
-

CAMPAGNES & COMMUNICATION DES ACTEURS DE LA SANTÉ

- - - - -
-@endsection diff --git a/resources/views/components/cover.blade.php b/resources/views/components/cover.blade.php index adacbed..c38e436 100644 --- a/resources/views/components/cover.blade.php +++ b/resources/views/components/cover.blade.php @@ -1,5 +1,11 @@
- - -

{{$pdf->title}} - {{$pdf->created_at->format('d/m/Y')}}

+ + + + +
+ +

{{$pdf->title}} - {{$pdf->created_at->format('d/m/Y')}}

+
+
diff --git a/resources/views/components/spotlight-news.blade.php b/resources/views/components/headline.blade.php similarity index 81% rename from resources/views/components/spotlight-news.blade.php rename to resources/views/components/headline.blade.php index 5a41e01..b7107b8 100644 --- a/resources/views/components/spotlight-news.blade.php +++ b/resources/views/components/headline.blade.php @@ -1,6 +1,6 @@
merge(['class' => 'spotlight-news'])}}>

{{$title}}

- {{$slot}} + {!! $content !!}
diff --git a/resources/views/components/pill-box.blade.php b/resources/views/components/pill-box.blade.php index 46cb6e0..d05a3bc 100644 --- a/resources/views/components/pill-box.blade.php +++ b/resources/views/components/pill-box.blade.php @@ -1,5 +1,6 @@ -
- Pill Icon +
merge(['class' => 'pill-box'])}}> + + Pill Icon

{{$title}}

{{$slot}}

diff --git a/resources/views/errors/401.blade.php b/resources/views/errors/401.blade.php new file mode 100644 index 0000000..5c586db --- /dev/null +++ b/resources/views/errors/401.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Unauthorized')) +@section('code', '401') +@section('message', __('Unauthorized')) diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php new file mode 100644 index 0000000..362d10e --- /dev/null +++ b/resources/views/errors/403.blade.php @@ -0,0 +1,16 @@ +@extends('layouts.app') + +@section('content') + +
+

Vous ne pouvez pas accéder à cette page !

+ + + @auth +

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

+ @elseauth +

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

+ + @endauth +
+@endsection diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php new file mode 100644 index 0000000..7549540 --- /dev/null +++ b/resources/views/errors/404.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Not Found')) +@section('code', '404') +@section('message', __('Not Found')) diff --git a/resources/views/errors/419.blade.php b/resources/views/errors/419.blade.php new file mode 100644 index 0000000..c09216e --- /dev/null +++ b/resources/views/errors/419.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Page Expired')) +@section('code', '419') +@section('message', __('Page Expired')) diff --git a/resources/views/errors/429.blade.php b/resources/views/errors/429.blade.php new file mode 100644 index 0000000..f01b07b --- /dev/null +++ b/resources/views/errors/429.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Too Many Requests')) +@section('code', '429') +@section('message', __('Too Many Requests')) diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php new file mode 100644 index 0000000..d9e95d9 --- /dev/null +++ b/resources/views/errors/500.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Server Error')) +@section('code', '500') +@section('message', __('Server Error')) diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php new file mode 100644 index 0000000..acd3810 --- /dev/null +++ b/resources/views/errors/503.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Service Unavailable')) +@section('code', '503') +@section('message', __($exception->getMessage() ?: 'Service Unavailable')) diff --git a/resources/views/errors/illustrated-layout.blade.php b/resources/views/errors/illustrated-layout.blade.php new file mode 100644 index 0000000..64eb7cb --- /dev/null +++ b/resources/views/errors/illustrated-layout.blade.php @@ -0,0 +1,486 @@ + + + + + + + @yield('title') + + + + + + + + + +
+
+
+
+ @yield('code', __('Oh no')) +
+ +
+ +

+ @yield('message') +

+ + + + +
+
+ +
+ @yield('image') +
+
+ + diff --git a/resources/views/errors/layout.blade.php b/resources/views/errors/layout.blade.php new file mode 100644 index 0000000..2c51d4f --- /dev/null +++ b/resources/views/errors/layout.blade.php @@ -0,0 +1,57 @@ + + + + + + + @yield('title') + + + + + + + + + +
+
+
+ @yield('message') +
+
+
+ + diff --git a/resources/views/errors/minimal.blade.php b/resources/views/errors/minimal.blade.php new file mode 100644 index 0000000..b63ac2b --- /dev/null +++ b/resources/views/errors/minimal.blade.php @@ -0,0 +1,62 @@ + + + + + + + @yield('title') + + + + + + + + + +
+
+ @yield('code') +
+ +
+ @yield('message') +
+
+ + diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php index 1fc70cb..dadc0dd 100644 --- a/resources/views/home/index.blade.php +++ b/resources/views/home/index.blade.php @@ -13,14 +13,10 @@ - @foreach([1, 2, 3] as $i) - - -
    -
  • Nouveau Boss d’IPSEN face à la presse
  • -
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit
  • -
-
+ @foreach($last_pdf->first()->headlines as $headline) + + + @endforeach diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index ba3f006..02f49fd 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -26,35 +26,55 @@
@if(!isset($hideNav)) - + + + diff --git a/routes/web.php b/routes/web.php index 4dee87f..fb28003 100644 --- a/routes/web.php +++ b/routes/web.php @@ -50,7 +50,9 @@ Route::domain(env('CLIENT_DOMAIN_NAME'))->group(function() { Route::get('/search', 'FileController@search'); + Route::get('/campaigns', 'AdCampaignController@index'); + Route::get('/campaigns/search', 'AdCampaignController@search'); /** Metadata */ Route::prefix('/files/{file:slug}')->group(function () { -- 2.39.5