Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rwatts3 committed Mar 5, 2016
1 parent 29e0071 commit e13c8bd
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 53 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,32 @@ This package brings the `Cloudinary` Image Management System to Orion CMS.
This package is an extension of **Orion** and requires the following packages in order to work.
`orionjs:filesystem` and `orionjs:image-attribute` or `orionjs:file-attribute`.

## Instructions
## Instructions `v1.0.0` *Warning Breaking Changes*
1. Install the package by adding `rwatts:orionjs-cloudinary` to your project.
2. Define your cloudinary settings your `settings.json` file. *see the code sample below*

`v1.0.0 sample`
```json
{
"public": {
"cloudinary": {
"cloud_name": "my-cloud-name",
"folder": "my-folder"
}
},
"private": {
"cloudinary": {
"cloud_name": "my-cloud-name",
"api_key": "my-api-key",
"api_secret": "my-api-secret",
"folder": "my-folder"
}
}
}

```

## Instructions `v0.1.1`
1. Install the package by adding `rwatts:orionjs-cloudinary` to your project.
2. Navigate to the **config** section of your admin panel.
3. Define your **Cloudinary** configuration settings by navigating to the **Cloudinary** Tab.
Expand Down
95 changes: 46 additions & 49 deletions cloudinary.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,52 @@
// config
if (Meteor.isClient) {
orion.filesystem.providerUpload = function(options, success, failure, progress) {
var before = _.pluck(Cloudinary.collection.find().fetch(), '_id');
files = options.fileList;

Cloudinary.upload(files,{
folder: orion.config.get('CLOUDINARY_FOLDER'),
}, function(error, result) {
if (error) {
failure(new Meteor.Error('cloudinary-error', i18n('filesystem.messages.errorUploading')));
} else {
success(result.url, { publicId: result.public_id });
}
Cloudinary.collection.remove({});
});
var after = _.pluck(Cloudinary.collection.find().fetch(), '_id');
var difference = _.difference(after, before);
var id = difference.length > 0 ? difference[0] : '';

Tracker.autorun(function () {
var file = Cloudinary.collection.findOne(id);
if (file) {
progress(file.percent_uploaded);
}
});
};
orion.filesystem.providerUpload = function (options, success, failure, progress) {
files = options.fileList;

orion.filesystem.providerRemove = function(file, success, failure) {
Cloudinary.delete(file.meta.publicId, function(error, result) {
if (error) {
failure(new Meteor.Error('cloudinary-error', i18n('filesystem.messages.errorRemoving')));
} else {
success();
}
});
};
}
Cloudinary.upload(files, {
folder: Meteor.settings.public.cloudinary.folder,
}, function (error, result) {
if (error) {
failure(new Meteor.Error('rwatts:orionjs-cloudinary', i18n('filesystem.messages.errorUploading')));
} else {
success(result.url, result);
}
Cloudinary.collection.remove({});
});

Tracker.autorun(function () {
var file = Cloudinary.collection.findOne();
if (file) {
progress(file.percent_uploaded);
}
});
};

orion.config.add('CLOUDINARY_CLOUD_NAME', 'cloudinary', {public: true});
orion.config.add('CLOUDINARY_FOLDER', 'cloudinary', {public: true});
orion.config.add('CLOUDINARY_API_KEY', 'cloudinary', {public: true, secret: true});
orion.config.add('CLOUDINARY_API_SECRET', 'cloudinary', {secret: true});
orion.filesystem.providerRemove = function (file, success, failure) {
Cloudinary.delete(file.meta.publicId, function (error, result) {
if (error) {
failure(new Meteor.Error('rwatts:orionjs-cloudinary', i18n('filesystem.messages.errorRemoving')));
} else {
success();
}
});
};
}

if (Meteor.isServer) {
Cloudinary.config({
cloud_name: orion.config.get('CLOUDINARY_CLOUD_NAME'),
api_key: orion.config.get('CLOUDINARY_API_KEY'),
api_secret: orion.config.get('CLOUDINARY_API_SECRET')
});
Cloudinary.config({
cloud_name: Meteor.settings.private.cloudinary.cloud_name,
api_key: Meteor.settings.private.cloudinary.api_key,
api_secret: Meteor.settings.private.cloudinary.api_secret
});

}
if (Meteor.isClient){
$.cloudinary.config({
cloud_name: orion.config.get('CLOUDINARY_CLOUD_NAME')
});
}
if (Meteor.isClient) {
let cloud_name = Meteor.settings.public.cloudinary.cloud_name;

$.cloudinary.config({
cloud_name: cloud_name
});
}

export default Cloudinary;
9 changes: 6 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package.describe({
name: 'rwatts:orionjs-cloudinary',
summary: 'Cloudinary storage for orionjs:filesystem',
version: '0.1.0',
version: '1.0.0',
git: 'https://github.com/rwatts3/orionjs-cloudinary'
});

Expand All @@ -14,11 +14,14 @@ Package.onUse(function(api) {
'orionjs:core@1.6.0',
'orionjs:filesystem@1.6.0',
'orionjs:config@1.6.0',
'lepozepo:cloudinary@4.0.3'
'lepozepo:cloudinary@4.1.3',
'ecmascript'
]);

api.addFiles([
'cloudinary.js'
]);

api.mainModule("cloudinary.js", "client");
api.export(['orion', 'Cloudinary']);

});

0 comments on commit e13c8bd

Please sign in to comment.