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="category"] .page-cover,
|
||||
[data-template="year"] .page-cover {
|
||||
height: initial;
|
||||
[data-template="year"] .page-cover,
|
||||
[data-template="email"] .page-cover,
|
||||
[data-template="error"] .page-cover {
|
||||
height: initial !important;
|
||||
}
|
||||
|
||||
.page-cover .links {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
title: Email
|
||||
status:
|
||||
draft: Brouillon
|
||||
unlisted: Testé
|
||||
listed: Envoyé
|
||||
image:
|
||||
back: black
|
||||
|
|
|
|||
|
|
@ -1,26 +1,28 @@
|
|||
<?php
|
||||
|
||||
function createEmptyCategories() {
|
||||
$categories = new Pages();
|
||||
function createEmptyCategories()
|
||||
{
|
||||
$categories = new Pages();
|
||||
foreach (page('textes')->categories()->split() as $categoryName) {
|
||||
$category = new Page([
|
||||
'slug' => Str::slug($categoryName),
|
||||
'slug' => Str::slug($categoryName),
|
||||
'template' => 'category',
|
||||
'status' => 'listed',
|
||||
'content' => [
|
||||
'status' => 'listed',
|
||||
'content' => [
|
||||
'title' => $categoryName,
|
||||
],
|
||||
'children' => []
|
||||
'children' => [],
|
||||
]);
|
||||
|
||||
$categories->add($category);
|
||||
}
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
|
||||
function createCategories() {
|
||||
function createCategories()
|
||||
{
|
||||
$emptyCategories = createEmptyCategories();
|
||||
foreach (page('textes')->grandChildren() as $text) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
<?php
|
||||
|
||||
return array(
|
||||
"debug" => true,
|
||||
"panel" => array(
|
||||
"menu" => require __DIR__ . "/menu.php",
|
||||
"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"
|
||||
]
|
||||
return [
|
||||
'debug' => true,
|
||||
'panel' => [
|
||||
'menu' => require __DIR__ . '/menu.php',
|
||||
'css' => 'assets/css/panel.css',
|
||||
],
|
||||
'email' => [
|
||||
'transport' => [
|
||||
'type' => 'smtp',
|
||||
'host' => 'smtp.mailersend.net',
|
||||
'port' => 587,
|
||||
'auth' => true,
|
||||
'username' => 'MS_K9grTE@actuel-inactuel.fr',
|
||||
'password' => 'mssp.GJGywUh.z3m5jgrq71xldpyo.owybzs9',
|
||||
],
|
||||
"routes" => array(
|
||||
require __DIR__ . "/routes/virtual-category.php",
|
||||
require __DIR__ . "/routes/send-newsletter.php",
|
||||
require __DIR__ . "/routes/subscribe.php",
|
||||
)
|
||||
);
|
||||
],
|
||||
'routes' => [
|
||||
require __DIR__ . '/routes/virtual-category.php',
|
||||
require __DIR__ . '/routes/subscribe.php',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,62 +2,62 @@
|
|||
|
||||
return [
|
||||
'site' => [
|
||||
'label' => 'Accueil',
|
||||
'label' => 'Accueil',
|
||||
'current' => function ($current) {
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'site');
|
||||
}
|
||||
},
|
||||
],
|
||||
'texts' => [
|
||||
'icon' => 'pen',
|
||||
'label' => 'Textes',
|
||||
'link' => 'pages/textes',
|
||||
'icon' => 'pen',
|
||||
'label' => 'Textes',
|
||||
'link' => 'pages/textes',
|
||||
'current' => function ($current) {
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'pages/textes');
|
||||
}
|
||||
},
|
||||
],
|
||||
'authors' => [
|
||||
'icon' => 'users',
|
||||
'label' => 'Auteurs',
|
||||
'link' => 'pages/auteurs',
|
||||
'icon' => 'users',
|
||||
'label' => 'Auteurs',
|
||||
'link' => 'pages/auteurs',
|
||||
'current' => function ($current) {
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'pages/auteurs');
|
||||
}
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'pages/auteurs');
|
||||
},
|
||||
],
|
||||
'-',
|
||||
'-',
|
||||
'infos' => [
|
||||
'icon' => 'question',
|
||||
'label' => 'À propos',
|
||||
'link' => 'pages/a-propos',
|
||||
'icon' => 'question',
|
||||
'label' => 'À propos',
|
||||
'link' => 'pages/a-propos',
|
||||
'current' => function ($current) {
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'pages/a-propos');
|
||||
}
|
||||
},
|
||||
],
|
||||
'subscription' => [
|
||||
'icon' => 'email',
|
||||
'label' => 'Liste de diffusion',
|
||||
'link' => 'pages/inscription',
|
||||
'icon' => 'email',
|
||||
'label' => 'Liste de diffusion',
|
||||
'link' => 'pages/lettre',
|
||||
'current' => function ($current) {
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'pages/liste-de-diffusion');
|
||||
}
|
||||
},
|
||||
],
|
||||
'-',
|
||||
'-',
|
||||
'users',
|
||||
'comments',
|
||||
'admin' => [
|
||||
'icon' => 'folder',
|
||||
'label' => 'Administration',
|
||||
'link' => 'pages/admin',
|
||||
'icon' => 'folder',
|
||||
'label' => 'Administration',
|
||||
'link' => 'pages/admin',
|
||||
'current' => function ($current) {
|
||||
$path = Kirby::instance()->request()->path()->toString();
|
||||
return Str::contains($path, 'pages/admin');
|
||||
}
|
||||
},
|
||||
],
|
||||
'-',
|
||||
'-',
|
||||
|
|
|
|||
|
|
@ -2,43 +2,42 @@
|
|||
|
||||
return [
|
||||
'pattern' => '/subscribe.json',
|
||||
'method' => 'POST',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$jsonRequest = file_get_contents("php://input");
|
||||
$jsonRequest = file_get_contents('php://input');
|
||||
$email = Str::lower(json_decode($jsonRequest));
|
||||
|
||||
if (V::email($email)) {
|
||||
kirby()->impersonate('kirby');
|
||||
|
||||
$page = page("inscription");
|
||||
|
||||
$page = page('lettre');
|
||||
$subscribers = $page->subscribers()->yaml();
|
||||
|
||||
$emailExists = in_array(["email" => $email], $subscribers);
|
||||
$emailExists = in_array(['email' => $email], $subscribers);
|
||||
|
||||
if ($emailExists) {
|
||||
return [
|
||||
"status" => "error",
|
||||
"message" => "Cet email est déjà inscris."
|
||||
'status' => 'error',
|
||||
'message' => 'Cet email est déjà inscris.',
|
||||
];
|
||||
}
|
||||
|
||||
$newSubscriber = ["email" => $email];
|
||||
$newSubscriber = ['email' => $email];
|
||||
$subscribers[] = $newSubscriber;
|
||||
|
||||
|
||||
$page->update([
|
||||
'subscribers' => $subscribers
|
||||
'subscribers' => $subscribers,
|
||||
]);
|
||||
|
||||
return [
|
||||
"status" => "success",
|
||||
"message" => "Inscription réussie."
|
||||
'status' => 'success',
|
||||
'message' => 'lettre réussie.',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
"status" => "error",
|
||||
"message" => "Email invalide."
|
||||
'status' => 'error',
|
||||
'message' => 'Email invalide.',
|
||||
];
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -29,3 +29,4 @@ function getAuthorBySlug($slug)
|
|||
|
||||
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}})})();
|
||||
|
|
|
|||
|
|
@ -5,12 +5,16 @@ Kirby::plugin('adrienpayet/send-button', [
|
|||
'send-button' => [
|
||||
'computed' => [
|
||||
'pageUri' => function () {
|
||||
return $this->model()->uri();
|
||||
return $this->model()->uri();
|
||||
},
|
||||
'pageStatus' => function () {
|
||||
return $this->model()->status();
|
||||
return $this->model()->status();
|
||||
},
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
'routes' => [
|
||||
require __DIR__ . '/routes/send-newsletter.php',
|
||||
require __DIR__ . '/routes/unsubscribe-newsletter.php',
|
||||
],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -2,74 +2,78 @@
|
|||
|
||||
return [
|
||||
'pattern' => '/send-newsletter.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$jsonRequest = file_get_contents("php://input");
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$jsonRequest = file_get_contents('php://input');
|
||||
$data = json_decode($jsonRequest);
|
||||
|
||||
if (!$data || !isset($data->pageUri) || !isset($data->isTest)) {
|
||||
return json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Invalid request data. Required fields: pageUri, isTest.'
|
||||
'status' => 'error',
|
||||
'message' => 'Invalid request data. Required fields: pageUri, isTest.',
|
||||
]);
|
||||
}
|
||||
|
||||
$kirby = kirby();
|
||||
$emailPage = page('inscription')->childrenAndDrafts()->find($data->pageUri);
|
||||
$emailPage = page('lettre')->childrenAndDrafts()->find($data->pageUri);
|
||||
|
||||
if (!$emailPage) {
|
||||
return json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'The specified page does not exist.'
|
||||
'status' => 'error',
|
||||
'message' => 'The specified page does not exist.',
|
||||
]);
|
||||
}
|
||||
|
||||
$recipients = $data->isTest
|
||||
? $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)) {
|
||||
return json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'No recipients found.'
|
||||
'status' => 'error',
|
||||
'message' => 'No recipients found.',
|
||||
]);
|
||||
}
|
||||
|
||||
$subject = $data->isTest
|
||||
? "[TEST] - " . $emailPage->title()->value()
|
||||
? '[TEST] - ' . $emailPage->title()->value()
|
||||
: $emailPage->title()->value();
|
||||
|
||||
$from = new \Kirby\Cms\User([
|
||||
'email' => 'info@actuel-inactuel.fr',
|
||||
'name' => 'actuel-inactuel',
|
||||
]);
|
||||
|
||||
|
||||
try {
|
||||
foreach ($recipients as $recipient) {
|
||||
$kirby->email([
|
||||
'from' => $from,
|
||||
'to' => $recipient,
|
||||
'subject' => $subject,
|
||||
'from' => $from,
|
||||
'to' => $recipient,
|
||||
'subject' => $subject,
|
||||
'template' => 'newsletter',
|
||||
'data' => [
|
||||
'body' => $emailPage->body()
|
||||
]
|
||||
'data' => [
|
||||
'body' => $emailPage->body(),
|
||||
'url' => (string) $emailPage->url(),
|
||||
'recipient' => $recipient,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
if (!$data->isTest) {
|
||||
$emailPage->changeStatus('listed');
|
||||
} else {
|
||||
$emailPage->changeStatus('unlisted');
|
||||
}
|
||||
|
||||
return json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Email(s) sent successfully.'
|
||||
'status' => 'success',
|
||||
'message' => 'Email(s) sent successfully.',
|
||||
]);
|
||||
} catch (Exception $error) {
|
||||
return json_encode([
|
||||
'status' => 'error',
|
||||
'message' => $error->getMessage() . " file " . $error->getFile() . " line " . $error->getLine()
|
||||
'status' => 'error',
|
||||
'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>
|
||||
<div class="wrapper" v-if="pageStatus === 'draft'">
|
||||
<div class="wrapper" v-if="pageStatus !== 'listed'">
|
||||
<div class="test-wrapper">
|
||||
<k-button
|
||||
@click="send($event, true)"
|
||||
|
|
@ -102,18 +102,9 @@ async function send(event, isTest = false) {
|
|||
error: null,
|
||||
};
|
||||
|
||||
if (!isTest) {
|
||||
setTimeout(() => {
|
||||
location.href = location.href;
|
||||
}, 2000);
|
||||
} else {
|
||||
currentBtnState.value = {
|
||||
icon: "plane",
|
||||
text: "Re-tester",
|
||||
theme: null,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
setTimeout(() => {
|
||||
location.href = location.href;
|
||||
}, 2000);
|
||||
} else {
|
||||
throw new Error(data.message || "Erreur inconnue");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,35 @@
|
|||
<?php
|
||||
$isOpen = isset($isOpen) ? $isOpen : false;
|
||||
$isOpen ??= false;
|
||||
?>
|
||||
|
||||
<header
|
||||
class="page-cover"
|
||||
>
|
||||
<header class="page-cover">
|
||||
<div class="title-wrapper">
|
||||
<a href="#main-content" class="no-underline" title="aller au texte">
|
||||
<?= $slots->title() ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php if ($slots->text()): ?>
|
||||
<div class="text-wrapper">
|
||||
<?= $slots->text() ?>
|
||||
</div>
|
||||
<?php if ($slots->text()): ?>
|
||||
<div class="text-wrapper">
|
||||
<?= $slots->text() ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<ul class="links">
|
||||
<?php if ($page->is(page('inscription'))): ?>
|
||||
<li>
|
||||
<a href="<?= $site->url() ?>">
|
||||
accueil
|
||||
</a>
|
||||
</li>
|
||||
<?php if ($page->is(page('lettre'))): ?>
|
||||
<li>
|
||||
<a href="<?= $site->url() ?>">
|
||||
accueil
|
||||
</a>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a href="/inscription" id="subscribe-btn" class="plus">
|
||||
s'inscrire
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/lettre" id="subscribe-btn" class="plus">
|
||||
s'inscrire
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<li>
|
||||
<a href="<?= $site->find('a-propos')->url() ?>">
|
||||
<a
|
||||
href="<?= $site->find('a-propos')->url() ?>">
|
||||
à propos
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<footer id="main-footer">
|
||||
<ul id="links">
|
||||
<?php if (!$page->isHomePage() && $kirby->user()->isLoggedIn()): ?>
|
||||
<?php if (!$page->isHomePage() && $kirby->user()): ?>
|
||||
<li class="open-nav-wrapper">
|
||||
<button class="plus open-nav" title="chercher parmi les textes">textes</button>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<?php if ($page->is(page('inscription'))): ?>
|
||||
<?php if ($page->is(page('lettre'))): ?>
|
||||
<li>
|
||||
<a href="<?= $site->url() ?>">
|
||||
accueil
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
</li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a href="/inscription" id="subscribe-btn" class="plus">
|
||||
<a href="/lettre" id="subscribe-btn" class="plus">
|
||||
s'inscrire
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -1,68 +1,82 @@
|
|||
<?php
|
||||
$entryTopPos = $entryTopPos ?? 20;
|
||||
|
||||
$kirby = kirby();
|
||||
$site = site();
|
||||
|
||||
$openPageURIS = [
|
||||
"home",
|
||||
"a-propos",
|
||||
"inscription"
|
||||
];
|
||||
|
||||
|
||||
if (!$kirby->user() && (!in_array($page->uri(), $openPageURIS))) {
|
||||
go($site->panel()->url());
|
||||
if(!$kirby->user() && $page->template() == 'linear' || $page->template() == 'grid') {
|
||||
go($site->errorPage()->url());
|
||||
}
|
||||
|
||||
$entryTopPos ??= 20;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<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) ?>" />
|
||||
|
||||
<script src="<?= url('assets') ?>/js/script.js?version-cache-prevent<?= rand(0, 1000)?>" 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">
|
||||
|
||||
<?php if ($page->template() == 'linear' || $page->template() == 'grid'): ?>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context":"https://schema.org",
|
||||
"@type":"NewsArticle",
|
||||
"headline":"<?= $page->title() ?>",
|
||||
"author":[{"@type": "Person","name": "<?= $page->author() ?>"}],
|
||||
"image":"<?= url('assets/images/logo.png') ?>",
|
||||
"description":"<?= $page->title() ?>, par <?= $page->author()->toPage()->title() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= $page->parent()->title() ?>/<?= $page->category() ?>",
|
||||
"datePublished":"<?= $page->published()->toDate('Y-m-d') ?>",
|
||||
"dateModified":"<?= $page->modified('Y-m-d') ?>",
|
||||
"url":"<?= $page->url() ?>",
|
||||
"mainEntityOfPage":{"@type":"WebPage","@id":"<?= $page->url() ?>"},
|
||||
"publisher":{"@type":"Organization","name":"actuel - inactuel"}
|
||||
}
|
||||
</script>
|
||||
<?php endif ?>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>
|
||||
<?= $site->title() ?><?= e($page->url() !== $site->url(), ' - ' . $page->title()) ?>
|
||||
</title>
|
||||
|
||||
<!-- FAVICON -->
|
||||
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<meta name="apple-mobile-web-app-title" content="actuel-inactuel" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
</head>
|
||||
<body class="background-grid <?= e($page->fullWidth() == 'true', 'full-width') ?>" data-template="<?= $page->template() ?>" >
|
||||
<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') ?>">
|
||||
<h1>
|
||||
<span id="actuel">actuel</span>
|
||||
<span id="inactuel">inactuel</span>
|
||||
</h1>
|
||||
</a>
|
||||
</header>
|
||||
<?php snippet('nav') ?>
|
||||
<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 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">
|
||||
|
||||
<?php if ($page->template() == 'linear' || $page->template() == 'grid'): ?>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "NewsArticle",
|
||||
"headline": "<?= $page->title() ?>",
|
||||
"author": [{
|
||||
"@type": "Person",
|
||||
"name": "<?= $page->author() ?>"
|
||||
}],
|
||||
"image": "<?= url('assets/images/logo.png') ?>",
|
||||
"description": "<?= $page->title() ?>, par <?= $page->author()->toPage()->title() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= $page->parent()->title() ?>/<?= $page->category() ?>",
|
||||
"datePublished": "<?= $page->published()->toDate('Y-m-d') ?>",
|
||||
"dateModified": "<?= $page->modified('Y-m-d') ?>",
|
||||
"url": "<?= $page->url() ?>",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "<?= $page->url() ?>"
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": "actuel - inactuel"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php endif ?>
|
||||
|
||||
<!-- FAVICON -->
|
||||
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<meta name="apple-mobile-web-app-title" content="actuel-inactuel" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
</head>
|
||||
|
||||
<body
|
||||
class="background-grid <?= e($page->fullWidth() == 'true', 'full-width') ?>"
|
||||
data-template="<?= $page->template() ?>">
|
||||
<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') ?>">
|
||||
<h1>
|
||||
<span id="actuel">actuel</span>
|
||||
<span id="inactuel">inactuel</span>
|
||||
</h1>
|
||||
</a>
|
||||
</header>
|
||||
<?php snippet('nav') ?>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<?php if ($page->published()->isNotEmpty()): ?>
|
||||
<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>
|
||||
<?php endif ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<?= $body ?>
|
||||
|
||||
<em>Vous pouvez demander votre désinscription en répondant directement à ce mail.</em>
|
||||
<p>
|
||||
<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') ?>
|
||||
<main id="<?= $page->template() ?>">
|
||||
<article>
|
||||
<?php snippet('cover', array('isOpen' => true), slots: true) ?>
|
||||
<?php slot('title') ?>
|
||||
<h2 class="main-title <?= setTitleFontSizeClass("Page introuvable") ?>">Page introuvable</h2>
|
||||
<p><a href="/">Retour à l'accueil</a></p>
|
||||
<?php endslot() ?>
|
||||
<?php snippet('cover', ['isOpen' => true], slots: true) ?>
|
||||
<?php slot('title') ?>
|
||||
<h2
|
||||
class="main-title fs-xl">
|
||||
<?= $page->title() ?></h2>
|
||||
<?php endslot() ?>
|
||||
<?php endsnippet() ?>
|
||||
<div id="main-content">
|
||||
<?= $page->body() ?>
|
||||
</div>
|
||||
</article>
|
||||
<p><a href="/">Retour à l'accueil</a></p>
|
||||
</main>
|
||||
|
||||
<?php snippet('footer') ?>
|
||||
|
|
@ -1,26 +1,33 @@
|
|||
<?php snippet('header') ?>
|
||||
<main id="<?= $page->template() ?>">
|
||||
<article>
|
||||
<?php snippet('cover', array('isOpen' => true), slots: true) ?>
|
||||
<?php slot('title') ?>
|
||||
<h1 class="main-title"><?= $page->title() ?></h1>
|
||||
<?php if ($page->subtitle()->isNotEmpty()): ?>
|
||||
<h2 class="main-subtitle fs-l"><?= $page->subtitle()->inline() ?></h2>
|
||||
<?php endif ?>
|
||||
<p>
|
||||
<span class="light">par</span>
|
||||
<a class="author" href="/auteurs/<?= Str::slug($page->author()->toPage()->title()) ?>"><?= $page->author()->toPage()->title() ?></a><br>
|
||||
<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>
|
||||
<?php endslot() ?>
|
||||
<?php snippet('cover', ['isOpen' => true], slots: true) ?>
|
||||
<?php slot('title') ?>
|
||||
<h1 class="main-title"><?= $page->title() ?></h1>
|
||||
<?php if ($page->subtitle()->isNotEmpty()): ?>
|
||||
<h2 class="main-subtitle fs-l"><?= $page->subtitle()->inline() ?>
|
||||
</h2>
|
||||
<?php endif ?>
|
||||
<p>
|
||||
<span class="light">par</span>
|
||||
<a class="author"
|
||||
href="/auteurs/<?= Str::slug($page->author()->toPage()->title()) ?>"><?= $page->author()->toPage()->title() ?></a><br>
|
||||
<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>
|
||||
<?php endslot() ?>
|
||||
<?php endsnippet() ?>
|
||||
|
||||
|
||||
<div id="main-content">
|
||||
<?php if ($page->chapo()->isNotEmpty()): ?>
|
||||
<div id="chapo">
|
||||
<?= $page->chapo() ?>
|
||||
</div>
|
||||
<?php if ($page->chapo()->isNotEmpty()): ?>
|
||||
<div id="chapo">
|
||||
<?= $page->chapo() ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?= $page->body() ?>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue