Skip to content

Commit b214baf

Browse files
committed
Initial commit
Signed-off-by: Jan Henckens <[email protected]>
0 parents  commit b214baf

12 files changed

+258
-0
lines changed

.gitattributes

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Do not export those files in the Composer archive (lighter dependency)
2+
.gitattributes export-ignore
3+
.github/ export-ignore
4+
.gitignore export-ignore
5+
CHANGELOG.md export-ignore
6+
README.md export-ignore
7+
SECURITY.md export-ignore
8+
composer.lock export-ignore
9+
ecs.php export-ignore
10+
package-lock.json export-ignore
11+
package.json export-ignore
12+
phpstan.neon export-ignore
13+
stubs/ export-ignore
14+
tests/ export-ignore
15+
16+
# Auto-detect text files and perform LF normalization
17+
* text=auto

.github/workflows/create-release.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Creates a new GitHub Release whenever the Craft Plugin Store
2+
# is notified of a new version tag.
3+
4+
name: Create Release
5+
run-name: Create release for ${{ github.event.client_payload.version }}
6+
7+
on:
8+
repository_dispatch:
9+
types:
10+
- craftcms/new-release
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- uses: ncipollo/release-action@v1
19+
with:
20+
body: ${{ github.event.client_payload.notes }}
21+
makeLatest: ${{ github.event.client_payload.latest }}
22+
name: ${{ github.event.client_payload.version }}
23+
prerelease: ${{ github.event.client_payload.prerelease }}
24+
tag: ${{ github.event.client_payload.tag }}

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.DS_Store
2+
*.idea/*
3+
*.log
4+
*Thumbs.db
5+
.env
6+
/node_modules
7+
/vendor

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Release Notes for Buttondown
2+
3+
## 1.0.0
4+
- Initial release

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Pixel & Tonic, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Buttondown
2+
3+
Buttondown integration
4+
5+
## Requirements
6+
7+
This plugin requires Craft CMS 5.6.0 or later, and PHP 8.2 or later.
8+
9+
## Installation
10+
11+
You can install this plugin from the Plugin Store or with Composer.
12+
13+
#### From the Plugin Store
14+
15+
Go to the Plugin Store in your project’s Control Panel and search for “Buttondown”. Then press “Install”.
16+
17+
#### With Composer
18+
19+
Open your terminal and run the following commands:
20+
21+
```bash
22+
# go to the project directory
23+
cd /path/to/my-project.test
24+
25+
# tell Composer to load the plugin
26+
composer require studioespresso/buttondown
27+
28+
# tell Craft to install the plugin
29+
./craft plugin/install craft-buttondown
30+
```

composer.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "studioespresso/buttondown",
3+
"description": "Buttondown integration",
4+
"type": "craft-plugin",
5+
"license": "mit",
6+
"support": {
7+
"email": "[email protected]",
8+
"issues": "https://github.com/studioespresso/craft-buttondown/issues?state=open",
9+
"source": "https://github.com/studioespresso/craft-buttondown",
10+
"docs": "https://github.com/studioespresso/craft-buttondown",
11+
"rss": "https://github.com/studioespresso/craft-buttondown/releases.atom"
12+
},
13+
"require": {
14+
"php": ">=8.2",
15+
"craftcms/cms": "^5.6.0"
16+
},
17+
"require-dev": {
18+
"craftcms/ecs": "dev-main",
19+
"craftcms/phpstan": "dev-main"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"studioespresso\\buttondown\\": "src/"
24+
}
25+
},
26+
"extra": {
27+
"handle": "craft-buttondown",
28+
"name": "Buttondown",
29+
"developer": "Studio Espresso",
30+
"documentationUrl": "https://github.com/studioespresso/craft-buttondown",
31+
"class": "studioespresso\\buttondown\\Buttondown"
32+
},
33+
"scripts": {
34+
"check-cs": "ecs check --ansi",
35+
"fix-cs": "ecs check --ansi --fix",
36+
"phpstan": "phpstan --memory-limit=1G"
37+
},
38+
"config": {
39+
"sort-packages": true,
40+
"platform": {
41+
"php": "8.2"
42+
},
43+
"allow-plugins": {
44+
"yiisoft/yii2-composer": true,
45+
"craftcms/plugin-installer": true
46+
}
47+
}
48+
}

ecs.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use craft\ecs\SetList;
6+
use Symplify\EasyCodingStandard\Config\ECSConfig;
7+
8+
return static function(ECSConfig $ecsConfig): void {
9+
$ecsConfig->paths([
10+
__DIR__ . '/src',
11+
__FILE__,
12+
]);
13+
14+
$ecsConfig->sets([
15+
SetList::CRAFT_CMS_4,
16+
]);
17+
};

phpstan.neon

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
includes:
2+
- vendor/craftcms/phpstan/phpstan.neon
3+
4+
parameters:
5+
level: 4
6+
paths:
7+
- src

src/Buttondown.php

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace studioespresso\buttondown;
4+
5+
use Craft;
6+
use craft\base\Model;
7+
use craft\base\Plugin;
8+
use studioespresso\buttondown\models\Settings;
9+
10+
/**
11+
* Buttondown plugin
12+
*
13+
* @method static Buttondown getInstance()
14+
* @method Settings getSettings()
15+
* @author Studio Espresso <[email protected]>
16+
* @copyright Studio Espresso
17+
* @license MIT
18+
*/
19+
class Buttondown extends Plugin
20+
{
21+
public string $schemaVersion = '1.0.0';
22+
public bool $hasCpSettings = true;
23+
24+
public static function config(): array
25+
{
26+
return [
27+
'components' => [
28+
// Define component configs here...
29+
],
30+
];
31+
}
32+
33+
public function init(): void
34+
{
35+
parent::init();
36+
37+
$this->attachEventHandlers();
38+
39+
// Any code that creates an element query or loads Twig should be deferred until
40+
// after Craft is fully initialized, to avoid conflicts with other plugins/modules
41+
Craft::$app->onInit(function() {
42+
// ...
43+
});
44+
}
45+
46+
protected function createSettingsModel(): ?Model
47+
{
48+
return Craft::createObject(Settings::class);
49+
}
50+
51+
protected function settingsHtml(): ?string
52+
{
53+
return Craft::$app->view->renderTemplate('craft-buttondown/_settings.twig', [
54+
'plugin' => $this,
55+
'settings' => $this->getSettings(),
56+
]);
57+
}
58+
59+
private function attachEventHandlers(): void
60+
{
61+
// Register event handlers here ...
62+
// (see https://craftcms.com/docs/5.x/extend/events.html to get started)
63+
}
64+
}

src/models/Settings.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace studioespresso\buttondown\models;
4+
5+
use Craft;
6+
use craft\base\Model;
7+
8+
/**
9+
* Buttondown settings
10+
*/
11+
class Settings extends Model
12+
{
13+
}

src/templates/_settings.twig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{# @var plugin \studioespresso\buttondown\Buttondown #}
2+
{# @var settings \studioespresso\buttondown\models\Settings #}
3+
4+
{% import '_includes/forms.twig' as forms %}
5+
6+
{# ... #}

0 commit comments

Comments
 (0)