-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7b01f17
Showing
19 changed files
with
834 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
bower_components | ||
config.js | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
Cloudinary | ||
========== | ||
|
||
Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. | ||
|
||
Easily upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website’s graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more. | ||
|
||
Cloudinary offers comprehensive APIs and administration capabilities and is easy to integrate with any web application, existing or new. | ||
|
||
Cloudinary provides URL and HTTP based APIs that can be easily integrated with any Web development framework. | ||
|
||
For AngularJS, Cloudinary provides a plugin for simplifying the integration even further. The plugin serves as a layer on top the [Cloudinary jQuery plugin](http://cloudinary.com/documentation/jquery_integration#installation) | ||
|
||
## Setup ###################################################################### | ||
|
||
Follow the setup procedure described in the [Cloudinary jQuery plugin](https://github.com/cloudinary/cloudinary_js#setup) setup procedure. The sample project contained in this repository can serve as an example. | ||
|
||
|
||
## Usage ###################################################################### | ||
|
||
The plugin provides two angular directives. URL directive and image tag directive. | ||
|
||
### Image tag generation directive - cl-image ################################## | ||
|
||
Similarly to the above this directive will generate an image tag with requested transformation, type, and format. The image tag can contain transformation tags that will be used as piped transformations: | ||
|
||
<cl-image public-id="{some_public_id}" class="thumbnail inline" angle="20" format="jpg"> | ||
<cl-transformation height="150" width="150" crop="fill" gravity="north" effect="sepia" radius="20"/> | ||
</cl-image> | ||
|
||
Will be translated to: | ||
|
||
<img ng-transclude="" public-id="{some_public_id}" class="thumbnail inline ng-isolate-scope" angle="20" format="jpg" | ||
src="http://res.cloudinary.com/{your cloud name}/image/upload/c_fill,e_sepia,g_north,h_150,r_20,w_150/a_20/{some_public_id}.jpg"></img> | ||
|
||
For a complete list of image manipulation options see [this reference](http://cloudinary.com/documentation/image_transformations#reference). | ||
|
||
### Manipulation URL generation directives - cl-src, cl-href, cl-srcset ####### | ||
|
||
These directives transform the given URI to a cloudinary URL. For example: | ||
|
||
<link rel="shortcut icon" cl-href="{publicly_available_image}" type="fetch" effect="sepia" width="16" heigh="16" crop="fit"/> | ||
|
||
Will be transformed to: | ||
|
||
<link rel="shortcut icon" cl-href="{publicly_available_image}" type="fetch" effect="sepia" width="16" height="16" crop="fit" | ||
href ="http://res.cloudinary.com/{your cloud name}/image/fetch/c_fit,e_sepia,h_16,w_16/{publicly_available_image}"> | ||
|
||
|
||
### Uploading images | ||
|
||
You can upload image sdirectly from the browser using Cloudinaty's jQuery plugin from you AngularJS app. See the sample [photo album app](https://github.com/cloudinary/cloudinary_angular/tree/master/samples/photo_album) for a usage example. | ||
|
||
|
||
## Samples | ||
|
||
You can find our simple and ready-to-use samples projects, along with documentation in the [samples folder](https://github.com/cloudinary/cloudinary_angular/tree/master/samples/photo_album). | ||
Please consult with the [README file](https://github.com/cloudinary/cloudinary_angular/blob/master/samples/photo_album/README.md), for usage and explanations. | ||
|
||
|
||
## Additional resources ########################################################## | ||
|
||
Additional resources are available at: | ||
|
||
* [Website](http://cloudinary.com) | ||
* [Documentation](http://cloudinary.com/documentation) | ||
* [Knowledge Base](http://support.cloudinary.com/forums) | ||
* [Documentation for jQuery integration](http://cloudinary.com/documentation/jquery_integration) | ||
* [Image upload documentation](http://cloudinary.com/documentation/upload_images) | ||
* [Image transformations documentation](http://cloudinary.com/documentation/image_transformations) | ||
|
||
## Support | ||
|
||
You can [open an issue through GitHub](https://github.com/cloudinary/cloudinary_gem/issues). | ||
|
||
Contact us [http://cloudinary.com/contact](http://cloudinary.com/contact) | ||
|
||
Stay tuned for updates, tips and tutorials: [Blog](http://cloudinary.com/blog), [Twitter](https://twitter.com/cloudinary), [Facebook](http://www.facebook.com/Cloudinary). | ||
|
||
|
||
## License ####################################################################### | ||
|
||
Released under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "cloudinary_ng", | ||
"description": "A set of AngularJS directives/helpers for using Cloudinary with AngularJS", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/cloudinary/cloudinary_agular", | ||
"license": "MIT", | ||
"private": true, | ||
"dependencies": { | ||
"angular": "1.2.x", | ||
"cloudinary_js": ">=1.0.16" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
(function (factory) { | ||
'use strict'; | ||
if (typeof define === 'function' && define.amd) { | ||
// Register as an anonymous AMD module: | ||
define([ | ||
'jquery.cloudinary', | ||
'angular' | ||
], factory); | ||
} else { | ||
// Browser globals: | ||
factory(window.jQuery, angular); | ||
} | ||
}(function ($, angular) { | ||
|
||
var angularModule = angular.module('cloudinary', []); | ||
|
||
var cloudinaryAttr = function(attr){ | ||
if (attr.match(/cl[A-Z]/)) attr = attr.substring(2); | ||
return attr.replace(/([a-z])([A-Z])/g,'$1_$2').toLowerCase(); | ||
}; | ||
|
||
|
||
['Src', 'Srcset', 'Href'].forEach(function(attrName) { | ||
var normalized = 'cl' + attrName; | ||
attrName = attrName.toLowerCase(); | ||
angularModule.directive(normalized, function($sniffer) { | ||
return { | ||
priority: 99, // it needs to run after the attributes are interpolated | ||
link: function(scope, element, attr) { | ||
var propName = attrName, | ||
name = attrName; | ||
|
||
if (attrName === 'href' && | ||
toString.call(element.prop('href')) === '[object SVGAnimatedString]') { | ||
name = 'xlinkHref'; | ||
attr.$attr[name] = 'xlink:href'; | ||
propName = null; | ||
} | ||
|
||
attr.$observe(normalized, function(value) { | ||
if (!value) | ||
return; | ||
|
||
var attributes = {} | ||
$.each(element[0].attributes, function(){attributes[cloudinaryAttr(this.name)] = this.value}); | ||
value = $.cloudinary.url(value, attributes); | ||
attr.$set(name, value); | ||
|
||
// on IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist | ||
// then calling element.setAttribute('src', 'foo') doesn't do anything, so we need | ||
// to set the property as well to achieve the desired effect. | ||
// we use attr[attrName] value since $set can sanitize the url. | ||
if ($sniffer.msie && propName) element.prop(propName, attr[name]); | ||
}); | ||
} | ||
}; | ||
}); | ||
}); | ||
|
||
angularModule.directive('clTransformation', function() { | ||
return { | ||
restrict : 'E', | ||
transclude : false, | ||
require: '^clImage', | ||
link : function (scope, element, attrs, clImageCtrl) { | ||
var attributes = {}; | ||
$.each(attrs, function(name,value){ | ||
if (name[0] !== '$') { | ||
attributes[cloudinaryAttr(name)] = value; | ||
} | ||
}); | ||
clImageCtrl.addTransformation(attributes); | ||
} | ||
} | ||
}); | ||
|
||
angularModule.directive('clImage', function() { | ||
return { | ||
restrict : 'E', | ||
replace: true, | ||
transclude : true, | ||
template: "<img ng-transclude/>", | ||
scope: {}, | ||
controller: function($scope) { | ||
this.addTransformation = function(ts){ | ||
$scope.transformations = $scope.transformations || []; | ||
$scope.transformations.push(ts); | ||
} | ||
}, | ||
// The linking function will add behavior to the template | ||
link : function(scope, element, attrs) { | ||
var attributes = {}; | ||
$.each(attrs, function(name, value){attributes[cloudinaryAttr(name)] = value}); | ||
|
||
if (scope.transformations) { | ||
attributes.transformation = scope.transformations; | ||
} | ||
|
||
var url = $.cloudinary.url(attrs.publicId, attributes); | ||
element.attr('src', url); | ||
if (attrs.htmlWidth) { | ||
element.attr("width", attrs.htmlWidth); | ||
} else { | ||
element.removeAttr("width"); | ||
} | ||
if (attrs.htmlHeight) { | ||
element.attr("height", attrs.htmlHeight); | ||
} else { | ||
element.removeAttr("height"); | ||
} | ||
} | ||
}; | ||
}); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Cloudinary AngularJS Photo Album Sample | ||
======================================= | ||
|
||
This sample project shows: | ||
|
||
1. How to use the Cloudinary AngularJS directives. | ||
2. How to upload files in an unsigned manner, using an upload preset, to Cloudinary. | ||
3. How to use the dynamic list resource in order to maintain short list of resources aggregated by tags. | ||
|
||
## Configuration ## | ||
|
||
There are 2 settings you need to change for this demo to work. Copy or rename `app/js/config.js.sample` to `app/js/config.js` and edit the following: | ||
|
||
1. **cloud_name** - Should be change to the cloud name you received when you registered for a Cloudinary account. | ||
2. **upload_preset** - You should first "Enable unsigned uploads" in the ["Upload Settings"](https://cloudinary.com/console/settings/upload) of your Cloudinary console and assign the resulting preset name to that field. Note, you may want to tweak and modify the upload preset's parameters. | ||
|
||
## Setup ## | ||
|
||
This sample uses Node's "http-server" to serve as simple http server. No other server components are required. For client side package management Bower is used. | ||
|
||
## Running ## | ||
|
||
npm start | ||
|
||
Then go to | ||
|
||
http://localhost:8000/app | ||
|
||
## Internals ## | ||
|
||
### Directives ### | ||
|
||
The `index.html` page and the `photo-upload.html` partial give some examples of both the URL directive and Image directive. | ||
|
||
### Unsignd Upload ### | ||
|
||
In order to add images to our photo album that would later be rettrievable from the Cloudinary service we must select a tag which will serve as our source for the list. In this case `myphotoalbum`. While this can tag can actually be set in the upload preset and be hidden from the client side, in this sample we included it in the request itself to make this sample work without fursther configuration steps. | ||
|
||
The `photoUploadCtrl` uses the Cloudinary JQuery library in order to configure the direct upload widget. Notice that changes to the title field are propagated to the `formData` being sent in the upload request. This is meant to illustrate the possiblity of attaching extra meta-data to each upload image. | ||
|
||
Also note, this upload widget uses the `upload_preset` we configured in Configuration step. This uses the settings defined on Cloudinary side to process the uploaded file. | ||
|
||
### List Resource ### | ||
|
||
Cloudinary supports a JSON list resource. This list represents all resources marked with a specific tag during upload (or later through other APIs). Whenever one a new resource is tagged or an existing resource already tagged is deleted the list is recomputed. This enables you to group a limited quantity of resources (100 currently) and make them retrievable for client only applications. | ||
|
||
The list retrieval is done here in this sample using the Angular's service using `myphotoalbum` as the seed tag. | ||
|
||
Notes: | ||
|
||
1. Currently the list is cached for 1 minute in the CDN. | ||
2. As mentioned above the maximum number of returned resources in the list 100 | ||
|
||
|
||
### |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* animations css stylesheet | ||
*/ | ||
|
||
/* animate ngRepeat in photo listing */ | ||
|
||
.photo-listing.ng-enter, | ||
.photo-listing.ng-leave, | ||
.photo-listing.ng-move { | ||
-webkit-transition: 0.5s linear all; | ||
-moz-transition: 0.5s linear all; | ||
-o-transition: 0.5s linear all; | ||
transition: 0.5s linear all; | ||
} | ||
|
||
.photo-listing.ng-enter, | ||
.photo-listing.ng-move { | ||
opacity: 0; | ||
height: 0; | ||
overflow: hidden; | ||
} | ||
|
||
.photo-listing.ng-move.ng-move-active, | ||
.photo-listing.ng-enter.ng-enter-active { | ||
opacity: 1; | ||
height: 120px; | ||
} | ||
|
||
.photo-listing.ng-leave { | ||
opacity: 1; | ||
overflow: hidden; | ||
} | ||
|
||
.photo-listing.ng-leave.ng-leave-active { | ||
opacity: 0; | ||
height: 0; | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
} | ||
|
||
/* cross fading between routes with ngView */ | ||
|
||
.view-container { | ||
position: relative; | ||
} | ||
|
||
.view-frame.ng-enter, | ||
.view-frame.ng-leave { | ||
background: white; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
} | ||
|
||
.view-frame.ng-enter { | ||
-webkit-animation: 0.5s fade-in; | ||
-moz-animation: 0.5s fade-in; | ||
-o-animation: 0.5s fade-in; | ||
animation: 0.5s fade-in; | ||
z-index: 100; | ||
} | ||
|
||
.view-frame.ng-leave { | ||
-webkit-animation: 0.5s fade-out; | ||
-moz-animation: 0.5s fade-out; | ||
-o-animation: 0.5s fade-out; | ||
animation: 0.5s fade-out; | ||
z-index: 99; | ||
} | ||
|
||
@keyframes fade-in { | ||
from { opacity: 0; } | ||
to { opacity: 1; } | ||
} | ||
@-moz-keyframes fade-in { | ||
from { opacity: 0; } | ||
to { opacity: 1; } | ||
} | ||
@-webkit-keyframes fade-in { | ||
from { opacity: 0; } | ||
to { opacity: 1; } | ||
} | ||
|
||
@keyframes fade-out { | ||
from { opacity: 1; } | ||
to { opacity: 0; } | ||
} | ||
@-moz-keyframes fade-out { | ||
from { opacity: 1; } | ||
to { opacity: 0; } | ||
} | ||
@-webkit-keyframes fade-out { | ||
from { opacity: 1; } | ||
to { opacity: 0; } | ||
} | ||
|
Oops, something went wrong.