diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d898ade --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Do not export those files in the Composer archive (lighter dependency) +.gitattributes export-ignore +.github/ export-ignore +.gitignore export-ignore +CHANGELOG.md export-ignore +README.md export-ignore +SECURITY.md export-ignore +composer.lock export-ignore +ecs.php export-ignore +package-lock.json export-ignore +package.json export-ignore +phpstan.neon export-ignore +stubs/ export-ignore +tests/ export-ignore + +# Auto-detect text files and perform LF normalization +* text=auto diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..b96abe3 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,24 @@ +# Creates a new GitHub Release whenever the Craft Plugin Store +# is notified of a new version tag. + +name: Create Release +run-name: Create release for ${{ github.event.client_payload.version }} + +on: + repository_dispatch: + types: + - craftcms/new-release + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: ncipollo/release-action@v1 + with: + body: ${{ github.event.client_payload.notes }} + makeLatest: ${{ github.event.client_payload.latest }} + name: ${{ github.event.client_payload.version }} + prerelease: ${{ github.event.client_payload.prerelease }} + tag: ${{ github.event.client_payload.tag }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8423dac --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.DS_Store +*.idea/* +*.log +*Thumbs.db +.env +/node_modules +/vendor diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6c51a6d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Release Notes for craft-quick-edit + +## 1.0.0 +- Initial release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..30c3235 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Pixel & Tonic, Inc. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9853547 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# craft-quick-edit + +A plugin that adds a cp edit url to the frontend. + +## Requirements + +This plugin requires Craft CMS 5.0.0 or later, and PHP 8.2 or later. + +## Installation + +You can install this plugin from the Plugin Store or with Composer. + +#### From the Plugin Store + +Go to the Plugin Store in your project’s Control Panel and search for “craft-quick-edit”. Then press “Install”. + +#### With Composer + +Open your terminal and run the following commands: + +```bash +# go to the project directory +cd /path/to/my-project.test + +# tell Composer to load the plugin +composer require samuelreichor/craft-quick-edit + +# tell Craft to install the plugin +./craft plugin/install craft-quick-edit +``` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..29dfda5 --- /dev/null +++ b/composer.json @@ -0,0 +1,48 @@ +{ + "name": "samuelreichor/craft-quick-edit", + "description": "A plugin that adds a cp edit url to the frontend.", + "type": "craft-plugin", + "license": "mit", + "support": { + "email": "samuelreichor@gmail.com", + "issues": "https://github.com/samuelreichor/craft-qick-edit/issues?state=open", + "source": "https://github.com/samuelreichor/craft-qick-edit", + "docs": "https://github.com/samuelreichor/craft-qick-edit", + "rss": "https://github.com/samuelreichor/craft-qick-edit/releases.atom" + }, + "require": { + "php": ">=8.2", + "craftcms/cms": "^5.0.0" + }, + "require-dev": { + "craftcms/ecs": "dev-main", + "craftcms/phpstan": "dev-main" + }, + "autoload": { + "psr-4": { + "samuelreichor\\quickedit\\": "src/" + } + }, + "extra": { + "handle": "craft-quick-edit", + "name": "craft-quick-edit", + "developer": "Samuel Reichör", + "documentationUrl": "https://github.com/samuelreichor/craft-qick-edit", + "class": "samuelreichor\\quickedit\\QickEdit" + }, + "scripts": { + "check-cs": "ecs check --ansi", + "fix-cs": "ecs check --ansi --fix", + "phpstan": "phpstan --memory-limit=1G" + }, + "config": { + "sort-packages": true, + "platform": { + "php": "8.2" + }, + "allow-plugins": { + "yiisoft/yii2-composer": true, + "craftcms/plugin-installer": true + } + } +} \ No newline at end of file diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..08742bd --- /dev/null +++ b/ecs.php @@ -0,0 +1,17 @@ +paths([ + __DIR__ . '/src', + __FILE__, + ]); + + $ecsConfig->sets([ + SetList::CRAFT_CMS_4, + ]); +}; diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..a2e5224 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,7 @@ +includes: + - vendor/craftcms/phpstan/phpstan.neon + +parameters: + level: 4 + paths: + - src diff --git a/src/QickEdit.php b/src/QickEdit.php new file mode 100644 index 0000000..5e33107 --- /dev/null +++ b/src/QickEdit.php @@ -0,0 +1,64 @@ + + * @copyright Samuel Reichör + * @license MIT + */ +class QickEdit extends Plugin +{ + public string $schemaVersion = '1.0.0'; + public bool $hasCpSettings = true; + + public static function config(): array + { + return [ + 'components' => [ + // Define component configs here... + ], + ]; + } + + public function init(): void + { + parent::init(); + + $this->attachEventHandlers(); + + // Any code that creates an element query or loads Twig should be deferred until + // after Craft is fully initialized, to avoid conflicts with other plugins/modules + Craft::$app->onInit(function() { + // ... + }); + } + + protected function createSettingsModel(): ?Model + { + return Craft::createObject(Settings::class); + } + + protected function settingsHtml(): ?string + { + return Craft::$app->view->renderTemplate('craft-quick-edit/_settings.twig', [ + 'plugin' => $this, + 'settings' => $this->getSettings(), + ]); + } + + private function attachEventHandlers(): void + { + // Register event handlers here ... + // (see https://craftcms.com/docs/5.x/extend/events.html to get started) + } +} diff --git a/src/models/Settings.php b/src/models/Settings.php new file mode 100644 index 0000000..a13544a --- /dev/null +++ b/src/models/Settings.php @@ -0,0 +1,13 @@ +