From 9bb5c9862368a9c6fb454ae2cb62c108745acfd2 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Mon, 21 Aug 2017 16:43:37 +0200 Subject: [PATCH 01/18] remove template helpers and templating dependency --- client/functions.coffee | 60 +++++++++++++++++++---------------------- package.js | 1 - 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/client/functions.coffee b/client/functions.coffee index 769da89..7bd821b 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -3,40 +3,39 @@ Cloudinary = _private_urls:{} _expiring_urls:{} xhr:null - _helpers: - "url": (public_id,options) -> - if public_id and not _.isEmpty public_id - $.cloudinary.url(public_id,options.hash) - - "private_url":(public_id,options) -> + url: (public_id,options) -> + if public_id and not _.isEmpty public_id + $.cloudinary.url(public_id,options.hash) + + private_url:(public_id,options) -> + private_url = Cloudinary._private_urls[public_id] + if not private_url + Cloudinary._private_urls[public_id] = new ReactiveVar "" private_url = Cloudinary._private_urls[public_id] - if not private_url - Cloudinary._private_urls[public_id] = new ReactiveVar "" - private_url = Cloudinary._private_urls[public_id] - if public_id and not _.isEmpty(public_id) and _.isEmpty(private_url.get()) - Meteor.call "c.get_private_resource",public_id,options.hash,(error,result) -> - if error - throw new Meteor.Error "Cloudinary","Failed to sign and fetch image" - else - private_url.set result + if public_id and not _.isEmpty(public_id) and _.isEmpty(private_url.get()) + Meteor.call "c.get_private_resource",public_id,options.hash,(error,result) -> + if error + throw new Meteor.Error "Cloudinary","Failed to sign and fetch image" + else + private_url.set result - private_url.get() + private_url.get() - "expiring_url":(public_id,options) -> + expiring_url:(public_id,options) -> + expiring_url = Cloudinary._expiring_urls[public_id] + if not expiring_url + Cloudinary._expiring_urls[public_id] = new ReactiveVar "" expiring_url = Cloudinary._expiring_urls[public_id] - if not expiring_url - Cloudinary._expiring_urls[public_id] = new ReactiveVar "" - expiring_url = Cloudinary._expiring_urls[public_id] - if public_id and not _.isEmpty(public_id) and _.isEmpty(expiring_url.get()) - Meteor.call "c.get_download_url",public_id,options.hash,(error,result) -> - if error - throw new Meteor.Error "Cloudinary","Failed to sign and fetch image" - else - expiring_url.set result + if public_id and not _.isEmpty(public_id) and _.isEmpty(expiring_url.get()) + Meteor.call "c.get_download_url",public_id,options.hash,(error,result) -> + if error + throw new Meteor.Error "Cloudinary","Failed to sign and fetch image" + else + expiring_url.set result - expiring_url.get() + expiring_url.get() delete: (public_id, type, callback) -> @@ -142,9 +141,4 @@ Cloudinary = Cloudinary.xhr.open "POST",result.form_attrs.action,true - Cloudinary.xhr.send form_data - - -# Define helpers -Template.registerHelper "c", -> - Cloudinary._helpers \ No newline at end of file + Cloudinary.xhr.send form_data \ No newline at end of file diff --git a/package.js b/package.js index 22367e3..5e81d83 100644 --- a/package.js +++ b/package.js @@ -15,7 +15,6 @@ Package.on_use(function (api){ // Core Packages api.use(["meteor-base@1.0.1","coffeescript","mongo","underscore"], ["client", "server"]); - api.use(["templating"], "client"); api.use(["check","random","reactive-var"], ["client","server"]); // External Packages From 6ad0e2364e58e27300686e0f0d91e8b4d5bdcafb Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Mon, 21 Aug 2017 18:28:43 +0200 Subject: [PATCH 02/18] update readme --- README.md | 160 +++++++----------- example/basic/client/basic.jade | 2 +- example/basic1_2/client/basic.jade | 12 +- .../client/collection-hooks.html | 4 +- package.js | 4 +- 5 files changed, 76 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index 1e621c7..8147fa1 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,76 @@ +# Fork +This package based on [lepozepo:cloudinary](https://github.com/Lepozepo/cloudinary). +It has no Blaze template helpers and templating-package dependency. In addition, the npm dependencies are updated. + # Cloudinary Image/File Uploader Cloudinary provides a simple way for uploading files to Cloudinary, which in turn can be set up to sync with your Amazon S3 service. This is useful for uploading and actively manipulating images and files that you want accesible to the public. Cloudinary is built on [Cloudinary (NPM)](https://github.com/cloudinary/cloudinary_npm) and [Cloudinary (JS)](https://github.com/cloudinary/cloudinary_js). Installing this package will make `Cloudinary` available server-side and `$.cloudinary` available client-side. -# Show your support! -Star my code in github or atmosphere if you like my code or shoot me a dollar or two! - -[DONATE HERE](https://cash.me/$lepozepo) - -## New Features -- Signed URLs: You can now easily generate a signed url for resources with transformations. -- Expiring URLs: You can now easily generate signed expiring urls for raw resources. -- More Auth Rules: You can now control who can do what easier with the Cloudinary.rules object. -- Improved Uploads: The method for signatures has been improved and now also allows private and authenticated images. -- Download URLs: You can now easily generate temporary download URLs with Meteor.call("c.get_download_url", public_id,ops,callback) - -## Previous Features -- Client to Cloudinary Uploads - ## Installation ``` sh -$ meteor add lepozepo:cloudinary +$ meteor add lmachens:cloudinary ``` ## How to upload ### Step 1 Configure your Cloudinary Credentials and Delete Authorization Rules. SERVER SIDE AND CLIENT SIDE. -``` coffeescript -#SERVER -Cloudinary.config - cloud_name: 'cloud_name' - api_key: '1237419' +``` js +// SERVER +Cloudinary.config({ + cloud_name: 'cloud_name', + api_key: '1237419', api_secret: 'asdf24adsfjk' - -# Rules are all optional -Cloudinary.rules.delete = -> - @userId is "my_user_id" # The rule must return true to pass validation, if you do not set a rule, the validation will always pass - @public_id # The public_id that is being deleted - -Cloudinary.rules.signature = -> # This one checks whether the user is allowed to upload or not - @userId is "my_user_id" # The rule must return true to pass validation, if you do not set a rule, the validation will always pass - -Cloudinary.rules.private_resource = -> - @userId is "my_user_id" # The rule must return true to pass validation, if you do not set a rule, the validation will always pass - -Cloudinary.rules.download_url = -> - @userId is "my_user_id" # The rule must return true to pass validation, if you do not set a rule, the validation will always pass - -#CLIENT -$.cloudinary.config - cloud_name:"cloud_name" +}); + +// Rules are all optional +Cloudinary.rules.delete = () => { + if (this.userId === "my_user_id") { + // The rule must return true to pass validation, if you do not set a rule, the validation will always pass + } + this.public_id; // The public_id that is being deleted +}; + +Cloudinary.rules.signature = () => { // This one checks whether the user is allowed to upload or not + if (this.userId === "my_user_id") { + // The rule must return true to pass validation, if you do not set a rule, the validation will always pass + } +}; + +Cloudinary.rules.private_resource = () => { + if (this.userId === "my_user_id") { + // The rule must return true to pass validation, if you do not set a rule, the validation will always pass + } +}; + +Cloudinary.rules.download_url = () => { + if (this.userId === "my_user_id") { + // The rule must return true to pass validation, if you do not set a rule, the validation will always pass + } +}; + +// CLIENT +$.cloudinary.config({ + cloud_name: "cloud_name" +}); ``` ### Step 2 Wire up your `input[type="file"]`. CLIENT SIDE. -``` coffeescript -Template.yourtemplate.events - "change input[type='file']": (e) -> - files = e.currentTarget.files - - Cloudinary.upload files, - folder:"secret" # optional parameters described in http://cloudinary.com/documentation/upload_images#remote_upload - type:"private" # optional: makes the image accessible only via a signed url. The signed url is available publicly for 1 hour. - (err,res) -> #optional callback, you can catch with the Cloudinary collection as well - console.log "Upload Error: #{err}" - console.log "Upload Result: #{res}" - -``` - - -## How to read and manipulate -All of Cloudinary's manipulation options are available in the c.url helper. You can access an image by passing a cloudinary public_id: - -``` handlebars - - -``` +``` js +Cloudinary.upload(event.currentTarget.files, { + folder: "secret", // optional parameters described in http://cloudinary.com/documentation/upload_images#remote_upload + type: "private", // optional: makes the image accessible only via a signed url. The signed url is available publicly for 1 hour. + (err, res) => { // optional callback, you can catch with the Cloudinary collection as well + console.log(`Upload Error: ${err}`); + console.log(`Upload Result: ${res}`); + } +}); -You can manipulate an image by adding parameters to the helper -``` handlebars - ``` -Obs: If you want to resize your image in a smaller size you will need to pass the `crop` parameter -``` handlebars - -``` -For more information see the cloudinary's documentation: -[http://cloudinary.com/documentation/image_transformations#crop_modes](http://cloudinary.com/documentation/image_transformations#crop_modes) - ## How to protect your images You will need an **Advanced Cloudinary** account before you can make your images fully private. Once you have your account you can do one of 2 things: @@ -117,19 +97,19 @@ App.accessRule("blob:*"); ## How to delete from Cloudinary Just pass the public_id of the image or file through this function (security features pending). It will return an object with a list of the images deleted as a result. -``` coffeescript -Template.yourtemplate.events - "click button.delete": -> - Cloudinary.delete @response.public_id, (err,res) -> - console.log "Upload Error: #{err}" - console.log "Upload Result: #{res}" +``` js +Cloudinary.delete(response.public_id, (err,res) => { + console.log(`Upload Error: ${err}`); + console.log(`Upload Result: ${res}`); +}); ``` ## How to generate a downloadable link -``` coffeescript -Meteor.call "c.get_download_url", public_id,(err,download_url) -> - console.log "Upload Error: #{err}" - console.log "#{download_url}" +``` js +Meteor.call("c.get_download_url", public_id, (err,d ownload_url) => { + console.log(`Upload Error: ${err}`); + console.log(download_url); +}); ``` ### API @@ -145,28 +125,18 @@ Meteor.call "c.get_download_url", public_id,(err,download_url) -> - Cloudinary.rules.download_url: Checks whether fetching a download link for a resource is allowed. Return true to allow the action. ### Helpers -- {{c.url public_id options}}: Generates a url + +- Cloudinary.url(public_id, options): Generates a url - public_id: The public ID returned after uploading a resource - options: A set of transformations described here [http://cloudinary.com/documentation/image_transformations#reference](http://cloudinary.com/documentation/image_transformations#reference) -- {{c.private_url public_id options}}: Generates a signed url +- Cloudinary.private_url(public_id, options): Generates a signed url - public_id: The public ID returned after uploading a resource - options: A set of transformations described here [http://cloudinary.com/documentation/image_transformations#reference](http://cloudinary.com/documentation/image_transformations#reference) -- {{c.expiring_url public_id}}: Generates a url that will expire in 1 hour, does not take any transformations +- Cloudinary.expiring_url(public_id): Generates a url that will expire in 1 hour, does not take any transformations - public_id: The public ID returned after uploading a resource ## Notes A security filter is missing, I know how I want it to work I just haven't had the time to build it. Enjoy the new version! - -### Donations and Sponsors - Thank You's -**If you prefer I list your github account let me know [who you are](https://github.com/Lepozepo/cloudinary/issues/56)!** - -- Casey R. -- David M. -- NetLive IT - - - - diff --git a/example/basic/client/basic.jade b/example/basic/client/basic.jade index b53e586..6f2b2c0 100644 --- a/example/basic/client/basic.jade +++ b/example/basic/client/basic.jade @@ -18,7 +18,7 @@ template(name="tester") p {{percent_uploaded}} % p {{response.public_id}} if complete - img(src="{{c.url response.public_id effect='blur:300' angle=10}}") + img(src="{{Cloudinary.url response.public_id effect='blur:300' angle=10}}") p {{status}} diff --git a/example/basic1_2/client/basic.jade b/example/basic1_2/client/basic.jade index a05cb3f..53b7aec 100644 --- a/example/basic1_2/client/basic.jade +++ b/example/basic1_2/client/basic.jade @@ -15,9 +15,9 @@ template(name="tester") h5 uploaded files each uploaded_images - img(src="{{c.url public_id effect='blur:300' angle=10}}") - img(src="{{c.private_url public_id effect='blur:300' angle=10}}") - img(src="{{c.expiring_url public_id}}") + img(src="{{Cloudinary.url public_id effect='blur:300' angle=10}}") + img(src="{{Cloudinary.private_url public_id effect='blur:300' angle=10}}") + img(src="{{Cloudinary.expiring_url public_id}}") button.delete Delete button.delete_private Delete Private @@ -26,9 +26,9 @@ template(name="tester") //- p {{percent_uploaded}} % //- p {{response.public_id}} //- if complete - //- img(src="{{c.url response.public_id effect='blur:300' angle=10}}") - //- img(src="{{c.private_url response.public_id effect='blur:300' angle=10}}") - //- img(src="{{c.expiring_url response.public_id format='jpg' effect='blur:300' angle=10}}") + //- img(src="{{Cloudinary.url response.public_id effect='blur:300' angle=10}}") + //- img(src="{{Cloudinary.private_url response.public_id effect='blur:300' angle=10}}") + //- img(src="{{Cloudinary.expiring_url response.public_id format='jpg' effect='blur:300' angle=10}}") //- button.delete Delete //- button.delete_private Delete Private diff --git a/example/collection-hooks/client/collection-hooks.html b/example/collection-hooks/client/collection-hooks.html index 45fb1fa..1647347 100644 --- a/example/collection-hooks/client/collection-hooks.html +++ b/example/collection-hooks/client/collection-hooks.html @@ -31,8 +31,8 @@

