add unsubscribe and view mail on the web buttons
This commit is contained in:
parent
8bdd63afe2
commit
f095954a33
20 changed files with 289 additions and 224 deletions
|
|
@ -123,8 +123,10 @@ button.toggle.right::before {
|
||||||
|
|
||||||
[data-template="author"] .page-cover,
|
[data-template="author"] .page-cover,
|
||||||
[data-template="category"] .page-cover,
|
[data-template="category"] .page-cover,
|
||||||
[data-template="year"] .page-cover {
|
[data-template="year"] .page-cover,
|
||||||
height: initial;
|
[data-template="email"] .page-cover,
|
||||||
|
[data-template="error"] .page-cover {
|
||||||
|
height: initial !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-cover .links {
|
.page-cover .links {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
title: Email
|
title: Email
|
||||||
status:
|
status:
|
||||||
draft: Brouillon
|
draft: Brouillon
|
||||||
|
unlisted: Testé
|
||||||
listed: Envoyé
|
listed: Envoyé
|
||||||
image:
|
image:
|
||||||
back: black
|
back: black
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function createEmptyCategories() {
|
function createEmptyCategories()
|
||||||
|
{
|
||||||
$categories = new Pages();
|
$categories = new Pages();
|
||||||
foreach (page('textes')->categories()->split() as $categoryName) {
|
foreach (page('textes')->categories()->split() as $categoryName) {
|
||||||
$category = new Page([
|
$category = new Page([
|
||||||
|
|
@ -10,7 +11,7 @@ function createEmptyCategories() {
|
||||||
'content' => [
|
'content' => [
|
||||||
'title' => $categoryName,
|
'title' => $categoryName,
|
||||||
],
|
],
|
||||||
'children' => []
|
'children' => [],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$categories->add($category);
|
$categories->add($category);
|
||||||
|
|
@ -20,7 +21,8 @@ function createEmptyCategories() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createCategories() {
|
function createCategories()
|
||||||
|
{
|
||||||
$emptyCategories = createEmptyCategories();
|
$emptyCategories = createEmptyCategories();
|
||||||
foreach (page('textes')->grandChildren() as $text) {
|
foreach (page('textes')->grandChildren() as $text) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
"debug" => true,
|
'debug' => true,
|
||||||
"panel" => array(
|
'panel' => [
|
||||||
"menu" => require __DIR__ . "/menu.php",
|
'menu' => require __DIR__ . '/menu.php',
|
||||||
"css" => "assets/css/panel.css"
|
'css' => 'assets/css/panel.css',
|
||||||
),
|
|
||||||
"email" => [
|
|
||||||
"transport" => [
|
|
||||||
"type" => "smtp",
|
|
||||||
"host" => "mail.infomaniak.com",
|
|
||||||
"port" => 465,
|
|
||||||
"auth" => true,
|
|
||||||
"username" => "info@actuel-inactuel.fr",
|
|
||||||
"password" => "v!Vr$#JH7quJ35"
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
"routes" => array(
|
'email' => [
|
||||||
require __DIR__ . "/routes/virtual-category.php",
|
'transport' => [
|
||||||
require __DIR__ . "/routes/send-newsletter.php",
|
'type' => 'smtp',
|
||||||
require __DIR__ . "/routes/subscribe.php",
|
'host' => 'smtp.mailersend.net',
|
||||||
)
|
'port' => 587,
|
||||||
);
|
'auth' => true,
|
||||||
|
'username' => 'MS_K9grTE@actuel-inactuel.fr',
|
||||||
|
'password' => 'mssp.GJGywUh.z3m5jgrq71xldpyo.owybzs9',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'routes' => [
|
||||||
|
require __DIR__ . '/routes/virtual-category.php',
|
||||||
|
require __DIR__ . '/routes/subscribe.php',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ return [
|
||||||
'current' => function ($current) {
|
'current' => function ($current) {
|
||||||
$path = Kirby::instance()->request()->path()->toString();
|
$path = Kirby::instance()->request()->path()->toString();
|
||||||
return Str::contains($path, 'site');
|
return Str::contains($path, 'site');
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'texts' => [
|
'texts' => [
|
||||||
'icon' => 'pen',
|
'icon' => 'pen',
|
||||||
|
|
@ -15,7 +15,7 @@ return [
|
||||||
'current' => function ($current) {
|
'current' => function ($current) {
|
||||||
$path = Kirby::instance()->request()->path()->toString();
|
$path = Kirby::instance()->request()->path()->toString();
|
||||||
return Str::contains($path, 'pages/textes');
|
return Str::contains($path, 'pages/textes');
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'authors' => [
|
'authors' => [
|
||||||
'icon' => 'users',
|
'icon' => 'users',
|
||||||
|
|
@ -24,7 +24,7 @@ return [
|
||||||
'current' => function ($current) {
|
'current' => function ($current) {
|
||||||
$path = Kirby::instance()->request()->path()->toString();
|
$path = Kirby::instance()->request()->path()->toString();
|
||||||
return Str::contains($path, 'pages/auteurs');
|
return Str::contains($path, 'pages/auteurs');
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'-',
|
'-',
|
||||||
'-',
|
'-',
|
||||||
|
|
@ -35,16 +35,16 @@ return [
|
||||||
'current' => function ($current) {
|
'current' => function ($current) {
|
||||||
$path = Kirby::instance()->request()->path()->toString();
|
$path = Kirby::instance()->request()->path()->toString();
|
||||||
return Str::contains($path, 'pages/a-propos');
|
return Str::contains($path, 'pages/a-propos');
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'subscription' => [
|
'subscription' => [
|
||||||
'icon' => 'email',
|
'icon' => 'email',
|
||||||
'label' => 'Liste de diffusion',
|
'label' => 'Liste de diffusion',
|
||||||
'link' => 'pages/inscription',
|
'link' => 'pages/lettre',
|
||||||
'current' => function ($current) {
|
'current' => function ($current) {
|
||||||
$path = Kirby::instance()->request()->path()->toString();
|
$path = Kirby::instance()->request()->path()->toString();
|
||||||
return Str::contains($path, 'pages/liste-de-diffusion');
|
return Str::contains($path, 'pages/liste-de-diffusion');
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'-',
|
'-',
|
||||||
'-',
|
'-',
|
||||||
|
|
@ -57,7 +57,7 @@ return [
|
||||||
'current' => function ($current) {
|
'current' => function ($current) {
|
||||||
$path = Kirby::instance()->request()->path()->toString();
|
$path = Kirby::instance()->request()->path()->toString();
|
||||||
return Str::contains($path, 'pages/admin');
|
return Str::contains($path, 'pages/admin');
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'-',
|
'-',
|
||||||
'-',
|
'-',
|
||||||
|
|
|
||||||
|
|
@ -4,41 +4,40 @@ return [
|
||||||
'pattern' => '/subscribe.json',
|
'pattern' => '/subscribe.json',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'action' => function () {
|
'action' => function () {
|
||||||
$jsonRequest = file_get_contents("php://input");
|
$jsonRequest = file_get_contents('php://input');
|
||||||
$email = Str::lower(json_decode($jsonRequest));
|
$email = Str::lower(json_decode($jsonRequest));
|
||||||
|
|
||||||
if (V::email($email)) {
|
if (V::email($email)) {
|
||||||
kirby()->impersonate('kirby');
|
kirby()->impersonate('kirby');
|
||||||
|
|
||||||
$page = page("inscription");
|
$page = page('lettre');
|
||||||
$subscribers = $page->subscribers()->yaml();
|
$subscribers = $page->subscribers()->yaml();
|
||||||
|
|
||||||
$emailExists = in_array(["email" => $email], $subscribers);
|
$emailExists = in_array(['email' => $email], $subscribers);
|
||||||
|
|
||||||
if ($emailExists) {
|
if ($emailExists) {
|
||||||
return [
|
return [
|
||||||
"status" => "error",
|
'status' => 'error',
|
||||||
"message" => "Cet email est déjà inscris."
|
'message' => 'Cet email est déjà inscris.',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$newSubscriber = ["email" => $email];
|
$newSubscriber = ['email' => $email];
|
||||||
$subscribers[] = $newSubscriber;
|
$subscribers[] = $newSubscriber;
|
||||||
|
|
||||||
$page->update([
|
$page->update([
|
||||||
'subscribers' => $subscribers
|
'subscribers' => $subscribers,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"status" => "success",
|
'status' => 'success',
|
||||||
"message" => "Inscription réussie."
|
'message' => 'lettre réussie.',
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
"status" => "error",
|
'status' => 'error',
|
||||||
"message" => "Email invalide."
|
'message' => 'Email invalide.',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,4 @@ function getAuthorBySlug($slug)
|
||||||
|
|
||||||
return $author;
|
return $author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
.wrapper[data-v-76f92a36]{display:flex;gap:10vw}.k-field-footer[data-v-76f92a36]{width:15rem}@media screen and (max-width: 800px){.k-field-footer[data-v-76f92a36]{width:9rem}}@media screen and (min-width: 533px){button[data-v-76f92a36]{margin-top:2.15rem}}
|
.wrapper[data-v-0e6a95b9]{display:flex;gap:10vw}.k-field-footer[data-v-0e6a95b9]{width:15rem}@media screen and (max-width: 800px){.k-field-footer[data-v-0e6a95b9]{width:9rem}}@media screen and (min-width: 533px){button[data-v-0e6a95b9]{margin-top:2.15rem}}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
(function(){"use strict";function d(t,e,r,n,o,l,a,i){var s=typeof t=="function"?t.options:t;return s.render=e,s.staticRenderFns=r,s._compiled=!0,s._scopeId="data-v-"+l,{exports:t,options:s}}const _={__name:"SendButtonField",props:{pageUri:String,pageStatus:String},setup(t){const{pageUri:e}=t,r=Vue.ref({icon:"plane",text:"Tester",theme:null,error:null}),n=Vue.ref({icon:"plane",text:"Envoyer",theme:"orange",error:null});async function o(l,a=!1){l.preventDefault();const i=a?r:n;i.value={theme:"blue",text:"En cours…",icon:"loader",error:null};const s={method:"POST",body:JSON.stringify({pageUri:e,isTest:a})};try{const u=await(await fetch("/send-newsletter.json",s)).json();if(u.status==="success")i.value={theme:"green",icon:"check",text:a?"Test envoyé":"Envoi réussi",error:null},a?i.value={icon:"plane",text:"Re-tester",theme:null,error:null}:setTimeout(()=>{location.href=location.href},2e3);else throw new Error(u.message||"Erreur inconnue")}catch(c){i.value={theme:"red",icon:"alert",text:a?"Échec du test":"Erreur",error:c.message}}}return{__sfc:!0,testBtnState:r,sendBtnState:n,send:o}}};var f=function(){var e=this,r=e._self._c,n=e._self._setupProxy;return e.pageStatus==="draft"?r("div",{staticClass:"wrapper"},[r("div",{staticClass:"test-wrapper"},[r("k-button",{staticStyle:{width:"max-content"},attrs:{variant:"filled",help:"test",theme:n.testBtnState.theme,icon:n.testBtnState.icon},on:{click:function(o){return n.send(o,!0)}}},[e._v(e._s(n.testBtnState.text))]),e._m(0),n.testBtnState.error?r("k-box",{staticStyle:{"margin-top":"var(--spacing-1)"},attrs:{theme:"error"}},[e._v(e._s(n.testBtnState.error))]):e._e()],1),r("div",{staticClass:"send-wrapper"},[r("k-button",{attrs:{variant:"filled",theme:n.sendBtnState.theme,icon:n.sendBtnState.icon},on:{click:function(o){return n.send(o)}}},[e._v(e._s(n.sendBtnState.text))]),n.sendBtnState.error?r("k-box",{staticStyle:{"margin-top":"var(--spacing-1)"},attrs:{theme:"error"}},[e._v(e._s(n.sendBtnState.error))]):e._e(),e._m(1)],1)]):e._e()},p=[function(){var t=this,e=t._self._c;return t._self._setupProxy,e("footer",{staticClass:"k-field-footer"},[e("div",{staticClass:"k-help k-field-help k-text"},[e("p",[t._v(" Envoie seulement aux "),e("a",{attrs:{href:"/panel/users",title:"voir la liste"}},[t._v("éditeurs")]),t._v(". ")])])])},function(){var t=this,e=t._self._c;return t._self._setupProxy,e("footer",{staticClass:"k-field-footer"},[e("div",{staticClass:"k-help k-field-help k-text"},[e("strong",[t._v("⚠ Envoie à tous les abonnés.")])])])}],v=d(_,f,p,!1,null,"76f92a36");const m=v.exports;window.panel.plugin("adrienpayet/send-button",{fields:{"send-button":m}})})();
|
(function(){"use strict";function d(t,e,r,n,o,l,a,i){var s=typeof t=="function"?t.options:t;return s.render=e,s.staticRenderFns=r,s._compiled=!0,s._scopeId="data-v-"+l,{exports:t,options:s}}const _={__name:"SendButtonField",props:{pageUri:String,pageStatus:String},setup(t){const{pageUri:e}=t,r=Vue.ref({icon:"plane",text:"Tester",theme:null,error:null}),n=Vue.ref({icon:"plane",text:"Envoyer",theme:"orange",error:null});async function o(l,a=!1){l.preventDefault();const i=a?r:n;i.value={theme:"blue",text:"En cours…",icon:"loader",error:null};const s={method:"POST",body:JSON.stringify({pageUri:e,isTest:a})};try{const u=await(await fetch("/send-newsletter.json",s)).json();if(u.status==="success")i.value={theme:"green",icon:"check",text:a?"Test envoyé":"Envoi réussi",error:null},setTimeout(()=>{location.href=location.href},2e3);else throw new Error(u.message||"Erreur inconnue")}catch(c){i.value={theme:"red",icon:"alert",text:a?"Échec du test":"Erreur",error:c.message}}}return{__sfc:!0,testBtnState:r,sendBtnState:n,send:o}}};var f=function(){var e=this,r=e._self._c,n=e._self._setupProxy;return e.pageStatus!=="listed"?r("div",{staticClass:"wrapper"},[r("div",{staticClass:"test-wrapper"},[r("k-button",{staticStyle:{width:"max-content"},attrs:{variant:"filled",help:"test",theme:n.testBtnState.theme,icon:n.testBtnState.icon},on:{click:function(o){return n.send(o,!0)}}},[e._v(e._s(n.testBtnState.text))]),e._m(0),n.testBtnState.error?r("k-box",{staticStyle:{"margin-top":"var(--spacing-1)"},attrs:{theme:"error"}},[e._v(e._s(n.testBtnState.error))]):e._e()],1),r("div",{staticClass:"send-wrapper"},[r("k-button",{attrs:{variant:"filled",theme:n.sendBtnState.theme,icon:n.sendBtnState.icon},on:{click:function(o){return n.send(o)}}},[e._v(e._s(n.sendBtnState.text))]),n.sendBtnState.error?r("k-box",{staticStyle:{"margin-top":"var(--spacing-1)"},attrs:{theme:"error"}},[e._v(e._s(n.sendBtnState.error))]):e._e(),e._m(1)],1)]):e._e()},p=[function(){var t=this,e=t._self._c;return t._self._setupProxy,e("footer",{staticClass:"k-field-footer"},[e("div",{staticClass:"k-help k-field-help k-text"},[e("p",[t._v(" Envoie seulement aux "),e("a",{attrs:{href:"/panel/users",title:"voir la liste"}},[t._v("éditeurs")]),t._v(". ")])])])},function(){var t=this,e=t._self._c;return t._self._setupProxy,e("footer",{staticClass:"k-field-footer"},[e("div",{staticClass:"k-help k-field-help k-text"},[e("strong",[t._v("⚠ Envoie à tous les abonnés.")])])])}],v=d(_,f,p,!1,null,"0e6a95b9");const m=v.exports;window.panel.plugin("adrienpayet/send-button",{fields:{"send-button":m}})})();
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@ Kirby::plugin('adrienpayet/send-button', [
|
||||||
'pageStatus' => function () {
|
'pageStatus' => function () {
|
||||||
return $this->model()->status();
|
return $this->model()->status();
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
|
'routes' => [
|
||||||
|
require __DIR__ . '/routes/send-newsletter.php',
|
||||||
|
require __DIR__ . '/routes/unsubscribe-newsletter.php',
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -4,39 +4,39 @@ return [
|
||||||
'pattern' => '/send-newsletter.json',
|
'pattern' => '/send-newsletter.json',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'action' => function () {
|
'action' => function () {
|
||||||
$jsonRequest = file_get_contents("php://input");
|
$jsonRequest = file_get_contents('php://input');
|
||||||
$data = json_decode($jsonRequest);
|
$data = json_decode($jsonRequest);
|
||||||
|
|
||||||
if (!$data || !isset($data->pageUri) || !isset($data->isTest)) {
|
if (!$data || !isset($data->pageUri) || !isset($data->isTest)) {
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'Invalid request data. Required fields: pageUri, isTest.'
|
'message' => 'Invalid request data. Required fields: pageUri, isTest.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$kirby = kirby();
|
$kirby = kirby();
|
||||||
$emailPage = page('inscription')->childrenAndDrafts()->find($data->pageUri);
|
$emailPage = page('lettre')->childrenAndDrafts()->find($data->pageUri);
|
||||||
|
|
||||||
if (!$emailPage) {
|
if (!$emailPage) {
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'The specified page does not exist.'
|
'message' => 'The specified page does not exist.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$recipients = $data->isTest
|
$recipients = $data->isTest
|
||||||
? $kirby->users()->pluck('email', null, true)
|
? $kirby->users()->pluck('email', null, true)
|
||||||
: page('inscription')->subscribers()->toStructure()->pluck('email', true, true);
|
: page('lettre')->subscribers()->toStructure()->pluck('email', true, true);
|
||||||
|
|
||||||
if (empty($recipients)) {
|
if (empty($recipients)) {
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'No recipients found.'
|
'message' => 'No recipients found.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject = $data->isTest
|
$subject = $data->isTest
|
||||||
? "[TEST] - " . $emailPage->title()->value()
|
? '[TEST] - ' . $emailPage->title()->value()
|
||||||
: $emailPage->title()->value();
|
: $emailPage->title()->value();
|
||||||
|
|
||||||
$from = new \Kirby\Cms\User([
|
$from = new \Kirby\Cms\User([
|
||||||
|
|
@ -52,24 +52,28 @@ return [
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
'template' => 'newsletter',
|
'template' => 'newsletter',
|
||||||
'data' => [
|
'data' => [
|
||||||
'body' => $emailPage->body()
|
'body' => $emailPage->body(),
|
||||||
]
|
'url' => (string) $emailPage->url(),
|
||||||
|
'recipient' => $recipient,
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$data->isTest) {
|
if (!$data->isTest) {
|
||||||
$emailPage->changeStatus('listed');
|
$emailPage->changeStatus('listed');
|
||||||
|
} else {
|
||||||
|
$emailPage->changeStatus('unlisted');
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Email(s) sent successfully.'
|
'message' => 'Email(s) sent successfully.',
|
||||||
]);
|
]);
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $error->getMessage() . " file " . $error->getFile() . " line " . $error->getLine()
|
'message' => $error->getMessage() . ' file ' . $error->getFile() . ' line ' . $error->getLine(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
39
site/plugins/send-button/routes/unsubscribe-newsletter.php
Normal file
39
site/plugins/send-button/routes/unsubscribe-newsletter.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'pattern' => '/deslettre',
|
||||||
|
'action' => function () {
|
||||||
|
$email = get('email');
|
||||||
|
$page = page('lettre');
|
||||||
|
|
||||||
|
$emailExists = in_array(['email' => $email], $page->subscribers()->yaml());
|
||||||
|
|
||||||
|
if (!$emailExists) {
|
||||||
|
$title = 'Erreur';
|
||||||
|
$body = '<p>' . $email . ' est introuvable dans la base de données. Vous pouvez demander une déslettre manuelle en écrivant à <a href="mailto:info@actuel-inactuel.fr?subject=Demande de déslettre&body=Bonjour,%0D%0AJe souhaite être désinscrit d\'actuel-inactuel.%0D%0AE-mail : ' . $email . '%0D%0AMerci.%0D%0A"">info@actuel-inactuel.fr</a>.</p>';
|
||||||
|
} else {
|
||||||
|
$subscribers = array_filter(
|
||||||
|
$page->subscribers()->yaml(),
|
||||||
|
fn($subscriber) => $subscriber !== ['email' => $email]
|
||||||
|
);
|
||||||
|
|
||||||
|
$page->update([
|
||||||
|
'subscribers' => $subscribers,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$title = $email . ' désinscrit';
|
||||||
|
$body = '<p>Si la déslettre automatique n\'a pas fonctionné et que vous continuez à recevoir des mails, vous pouvez demander la déslettre manuelle à <a href="mailto:info@actuel-inactuel.fr?subject=Demande de déslettre&body=Bonjour,%0D%0AJe souhaite être désinscrit d\'actuel-inactuel.%0D%0AE-mail : ' . $email . '%0D%0AMerci.%0D%0A"">info@actuel-inactuel.fr</a>.<p>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Page([
|
||||||
|
'slug' => Str::slug('test'),
|
||||||
|
'template' => 'error',
|
||||||
|
'status' => 'unlisted',
|
||||||
|
'content' => [
|
||||||
|
'title' => $title,
|
||||||
|
'body' => $body,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="wrapper" v-if="pageStatus === 'draft'">
|
<div class="wrapper" v-if="pageStatus !== 'listed'">
|
||||||
<div class="test-wrapper">
|
<div class="test-wrapper">
|
||||||
<k-button
|
<k-button
|
||||||
@click="send($event, true)"
|
@click="send($event, true)"
|
||||||
|
|
@ -102,18 +102,9 @@ async function send(event, isTest = false) {
|
||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isTest) {
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
location.href = location.href;
|
location.href = location.href;
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} else {
|
|
||||||
currentBtnState.value = {
|
|
||||||
icon: "plane",
|
|
||||||
text: "Re-tester",
|
|
||||||
theme: null,
|
|
||||||
error: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.message || "Erreur inconnue");
|
throw new Error(data.message || "Erreur inconnue");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
$isOpen = isset($isOpen) ? $isOpen : false;
|
$isOpen ??= false;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<header
|
<header class="page-cover">
|
||||||
class="page-cover"
|
|
||||||
>
|
|
||||||
<div class="title-wrapper">
|
<div class="title-wrapper">
|
||||||
<a href="#main-content" class="no-underline" title="aller au texte">
|
<a href="#main-content" class="no-underline" title="aller au texte">
|
||||||
<?= $slots->title() ?>
|
<?= $slots->title() ?>
|
||||||
|
|
@ -16,7 +14,7 @@ $isOpen = isset($isOpen) ? $isOpen : false;
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<ul class="links">
|
<ul class="links">
|
||||||
<?php if ($page->is(page('inscription'))): ?>
|
<?php if ($page->is(page('lettre'))): ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= $site->url() ?>">
|
<a href="<?= $site->url() ?>">
|
||||||
accueil
|
accueil
|
||||||
|
|
@ -24,13 +22,14 @@ $isOpen = isset($isOpen) ? $isOpen : false;
|
||||||
</li>
|
</li>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="/inscription" id="subscribe-btn" class="plus">
|
<a href="/lettre" id="subscribe-btn" class="plus">
|
||||||
s'inscrire
|
s'inscrire
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= $site->find('a-propos')->url() ?>">
|
<a
|
||||||
|
href="<?= $site->find('a-propos')->url() ?>">
|
||||||
à propos
|
à propos
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<footer id="main-footer">
|
<footer id="main-footer">
|
||||||
<ul id="links">
|
<ul id="links">
|
||||||
<?php if (!$page->isHomePage() && $kirby->user()->isLoggedIn()): ?>
|
<?php if (!$page->isHomePage() && $kirby->user()): ?>
|
||||||
<li class="open-nav-wrapper">
|
<li class="open-nav-wrapper">
|
||||||
<button class="plus open-nav" title="chercher parmi les textes">textes</button>
|
<button class="plus open-nav" title="chercher parmi les textes">textes</button>
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if ($page->is(page('inscription'))): ?>
|
<?php if ($page->is(page('lettre'))): ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= $site->url() ?>">
|
<a href="<?= $site->url() ?>">
|
||||||
accueil
|
accueil
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
</li>
|
</li>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="/inscription" id="subscribe-btn" class="plus">
|
<a href="/lettre" id="subscribe-btn" class="plus">
|
||||||
s'inscrire
|
s'inscrire
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,57 @@
|
||||||
<?php
|
<?php
|
||||||
$entryTopPos = $entryTopPos ?? 20;
|
|
||||||
|
|
||||||
$kirby = kirby();
|
if(!$kirby->user() && $page->template() == 'linear' || $page->template() == 'grid') {
|
||||||
$site = site();
|
go($site->errorPage()->url());
|
||||||
|
|
||||||
$openPageURIS = [
|
|
||||||
"home",
|
|
||||||
"a-propos",
|
|
||||||
"inscription"
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
if (!$kirby->user() && (!in_array($page->uri(), $openPageURIS))) {
|
|
||||||
go($site->panel()->url());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entryTopPos ??= 20;
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title><?= $site->title() ?><?= e($page->url() !== $site->url(), ' - ' . $page->title()) ?></title>
|
<title>
|
||||||
|
<?= $site->title() ?><?= e($page->url() !== $site->url(), ' - ' . $page->title()) ?>
|
||||||
|
</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="<?= url('assets/css/style.css') . '?version-cache-prevent' . rand(0, 1000) ?>" />
|
<link rel="stylesheet"
|
||||||
|
href="<?= url('assets/css/style.css') . '?version-cache-prevent' . rand(0, 1000) ?>" />
|
||||||
|
|
||||||
<script src="<?= url('assets') ?>/js/script.js?version-cache-prevent<?= rand(0, 1000)?>" defer></script>
|
<script
|
||||||
<script defer src="<?= url('assets/js/alpine.min.js') ?>"></script>
|
src="<?= url('assets') ?>/js/script.js?version-cache-prevent<?= rand(0, 1000)?>"
|
||||||
<script defer src="<?= url('assets/js/ragadjust.js') ?>"></script>
|
defer></script>
|
||||||
|
<script defer src="<?= url('assets/js/alpine.min.js') ?>">
|
||||||
|
</script>
|
||||||
|
<script defer src="<?= url('assets/js/ragadjust.js') ?>">
|
||||||
|
</script>
|
||||||
|
|
||||||
<meta name="robots" content="noindex, nofollow, noarchive">
|
<meta name="robots" content="noindex, nofollow, noarchive">
|
||||||
|
|
||||||
<?php if ($page->template() == 'linear' || $page->template() == 'grid'): ?>
|
<?php if ($page->template() == 'linear' || $page->template() == 'grid'): ?>
|
||||||
<script type="application/ld+json">
|
<script type="application/ld+json">
|
||||||
{
|
{
|
||||||
"@context":"https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type":"NewsArticle",
|
"@type": "NewsArticle",
|
||||||
"headline":"<?= $page->title() ?>",
|
"headline": "<?= $page->title() ?>",
|
||||||
"author":[{"@type": "Person","name": "<?= $page->author() ?>"}],
|
"author": [{
|
||||||
"image":"<?= url('assets/images/logo.png') ?>",
|
"@type": "Person",
|
||||||
"description":"<?= $page->title() ?>, par <?= $page->author()->toPage()->title() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= $page->parent()->title() ?>/<?= $page->category() ?>",
|
"name": "<?= $page->author() ?>"
|
||||||
"datePublished":"<?= $page->published()->toDate('Y-m-d') ?>",
|
}],
|
||||||
"dateModified":"<?= $page->modified('Y-m-d') ?>",
|
"image": "<?= url('assets/images/logo.png') ?>",
|
||||||
"url":"<?= $page->url() ?>",
|
"description": "<?= $page->title() ?>, par <?= $page->author()->toPage()->title() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= $page->parent()->title() ?>/<?= $page->category() ?>",
|
||||||
"mainEntityOfPage":{"@type":"WebPage","@id":"<?= $page->url() ?>"},
|
"datePublished": "<?= $page->published()->toDate('Y-m-d') ?>",
|
||||||
"publisher":{"@type":"Organization","name":"actuel - inactuel"}
|
"dateModified": "<?= $page->modified('Y-m-d') ?>",
|
||||||
|
"url": "<?= $page->url() ?>",
|
||||||
|
"mainEntityOfPage": {
|
||||||
|
"@type": "WebPage",
|
||||||
|
"@id": "<?= $page->url() ?>"
|
||||||
|
},
|
||||||
|
"publisher": {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "actuel - inactuel"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
@ -55,10 +63,16 @@ if (!$kirby->user() && (!in_array($page->uri(), $openPageURIS))) {
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||||
<meta name="apple-mobile-web-app-title" content="actuel-inactuel" />
|
<meta name="apple-mobile-web-app-title" content="actuel-inactuel" />
|
||||||
<link rel="manifest" href="/site.webmanifest" />
|
<link rel="manifest" href="/site.webmanifest" />
|
||||||
</head>
|
</head>
|
||||||
<body class="background-grid <?= e($page->fullWidth() == 'true', 'full-width') ?>" data-template="<?= $page->template() ?>" >
|
|
||||||
|
<body
|
||||||
|
class="background-grid <?= e($page->fullWidth() == 'true', 'full-width') ?>"
|
||||||
|
data-template="<?= $page->template() ?>">
|
||||||
<header id="main-header">
|
<header id="main-header">
|
||||||
<a id="logo" href="<?= e($page->isHomePage(), '#main-edito', $site->url()) ?>" class="no-underline" title="<?= e($page->isHomePage(), 'lire l\'éditorial', 'aller à l\'accueil') ?>">
|
<a id="logo"
|
||||||
|
href="<?= e($page->isHomePage(), '#main-edito', $site->url()) ?>"
|
||||||
|
class="no-underline"
|
||||||
|
title="<?= e($page->isHomePage(), 'lire l\'éditorial', 'aller à l\'accueil') ?>">
|
||||||
<h1>
|
<h1>
|
||||||
<span id="actuel">actuel</span>
|
<span id="actuel">actuel</span>
|
||||||
<span id="inactuel">inactuel</span>
|
<span id="inactuel">inactuel</span>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<?php if ($page->published()->isNotEmpty()): ?>
|
<?php if ($page->published()->isNotEmpty()): ?>
|
||||||
<p>
|
<p>
|
||||||
<span class="light">envoyée le </span><?= $page->published()->toDate('d/m/Y') ?>
|
<span class="light">courrier du </span><?= $page->published()->toDate('d/m/Y') ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<?= $body ?>
|
<?= $body ?>
|
||||||
|
<p>
|
||||||
<em>Vous pouvez demander votre désinscription en répondant directement à ce mail.</em>
|
<a href="https://actuel-inactuel.fr/desinscription?email=<?= $recipient ?>">se désinscrire</a> - <a href="<?= $url ?>">voir la version web</a><br />
|
||||||
|
</p>
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
<?php snippet('header') ?>
|
<?php snippet('header') ?>
|
||||||
<main id="<?= $page->template() ?>">
|
<main id="<?= $page->template() ?>">
|
||||||
<article>
|
<article>
|
||||||
<?php snippet('cover', array('isOpen' => true), slots: true) ?>
|
<?php snippet('cover', ['isOpen' => true], slots: true) ?>
|
||||||
<?php slot('title') ?>
|
<?php slot('title') ?>
|
||||||
<h2 class="main-title <?= setTitleFontSizeClass("Page introuvable") ?>">Page introuvable</h2>
|
<h2
|
||||||
<p><a href="/">Retour à l'accueil</a></p>
|
class="main-title fs-xl">
|
||||||
|
<?= $page->title() ?></h2>
|
||||||
<?php endslot() ?>
|
<?php endslot() ?>
|
||||||
<?php endsnippet() ?>
|
<?php endsnippet() ?>
|
||||||
<div id="main-content">
|
<div id="main-content">
|
||||||
<?= $page->body() ?>
|
<?= $page->body() ?>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
<p><a href="/">Retour à l'accueil</a></p>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<?php snippet('footer') ?>
|
<?php snippet('footer') ?>
|
||||||
|
|
@ -1,17 +1,24 @@
|
||||||
<?php snippet('header') ?>
|
<?php snippet('header') ?>
|
||||||
<main id="<?= $page->template() ?>">
|
<main id="<?= $page->template() ?>">
|
||||||
<article>
|
<article>
|
||||||
<?php snippet('cover', array('isOpen' => true), slots: true) ?>
|
<?php snippet('cover', ['isOpen' => true], slots: true) ?>
|
||||||
<?php slot('title') ?>
|
<?php slot('title') ?>
|
||||||
<h1 class="main-title"><?= $page->title() ?></h1>
|
<h1 class="main-title"><?= $page->title() ?></h1>
|
||||||
<?php if ($page->subtitle()->isNotEmpty()): ?>
|
<?php if ($page->subtitle()->isNotEmpty()): ?>
|
||||||
<h2 class="main-subtitle fs-l"><?= $page->subtitle()->inline() ?></h2>
|
<h2 class="main-subtitle fs-l"><?= $page->subtitle()->inline() ?>
|
||||||
|
</h2>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<p>
|
<p>
|
||||||
<span class="light">par</span>
|
<span class="light">par</span>
|
||||||
<a class="author" href="/auteurs/<?= Str::slug($page->author()->toPage()->title()) ?>"><?= $page->author()->toPage()->title() ?></a><br>
|
<a class="author"
|
||||||
<span class="light">publié le </span><?= $page->published()->toDate('d/m/Y') ?><br>
|
href="/auteurs/<?= Str::slug($page->author()->toPage()->title()) ?>"><?= $page->author()->toPage()->title() ?></a><br>
|
||||||
<span class="light">dans</span> <a href="<?= $page->parent()->url() ?>" title="voir les textes liés à l'année <?= $page->parent()->title() ?>"><?= $page->parent()->title() ?></a> / <a href="/categories/<?= $page->category() ?>" title="voir les textes de la catégorie <?= $page->category() ?>"><?= $page->category() ?></a>
|
<span class="light">publié le
|
||||||
|
</span><?= $page->published()->toDate('d/m/Y') ?><br>
|
||||||
|
<span class="light">dans</span> <a
|
||||||
|
href="<?= $page->parent()->url() ?>"
|
||||||
|
title="voir les textes liés à l'année <?= $page->parent()->title() ?>"><?= $page->parent()->title() ?></a>
|
||||||
|
/ <a href="/categories/<?= $page->category() ?>"
|
||||||
|
title="voir les textes de la catégorie <?= $page->category() ?>"><?= $page->category() ?></a>
|
||||||
</p>
|
</p>
|
||||||
<?php endslot() ?>
|
<?php endslot() ?>
|
||||||
<?php endsnippet() ?>
|
<?php endsnippet() ?>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue