Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
✨ added new methods/models from kirby v3.6
Browse files Browse the repository at this point in the history
closes #14
  • Loading branch information
bnomei committed Oct 22, 2021
1 parent 30a7d7f commit 2b20e29
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module.exports = function (plop) {
};
```

### Generators (52)
### Generators (58)

- [x] blueprint (folder, type, template, extension, import)
- [x] config-option (file, key, value)
Expand All @@ -178,6 +178,9 @@ module.exports = function (plop) {
- [x] ext-auth-challenge (folder, key, value)
- [x] ext-api-data (folder, key, params, todo)
- [x] ext-api-route (folder, params, pattern, method, todo)
- [x] ext-block-method (folder, key, params, todo)
- [x] ext-block-model (folder, key, value)
- [x] ext-blocks-method (folder, key, params, todo)
- [x] ext-blueprint (folder, file)
- [x] ext-cache-type (folder, key, value)
- [x] ext-class-alias (folder, key, value)
Expand All @@ -191,6 +194,9 @@ module.exports = function (plop) {
- [x] ext-file-method (folder, key, params, todo)
- [x] ext-files-method (folder, key, params, todo)
- [x] ext-hook (folder, hook, todo)
- [x] ext-layoutcolumn-method (folder, key, params, todo)
- [x] ext-layout-method (folder, key, params, todo)
- [x] ext-layouts-method (folder, key, params, todo)
- [x] ext-kirbytag (folder, key, attr, params, todo)
- [x] ext-option (folder, key, value)
- [x] ext-page-method (folder, key, params, todo)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-plopfile",
"type": "kirby-plugin",
"version": "1.0.5",
"version": "1.0.6",
"description": "Plopfile to generate and append to various files for Kirby3 CMS using Plop.js",
"license": "MIT",
"keywords": [
Expand Down
35 changes: 35 additions & 0 deletions src/ext-block-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const F = require("./utils/f.js");
const helper = require("./utils/helpers.js");
const kirby = require("./utils/kirby.js");
const prompts = require("./utils/prompts.js");

module.exports = function (plop) {
const basepath = kirby.root("plugins");
const pattern = /^( *)(\/\/ @PLOP_EXT_BLOCK_METHOD)\r?\n/gim;

plop.setHelper("commaSpace", helper.commaSpace);

plop.setGenerator("ext-block-method", {
description: "append block method code to a file",
prompts: [
prompts.folder(basepath),
prompts.key(),
prompts.params(),
prompts.todo(),
],
actions: [
function (data) {
data = kirby.resolvePluginInclude(data, basepath);
},
{
path: "{{ indexphp }}",
type: "modify",
pattern: pattern,
templateFile: "ext-block-method.php.hbs",
},
function (data) {
return F.clipboard(plop, data.indexphp, pattern);
},
],
});
};
5 changes: 5 additions & 0 deletions src/ext-block-method.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$1'{{ key }}' => function ({{{commaSpace params }}}) { {{#if todo }}
$1 // TODO: {{{ todo }}}{{/if}}
$1 return null;
$1},
$1$2
30 changes: 30 additions & 0 deletions src/ext-block-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const F = require("./utils/f.js");
const helper = require("./utils/helpers.js");
const kirby = require("./utils/kirby.js");
const prompts = require("./utils/prompts.js");

module.exports = function (plop) {
const basepath = kirby.root("plugins");
const pattern = /^( *)(\/\/ @PLOP_EXT_BLOCK_MODEL)\r?\n/gim;

plop.setHelper("camelize", helper.camelize);

plop.setGenerator("ext-block-model", {
description: "append block model to an index.php",
prompts: [prompts.folder(basepath), prompts.key(), prompts.value()],
actions: [
function (data) {
data = kirby.resolvePluginInclude(data, basepath);
},
{
path: "{{ indexphp }}",
type: "modify",
pattern: pattern,
templateFile: "ext-block-model.php.hbs",
},
function (data) {
return F.clipboard(plop, data.indexphp, pattern);
},
],
});
};
2 changes: 2 additions & 0 deletions src/ext-block-model.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$1'{{{ key }}}' => {{{camelize value}}}::class,
$1$2
35 changes: 35 additions & 0 deletions src/ext-blocks-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const F = require("./utils/f.js");
const helper = require("./utils/helpers.js");
const kirby = require("./utils/kirby.js");
const prompts = require("./utils/prompts.js");

module.exports = function (plop) {
const basepath = kirby.root("plugins");
const pattern = /^( *)(\/\/ @PLOP_EXT_BLOCKS_METHOD)\r?\n/gim;

plop.setHelper("commaSpace", helper.commaSpace);

plop.setGenerator("ext-blocks-method", {
description: "append blocks method code to a file",
prompts: [
prompts.folder(basepath),
prompts.key(),
prompts.params(),
prompts.todo(),
],
actions: [
function (data) {
data = kirby.resolvePluginInclude(data, basepath);
},
{
path: "{{ indexphp }}",
type: "modify",
pattern: pattern,
templateFile: "ext-blocks-method.php.hbs",
},
function (data) {
return F.clipboard(plop, data.indexphp, pattern);
},
],
});
};
5 changes: 5 additions & 0 deletions src/ext-blocks-method.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$1'{{ key }}' => function ({{{commaSpace params }}}) { {{#if todo }}
$1 // TODO: {{{ todo }}}{{/if}}
$1 return null;
$1},
$1$2
35 changes: 35 additions & 0 deletions src/ext-layout-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const F = require("./utils/f.js");
const helper = require("./utils/helpers.js");
const kirby = require("./utils/kirby.js");
const prompts = require("./utils/prompts.js");

module.exports = function (plop) {
const basepath = kirby.root("plugins");
const pattern = /^( *)(\/\/ @PLOP_EXT_LAYOUT_METHOD)\r?\n/gim;

plop.setHelper("commaSpace", helper.commaSpace);

plop.setGenerator("ext-layout-method", {
description: "append layout method code to a file",
prompts: [
prompts.folder(basepath),
prompts.key(),
prompts.params(),
prompts.todo(),
],
actions: [
function (data) {
data = kirby.resolvePluginInclude(data, basepath);
},
{
path: "{{ indexphp }}",
type: "modify",
pattern: pattern,
templateFile: "ext-layout-method.php.hbs",
},
function (data) {
return F.clipboard(plop, data.indexphp, pattern);
},
],
});
};
5 changes: 5 additions & 0 deletions src/ext-layout-method.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$1'{{ key }}' => function ({{{commaSpace params }}}) { {{#if todo }}
$1 // TODO: {{{ todo }}}{{/if}}
$1 return null;
$1},
$1$2
35 changes: 35 additions & 0 deletions src/ext-layoutcolumn-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const F = require("./utils/f.js");
const helper = require("./utils/helpers.js");
const kirby = require("./utils/kirby.js");
const prompts = require("./utils/prompts.js");

module.exports = function (plop) {
const basepath = kirby.root("plugins");
const pattern = /^( *)(\/\/ @PLOP_EXT_LAYOUTCOLUMN_METHOD)\r?\n/gim;

plop.setHelper("commaSpace", helper.commaSpace);

plop.setGenerator("ext-layoutcolumn-method", {
description: "append layout column method code to a file",
prompts: [
prompts.folder(basepath),
prompts.key(),
prompts.params(),
prompts.todo(),
],
actions: [
function (data) {
data = kirby.resolvePluginInclude(data, basepath);
},
{
path: "{{ indexphp }}",
type: "modify",
pattern: pattern,
templateFile: "ext-layoutcolum-method.php.hbs",
},
function (data) {
return F.clipboard(plop, data.indexphp, pattern);
},
],
});
};
5 changes: 5 additions & 0 deletions src/ext-layoutcolumn-method.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$1'{{ key }}' => function ({{{commaSpace params }}}) { {{#if todo }}
$1 // TODO: {{{ todo }}}{{/if}}
$1 return null;
$1},
$1$2
35 changes: 35 additions & 0 deletions src/ext-layouts-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const F = require("./utils/f.js");
const helper = require("./utils/helpers.js");
const kirby = require("./utils/kirby.js");
const prompts = require("./utils/prompts.js");

module.exports = function (plop) {
const basepath = kirby.root("plugins");
const pattern = /^( *)(\/\/ @PLOP_EXT_LAYOUTS_METHOD)\r?\n/gim;

plop.setHelper("commaSpace", helper.commaSpace);

plop.setGenerator("ext-layouts-method", {
description: "append layouts method code to a file",
prompts: [
prompts.folder(basepath),
prompts.key(),
prompts.params(),
prompts.todo(),
],
actions: [
function (data) {
data = kirby.resolvePluginInclude(data, basepath);
},
{
path: "{{ indexphp }}",
type: "modify",
pattern: pattern,
templateFile: "ext-layouts-method.php.hbs",
},
function (data) {
return F.clipboard(plop, data.indexphp, pattern);
},
],
});
};
5 changes: 5 additions & 0 deletions src/ext-layouts-method.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$1'{{ key }}' => function ({{{commaSpace params }}}) { {{#if todo }}
$1 // TODO: {{{ todo }}}{{/if}}
$1 return null;
$1},
$1$2
36 changes: 36 additions & 0 deletions src/plugin.index.php.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ Kirby::plugin('{{{toLowerCase user }}}/{{{toLowerCase repository }}}', [
{{/if}}
],
{{/if}}
{{#if extensions.blockmodel}}

'blockModels' => [
// @PLOP_EXT_BLOCK_MODEL
],
{{/if}}
{{#if extensions.blockmethod}}

'blockMethods' => [
// @PLOP_EXT_BLOCK_METHOD
],
{{/if}}
{{#if extensions.blocksmethod}}

'blocksMethods' => [
// @PLOP_EXT_BLOCKS_METHOD
],
{{/if}}
{{#if extensions.blueprint}}

'blueprints' => [
Expand Down Expand Up @@ -116,6 +134,24 @@ Kirby::plugin('{{{toLowerCase user }}}/{{{toLowerCase repository }}}', [
// @PLOP_EXT_HOOK
],
{{/if}}
{{#if extensions.layoutcolumnmethod}}

'layoutColumnMethods' => [
// @PLOP_EXT_LAYOUTCOLUMN_METHOD
],
{{/if}}
{{#if extensions.layoutmethod}}

'layoutMethods' => [
// @PLOP_EXT_LAYOUT_METHOD
],
{{/if}}
{{#if extensions.layoutsmethod}}

'layoutsMethods' => [
// @PLOP_EXT_LAYOUTS_METHOD
],
{{/if}}
{{#if extensions.kirbytag}}

'tags' => [
Expand Down
6 changes: 6 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ module.exports = function (plop) {
choices.authchallenge(false),
choices.apidata(false),
choices.apiroute(false),
choices.blockmodel(true),
choices.blockmethod(true),
choices.blocksmethod(false),
choices.blueprint(true),
choices.cachetype(false),
choices.collection(true),
Expand All @@ -59,6 +62,9 @@ module.exports = function (plop) {
choices.filemethod(true),
choices.filesmethod(false),
choices.hook(true),
choices.layoutcolumnmethod(false),
choices.layoutmethod(true),
choices.layoutsmethod(false),
choices.kirbytag(true),
choices.option(true),
choices.pagemethod(true),
Expand Down
Loading

0 comments on commit 2b20e29

Please sign in to comment.