Cloudinary Upload Stream

Saved images

{{#each saved_images}}
- - + + {{/each}} diff --git a/package.js b/package.js index a357c97..f25b1d6 100644 --- a/package.js +++ b/package.js @@ -1,8 +1,8 @@ Package.describe({ - name:"lepozepo:cloudinary", + name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", version:"4.2.6", - git:"https://github.com/Lepozepo/cloudinary" + git:"https://github.com/lmachens/cloudinary" }); Npm.depends({ From 3bdd2bab28074557fe3bb1b7659913be7f7a444b Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Mon, 21 Aug 2017 18:35:55 +0200 Subject: [PATCH 03/18] set version --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index f25b1d6..d040913 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"4.2.6", + version:"5.0.0", git:"https://github.com/lmachens/cloudinary" }); From ca8cdec61be02dea7cc5ee9cc9e923d4b3c33834 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Tue, 22 Aug 2017 08:28:30 +0200 Subject: [PATCH 04/18] update dependencies --- .npm/package/npm-shrinkwrap.json | 46 ++++++------- .versions | 109 +++++++++++++++---------------- 2 files changed, 75 insertions(+), 80 deletions(-) diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index 5ed67eb..c376871 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -1,33 +1,29 @@ { "dependencies": { "cloudinary": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.3.1.tgz", - "from": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.3.1.tgz", - "dependencies": { - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "from": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" - }, - "q": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "from": "https://registry.npmjs.org/q/-/q-1.4.1.tgz" - } - } + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.9.0.tgz", + "from": "cloudinary@1.9.0" }, "cloudinary-jquery": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/cloudinary-jquery/-/cloudinary-jquery-2.0.9.tgz", - "from": "cloudinary-jquery@2.0.9", - "dependencies": { - "jquery": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz", - "from": "jquery@>=1.6.0" - } - } + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cloudinary-jquery/-/cloudinary-jquery-2.3.0.tgz", + "from": "cloudinary-jquery@2.3.0" + }, + "jquery": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz", + "from": "jquery@>=1.6.0" + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "from": "lodash@>=3.10.0 <3.11.0" + }, + "q": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", + "from": "q@>=1.4.0 <1.5.0" } } } diff --git a/.versions b/.versions index e88b785..d985c22 100644 --- a/.versions +++ b/.versions @@ -1,60 +1,59 @@ -allow-deny@1.0.5 -autoupdate@1.2.10 -babel-compiler@6.8.3 -babel-runtime@0.1.9_1 -base64@1.0.9 -binary-heap@1.0.9 -blaze@2.1.8 -blaze-tools@1.0.9 -boilerplate-generator@1.0.9 -caching-compiler@1.0.5_1 -caching-html-compiler@1.0.6 -callback-hook@1.0.9 -check@1.2.3 -coffeescript@1.1.2_1 -ddp@1.2.5 -ddp-client@1.2.8_1 -ddp-common@1.2.6 -ddp-server@1.2.8_1 +allow-deny@1.0.6 +autoupdate@1.3.12 +babel-compiler@6.19.4 +babel-runtime@1.0.1 +base64@1.0.10 +binary-heap@1.0.10 +blaze@2.3.2 +blaze-tools@1.0.10 +boilerplate-generator@1.1.1 +caching-compiler@1.1.9 +callback-hook@1.0.10 +check@1.2.5 +coffeescript@1.11.1_3 +ddp@1.3.0 +ddp-client@2.0.0 +ddp-common@1.2.9 +ddp-server@2.0.0 deps@1.0.12 -diff-sequence@1.0.6 -ecmascript@0.4.6_1 -ecmascript-runtime@0.2.11_1 -ejson@1.0.12 -geojson-utils@1.0.9 +diff-sequence@1.0.7 +dynamic-import@0.1.1 +ecmascript@0.8.1 +ecmascript-runtime@0.4.1 +ecmascript-runtime-client@0.4.3 +ecmascript-runtime-server@0.4.1 +ejson@1.0.13 +geojson-utils@1.0.10 hot-code-push@1.0.4 -html-tools@1.0.10 -htmljs@1.0.10 -http@1.1.7 -id-map@1.0.8 -jquery@1.11.9 -lepozepo:cloudinary@4.2.6 +html-tools@1.0.11 +htmljs@1.0.11 +http@1.2.12 +id-map@1.0.9 +jquery@1.11.10 livedata@1.0.18 -logging@1.0.13_1 -meteor@1.1.15_1 -meteor-base@1.0.4 -minifier-js@1.1.12_1 -minimongo@1.0.17 -modules@0.6.4 -modules-runtime@0.6.4_1 -mongo@1.1.9_1 -mongo-id@1.0.5 -npm-mongo@1.4.44_1 -observe-sequence@1.0.12 -ordered-dict@1.0.8 -promise@0.7.2_1 +lmachens:cloudinary@5.0.0 +logging@1.1.17 +meteor@1.7.0 +meteor-base@1.1.0 +minimongo@1.2.1 +modules@0.9.2 +modules-runtime@0.8.0 +mongo@1.1.19 +mongo-id@1.0.6 +npm-mongo@2.2.30 +observe-sequence@1.0.16 +ordered-dict@1.0.9 +promise@0.8.9 random@1.0.10 -reactive-var@1.0.10 -reload@1.1.10 -retry@1.0.8 -routepolicy@1.0.11 -spacebars@1.0.12 -spacebars-compiler@1.0.12 -templating@1.1.12_1 -templating-tools@1.0.4 -tracker@1.0.14 -ui@1.0.11 -underscore@1.0.9 -url@1.0.10 -webapp@1.2.9_1 +reactive-var@1.0.11 +reload@1.1.11 +retry@1.0.9 +routepolicy@1.0.12 +spacebars@1.0.15 +spacebars-compiler@1.1.2 +tracker@1.1.3 +ui@1.0.13 +underscore@1.0.10 +url@1.1.0 +webapp@1.3.17 webapp-hashing@1.0.9 From a83d958135f80cca0038187c1b40e23c17c0f017 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Tue, 22 Aug 2017 09:12:58 +0200 Subject: [PATCH 05/18] add config --- client/functions.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/functions.coffee b/client/functions.coffee index 7bd821b..4e5db86 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -3,6 +3,8 @@ Cloudinary = _private_urls:{} _expiring_urls:{} xhr:null + config: (options) -> + $.cloudinary.options options url: (public_id,options) -> if public_id and not _.isEmpty public_id $.cloudinary.url(public_id,options.hash) From 55318ca0059b260d08414ffa4624c776d8af25ef Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Tue, 22 Aug 2017 09:13:11 +0200 Subject: [PATCH 06/18] 5.0.1 --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index d040913..82ea36a 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.0", + version:"5.0.1", git:"https://github.com/lmachens/cloudinary" }); From 0870b2ef718cb2c7e4d75146be8f6079f5dedd9e Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Tue, 22 Aug 2017 09:18:07 +0200 Subject: [PATCH 07/18] fix config --- .versions | 2 +- client/functions.coffee | 2 +- package.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.versions b/.versions index d985c22..fb822c7 100644 --- a/.versions +++ b/.versions @@ -31,7 +31,7 @@ http@1.2.12 id-map@1.0.9 jquery@1.11.10 livedata@1.0.18 -lmachens:cloudinary@5.0.0 +lmachens:cloudinary@5.0.1 logging@1.1.17 meteor@1.7.0 meteor-base@1.1.0 diff --git a/client/functions.coffee b/client/functions.coffee index 4e5db86..4f59ca0 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -4,7 +4,7 @@ Cloudinary = _expiring_urls:{} xhr:null config: (options) -> - $.cloudinary.options options + $.cloudinary.config options url: (public_id,options) -> if public_id and not _.isEmpty public_id $.cloudinary.url(public_id,options.hash) diff --git a/package.js b/package.js index 82ea36a..a1ed26b 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.1", + version:"5.0.2", git:"https://github.com/lmachens/cloudinary" }); From a129ae61eface7cad12697b28d7655728d9f4971 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Fri, 25 Aug 2017 08:04:33 +0200 Subject: [PATCH 08/18] fix url --- .versions | 2 +- client/functions.coffee | 2 +- package.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.versions b/.versions index fb822c7..fae8143 100644 --- a/.versions +++ b/.versions @@ -31,7 +31,7 @@ http@1.2.12 id-map@1.0.9 jquery@1.11.10 livedata@1.0.18 -lmachens:cloudinary@5.0.1 +lmachens:cloudinary@5.0.2 logging@1.1.17 meteor@1.7.0 meteor-base@1.1.0 diff --git a/client/functions.coffee b/client/functions.coffee index 4f59ca0..bab75cf 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -7,7 +7,7 @@ Cloudinary = $.cloudinary.config options url: (public_id,options) -> if public_id and not _.isEmpty public_id - $.cloudinary.url(public_id,options.hash) + $.cloudinary.url(public_id,options) private_url:(public_id,options) -> private_url = Cloudinary._private_urls[public_id] diff --git a/package.js b/package.js index a1ed26b..577f528 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.2", + version:"5.0.3", git:"https://github.com/lmachens/cloudinary" }); From 3f1d292a438fcef6aabc665d72949ff30f98bda5 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 13:39:08 +0100 Subject: [PATCH 09/18] Replace cloudinary-jquery with cloudinary-core to remove jQuery dependency --- CHANGELOG.md | 4 ++++ client/functions.coffee | 7 +++++-- package.js | 9 +++------ 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2084061 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Change Log + +## [5.0.4] - 2018-01-04 +- Replace cloudinary-jquery with cloudinary-core to remove jQuery dependency \ No newline at end of file diff --git a/client/functions.coffee b/client/functions.coffee index bab75cf..7875c70 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -1,13 +1,16 @@ +cloudinary = require 'cloudinary-core' +cl = cloudinary.Cloudinary.new() + Cloudinary = collection: new Mongo.Collection "_cloudinary", connection:null _private_urls:{} _expiring_urls:{} xhr:null config: (options) -> - $.cloudinary.config options + cl.config options url: (public_id,options) -> if public_id and not _.isEmpty public_id - $.cloudinary.url(public_id,options) + cl.url(public_id,options) private_url:(public_id,options) -> private_url = Cloudinary._private_urls[public_id] diff --git a/package.js b/package.js index 577f528..31668a7 100644 --- a/package.js +++ b/package.js @@ -1,13 +1,13 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.3", + version:"5.0.4.rc1", git:"https://github.com/lmachens/cloudinary" }); Npm.depends({ - cloudinary: "1.9.0", - "cloudinary-jquery": "2.3.0" + cloudinary: "1.9.1", // Server side + "cloudinary-core": "2.4.0" // Client side }); Package.on_use(function (api){ @@ -20,9 +20,6 @@ Package.on_use(function (api){ // External Packages api.use(["matb33:collection-hooks@0.7.3","audit-argument-checks"], ["client", "server"],{weak:true}); - // Cloudinary Client Side - api.add_files(".npm/package/node_modules/cloudinary-jquery/cloudinary-jquery.min.js","client"); - // Core Files api.add_files("server/configuration.coffee", "server"); api.add_files("server/signature.coffee", "server"); From 385e9614a3ad9b1fb6193b1f27e00382d1bbf4a4 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 13:40:48 +0100 Subject: [PATCH 10/18] change version --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index 31668a7..630d4ac 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.4.rc1", + version:"5.0.4", git:"https://github.com/lmachens/cloudinary" }); From 0faf722ca5409e8dc0e2a2f140fdc108651d1248 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 13:56:22 +0100 Subject: [PATCH 11/18] import cloudinary --- .npm/package/npm-shrinkwrap.json | 24 +++++------- .versions | 63 ++++++++++++++------------------ client/functions.coffee | 3 +- package.js | 2 +- 4 files changed, 40 insertions(+), 52 deletions(-) diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index c376871..3fc0f48 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -1,29 +1,25 @@ { + "lockfileVersion": 1, "dependencies": { "cloudinary": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.9.0.tgz", - "from": "cloudinary@1.9.0" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.9.1.tgz", + "integrity": "sha512-VfeDkEmamZ5R5BWpMs4rPLwaVDjONE2zxLOrqV+lKzLeqn2TTvEAy/CRQxUmcdxFLJ96gl62LUn+IoUMiYiuYw==" }, - "cloudinary-jquery": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/cloudinary-jquery/-/cloudinary-jquery-2.3.0.tgz", - "from": "cloudinary-jquery@2.3.0" - }, - "jquery": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz", - "from": "jquery@>=1.6.0" + "cloudinary-core": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.4.0.tgz", + "integrity": "sha512-rQ61pNzokdMedF5gFhxbBTEjzouex+BFWqlCwRQXHqO6WPsv57Mm4w5Kf4uDz5qwnS++lAcCDiayhHo+TplGiA==" }, "lodash": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "from": "lodash@>=3.10.0 <3.11.0" + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" }, "q": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "from": "q@>=1.4.0 <1.5.0" + "integrity": "sha1-VXBbzZPF82c1MMLCy8DCs63cKG4=" } } } diff --git a/.versions b/.versions index fae8143..971dbc1 100644 --- a/.versions +++ b/.versions @@ -1,59 +1,50 @@ -allow-deny@1.0.6 +allow-deny@1.1.0 autoupdate@1.3.12 -babel-compiler@6.19.4 -babel-runtime@1.0.1 +babel-compiler@6.24.7 +babel-runtime@1.1.1 base64@1.0.10 binary-heap@1.0.10 -blaze@2.3.2 -blaze-tools@1.0.10 -boilerplate-generator@1.1.1 +boilerplate-generator@1.3.0 caching-compiler@1.1.9 callback-hook@1.0.10 check@1.2.5 coffeescript@1.11.1_3 -ddp@1.3.0 -ddp-client@2.0.0 -ddp-common@1.2.9 -ddp-server@2.0.0 -deps@1.0.12 +ddp@1.4.0 +ddp-client@2.2.0 +ddp-common@1.3.0 +ddp-server@2.1.0 diff-sequence@1.0.7 -dynamic-import@0.1.1 -ecmascript@0.8.1 -ecmascript-runtime@0.4.1 -ecmascript-runtime-client@0.4.3 -ecmascript-runtime-server@0.4.1 -ejson@1.0.13 +dynamic-import@0.2.0 +ecmascript@0.9.0 +ecmascript-runtime@0.5.0 +ecmascript-runtime-client@0.5.0 +ecmascript-runtime-server@0.5.0 +ejson@1.1.0 geojson-utils@1.0.10 hot-code-push@1.0.4 -html-tools@1.0.11 -htmljs@1.0.11 -http@1.2.12 +http@1.3.0 id-map@1.0.9 -jquery@1.11.10 livedata@1.0.18 -lmachens:cloudinary@5.0.2 -logging@1.1.17 -meteor@1.7.0 -meteor-base@1.1.0 -minimongo@1.2.1 -modules@0.9.2 -modules-runtime@0.8.0 -mongo@1.1.19 +lmachens:cloudinary@5.0.4 +logging@1.1.19 +meteor@1.8.0 +meteor-base@1.2.0 +minimongo@1.4.0 +modules@0.11.0 +modules-runtime@0.9.0 +mongo@1.3.1 +mongo-dev-server@1.1.0 mongo-id@1.0.6 -npm-mongo@2.2.30 -observe-sequence@1.0.16 +npm-mongo@2.2.33 ordered-dict@1.0.9 -promise@0.8.9 +promise@0.10.0 random@1.0.10 reactive-var@1.0.11 reload@1.1.11 retry@1.0.9 routepolicy@1.0.12 -spacebars@1.0.15 -spacebars-compiler@1.1.2 tracker@1.1.3 -ui@1.0.13 underscore@1.0.10 url@1.1.0 -webapp@1.3.17 +webapp@1.4.0 webapp-hashing@1.0.9 diff --git a/client/functions.coffee b/client/functions.coffee index 7875c70..f53c8e7 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -1,4 +1,5 @@ -cloudinary = require 'cloudinary-core' +`import cloudinary from 'cloudinary-core';` + cl = cloudinary.Cloudinary.new() Cloudinary = diff --git a/package.js b/package.js index 630d4ac..2583337 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.4", + version:"5.0.4_2", git:"https://github.com/lmachens/cloudinary" }); From 177bbaffd3c31d380f3b3ac21597c90d9eca5ed2 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 14:03:12 +0100 Subject: [PATCH 12/18] use ecmascript --- .versions | 2 +- client/functions.coffee | 2 +- package.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.versions b/.versions index 971dbc1..8dfcd55 100644 --- a/.versions +++ b/.versions @@ -25,7 +25,7 @@ hot-code-push@1.0.4 http@1.3.0 id-map@1.0.9 livedata@1.0.18 -lmachens:cloudinary@5.0.4 +lmachens:cloudinary@5.0.4_2 logging@1.1.19 meteor@1.8.0 meteor-base@1.2.0 diff --git a/client/functions.coffee b/client/functions.coffee index f53c8e7..52760f4 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -1,4 +1,4 @@ -`import cloudinary from 'cloudinary-core';` +`import cloudinary from 'cloudinary-core'` cl = cloudinary.Cloudinary.new() diff --git a/package.js b/package.js index 2583337..bdb523e 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.4_2", + version:"5.0.4_3", git:"https://github.com/lmachens/cloudinary" }); @@ -15,7 +15,7 @@ Package.on_use(function (api){ // Core Packages api.use(["meteor-base@1.0.1","coffeescript","mongo","underscore"], ["client", "server"]); - api.use(["check","random","reactive-var"], ["client","server"]); + api.use(["check","ecmascript","random","reactive-var"], ["client","server"]); // External Packages api.use(["matb33:collection-hooks@0.7.3","audit-argument-checks"], ["client", "server"],{weak:true}); From 2f53979ad77ca1f4db249832231ca13a82f218f4 Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 14:06:02 +0100 Subject: [PATCH 13/18] use ecmascript --- .versions | 2 +- package.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.versions b/.versions index 8dfcd55..724d5d4 100644 --- a/.versions +++ b/.versions @@ -25,7 +25,7 @@ hot-code-push@1.0.4 http@1.3.0 id-map@1.0.9 livedata@1.0.18 -lmachens:cloudinary@5.0.4_2 +lmachens:cloudinary@5.0.4_3 logging@1.1.19 meteor@1.8.0 meteor-base@1.2.0 diff --git a/package.js b/package.js index bdb523e..d0c261c 100644 --- a/package.js +++ b/package.js @@ -15,7 +15,7 @@ Package.on_use(function (api){ // Core Packages api.use(["meteor-base@1.0.1","coffeescript","mongo","underscore"], ["client", "server"]); - api.use(["check","ecmascript","random","reactive-var"], ["client","server"]); + api.use(["check","ecmascript@0.9.0","random","reactive-var"], ["client","server"]); // External Packages api.use(["matb33:collection-hooks@0.7.3","audit-argument-checks"], ["client", "server"],{weak:true}); From 31f655ba12bc7b6b4677e0b1c0524f9307a599ff Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 14:10:19 +0100 Subject: [PATCH 14/18] use require --- client/functions.coffee | 2 +- package.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/functions.coffee b/client/functions.coffee index 52760f4..7e171e3 100644 --- a/client/functions.coffee +++ b/client/functions.coffee @@ -1,4 +1,4 @@ -`import cloudinary from 'cloudinary-core'` +cloudinary = require 'cloudinary-core' cl = cloudinary.Cloudinary.new() diff --git a/package.js b/package.js index d0c261c..6cd370b 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.4_3", + version:"5.0.4_4", git:"https://github.com/lmachens/cloudinary" }); From 17777790d356c9b7d9eedeea292a1b5905b5db3c Mon Sep 17 00:00:00 2001 From: Leon Machens Date: Thu, 4 Jan 2018 14:14:21 +0100 Subject: [PATCH 15/18] version bump --- .versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.versions b/.versions index 724d5d4..6fd327f 100644 --- a/.versions +++ b/.versions @@ -25,7 +25,7 @@ hot-code-push@1.0.4 http@1.3.0 id-map@1.0.9 livedata@1.0.18 -lmachens:cloudinary@5.0.4_3 +lmachens:cloudinary@5.0.4_4 logging@1.1.19 meteor@1.8.0 meteor-base@1.2.0 From a5b3b0860ef2a484d34c90934d677140f585783d Mon Sep 17 00:00:00 2001 From: Leon Date: Wed, 21 Feb 2018 16:58:23 +0100 Subject: [PATCH 16/18] chore(deps): update npm packages --- CHANGELOG.md | 2 ++ package.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2084061..f885b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Change Log +## [5.0.5] - 2018-02-21 +- Update npm dependencies ## [5.0.4] - 2018-01-04 - Replace cloudinary-jquery with cloudinary-core to remove jQuery dependency \ No newline at end of file diff --git a/package.js b/package.js index 6cd370b..c67dd51 100644 --- a/package.js +++ b/package.js @@ -1,13 +1,13 @@ Package.describe({ name:"lmachens:cloudinary", summary: "Upload files to Cloudinary", - version:"5.0.4_4", + version:"5.0.5", git:"https://github.com/lmachens/cloudinary" }); Npm.depends({ - cloudinary: "1.9.1", // Server side - "cloudinary-core": "2.4.0" // Client side + cloudinary: "1.10.0", // Server side + "cloudinary-core": "2.5.0" // Client side }); Package.on_use(function (api){ From fa37c83620db66dcabd3c9c2aaca73bf6f380271 Mon Sep 17 00:00:00 2001 From: Leon Date: Wed, 21 Feb 2018 17:03:10 +0100 Subject: [PATCH 17/18] published new version --- .npm/package/npm-shrinkwrap.json | 24 ++++++------ .versions | 64 +++++++++++++++++--------------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index 3fc0f48..e85215f 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -2,24 +2,24 @@ "lockfileVersion": 1, "dependencies": { "cloudinary": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.9.1.tgz", - "integrity": "sha512-VfeDkEmamZ5R5BWpMs4rPLwaVDjONE2zxLOrqV+lKzLeqn2TTvEAy/CRQxUmcdxFLJ96gl62LUn+IoUMiYiuYw==" + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.10.0.tgz", + "integrity": "sha512-+8GXHTNPKAcCKiSGYwdglIUYMjXxKoOgAVXPQMrDEHjSTVovCeqVnUtoXdF+v0RyAkAqK/sun0hJd5uw4o0plA==" }, "cloudinary-core": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.4.0.tgz", - "integrity": "sha512-rQ61pNzokdMedF5gFhxbBTEjzouex+BFWqlCwRQXHqO6WPsv57Mm4w5Kf4uDz5qwnS++lAcCDiayhHo+TplGiA==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.5.0.tgz", + "integrity": "sha512-lrzdLUzFZPnxpWgIAGtOwfqM2D+rG+fLsgd6KqZwDkQX+DYOUNaJpD3lEqxhoMI90zoT1gP/7+pMh/AscSaQ0w==" }, "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" }, "q": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "integrity": "sha1-VXBbzZPF82c1MMLCy8DCs63cKG4=" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" } } } diff --git a/.versions b/.versions index 6fd327f..0bb35e9 100644 --- a/.versions +++ b/.versions @@ -1,50 +1,54 @@ allow-deny@1.1.0 -autoupdate@1.3.12 -babel-compiler@6.24.7 -babel-runtime@1.1.1 +autoupdate@1.4.0 +babel-compiler@7.0.4 +babel-runtime@1.2.0 base64@1.0.10 binary-heap@1.0.10 -boilerplate-generator@1.3.0 +boilerplate-generator@1.4.0 caching-compiler@1.1.9 -callback-hook@1.0.10 -check@1.2.5 -coffeescript@1.11.1_3 +callback-hook@1.1.0 +check@1.3.0 +coffeescript@1.0.17 ddp@1.4.0 -ddp-client@2.2.0 -ddp-common@1.3.0 -ddp-server@2.1.0 -diff-sequence@1.0.7 -dynamic-import@0.2.0 -ecmascript@0.9.0 +ddp-client@2.3.1 +ddp-common@1.4.0 +ddp-server@2.1.2 +diff-sequence@1.1.0 +dynamic-import@0.3.0 +ecmascript@0.10.0 ecmascript-runtime@0.5.0 -ecmascript-runtime-client@0.5.0 +ecmascript-runtime-client@0.6.0 ecmascript-runtime-server@0.5.0 ejson@1.1.0 +es5-shim@4.7.3 geojson-utils@1.0.10 hot-code-push@1.0.4 -http@1.3.0 -id-map@1.0.9 +http@1.4.0 +id-map@1.1.0 livedata@1.0.18 -lmachens:cloudinary@5.0.4_4 +lmachens:cloudinary@5.0.5 logging@1.1.19 -meteor@1.8.0 -meteor-base@1.2.0 -minimongo@1.4.0 -modules@0.11.0 -modules-runtime@0.9.0 -mongo@1.3.1 +meteor@1.8.2 +meteor-base@1.3.0 +minimongo@1.4.3 +modules@0.11.3 +modules-runtime@0.9.1 +mongo@1.4.2 mongo-dev-server@1.1.0 mongo-id@1.0.6 npm-mongo@2.2.33 -ordered-dict@1.0.9 -promise@0.10.0 -random@1.0.10 +ordered-dict@1.1.0 +promise@0.10.1 +random@1.1.0 reactive-var@1.0.11 -reload@1.1.11 -retry@1.0.9 +reload@1.2.0 +retry@1.1.0 routepolicy@1.0.12 +server-render@0.3.0 +shim-common@0.1.0 +socket-stream-client@0.1.0 tracker@1.1.3 underscore@1.0.10 -url@1.1.0 -webapp@1.4.0 +url@1.2.0 +webapp@1.5.0 webapp-hashing@1.0.9 From 4de84ae22d4c936039951c3cda3146b602939524 Mon Sep 17 00:00:00 2001 From: lukas strassel Date: Wed, 27 Jun 2018 00:48:42 +0200 Subject: [PATCH 18/18] refactor(coffee): remove coffee --- .gitignore | 3 +- client/functions.coffee | 150 -------------------------- client/functions.js | 203 ++++++++++++++++++++++++++++++++++++ package.js | 39 +++---- server/configuration.coffee | 3 - server/configuration.js | 3 + server/signature.coffee | 78 -------------- server/signature.js | 103 ++++++++++++++++++ 8 files changed, 331 insertions(+), 251 deletions(-) delete mode 100644 client/functions.coffee create mode 100644 client/functions.js delete mode 100644 server/configuration.coffee create mode 100644 server/configuration.js delete mode 100644 server/signature.coffee create mode 100644 server/signature.js diff --git a/.gitignore b/.gitignore index cf58cef..0b56d06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .build* -.test_config* \ No newline at end of file +.test_config* +.idea/ \ No newline at end of file diff --git a/client/functions.coffee b/client/functions.coffee deleted file mode 100644 index 7e171e3..0000000 --- a/client/functions.coffee +++ /dev/null @@ -1,150 +0,0 @@ -cloudinary = require 'cloudinary-core' - -cl = cloudinary.Cloudinary.new() - -Cloudinary = - collection: new Mongo.Collection "_cloudinary", connection:null - _private_urls:{} - _expiring_urls:{} - xhr:null - config: (options) -> - cl.config options - url: (public_id,options) -> - if public_id and not _.isEmpty public_id - cl.url(public_id,options) - - private_url:(public_id,options) -> - private_url = Cloudinary._private_urls[public_id] - if not private_url - Cloudinary._private_urls[public_id] = new ReactiveVar "" - private_url = Cloudinary._private_urls[public_id] - - if public_id and not _.isEmpty(public_id) and _.isEmpty(private_url.get()) - Meteor.call "c.get_private_resource",public_id,options.hash,(error,result) -> - if error - throw new Meteor.Error "Cloudinary","Failed to sign and fetch image" - else - private_url.set result - - private_url.get() - - expiring_url:(public_id,options) -> - expiring_url = Cloudinary._expiring_urls[public_id] - if not expiring_url - Cloudinary._expiring_urls[public_id] = new ReactiveVar "" - expiring_url = Cloudinary._expiring_urls[public_id] - - if public_id and not _.isEmpty(public_id) and _.isEmpty(expiring_url.get()) - Meteor.call "c.get_download_url",public_id,options.hash,(error,result) -> - if error - throw new Meteor.Error "Cloudinary","Failed to sign and fetch image" - else - expiring_url.set result - - expiring_url.get() - - - delete: (public_id, type, callback) -> - if _.isFunction type - callback = type - type = undefined - - Meteor.call "c.delete_by_public_id", public_id, type, (error,result) -> - if error - return callback and callback error, null - else - if result.deleted[public_id] and result.deleted[public_id] is "not_found" - return callback and callback result, null - else - return callback and callback null,result - - upload: (files, ops={}, callback) -> - if _.isFunction ops - callback = ops - ops = {} - - if files instanceof File or files instanceof Blob - file = files - reader = new FileReader - - reader.onload = -> - Cloudinary._upload_file reader.result, ops, callback - - return reader.readAsDataURL file - - if _.isArray(files) or files instanceof FileList - _.each files, (file) -> - reader = new FileReader - - reader.onload = -> - Cloudinary._upload_file reader.result, ops, callback - - reader.readAsDataURL file - - _upload_file: (file, ops={}, callback) -> - Meteor.call "c.sign", ops, (error,result) -> - if error - return callback and callback error,null - - # Build form - form_data = new FormData() - _.each result.hidden_fields, (v,k) -> - form_data.append k,v - - form_data.append "file",file - - # Create collection document ID - collection_id = Random.id() - - # Send data - Cloudinary.xhr = new XMLHttpRequest() - - Cloudinary.collection.insert - _id:collection_id - status:"uploading" - preview:file - - Cloudinary.xhr.upload.addEventListener "progress", (event) -> - Cloudinary.collection.update _id:collection_id, - $set: - loaded:event.loaded - total:event.total - percent_uploaded: Math.floor ((event.loaded / event.total) * 100) - ,false - - Cloudinary.xhr.addEventListener "load", -> - if Cloudinary.xhr.status < 400 - response = JSON.parse @response - Cloudinary.collection.upsert collection_id, - $set: - status:"complete" - percent_uploaded: 100 - response: response - - callback and callback null,response - else - response = JSON.parse @response - Cloudinary.collection.upsert collection_id, - $set: - status:"error" - response: response - - callback and callback response,null - - Cloudinary.xhr.addEventListener "error", -> - response = JSON.parse @response - Cloudinary.collection.upsert collection_id, - $set: - status:"error" - response: response - - callback and callback response,null - - Cloudinary.xhr.addEventListener "abort", -> - Cloudinary.collection.upsert collection_id, - $set: - status:"aborted" - - Cloudinary.xhr.open "POST",result.form_attrs.action,true - - Cloudinary.xhr.send form_data \ No newline at end of file diff --git a/client/functions.js b/client/functions.js new file mode 100644 index 0000000..c1f58d2 --- /dev/null +++ b/client/functions.js @@ -0,0 +1,203 @@ +const cloudinary = require('cloudinary-core'); + +const cl = cloudinary.Cloudinary.new(); + +Cloudinary = { + collection: new Mongo.Collection('_cloudinary', { connection: null }), + _private_urls: {}, + _expiring_urls: {}, + xhr: null, + config(options) { + return cl.config(options); + }, + url(public_id, options) { + if (public_id && !_.isEmpty(public_id)) { + return cl.url(public_id, options); + } + }, + + private_url(public_id, options) { + let private_url = Cloudinary._private_urls[public_id]; + if (!private_url) { + Cloudinary._private_urls[public_id] = new ReactiveVar(''); + private_url = Cloudinary._private_urls[public_id]; + } + + if (public_id && !_.isEmpty(public_id) && _.isEmpty(private_url.get())) { + Meteor.call('c.get_private_resource', public_id, options.hash, function(error, result) { + if (error) { + throw new Meteor.Error('Cloudinary', 'Failed to sign and fetch image'); + } else { + return private_url.set(result); + } + }); + } + + return private_url.get(); + }, + + expiring_url(public_id, options) { + let expiring_url = Cloudinary._expiring_urls[public_id]; + if (!expiring_url) { + Cloudinary._expiring_urls[public_id] = new ReactiveVar(''); + expiring_url = Cloudinary._expiring_urls[public_id]; + } + + if (public_id && !_.isEmpty(public_id) && _.isEmpty(expiring_url.get())) { + Meteor.call('c.get_download_url', public_id, options.hash, function(error, result) { + if (error) { + throw new Meteor.Error('Cloudinary', 'Failed to sign and fetch image'); + } else { + return expiring_url.set(result); + } + }); + } + + return expiring_url.get(); + }, + + delete(public_id, type, callback) { + if (_.isFunction(type)) { + callback = type; + type = undefined; + } + + return Meteor.call('c.delete_by_public_id', public_id, type, function(error, result) { + if (error) { + return callback && callback(error, null); + } else { + if (result.deleted[public_id] && result.deleted[public_id] === 'not_found') { + return callback && callback(result, null); + } else { + return callback && callback(null, result); + } + } + }); + }, + + upload(files, ops, callback) { + let reader; + if (ops == null) { + ops = {}; + } + if (_.isFunction(ops)) { + callback = ops; + ops = {}; + } + + if (files instanceof File || files instanceof Blob) { + const file = files; + reader = new FileReader(); + + reader.onload = () => Cloudinary._upload_file(reader.result, ops, callback); + + return reader.readAsDataURL(file); + } + + if (_.isArray(files) || files instanceof FileList) { + return _.each(files, function(file) { + reader = new FileReader(); + + reader.onload = () => Cloudinary._upload_file(reader.result, ops, callback); + + return reader.readAsDataURL(file); + }); + } + }, + + _upload_file(file, ops, callback) { + if (ops == null) { + ops = {}; + } + return Meteor.call('c.sign', ops, function(error, result) { + if (error) { + return callback && callback(error, null); + } + + // Build form + const form_data = new FormData(); + _.each(result.hidden_fields, (v, k) => form_data.append(k, v)); + + form_data.append('file', file); + + // Create collection document ID + const collection_id = Random.id(); + + // Send data + Cloudinary.xhr = new XMLHttpRequest(); + + Cloudinary.collection.insert({ + _id: collection_id, + status: 'uploading', + preview: file + }); + + Cloudinary.xhr.upload.addEventListener( + 'progress', + event => + Cloudinary.collection.update( + { _id: collection_id }, + { + $set: { + loaded: event.loaded, + total: event.total, + percent_uploaded: Math.floor((event.loaded / event.total) * 100) + } + } + ), + + false + ); + + Cloudinary.xhr.addEventListener('load', function() { + let response; + if (Cloudinary.xhr.status < 400) { + response = JSON.parse(this.response); + Cloudinary.collection.upsert(collection_id, { + $set: { + status: 'complete', + percent_uploaded: 100, + response + } + }); + + return callback && callback(null, response); + } else { + response = JSON.parse(this.response); + Cloudinary.collection.upsert(collection_id, { + $set: { + status: 'error', + response + } + }); + + return callback && callback(response, null); + } + }); + + Cloudinary.xhr.addEventListener('error', function() { + const response = JSON.parse(this.response); + Cloudinary.collection.upsert(collection_id, { + $set: { + status: 'error', + response + } + }); + + return callback && callback(response, null); + }); + + Cloudinary.xhr.addEventListener('abort', () => + Cloudinary.collection.upsert(collection_id, { + $set: { + status: 'aborted' + } + }) + ); + + Cloudinary.xhr.open('POST', result.form_attrs.action, true); + + return Cloudinary.xhr.send(form_data); + }); + } +}; diff --git a/package.js b/package.js index c67dd51..ec56c5a 100644 --- a/package.js +++ b/package.js @@ -1,31 +1,32 @@ Package.describe({ - name:"lmachens:cloudinary", - summary: "Upload files to Cloudinary", - version:"5.0.5", - git:"https://github.com/lmachens/cloudinary" + name: 'lmachens:cloudinary', + summary: 'Upload files to Cloudinary', + version: '5.0.6', + git: 'https://github.com/lmachens/cloudinary' }); Npm.depends({ - cloudinary: "1.10.0", // Server side - "cloudinary-core": "2.5.0" // Client side + cloudinary: '1.10.0', // Server side + 'cloudinary-core': '2.5.0' // Client side }); -Package.on_use(function (api){ - api.versionsFrom('METEOR@1.0'); +Package.onUse(function(api) { + api.versionsFrom('METEOR@1.0'); - // Core Packages - api.use(["meteor-base@1.0.1","coffeescript","mongo","underscore"], ["client", "server"]); - api.use(["check","ecmascript@0.9.0","random","reactive-var"], ["client","server"]); + // Core Packages + api.use(['meteor-base@1.0.1', 'mongo', 'underscore'], ['client', 'server']); + api.use(['check', 'ecmascript@0.9.0', 'random', 'reactive-var'], ['client', 'server']); - // External Packages - api.use(["matb33:collection-hooks@0.7.3","audit-argument-checks"], ["client", "server"],{weak:true}); + // External Packages + api.use(['matb33:collection-hooks@0.7.3', 'audit-argument-checks'], ['client', 'server'], { + weak: true + }); - // Core Files - api.add_files("server/configuration.coffee", "server"); - api.add_files("server/signature.coffee", "server"); + // Core Files + api.addFiles('server/configuration.js', 'server'); + api.addFiles('server/signature.js', 'server'); - api.add_files("client/functions.coffee", "client"); + api.addFiles('client/functions.js', 'client'); - api.export && api.export("Cloudinary",["server","client"]); + api.export('Cloudinary', ['server', 'client']); }); - diff --git a/server/configuration.coffee b/server/configuration.coffee deleted file mode 100644 index e475788..0000000 --- a/server/configuration.coffee +++ /dev/null @@ -1,3 +0,0 @@ -Cloudinary = Npm.require "cloudinary" - -Cloudinary.rules = {} diff --git a/server/configuration.js b/server/configuration.js new file mode 100644 index 0000000..d5da4d8 --- /dev/null +++ b/server/configuration.js @@ -0,0 +1,3 @@ +Cloudinary = Npm.require('cloudinary'); + +Cloudinary.rules = {}; diff --git a/server/signature.coffee b/server/signature.coffee deleted file mode 100644 index b7045e1..0000000 --- a/server/signature.coffee +++ /dev/null @@ -1,78 +0,0 @@ -Future = Npm.require "fibers/future" - -Meteor.methods - "c.sign": (ops={}) -> - check ops, Match.Optional(Object) - @unblock() - - if Cloudinary.rules.signature - @options = ops - auth_function = _.bind Cloudinary.rules.signature,this - if not auth_function() - throw new Meteor.Error "Unauthorized", "Signature not allowed" - - # Need to add some way to do custom auth - # signature = Cloudinary.utils.sign_request ops - signature = Cloudinary.uploader.direct_upload "",ops # This is better than utils.sign_request, it returns a POST url as well and properly manages optional parameters - - return signature - - - "c.delete_by_public_id": (public_id,type) -> - check public_id, String - check type, Match.OneOf(String,undefined,null) - @unblock() - - if Cloudinary.rules.delete - @public_id = public_id - auth_function = _.bind Cloudinary.rules.delete,this - if not auth_function() - throw new Meteor.Error "Unauthorized", "Delete not allowed" - - if type - ops = - type:type - - future = new Future() - - Cloudinary.api.delete_resources [public_id], (result) -> - future.return result - ,ops - - return future.wait() - - "c.get_private_resource": (public_id,ops={}) -> - check public_id, String - check ops, Match.Optional(Object) - @unblock() - - _.extend ops, - sign_url:true - type:"private" - - if Cloudinary.rules.private_resource - @public_id = public_id - auth_function = _.bind Cloudinary.rules.private_resource,this - if not auth_function() - throw new Meteor.Error "Unauthorized", "Access not allowed" - - - Cloudinary.url public_id,ops - - "c.get_download_url": (public_id,ops={}) -> - check public_id, String - check ops, Match.Optional(Object) - @unblock() - - if Cloudinary.rules.download_url - @public_id = public_id - auth_function = _.bind Cloudinary.rules.download_url,this - if not auth_function() - throw new Meteor.Error "Unauthorized", "Access not allowed" - - format = ops.format or "" - - Cloudinary.utils.private_download_url public_id,format,_.omit(ops,"format") - - - diff --git a/server/signature.js b/server/signature.js new file mode 100644 index 0000000..d0bcce6 --- /dev/null +++ b/server/signature.js @@ -0,0 +1,103 @@ +const Future = Npm.require("fibers/future"); + +Meteor.methods({ + "c.sign"(ops) { + if (ops == null) { + ops = {}; + } + check(ops, Match.Optional(Object)); + this.unblock(); + + if (Cloudinary.rules.signature) { + this.options = ops; + const auth_function = _.bind(Cloudinary.rules.signature, this); + if (!auth_function()) { + throw new Meteor.Error("Unauthorized", "Signature not allowed"); + } + } + + // Need to add some way to do custom auth + // signature = Cloudinary.utils.sign_request ops + const signature = Cloudinary.uploader.direct_upload("", ops); // This is better than utils.sign_request, it returns a POST url as well and properly manages optional parameters + + return signature; + }, + + + "c.delete_by_public_id"(public_id, type) { + let ops; + check(public_id, String); + check(type, Match.OneOf(String, undefined, null)); + this.unblock(); + + if (Cloudinary.rules.delete) { + this.public_id = public_id; + const auth_function = _.bind(Cloudinary.rules.delete, this); + if (!auth_function()) { + throw new Meteor.Error("Unauthorized", "Delete not allowed"); + } + } + + if (type) { + ops = + {type}; + } + + const future = new Future(); + + Cloudinary.api.delete_resources([public_id], result => future.return(result) + , ops); + + return future.wait(); + }, + + "c.get_private_resource"(public_id, ops) { + if (ops == null) { + ops = {}; + } + check(public_id, String); + check(ops, Match.Optional(Object)); + this.unblock(); + + _.extend(ops, { + sign_url: true, + type: "private" + } + ); + + if (Cloudinary.rules.private_resource) { + this.public_id = public_id; + const auth_function = _.bind(Cloudinary.rules.private_resource, this); + if (!auth_function()) { + throw new Meteor.Error("Unauthorized", "Access not allowed"); + } + } + + + return Cloudinary.url(public_id, ops); + }, + + "c.get_download_url"(public_id, ops) { + if (ops == null) { + ops = {}; + } + check(public_id, String); + check(ops, Match.Optional(Object)); + this.unblock(); + + if (Cloudinary.rules.download_url) { + this.public_id = public_id; + const auth_function = _.bind(Cloudinary.rules.download_url, this); + if (!auth_function()) { + throw new Meteor.Error("Unauthorized", "Access not allowed"); + } + } + + const format = ops.format || ""; + + return Cloudinary.utils.private_download_url(public_id, format, _.omit(ops, "format")); + } +}); + + +