Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Dec 28, 2022
2 parents ffdd3a1 + ffba8b9 commit bdd8393
Show file tree
Hide file tree
Showing 24 changed files with 510 additions and 48 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# v1.6.0
## 12/28/2022

1. [](#new)
* Added new "FlexObjects" basic plugin type [#77](https://github.com/getgrav/grav-plugin-devtools/pull/77)
1. [](#improved)
* Improvements for Tailwind CSS theme + AlpineJS [#74](https://github.com/getgrav/grav-plugin-devtools/pull/74)
* Updated `languages.yaml` [#76](https://github.com/getgrav/grav-plugin-devtools/pull/76)
* Updated links + default branch [#72](https://github.com/getgrav/grav-plugin-devtools/pull/72)
1. [](#bugfix)
* Various PSR Fixes [#71](https://github.com/getgrav/grav-plugin-devtools/pull/71)

# v1.5.4
## 10/26/2021

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DevTools
slug: devtools
type: plugin
version: 1.5.4
version: 1.6.0
description: Plugin and Theme scaffolding utilities
icon: cogs
author:
Expand Down
27 changes: 20 additions & 7 deletions classes/DevToolsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function createComponent(): bool
if ($template === 'inheritance') {
$parent_theme = $this->component['extends'];
$yaml_file = $this->locator->findResource('themes://' . $parent_theme) . '/' . $parent_theme . '.yaml';
$this->component['config'] = file_get_contents($yaml_file);;
$this->component['config'] = file_get_contents($yaml_file);
}

if (isset($source_theme)) {
Expand Down Expand Up @@ -156,8 +156,8 @@ protected function createComponent(): bool
// Do some filename renaming
$base_old_filename = $component_folder . '/' . $current_theme;
$base_new_filename = $component_folder . '/' . $new_theme;
@rename( $base_old_filename . '.php', $base_new_filename . '.php');
@rename( $base_old_filename . '.yaml', $base_new_filename . '.yaml');
@rename($base_old_filename . '.php', $base_new_filename . '.php');
@rename($base_old_filename . '.yaml', $base_new_filename . '.yaml');

$camelized_current = $this->inflector::camelize($current_theme);
$camelized_new = $this->inflector::camelize($name);
Expand Down Expand Up @@ -211,7 +211,6 @@ protected function createComponent(): bool
}

echo $source_theme;

} else {
/**
* Use components folder and twig processing
Expand All @@ -233,7 +232,7 @@ protected function createComponent(): bool
$templates = Folder::all($component_folder);

try {
foreach($templates as $templateFile) {
foreach ($templates as $templateFile) {
if (Utils::endsWith($templateFile, '.twig') && !Utils::endsWith($templateFile, '.html.twig')) {
$content = $this->twig->processTemplate($templateFile);
$file = File::instance($component_folder . DS . str_replace('.twig', '', $templateFile));
Expand All @@ -259,6 +258,20 @@ protected function createComponent(): bool
$bpname = $this->inflector::hyphenize($this->component['bpname']);
rename($component_folder . DS . $type . '.yaml', $component_folder . DS . $bpname . '.yaml');
}

if ($this->component['flex_name']) {
$flex_classes_folder = $component_folder . DS . 'classes' . DS . 'Flex' . DS . 'Types';
$flex_name = strtolower($this->inflector::underscorize($this->component['flex_name']));
$flex_name_camel = $this->inflector::camelize($this->component['flex_name']);

rename($flex_classes_folder . DS . 'flex_name',$flex_classes_folder . DS . $flex_name_camel);

rename($flex_classes_folder . DS . $flex_name_camel . DS . 'Object' . '.php',$flex_classes_folder . DS . $flex_name_camel . DS . $flex_name_camel . 'Object' . '.php');
rename($flex_classes_folder . DS . $flex_name_camel . DS . 'Collection' . '.php',$flex_classes_folder . DS . $flex_name_camel . DS . $flex_name_camel . 'Collection' . '.php');

rename($component_folder . DS . 'blueprints' . DS . 'flex-objects' . DS . $type . '.yaml', $component_folder . DS . 'blueprints' . DS . 'flex-objects' . DS . $flex_name . '.yaml');
}

}

$this->output->writeln('');
Expand Down Expand Up @@ -318,13 +331,13 @@ protected function validate(string $type, $value)
break;

case 'description':
if($value === null || trim($value) === '') {
if ($value === null || trim($value) === '') {
throw new \RuntimeException('Description cannot be empty');
}

break;
case 'themename':
if($value === null || trim($value) === '') {
if ($value === null || trim($value) === '') {
throw new \RuntimeException('Theme Name cannot be empty');
}

Expand Down
28 changes: 25 additions & 3 deletions cli/NewPluginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Grav\Plugin\Console;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\Question;

require_once(__DIR__ . '/../classes/DevToolsCommand.php');
Expand Down Expand Up @@ -35,7 +36,7 @@ protected function configure(): void
)
->addOption(
'dev',
null,
null,
InputOption::VALUE_OPTIONAL,
'The name/username of the developer'
)
Expand Down Expand Up @@ -136,11 +137,32 @@ protected function serve(): int
$this->component['author']['email'] = $io->askQuestion($question);
}

$this->component['template'] = 'blank';
$question = new ChoiceQuestion(
'Please choose an option',
['blank' => 'Basic Plugin',
'flex' => 'Basic Plugin prepared for custom Flex Objects'
]
);
$this->component['template'] = $io->askQuestion($question);

if ($this->component['template'] === 'flex') {

$question = new Question('Enter Flex Object Name');
$question->setValidator(function ($value) {
return $this->validate('name', $value);
});
$this->component['flex_name'] = $io->askQuestion($question);

$question = new ChoiceQuestion('Please choose a storage type', [
'simple' => 'Basic Storage (1 file for all objects) - no media support',
'file' => 'File Storage (1 file per object)',
'folder' => 'Folder Storage (1 folder per object)'
]);
$this->component['flex_storage'] = $io->askQuestion($question);
}

$this->createComponent();

return 0;
}

}
8 changes: 4 additions & 4 deletions components/plugin/blank/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@

**This README.md file should be modified to describe the features, installation, configuration, and general usage of the plugin.**

The **{{ component_title }}** Plugin is an extension for [Grav CMS](http://github.com/getgrav/grav). {{ component.description }}
The **{{ component_title }}** Plugin is an extension for [Grav CMS](https://github.com/getgrav/grav). {{ component.description }}

## Installation

Installing the {{ component_title }} plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.

### GPM Installation (Preferred)

To install the plugin via the [GPM](http://learn.getgrav.org/advanced/grav-gpm), through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:
To install the plugin via the [GPM](https://learn.getgrav.org/cli-console/grav-cli-gpm), through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:

bin/gpm install {{ component_hyphenated }}

This will install the {{ component_title }} plugin into your `/user/plugins`-directory within Grav. Its files can be found under `/your/site/grav/user/plugins/{{ component_hyphenated }}`.

### Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under `/your/site/grav/user/plugins`. Then rename the folder to `{{ component_hyphenated }}`. You can find these files on [GitHub](https://github.com/{{ developer_hyphenated }}/grav-plugin-{{ component_hyphenated }}) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
To install the plugin manually, download the zip-version of this repository and unzip it under `/your/site/grav/user/plugins`. Then rename the folder to `{{ component_hyphenated }}`. You can find these files on [GitHub](https://github.com/{{ developer_hyphenated }}/grav-plugin-{{ component_hyphenated }}) or via [GetGrav.org](https://getgrav.org/downloads/plugins).

You should now have all the plugin files under

/your/site/grav/user/plugins/{{ component_hyphenated }}

> NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its [blueprints.yaml-file on GitHub](https://github.com/{{ developer_hyphenated }}/grav-plugin-{{ component_hyphenated }}/blob/master/blueprints.yaml).
> NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its [blueprints.yaml-file on GitHub](https://github.com/{{ developer_hyphenated }}/grav-plugin-{{ component_hyphenated }}/blob/main/blueprints.yaml).

### Admin Plugin

Expand Down
5 changes: 5 additions & 0 deletions components/plugin/flex/CHANGELOG.md.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# v0.1.0
## {{ "now"|date("m/d/Y") }}

1. [](#new)
* ChangeLog started...
21 changes: 21 additions & 0 deletions components/plugin/flex/LICENSE.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) {{ "now"|date("Y") }} {{ component.author.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.
59 changes: 59 additions & 0 deletions components/plugin/flex/README.md.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% set component_title = (component.name|titleize) %}
{% set component_hyphenated = (component.name|hyphenize) %}
{% set developer_hyphenated = (component.author.githubid|hyphenize) %}
# {{ component_title }} Plugin

**This README.md file should be modified to describe the features, installation, configuration, and general usage of the plugin.**

The **{{ component_title }}** Plugin is an extension for [Grav CMS](https://github.com/getgrav/grav). {{ component.description }}

## Installation

Installing the {{ component_title }} plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.

### GPM Installation (Preferred)

To install the plugin via the [GPM](https://learn.getgrav.org/cli-console/grav-cli-gpm), through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:

bin/gpm install {{ component_hyphenated }}

This will install the {{ component_title }} plugin into your `/user/plugins`-directory within Grav. Its files can be found under `/your/site/grav/user/plugins/{{ component_hyphenated }}`.

### Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under `/your/site/grav/user/plugins`. Then rename the folder to `{{ component_hyphenated }}`. You can find these files on [GitHub](https://github.com/{{ developer_hyphenated }}/grav-plugin-{{ component_hyphenated }}) or via [GetGrav.org](https://getgrav.org/downloads/plugins).

You should now have all the plugin files under

/your/site/grav/user/plugins/{{ component_hyphenated }}

> NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its [blueprints.yaml-file on GitHub](https://github.com/{{ developer_hyphenated }}/grav-plugin-{{ component_hyphenated }}/blob/main/blueprints.yaml).

### Admin Plugin

If you use the Admin Plugin, you can install the plugin directly by browsing the `Plugins`-menu and clicking on the `Add` button.

## Configuration

Before configuring this plugin, you should copy the `user/plugins/{{ component_hyphenated }}/{{ component_hyphenated }}.yaml` to `user/config/plugins/{{ component_hyphenated }}.yaml` and only edit that copy.

Here is the default configuration and an explanation of available options:

```yaml
enabled: true
```

Note that if you use the Admin Plugin, a file with your configuration named {{component_hyphenated}}.yaml will be saved in the `user/config/plugins/`-folder once the configuration is saved in the Admin.

## Usage

**Describe how to use the plugin.**

## Credits

**Did you incorporate third-party code? Want to thank somebody?**

## To Do

- [ ] Future plans, if any

37 changes: 37 additions & 0 deletions components/plugin/flex/blueprints.yaml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% set githubid = component.author.githubid ?: component.author.name|hyphenize -%}
name: {{ component.name|titleize }}
slug: {{ component.name|hyphenize }}
type: plugin
version: 0.1.0
description: {{ component.description }}
icon: plug
author:
name: {{ component.author.name }}
email: {{ component.author.email }}
homepage: https://github.com/{{ githubid }}/grav-plugin-{{ component.name|hyphenize }}
demo: http://demo.yoursite.com
keywords: grav, plugin, etc
bugs: https://github.com/{{ githubid }}/grav-plugin-{{ component.name|hyphenize }}/issues
docs: https://github.com/{{ githubid }}/grav-plugin-{{ component.name|hyphenize }}/blob/develop/README.md
license: MIT

dependencies:
- { name: grav, version: '>=1.6.0' }

form:
validation: loose
fields:
enabled:
type: toggle
label: PLUGIN_ADMIN.PLUGIN_STATUS
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
text_var:
type: text
label: PLUGIN_{{ component.name|underscorize|upper }}.TEXT_VARIABLE
help: PLUGIN_{{ component.name|underscorize|upper }}.TEXT_VARIABLE_HELP
Loading

0 comments on commit bdd8393

Please sign in to comment.