update kirby to v5 and add refresh cache panel view button
This commit is contained in:
commit
9a86d41254
466 changed files with 19960 additions and 10497 deletions
20
public/site/plugins/refresh-cache-button/.editorconfig
Normal file
20
public/site/plugins/refresh-cache-button/.editorconfig
Normal 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
public/site/plugins/refresh-cache-button/.gitattributes
vendored
Normal file
11
public/site/plugins/refresh-cache-button/.gitattributes
vendored
Normal 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
public/site/plugins/refresh-cache-button/.gitignore
vendored
Normal file
14
public/site/plugins/refresh-cache-button/.gitignore
vendored
Normal 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
|
||||
21
public/site/plugins/refresh-cache-button/LICENSE.md
Executable file
21
public/site/plugins/refresh-cache-button/LICENSE.md
Executable 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.
|
||||
117
public/site/plugins/refresh-cache-button/README.md
Executable file
117
public/site/plugins/refresh-cache-button/README.md
Executable 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)
|
||||
18
public/site/plugins/refresh-cache-button/SECURITY.md
Normal file
18
public/site/plugins/refresh-cache-button/SECURITY.md
Normal 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.*
|
||||
21
public/site/plugins/refresh-cache-button/composer.json
Executable file
21
public/site/plugins/refresh-cache-button/composer.json
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "adrienpayet/refresh-cache-button",
|
||||
"description": "A panel view buttons that allows to refresh the project or projects cache.",
|
||||
"license": "MIT",
|
||||
"type": "kirby-plugin",
|
||||
"version": "1.0.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Adrien Payet",
|
||||
"email": "adrien@studio-variable.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"getkirby/composer-installer": "^1.1"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"getkirby/composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
66
public/site/plugins/refresh-cache-button/composer.lock
generated
Normal file
66
public/site/plugins/refresh-cache-button/composer.lock
generated
Normal 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"
|
||||
}
|
||||
2
public/site/plugins/refresh-cache-button/index.css
Normal file
2
public/site/plugins/refresh-cache-button/index.css
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
/** Put your CSS here **/
|
||||
1
public/site/plugins/refresh-cache-button/index.js
Normal file
1
public/site/plugins/refresh-cache-button/index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
(function(){"use strict";function f(n,e,c,t,r,o,i,u){var a=typeof n=="function"?n.options:n;return e&&(a.render=e,a.staticRenderFns=c,a._compiled=!0),{exports:n,options:a}}const l={__name:"RefreshCacheButton",props:{pageUri:String,pageStatus:String},setup(n){const{pageUri:e,pageStatus:c}=n,t=Vue.ref("Rafraîchir"),r=Vue.ref("refresh"),o=Vue.ref("aqua-icon");async function i(){t.value="En cours…",r.value="loader",o.value="orange-icon";const u={method:"POST","Content-Type":"application/json",body:JSON.stringify({pageUri:e})},s=await(await fetch("/refresh-cache.json",u)).json();s.status==="error"?(console.error(s),t.value="Erreur",r.value="alert",o.value="red-icon"):(console.log(s),t.value="Terminé",r.value="check",o.value="green-icon",setTimeout(()=>{t.value="Rafraîchir",r.value="refresh",o.value="aqua-icon"},2e3))}return{__sfc:!0,text:t,icon:r,theme:o,refreshCache:i}}};var h=function(){var e=this,c=e._self._c,t=e._self._setupProxy;return e.pageStatus!=="draft"?c("k-button",{attrs:{theme:t.theme,variant:"dimmed",icon:t.icon,title:"Rafraîchir le cache front"},on:{click:function(r){return t.refreshCache()}}},[e._v(e._s(t.text))]):e._e()},_=[],p=f(l,h,_);const v=p.exports;window.panel.plugin("adrienpayet/refresh-cache-button",{components:{"refresh-cache-button":v}})})();
|
||||
24
public/site/plugins/refresh-cache-button/index.php
Executable file
24
public/site/plugins/refresh-cache-button/index.php
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
Kirby::plugin('adrienpayet/refresh-cache-button', [
|
||||
'areas' => [
|
||||
'site' => function () {
|
||||
return [
|
||||
'buttons'=> [
|
||||
'refresh-cache' => function($page) {
|
||||
return [
|
||||
'component' => 'refresh-cache-button',
|
||||
'props' => [
|
||||
'pageUri' => $page->uri(),
|
||||
'pageStatus' => $page->status()
|
||||
]
|
||||
];
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
'routes' => [
|
||||
require_once(__DIR__ . '/src/routes/refresh-cache.php')
|
||||
]
|
||||
]);
|
||||
7
public/site/plugins/refresh-cache-button/package.json
Normal file
7
public/site/plugins/refresh-cache-button/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<template>
|
||||
<k-button
|
||||
v-if="pageStatus !== 'draft'"
|
||||
:theme="theme"
|
||||
variant="dimmed"
|
||||
:icon="icon"
|
||||
title="Rafraîchir le cache front"
|
||||
@click="refreshCache()"
|
||||
>{{ text }}</k-button
|
||||
>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
const { pageUri, pageStatus } = defineProps({
|
||||
pageUri: String,
|
||||
pageStatus: String,
|
||||
});
|
||||
|
||||
const text = ref("Rafraîchir");
|
||||
const icon = ref("refresh");
|
||||
const theme = ref("aqua-icon");
|
||||
|
||||
async function refreshCache() {
|
||||
text.value = "En cours…";
|
||||
icon.value = "loader";
|
||||
theme.value = "orange-icon";
|
||||
|
||||
const init = {
|
||||
method: "POST",
|
||||
"Content-Type": "application/json",
|
||||
body: JSON.stringify({ pageUri }),
|
||||
};
|
||||
|
||||
const res = await fetch("/refresh-cache.json", init);
|
||||
const json = await res.json();
|
||||
|
||||
if (json.status === "error") {
|
||||
console.error(json);
|
||||
text.value = "Erreur";
|
||||
icon.value = "alert";
|
||||
theme.value = "red-icon";
|
||||
} else {
|
||||
console.log(json);
|
||||
text.value = "Terminé";
|
||||
icon.value = "check";
|
||||
theme.value = "green-icon";
|
||||
|
||||
setTimeout(() => {
|
||||
text.value = "Rafraîchir";
|
||||
icon.value = "refresh";
|
||||
theme.value = "aqua-icon";
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
7
public/site/plugins/refresh-cache-button/src/index.js
Executable file
7
public/site/plugins/refresh-cache-button/src/index.js
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
import RefreshCacheButton from "./components/RefreshCacheButton.vue";
|
||||
|
||||
window.panel.plugin("adrienpayet/refresh-cache-button", {
|
||||
components: {
|
||||
"refresh-cache-button": RefreshCacheButton,
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
set_time_limit(0);
|
||||
|
||||
return [
|
||||
'pattern' => '/refresh-cache.json',
|
||||
'method' => 'POST',
|
||||
'action' => function() {
|
||||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
if ($data->pageUri === 'projects') {
|
||||
$projects = page('projects')->children();
|
||||
foreach ($projects as $project) {
|
||||
$project->rebuildStepsCache();
|
||||
}
|
||||
return [
|
||||
'satus' => 'success',
|
||||
'message' => 'Données des pages projets rafraîchies avec succès.'
|
||||
];
|
||||
} else {
|
||||
try {
|
||||
$page = page($data->pageUri);
|
||||
} catch (\Throwable $th) {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => 'Impossible de rafraîchir le cache de la page : ' . $data->pageUri . '.',
|
||||
'details' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' > $th->getLine()
|
||||
];
|
||||
}
|
||||
|
||||
$project = $page->template() == 'project' ?
|
||||
$page
|
||||
: $page->parents()->findBy('template', 'project');
|
||||
|
||||
if (!$project) {
|
||||
return [
|
||||
'satus' => 'error',
|
||||
'message' => 'Impossible de rafraîchir les données de la page ' . $data->pageUri . '. Aucun projet correspondant.'
|
||||
];
|
||||
}
|
||||
|
||||
$project->rebuildStepsCache();
|
||||
|
||||
return [
|
||||
'satus' => 'success',
|
||||
'message' => 'Données de la page ' . $data->pageUri . ' rafraîchie avec succès.'
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue