finish author system

This commit is contained in:
isUnknown 2024-10-16 08:53:53 +02:00
parent db8669d30d
commit fe6e01acdf
38 changed files with 614 additions and 73 deletions

59
package-lock.json generated
View file

@ -494,18 +494,18 @@
} }
}, },
"node_modules/@babel/helper-string-parser": { "node_modules/@babel/helper-string-parser": {
"version": "7.23.4", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz",
"integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-validator-identifier": { "node_modules/@babel/helper-validator-identifier": {
"version": "7.22.20", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz",
"integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@ -610,10 +610,13 @@
} }
}, },
"node_modules/@babel/parser": { "node_modules/@babel/parser": {
"version": "7.23.9", "version": "7.25.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.9.tgz", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz",
"integrity": "sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==", "integrity": "sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==",
"dev": true, "dev": true,
"dependencies": {
"@babel/types": "^7.25.8"
},
"bin": { "bin": {
"parser": "bin/babel-parser.js" "parser": "bin/babel-parser.js"
}, },
@ -1882,13 +1885,13 @@
"dev": true "dev": true
}, },
"node_modules/@babel/types": { "node_modules/@babel/types": {
"version": "7.23.9", "version": "7.25.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.9.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz",
"integrity": "sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==", "integrity": "sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/helper-string-parser": "^7.23.4", "@babel/helper-string-parser": "^7.25.7",
"@babel/helper-validator-identifier": "^7.22.20", "@babel/helper-validator-identifier": "^7.25.7",
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
}, },
"engines": { "engines": {
@ -1928,9 +1931,9 @@
} }
}, },
"node_modules/@jridgewell/sourcemap-codec": { "node_modules/@jridgewell/sourcemap-codec": {
"version": "1.4.15", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
"dev": true "dev": true
}, },
"node_modules/@jridgewell/trace-mapping": { "node_modules/@jridgewell/trace-mapping": {
@ -5672,9 +5675,9 @@
} }
}, },
"node_modules/picocolors": { "node_modules/picocolors": {
"version": "1.0.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==",
"dev": true "dev": true
}, },
"node_modules/pify": { "node_modules/pify": {
@ -5785,9 +5788,9 @@
} }
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.4.33", "version": "8.4.47",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz",
"integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -5805,8 +5808,8 @@
], ],
"dependencies": { "dependencies": {
"nanoid": "^3.3.7", "nanoid": "^3.3.7",
"picocolors": "^1.0.0", "picocolors": "^1.1.0",
"source-map-js": "^1.0.2" "source-map-js": "^1.2.1"
}, },
"engines": { "engines": {
"node": "^10 || ^12 || >=14" "node": "^10 || ^12 || >=14"
@ -7887,9 +7890,9 @@
} }
}, },
"node_modules/source-map-js": { "node_modules/source-map-js": {
"version": "1.0.2", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"

View file

@ -0,0 +1,19 @@
title: Auteur
image: false
tabs:
contentTab:
label: Contenu
sections:
presentationSection:
type: fields
fields:
presentation:
label: Présentation
type: writer
help: Optionnelle
texts:
label: Textes
type: pages
create: false
query: page.getTexts()

View file

@ -0,0 +1,9 @@
title: Auteurs
tabs:
contentTab:
sections:
authorsSection:
label: Liste
type: pages
template: author

View file

@ -0,0 +1,26 @@
title: Email
status:
draft: Brouillon
listed: Envoyé
image:
back: black
color: white
icon: email
options:
changeStatus: false
tabs:
contentTab:
fields:
month:
label: Mois
type: date
display: "mmmm YYYY"
default: today
width: 1/4
sendBtn:
type: send-button
width: 1/4
content:
label: Contenu
type: writer

View file

@ -0,0 +1,21 @@
title: Liste de diffusion
tabs:
content:
columns:
- width: 1/2
fields:
subscribers:
label: Abonnés
type: structure
fields:
email:
type: email
- width: 1/2
sections:
newsletters:
label: Emails
type: pages
template: email
info: "{{ page.month.toDate('M Y') }}"
sortBy: month desc

View file

@ -12,12 +12,13 @@ sections:
label: Catégorie label: Catégorie
type: select type: select
options: query options: query
query: site.find('texts').categories.split query: site.find('textes').categories.split
required: true required: true
width: 1/3 width: 1/3
author: author:
label: Auteur label: Auteur
type: users type: pages
max: 1 query: page('auteurs').children
multiple: false
required: true required: true
width: 1/3 width: 1/3

View file

@ -5,7 +5,7 @@ function createCategories($textsPage) {
foreach ($textsPage->categories()->split() as $category) { foreach ($textsPage->categories()->split() as $category) {
$categories[$category] = array( $categories[$category] = array(
'title' => $category, 'title' => $category,
'texts' => array() 'texts' => new Pages()
); );
} }
return $categories; return $categories;
@ -16,7 +16,7 @@ function fillCategoriesWithTexts($emptyCategories, $texts) {
foreach ($texts as $text) { foreach ($texts as $text) {
try { try {
$textCategory = $text->category()->value(); $textCategory = $text->category()->value();
$filledCategories[$textCategory]['texts'][] = $text; $filledCategories[$textCategory]['texts']->add($text);
} catch (\Throwable $th) { } catch (\Throwable $th) {
throw new Exception(json_encode($th->getFile() . ' : ' . $th->getMessage())); throw new Exception(json_encode($th->getFile() . ' : ' . $th->getMessage()));
} }
@ -29,7 +29,7 @@ function fillCategoriesWithTexts($emptyCategories, $texts) {
} }
return function ($site) { return function ($site) {
$textsPage = $site->find('texts'); $textsPage = $site->find('textes');
$years = $textsPage->children(); $years = $textsPage->children();
$texts = $years->children()->index(); $texts = $years->children()->index();

View file

@ -1,5 +1,5 @@
<?php <?php
return function ($site) { return function ($site) {
return $site->find('texts')->children(); return $site->find('textes')->children();
}; };

View file

@ -6,8 +6,20 @@ return array(
'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' => 'smtp.outlook.com',
'port' => 587,
'security' => 'tls',
'auth' => true,
'username' => 'adrien.payet@outlook.com',
'password' => 't8nVpxCpEZcqH8y'
]
],
'routes' => array( 'routes' => array(
require __DIR__ . '/routes/virtual-author.php', require __DIR__ . '/routes/virtual-author.php',
require __DIR__ . '/routes/virtual-category.php', require __DIR__ . '/routes/virtual-category.php',
require __DIR__ . '/routes/send-newsletter.php',
), ),
); );

View file

@ -11,12 +11,21 @@ return [
'texts' => [ 'texts' => [
'icon' => 'pen', 'icon' => 'pen',
'label' => 'Textes', 'label' => 'Textes',
'link' => 'pages/texts', 'link' => 'pages/textes',
'current' => function ($current) { 'current' => function ($current) {
$path = Kirby::instance()->request()->path()->toString(); $path = Kirby::instance()->request()->path()->toString();
return Str::contains($path, 'pages/texts'); return Str::contains($path, 'pages/textes');
} }
], ],
'authors' => [
'icon' => 'users',
'label' => 'Auteurs',
'link' => 'pages/auteurs',
'current' => function ($current) {
$path = Kirby::instance()->request()->path()->toString();
return Str::contains($path, 'pages/auteurs');
}
],
'-', '-',
'-', '-',
'infos' => [ 'infos' => [
@ -30,11 +39,11 @@ return [
], ],
'newsletter' => [ 'newsletter' => [
'icon' => 'email', 'icon' => 'email',
'label' => 'Infolettre', 'label' => 'Liste de diffusion',
'link' => 'pages/lettre', 'link' => 'pages/liste-de-diffusion',
'current' => function ($current) { 'current' => function ($current) {
$path = Kirby::instance()->request()->path()->toString(); $path = Kirby::instance()->request()->path()->toString();
return Str::contains($path, 'pages/lettre'); return Str::contains($path, 'pages/liste-de-diffusion');
} }
], ],
'-', '-',

View file

@ -0,0 +1,24 @@
<?php
return [
'pattern' => '/send-newsletter.json',
'method' => 'POST',
'action' => function () {
$jsonRequest = file_get_contents("php://input");
$request = json_decode($jsonRequest);
$kirby = kirby();
try {
$kirby->email([
'from' => "adrien.payet@outlook.com",
'to' => 'payet.adrien@protonmail.com',
'subject' => 'actualités',
'body' => 'Ceci est un test simple.',
]);
return json_encode(['status' => 'success', 'message' => 'Email envoyé avec succès.']);
} catch (Exception $error) {
return json_encode(['status' => 'error', 'message' => $error->getMessage()]);
}
}
];

8
site/models/author.php Normal file
View file

@ -0,0 +1,8 @@
<?php
class AuthorPage extends Page {
public function getTexts() {
return page('textes')->index()->filter(function($text) {
return $text->author()->toPage() === $this;
});
}
}

View file

@ -0,0 +1,20 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.php]
indent_size = 4
[*.md,*.txt]
trim_trailing_whitespace = false
insert_final_newline = false
[composer.json]
indent_size = 4

11
site/plugins/send-button/.gitattributes vendored Normal file
View file

@ -0,0 +1,11 @@
# Note: You need to uncomment the lines you want to use; the other lines can be deleted
# Git
# .gitattributes export-ignore
# .gitignore export-ignore
# Tests
# /.coveralls.yml export-ignore
# /.travis.yml export-ignore
# /phpunit.xml.dist export-ignore
# /tests/ export-ignore

14
site/plugins/send-button/.gitignore vendored Normal file
View file

@ -0,0 +1,14 @@
# OS files
.DS_Store
# npm modules
/node_modules
# Parcel cache folder
.cache
# Composer files
/vendor
# kirbyup temp development entry
/index.dev.mjs

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) <Year> <Your Name>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,117 @@
# Kirby Pluginkit: Example plugin for Kirby
> Variant "Panel plugin setup"
This is a boilerplate for a Kirby Panel plugin that can be installed via all three [supported installation methods](https://getkirby.com/docs/guide/plugins/plugin-setup-basic#the-three-plugin-installation-methods).
You can find a list of Pluginkit variants on the [`master` branch](https://github.com/getkirby/pluginkit/tree/master).
****
## How to use the Pluginkit
1. Fork this repository
2. Change the plugin name and description in the `composer.json`
3. Change the plugin name in the `index.php` and `src/index.js`
4. Change the license if you don't want to publish under MIT
5. Add your plugin code to the `index.php` and `src/index.js`
6. Update this `README` with instructions for your plugin
### Install the development and build setup
We use [kirbyup](https://github.com/johannschopplich/kirbyup) for the development and build setup.
You can start developing directly. kirbyup will be fetched remotely with your first `npm run` command, which may take a short amount of time.
### Development
You can start the dev process with:
```bash
npm run dev
```
This will automatically update the `index.js` and `index.css` of your plugin as soon as you make changes.
Reload the Panel to see your code changes reflected.
With kirbyup 2.0.0+ and Kirby 3.7.4+ you can alternatively use hot module reloading (HMR):
```bash
npm run serve
```
This will start a development server that updates the page as soon as you make changes. Some updates are instant, like CSS or Vue template changes, others require a reload of the page, which happens automatically.
> [!NOTE]
> The live reload functionality requires top level await, [which is only supported in modern browsers](https://caniuse.com/mdn-javascript_operators_await_top_level). If you're developing in older browsers, use `npm run dev` and reload the page manually to see changes.
### Production
As soon as you are happy with your plugin, you should build the final version with:
```bash
npm run build
```
This will automatically create a minified and optimized version of your `index.js` and `index.css`
which you can ship with your plugin.
We have a tutorial on how to build your own plugin based on the Pluginkit [in the Kirby documentation](https://getkirby.com/docs/guide/plugins/plugin-setup-basic).
### Build reproducibility
While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, we recommend to target a specific package version, rather than using npx:
```json
{
"scripts": {
"dev": "kirbyup src/index.js --watch",
"build": "kirbyup src/index.js"
},
"devDependencies": {
"kirbyup": "^3.1.0"
}
}
```
What follows is an example README for your plugin.
****
## Installation
### Download
Download and copy this repository to `/site/plugins/{{ plugin-name }}`.
### Git submodule
```bash
git submodule add https://github.com/{{ your-name }}/{{ plugin-name }}.git site/plugins/{{ plugin-name }}
```
### Composer
```bash
composer require {{ your-name }}/{{ plugin-name }}
```
## Setup
*Additional instructions on how to configure the plugin (e.g. blueprint setup, config options, etc.)*
## Options
*Document the options and APIs that this plugin offers*
## Development
*Add instructions on how to help working on the plugin (e.g. npm setup, Composer dev dependencies, etc.)*
## License
MIT
## Credits
- [Your Name](https://github.com/ghost)

View file

@ -0,0 +1,18 @@
# Security Policy
## Supported Versions
*Use this section to tell people about which versions of your project are currently being supported with security updates.*
| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |
## Reporting a Vulnerability
*Use this section to tell people how to report a vulnerability.*
*Tell them where to go, how often they can expect to get an update on a reported vulnerability, what to expect if the vulnerability is accepted or declined, etc.*

View file

@ -0,0 +1,21 @@
{
"name": "adrienpayet/send-button",
"description": "Send button",
"license": "MIT",
"type": "kirby-plugin",
"version": "1.0.0",
"authors": [
{
"name": "Adrien Payet",
"email": "contact@adrien-payet.fr"
}
],
"require": {
"getkirby/composer-installer": "^1.1"
},
"config": {
"allow-plugins": {
"getkirby/composer-installer": true
}
}
}

66
site/plugins/send-button/composer.lock generated Normal file
View file

@ -0,0 +1,66 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "37a8e61308b9b6f49cb9835f477f0c64",
"packages": [
{
"name": "getkirby/composer-installer",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/getkirby/composer-installer.git",
"reference": "c98ece30bfba45be7ce457e1102d1b169d922f3d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getkirby/composer-installer/zipball/c98ece30bfba45be7ce457e1102d1b169d922f3d",
"reference": "c98ece30bfba45be7ce457e1102d1b169d922f3d",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.8 || ^2.0"
},
"type": "composer-plugin",
"extra": {
"class": "Kirby\\ComposerInstaller\\Plugin"
},
"autoload": {
"psr-4": {
"Kirby\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Kirby's custom Composer installer for the Kirby CMS and for Kirby plugins",
"homepage": "https://getkirby.com",
"support": {
"issues": "https://github.com/getkirby/composer-installer/issues",
"source": "https://github.com/getkirby/composer-installer/tree/1.2.1"
},
"funding": [
{
"url": "https://getkirby.com/buy",
"type": "custom"
}
],
"time": "2020-12-28T12:54:39+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

View file

@ -0,0 +1,6 @@
@media screen and (min-width: 533px) {
button[data-v-4847e765] {
margin-top: 2.15rem;
}
}

View file

@ -0,0 +1,62 @@
(function() {
"use strict";
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
if (render) {
options.render = render;
options.staticRenderFns = staticRenderFns;
options._compiled = true;
}
{
options._scopeId = "data-v-" + scopeId;
}
return {
exports: scriptExports,
options
};
}
const _sfc_main = {
__name: "SendButtonField",
props: {
pageUri: String
},
setup(__props) {
const { pageUri } = __props;
const text = Vue.ref("Envoyer");
const headers = {
method: "POST",
body: JSON.stringify({
pageUri
})
};
function send(event) {
event.preventDefault();
fetch("/send-newsletter.json", headers).then((res) => res.json()).then((json) => console.log(json));
}
return { __sfc: true, text, headers, send };
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy;
return _c("k-button", { attrs: { "variant": "filled", "icon": "plane" }, on: { "click": function($event) {
return _setup.send($event);
} } }, [_vm._v(_vm._s(_setup.text))]);
};
var _sfc_staticRenderFns = [];
_sfc_render._withStripped = true;
var __component__ = /* @__PURE__ */ normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns,
false,
null,
"4847e765"
);
__component__.options.__file = "/Users/adrienpayet/code/actuel-inactuel/site/plugins/send-button/src/components/SendButtonField.vue";
const SendButtonField = __component__.exports;
window.panel.plugin("adrienpayet/send-button", {
fields: {
"send-button": SendButtonField
}
});
})();

View file

@ -0,0 +1,13 @@
<?php
Kirby::plugin('adrienpayet/send-button', [
'fields' => [
'send-button' => [
'computed' => [
'pageUri' => function () {
return $this->model()->uri();
},
]
]
]
]);

View file

@ -0,0 +1,7 @@
{
"scripts": {
"dev": "npx -y kirbyup src/index.js --watch",
"serve": "npx -y kirbyup serve src/index.js",
"build": "npx -y kirbyup src/index.js"
}
}

View file

@ -0,0 +1,37 @@
<template>
<k-button @click="send($event)" variant="filled" icon="plane">{{
text
}}</k-button>
</template>
<script setup>
import { ref } from "vue";
const { pageUri } = defineProps({
pageUri: String,
});
const text = ref("Envoyer");
const headers = {
method: "POST",
body: JSON.stringify({
pageUri,
}),
};
function send(event) {
event.preventDefault();
fetch("/send-newsletter.json", headers)
.then((res) => res.json())
.then((json) => console.log(json));
}
</script>
<style scoped>
@media screen and (min-width: 533px) {
button {
margin-top: 2.15rem;
}
}
</style>

View file

@ -0,0 +1,7 @@
import SendButtonField from "./components/SendButtonField.vue";
window.panel.plugin("adrienpayet/send-button", {
fields: {
"send-button": SendButtonField,
},
});

View file

@ -1,16 +1,12 @@
<?php <?php
$firstCol = rand(0, 8); $firstCol = rand(0, 8);
$secondCol = rand(0, 8) $secondCol = rand(0, 8);
?> ?>
<sidebar id="desktop-nav"> <sidebar id="desktop-nav">
<ul> <ul>
<li <li
class="left top" class="left top"
style="
--left: <?= e($page->fullWidth() != 'true', $firstCol, 0) ?>;
--top: <?= e($page->fullWidth() != 'true', rand(0, 6), 0) ?>
"
> >
<button class="toggle-btn toggle-btn--left" onclick="togglePanel('left', event)"> <button class="toggle-btn toggle-btn--left" onclick="togglePanel('left', event)">
années années
@ -18,10 +14,6 @@
</li> </li>
<li <li
class="left top" class="left top"
style="
--left: <?= e($page->fullWidth() != 'true', $secondCol, 0) ?>;
--top: <?= e($page->fullWidth() != 'true', rand(0, 6), 0) ?>
"
> >
<button class="toggle-btn toggle-btn--left" onclick="togglePanel('right', event)"> <button class="toggle-btn toggle-btn--left" onclick="togglePanel('right', event)">
catégories catégories
@ -31,10 +23,6 @@
"></li> "></li>
<li <li
class="left top" class="left top"
style="
--left: <?= e($page->fullWidth() != 'true', $firstCol, 0) ?>;
--top: <?= e($page->fullWidth() != 'true', rand(0, 6), 0) ?>
"
> >
<a href="#"> <a href="#">
s'abonner s'abonner
@ -42,10 +30,6 @@
</li> </li>
<li <li
class="left top" class="left top"
style="
--left: <?= e($page->fullWidth() != 'true', $secondCol, 0) ?>;
--top: <?= e($page->fullWidth() != 'true', rand(0, 6), 0) ?>
"
> >
<a href="<?= $site->find('a-propos')->url() ?>"> <a href="<?= $site->find('a-propos')->url() ?>">
à propos à propos

View file

@ -24,7 +24,7 @@ $entryTopPos = $entryTopPos ?? 20;
"headline":"<?= $page->title() ?>", "headline":"<?= $page->title() ?>",
"author":[{"@type": "Person","name": "<?= $page->author() ?>"}], "author":[{"@type": "Person","name": "<?= $page->author() ?>"}],
"image":"<?= url('assets/images/logo.png') ?>", "image":"<?= url('assets/images/logo.png') ?>",
"description":"<?= $page->title() ?>, par <?= $page->author()->toUser()->name() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= $page->parent()->title() ?>/<?= $page->category() ?>", "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') ?>", "datePublished":"<?= $page->published()->toDate('Y-m-d') ?>",
"dateModified":"<?= $page->modified('Y-m-d') ?>", "dateModified":"<?= $page->modified('Y-m-d') ?>",
"url":"<?= $page->url() ?>", "url":"<?= $page->url() ?>",

View file

@ -52,14 +52,17 @@
> >
<ul class="panel-item-content__texts"> <ul class="panel-item-content__texts">
<?php <?php
shuffle($category['texts']); $category['texts'];
foreach($category['texts'] as $article): foreach($category['texts'] as $article):
?>
<?php
$author = $article->author()->toPage() == null ? "inconnu" : $article->author()->toPage()->title();
?> ?>
<li <li
class="text" class="text"
x-data="{ x-data="{
title: '<?= str_replace("'", "\'", $article->title()->value()) ?>', title: '<?= str_replace("'", "\'", $article->title()->value()) ?>',
author: '<?= $article->author()->toUser()->name() ?>', author: '<?= $author ?>',
yearParent: '<?= $article->parent()->title()->value() ?>', yearParent: '<?= $article->parent()->title()->value() ?>',
category: '<?= $article->category() ?>', category: '<?= $article->category() ?>',
}" }"
@ -75,8 +78,7 @@
</a> </a>
<div class="text__infos"> <div class="text__infos">
<p> <p>
<span class="light">par</span> <span class="light">par</span><a class="author" href="/auteurs/<?= Str::slug($author) ?>"><?= $author ?></a><br>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br> <span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> <span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p> </p>

View file

@ -61,12 +61,15 @@
@click="edito = !edito" @click="edito = !edito"
>Lire</button> >Lire</button>
<ul class="panel-item-content__texts"> <ul class="panel-item-content__texts">
<?php foreach($year->children()->shuffle() as $article): ?> <?php foreach($year->children() as $article): ?>
<?php
$author = $article->author()->toPage() == null ? "inconnu" : $article->author()->toPage()->title();
?>
<li <li
class="text" class="text"
x-data="{ x-data="{
title: '<?= str_replace("'", "\'", $article->title()->value()) ?>', title: '<?= str_replace("'", "\'", $article->title()->value()) ?>',
author: '<?= $article->author()->toUser()->name() ?>', author: '<?= $author ?>',
yearParent: '<?= $article->parent()->title()->value() ?>', yearParent: '<?= $article->parent()->title()->value() ?>',
category: '<?= $article->category() ?>', category: '<?= $article->category() ?>',
}" }"
@ -83,7 +86,7 @@
<div class="text__infos"> <div class="text__infos">
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a><br> <a class="author" href="/auteurs/<?= Str::slug($author) ?>"><?= $author ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br> <span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> <span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p> </p>

View file

@ -66,7 +66,7 @@ $activeTab = isset($activeTab) ? Str::slug($activeTab) : '';
class="see-more toggle left" @click="isOpen = !isOpen">Lire</button> class="see-more toggle left" @click="isOpen = !isOpen">Lire</button>
</div> </div>
<?php foreach($year->children() as $article): ?> <?php foreach($year->children() as $article): ?>
<?php if (!$authorFilter || $authorFilter == $article->author()->toUser()->name()->value()) : ?> <?php if (!$authorFilter || $authorFilter == $article->author()->toPage()->title()->value()) : ?>
<?php snippet( <?php snippet(
'text-item', 'text-item',
array( array(

View file

@ -7,7 +7,7 @@
<div class="text__infos"> <div class="text__infos">
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a><br> <a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br> <span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> <span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p> </p>

View file

@ -9,7 +9,7 @@
<p class="h3">textes :</p> <p class="h3">textes :</p>
<ul class="texts"> <ul class="texts">
<?php foreach($site->index()->filterBy('template', 'in', array('linear', 'grid')) as $article): ?> <?php foreach($site->index()->filterBy('template', 'in', array('linear', 'grid')) as $article): ?>
<?php if ($article->author()->isNotEmpty() && $article->author()->toUser()->name() == $page->title()->value()): ?> <?php if ($article->author()->isNotEmpty() && $article->author()->toPage()->title() == $page->title()->value()): ?>
<li <li
class="text" class="text"
> >
@ -19,7 +19,7 @@
<div class="text__infos"> <div class="text__infos">
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a><br> <a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br> <span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> <span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p> </p>

View file

View file

@ -20,7 +20,7 @@
<div class="text__infos"> <div class="text__infos">
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a><br> <a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br> <span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> <span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p> </p>

View file

@ -6,7 +6,7 @@
<h2 class="main-title <?= setTitleFontSizeClass($page->title()) ?>"><?= $page->title() ?></h2> <h2 class="main-title <?= setTitleFontSizeClass($page->title()) ?>"><?= $page->title() ?></h2>
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($page->author()->toUser()->name()) ?>"><?= $page->author()->toUser()->name() ?></a><br> <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">publié le </span><?= $page->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $page->parent()->url() ?>"><?= $page->parent()->title() ?></a> / <a href="/categories/<?= $page->category() ?>"><?= $page->category() ?></a> <span class="light">dans</span> <a href="<?= $page->parent()->url() ?>"><?= $page->parent()->title() ?></a> / <a href="/categories/<?= $page->category() ?>"><?= $page->category() ?></a>
</p> </p>

View file

@ -6,7 +6,7 @@
<h2 class="main-title <?= setTitleFontSizeClass($page->title()) ?>"><?= $page->title() ?></h2> <h2 class="main-title <?= setTitleFontSizeClass($page->title()) ?>"><?= $page->title() ?></h2>
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($page->author()->toUser()->name()) ?>"><?= $page->author()->toUser()->name() ?></a><br> <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">publié le </span><?= $page->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $page->parent()->url() ?>"><?= $page->parent()->title() ?></a> / <a href="/categories/<?= $page->category() ?>"><?= $page->category() ?></a> <span class="light">dans</span> <a href="<?= $page->parent()->url() ?>"><?= $page->parent()->title() ?></a> / <a href="/categories/<?= $page->category() ?>"><?= $page->category() ?></a>
</p> </p>

View file

@ -18,7 +18,7 @@
<div class="text__infos"> <div class="text__infos">
<p> <p>
<span class="light">par</span> <span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a><br> <a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br> <span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> <span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p> </p>