Skip to content

Commit

Permalink
better readme
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Meilick <b@bnomei.com>
  • Loading branch information
bnomei committed Aug 25, 2019
1 parent 711682d commit 9059041
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions README.md
Expand Up @@ -25,19 +25,6 @@ This plugin is free but if you use it in a commercial project please consider to
- `git submodule add https://github.com/bnomei/kirby3-cloudconvert.git site/plugins/kirby3-cloudconvert` or
- `composer require bnomei/kirby3-cloudconvert`

## Performance

**TD;DR**
Calling File-Method is performant since it only converts the file if it was modified or new.

### File-Object
Using `Kirby\Cms\File` object for `$options['file']` is recommended. In that case the modified timestamp will be checked against a cached value and a conversion triggered only if a file was modified or output does not exist. This is the default behaviour for the FileMethod provided by this plugin.

> DANGER: There is no check (yet) if a file is currently processed by cloudconvert. This might be improved at a later point.
### Path
When a path is used then file will be created only if ouput does not exist. You need to do modification checks and removing of old files yourself before starting the conversion.

## How to convert files on demand (synchronously)?

### Example 1: docx to pdf
Expand Down Expand Up @@ -166,40 +153,35 @@ $obj = cloudconvert($options, $outputPath, $async); // a/sync
- otherwise it returns an instance of `CloudConvert\Process`
- or `null` on error

## Settings
## Performance

All settings have to be prefixed with `bnomei.cloudconvert.`.
**TD;DR**
Calling File-Method has best performance since it only converts the file if it was modified or is new.

**apikey**
- default: `null` – your cloudconvert apikey as string
### File-Object
Using `Kirby\Cms\File` object for `$options['file']` is recommended. In that case the modified timestamp will be checked against a cached value and a conversion triggered only if a file was modified or output does not exist. This is the default behaviour for the FileMethod provided by this plugin.

> TIP: you can also set a callback if you use the [dotenv Plugin](https://github.com/bnomei/kirby3-dotenv)
> `'bnomei.cloudconvert.apikey' => function() { return env('CLOUDCONVERT_APIKEY'); },`
> DANGER: There is no check (yet) if a file is currently processed by cloudconvert. This might be improved at a later point.
**convert**
- default: asynchronous or synchronous conversion depending on params.
### Path
When a path is used then file will be created only if ouput does not exist. You need to do modification checks and removing of old files yourself before starting the conversion.

**async**
- default: `true`
## Settings

**options**
- default: By default this plugin requires the file to be public otherwise use `upload` here. On localhost `upload` is used as a default.
| bnomei.cloudconvert. | Default | Description |
|---------------------------|----------------|---------------------------|
| apikey | `null` | your cloudconvert apikey as string |
| convert | `callback` | asynchronous or synchronous conversion depending on params. |
| async | `true` | |
| options | `['input' => 'download']` | By default this plugin requires the file to be public otherwise use `upload` here. On localhost `upload` is used as a default. |
| log.enabled | `false` | |
| log | `callback` | to `kirbyLog()` |

```php
[
'input' => 'download', // but automatically uses 'upload' on localhost
]
```
> TIP: you can also set a callback if you use the [dotenv Plugin](https://github.com/bnomei/kirby3-dotenv)
> `'bnomei.cloudconvert.apikey' => function() { return env('CLOUDCONVERT_APIKEY'); },`
> TIP: consider setting up [presets](https://cloudconvert.com/presets) to manage your settings from within the cloudconvert dashboard instead of the Kirby config file.
**log.enabled**
- default: `false`

**log**
- default: callback to `kirbyLog()`


## Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby3-cloudconvert/issues/new).
Expand Down

0 comments on commit 9059041

Please sign in to comment.