Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove coffeescript #117

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.build*
.test_config*
.test_config*
.idea/
44 changes: 18 additions & 26 deletions .npm/package/npm-shrinkwrap.json

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

108 changes: 51 additions & 57 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,60 +1,54 @@
allow-deny@1.0.5
autoupdate@1.2.10
babel-compiler@6.8.3
babel-runtime@0.1.9_1
[email protected].9
[email protected].9
[email protected]
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
[email protected]
[email protected]_1
[email protected]
diff-sequence@1.0.6
ecmascript@0.4.6_1
[email protected]_1
[email protected]
[email protected].9
allow-deny@1.1.0
autoupdate@1.4.0
babel-compiler@7.0.4
babel-runtime@1.2.0
[email protected].10
[email protected].10
[email protected]
caching-compiler@1.1.9
callback-hook@1.1.0
check@1.3.0
coffeescript@1.0.17
ddp@1.4.0
ddp-client@2.3.1
ddp-common@1.4.0
ddp-server@2.1.2
diff-sequence@1.1.0
[email protected]
[email protected]
[email protected]
ecmascript-runtime-client@0.6.0
ecmascript-runtime-server@0.5.0
[email protected]
[email protected]
[email protected].10
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
lepozepo:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]_1
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]_1
[email protected]_1
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
lmachens:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +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
160 changes: 65 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<img src="{{c.url public_id}}">
<img src="{{c.private_url public_id}}">
```
``` 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
<img width="250" src="{{c.url public_id effect='blur:300' angle=10}}">
```

Obs: If you want to resize your image in a smaller size you will need to pass the `crop` parameter
``` handlebars
<img src="{{c.url public_id width=250 height=250 crop="fill"}}">
```
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:

Expand All @@ -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
Expand All @@ -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




Loading