Skip to content

Commit 9383df1

Browse files
committed
Initial commit
0 parents  commit 9383df1

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 kenshō digital
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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# File Types for Kirby
2+
3+
Adds additional [supported file types][1] from [configuration][2] to [Kirby][3] projects.
4+
5+
## General
6+
7+
Kirby offers plenty of [configuration options][4] to modify the system’s behavior in an easy and straightforward way based on your project specific requirements. Registering additional file types, however, requires the [creation of a dedicated plugin][5] by default.
8+
9+
This is actually easy enough, but still feels like overkill sometimes. So this plugin adds file types to the configuration options.
10+
11+
## Installation
12+
13+
```shell
14+
composer require kenshodigital/kirby-file-types ^1.0
15+
```
16+
17+
## Usage
18+
19+
Just add your file types directly to your `config.php`.
20+
21+
This example adds support for [WebVTT][6] files to you project:
22+
23+
```php
24+
<?php declare(strict_types=1);
25+
26+
return [
27+
'fileTypes' => [
28+
'vtt' => [
29+
'mime' => 'text/vtt',
30+
'type' => 'document',
31+
],
32+
],
33+
...
34+
];
35+
```
36+
37+
[1]: https://getkirby.com/docs/guide/files#supported-file-types
38+
[2]: https://getkirby.com/docs/guide/configuration
39+
[3]: https://getkirby.com
40+
[4]: https://getkirby.com/docs/guide/configuration#using-options__all-configuration-options
41+
[5]: https://getkirby.com/docs/reference/plugins/extensions/file-types#registering-a-new-file-type
42+
[6]: https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API

composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "kenshodigital/kirby-file-types",
3+
"description": "Adds additional file types from configuration to Kirby projects.",
4+
"type": "kirby-plugin",
5+
"version": "1.0.0",
6+
"license": "MIT",
7+
"support":
8+
{
9+
"source": "https://github.com/kenshodigital/kirby-file-types"
10+
},
11+
"require":
12+
{
13+
"php": "^8.3",
14+
"getkirby/cms": "^4.1",
15+
"getkirby/composer-installer": "^1.2"
16+
}
17+
}

hooks/system/load-plugins/after.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
return function (): void
4+
{
5+
$this->extend(
6+
[
7+
'fileTypes' => kirby()->option('fileTypes', []),
8+
]
9+
);
10+
};

index.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php declare(strict_types=1);
2+
3+
use Kirby\Cms\App;
4+
5+
App::plugin('kensho/file-types', [
6+
'hooks' => [
7+
'system.loadPlugins:after' => require __DIR__ . '/hooks/system/load-plugins/after.php',
8+
],
9+
]);

0 commit comments

Comments
 (0)