Skip to content

Commit

Permalink
I am Batman
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelreichor committed Jan 14, 2025
0 parents commit d65b0f1
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.DS_Store
*.idea/*
*.log
*Thumbs.db
.env
/node_modules
/vendor
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release Notes for craft-quick-edit

## 1.0.0
- Initial release
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
48 changes: 48 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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
}
}
}
17 changes: 17 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use craft\ecs\SetList;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function(ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__FILE__,
]);

$ecsConfig->sets([
SetList::CRAFT_CMS_4,
]);
};
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- vendor/craftcms/phpstan/phpstan.neon

parameters:
level: 4
paths:
- src
64 changes: 64 additions & 0 deletions src/QickEdit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace samuelreichor\quickedit;

use Craft;
use craft\base\Model;
use craft\base\Plugin;
use samuelreichor\quickedit\models\Settings;

/**
* craft-quick-edit plugin
*
* @method static QickEdit getInstance()
* @method Settings getSettings()
* @author Samuel Reichör <[email protected]>
* @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)
}
}
13 changes: 13 additions & 0 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace samuelreichor\quickedit\models;

use Craft;
use craft\base\Model;

/**
* craft-quick-edit settings
*/
class Settings extends Model
{
}
6 changes: 6 additions & 0 deletions src/templates/_settings.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{# @var plugin \samuelreichor\quickedit\QickEdit #}
{# @var settings \samuelreichor\quickedit\models\Settings #}

{% import '_includes/forms.twig' as forms %}

{# ... #}

0 comments on commit d65b0f1

Please sign in to comment.