Skip to content

Commit

Permalink
Merge pull request #163 from MadeHQ/widget-laphil
Browse files Browse the repository at this point in the history
Improved functionality, remove username requirement, etc
  • Loading branch information
hpatel-mm authored Oct 4, 2023
2 parents 2b3f80b + c052fff commit 4bd66b9
Show file tree
Hide file tree
Showing 33 changed files with 14,441 additions and 6,740 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.13.2
v16.13.0
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Actually, that's a lie. You don't even have to worry about that, because this mo

### Provide Cloudinary config

You'll need to provide the Cloud Name, API Key, API Secret, and Username[^1]. These values are the core requirements that enables the module to talk to Cloudinary.
You'll need to provide the Cloud Name, API Key, and API Secret. These values are the core requirements that enables the module to talk to Cloudinary.

Put these values in any YAML file you may be using to configure other parts of SilverStripe.

Expand All @@ -71,18 +71,17 @@ MadeHQ\Cloudinary:
cloud_name: 'CLOUDINARY_CLOUD_NAME'
api_key: 'CLOUDINARY_API_KEY'
api_secret: 'CLOUDINARY_API_SECRET'
username: 'CLOUDINARY_USERNAME'
```
### Create database fields
The provides support for six database fields:
* `CloudinaryImage` – store an image
* `CloudinaryMedia` – store a video or audio[^2]
* `CloudinaryMedia` – store a video or audio[^1]
* `CloudinaryFile` – store a raw file such as documents
* `CloudinaryMultiImage` – store multiple images
* `CloudinaryMultiMedia` – store multiple videos or audio[^2]
* `CloudinaryMultiMedia` – store multiple videos or audio[^1]
* `CloudinaryMultiFile` – store multiple files

Use these as you would use any other database fields – add an entry in the `$db` static:
Expand Down Expand Up @@ -490,8 +489,7 @@ This version of the module is still in its infancy. We will flesh it out as our
- [x] Provide better support for colours
- [ ] Add handling for Edit/Remove functionality in WYSIWYG

[^1]: Username in this instance is interchangeable with email. Provide the email you used to sign up for Cloudinary.
[^2]: Due to limitation of Cloudinary, audio and videos both have the resource type of `video`. It's a minor inconvinience but the module exposes the `getActualType` method which will help differenciate the two when rendering.
[^1]: Due to limitation of Cloudinary, audio and videos both have the resource type of `video`. It's a minor inconvinience but the module exposes the `getActualType` method which will help differenciate the two when rendering.

### Migration

Expand Down
2 changes: 0 additions & 2 deletions _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use SilverStripe\AssetAdmin\Controller\AssetAdmin;
use SilverStripe\Core\Config\Config;
use Cloudinary\Configuration\Configuration;
use Cloudinary\Utils;
use MadeHQ\Cloudinary\UserForms\Controllers\FormAdmin;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
Expand Down Expand Up @@ -36,7 +35,6 @@
'cloud_name' => $settings['cloud_name'],
'api_key' => $settings['api_key'],
'api_secret' => $settings['api_secret'],
'signature_algorithm' => Utils::ALGO_SHA256,
],
'url' => [
'secure' => true,
Expand Down
2 changes: 0 additions & 2 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ After:
SilverStripe\Core\Injector\Injector:
MadeHQ\Cloudinary\Tasks\MigrationTaskStep2:
constructor:
- '%$Cloudinary\Cloudinary'
- '%$MadeHQ\Cloudinary\MigrationDataCache'
# - '%$MadeHQ\Cloudinary\Controllers\API' // Injected within __constructor() as need to set user before it can be instantiated

MadeHQ\Cloudinary\MigrationDataCache:
factory: SilverStripe\Core\Cache\CacheFactory
Expand Down
2 changes: 1 addition & 1 deletion client/dist/bundle.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/bundle.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6,851 changes: 6,850 additions & 1 deletion client/dist/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/dist/bundle.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! silverstripe-cloudinary - v2.0.0 */
2 changes: 1 addition & 1 deletion client/dist/bundle.js.map

Large diffs are not rendered by default.

34 changes: 33 additions & 1 deletion client/dist/userform.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/dist/userform.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! silverstripe-cloudinary - v2.0.0 */
2 changes: 1 addition & 1 deletion client/dist/userform.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions client/src/css/bundle.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// .cloudinary-field {

// }
.cloudinary-input-field {
position: relative;
}

.cloudinary-field__sr-only {
clip: rect(0 0 0 0);
Expand Down Expand Up @@ -69,17 +69,14 @@
}

.cloudinary-field-order__move {
cursor: pointer;
display: block;
padding: 0;
width: auto;
height: auto;

ins {
text-decoration: none;
}
}
.cloudinary-field-order__move--up.cloudinary-field-order__move--first,
.cloudinary-field-order__move--down.cloudinary-field-order__move--last {
cursor: not-allowed;
}

.cloudinary-field__media {
position: relative;
Expand Down
8 changes: 1 addition & 7 deletions client/src/js/TinyMCE_ssmedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
const options = {
...CLOUDINARY_CONFIG,
multiple: false,
remove_header: true,
};

const defaultTransformations = this.editor.getParam('default_transformations');
Expand All @@ -76,13 +77,6 @@
options.default_transformations = [defaultTransformations];
}

// Safari is the devil. Force users to login manually.
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
delete options.username;
delete options.timestamp;
delete options.signature;
}

cloudinary.openMediaLibrary(options, {
insertHandler,
});
Expand Down
6 changes: 3 additions & 3 deletions client/src/js/bundle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jQuery from 'jquery';
import React from 'react';
import { unmountComponentAtNode, render } from 'react-dom';
import { unmountComponentAtNode, render } from 'react-dom'; // eslint-disable-line react/no-deprecated
import Field from './components/field';

jQuery.noConflict();
Expand All @@ -12,7 +12,7 @@ jQuery.entwine('ss', $ => {
onmatch() {
this._super();

this.addClass('sr-only');
this.addClass('cloudinary-field__sr-only');

this.HolderInstance = $('<div class="cloudinary-field"></div>');

Expand All @@ -32,7 +32,7 @@ jQuery.entwine('ss', $ => {
onunmatch() {
this._super();

this.removeClass('sr-only');
this.removeClass('cloudinary-field__sr-only');

if (!(this.HolderInstance instanceof jQuery)) {
return;
Expand Down
10 changes: 2 additions & 8 deletions client/src/js/components/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,9 @@ export default class Field extends Component {
...CLOUDINARY_CONFIG,
multiple: !!isMultiple,
max_files: maxFiles - this.state.resources.length,
remove_header: true,
};

// Safari is the devil. Force users to login manually.
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
delete options.username;
delete options.timestamp;
delete options.signature;
}

cloudinary.openMediaLibrary(options, {
insertHandler: this.insertHandler,
});
Expand Down Expand Up @@ -361,7 +355,7 @@ export default class Field extends Component {
<div className="cloudinary-field__inner">
{ this.state.loading === true && (
<div className="cloudinary-field__loader">
<span className="sr-only">Loading…</span>
<span className="cloudinary-field__sr-only">Loading…</span>
</div>
) }

Expand Down
Loading

0 comments on commit 4bd66b9

Please sign in to comment.