├── .gitignore ├── example ├── loading_16x16.gif └── index.html ├── lib └── browserUtil.js ├── bower.json ├── src ├── app.js └── directives │ ├── angular-linkedin-login-ptl.html │ └── angular-linkedin-login.js ├── README.md ├── package.json ├── karma.conf.js ├── test └── linkedin-login-spec.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | */node_modules 4 | node_modules 5 | 6 | */bower_components 7 | bower_components 8 | -------------------------------------------------------------------------------- /example/loading_16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfriv/angular-linkedin-directive/HEAD/example/loading_16x16.gif -------------------------------------------------------------------------------- /lib/browserUtil.js: -------------------------------------------------------------------------------- 1 | BrowserUtil = { 2 | iOS: function(){ 3 | var ua = navigator.userAgent.toLowerCase(); 4 | var iOS = /(ipad|iphone|ipod)/.test( ua ); 5 | return iOS; 6 | } 7 | } -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-linkedin-directive", 3 | "description": "AngularJS directive integrating with LinkedIn's JS API for login", 4 | "keywords": [ 5 | "angularjs", 6 | "javascript", 7 | "directive", 8 | "linkedin" 9 | ], 10 | "dependencies": { 11 | "jquery": "2.1.x", 12 | "angular": "1.2.x" 13 | }, 14 | "devDependencies": { 15 | "angular-mocks": "1.2.x" 16 | } 17 | } -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | angular.module('linkedinExample', []) 2 | .controller('linkedinExampleCtrl', ['$scope', '$http', 3 | function($scope, $http) { 4 | 5 | $scope.linkedinMsg = {}; 6 | $scope.showLinkedinLogin = true; 7 | $scope.showEmailForm = true; 8 | 9 | $scope.linkedinProfileDataCallback = function(data){ 10 | console.log('profileDataCallback',data); 11 | }; 12 | 13 | } 14 | ]); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angular-linkedin-directive 2 | ========================== 3 | 4 | Angular directive for linkedin JS API login 5 | 6 | Please see the example for usage. Directive offers two possible callback 7 | attributes, one for simple authentication, the other for retrieving the 8 | LinkedIn user's profile information. If you need to change the information 9 | thats being passed back from linkedin, you will need to edit line 105 which 10 | specifies the fields which linkedin will pass back. 11 | 12 | LinkedIn's JS API will not work with iOS Safari because that browser blocks 13 | javascript communication between parent and child browser windows. This 14 | directive simply hides the linkedin login button for iOS Safari. 15 | 16 | Note that you will need to replace "LINKEDIN_API_KEY" on line 26 of 17 | the directive with your own LinkedIn JS API key for this directive to function. 18 | 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "https://github.com/feedthefire/", 3 | "name": "angular-linkedin-directive", 4 | "description": "angular-linkedin-directive - AngularJS directive integrating with LinkedIn's JS API for login", 5 | "version": "0.1.0", 6 | "homepage": "https://github.com/feedthefire/angular-linkedin-directive/", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/feedthefire/angular-linkedin-directive" 10 | }, 11 | "keywords": [ 12 | "angularjs", 13 | "linkedin" 14 | ], 15 | "license": "Apache2", 16 | "dependencies": {}, 17 | "devDependencies": { 18 | "grunt": "*", 19 | "grunt-shell": "*", 20 | "grunt-karma": "*", 21 | "grunt-contrib-watch": "*", 22 | "karma-html2js-preprocessor": "*", 23 | "karma-jasmine": "*", 24 | "karma-requirejs": "*", 25 | "karma-phantomjs-launcher": "*", 26 | "karma-coverage": "*", 27 | "karma": "*", 28 | "karma-junit-reporter": "*", 29 | "karma-ng-html2js-preprocessor": "*" 30 | } 31 | } -------------------------------------------------------------------------------- /src/directives/angular-linkedin-login-ptl.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | {{_buttonText}} 6 |
7 |
8 |
9 |
10 |
11 | 12 | Waiting for LinkedIn Authorization 13 |
14 |
15 |
16 | {{linkedinMsg.message}} 17 |
18 |
19 |
20 |

{{linkedinMsg.errorMsg}}

21 |
22 |
23 | {{linkedinMsg.successMsg}} 24 |
25 |
-------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 58 | 59 | 60 |
61 |

Linkedin Login Directive Example

62 |
66 |
67 | 68 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Thu Sep 26 2013 16:43:03 GMT-0400 (EDT) 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | 7 | // base path, that will be used to resolve files and exclude 8 | basePath: '', 9 | 10 | 11 | // frameworks to use 12 | frameworks: ['jasmine'], 13 | 14 | 15 | // list of files / patterns to load in the browser 16 | files: [ 17 | 'bower_components/jquery/dist/jquery.min.js', 18 | 'lib/BrowserUtil.js', 19 | 'bower_components/angular/angular.min.js', 20 | 'bower_components/angular-mocks/angular-mocks.js', 21 | 'src/app.js', 22 | 'src/**/*.js', 23 | 'src/**/*-ptl.html', 24 | 'test/*-spec.js' 25 | ], 26 | 27 | // due to a documented issue (https://github.com/karma-runner/karma/issues/558) 28 | // with socket.io on node 10.8/10.9, the default websocket polling does not work 29 | // with phantom at the moment. removing this from the the list fixes the issue 30 | // 31 | // default is ['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling'] 32 | transports: ['flashsocket', 'xhr-polling', 'jsonp-polling'], 33 | 34 | // list of files to exclude 35 | exclude: [], 36 | 37 | preprocessors: { 38 | 'src/**/*.js': 'coverage', 39 | 'src/**/*-ptl.html': 'ng-html2js' 40 | }, 41 | 42 | ngHtml2JsPreprocessor: { 43 | stripPrefix: 'src/', 44 | moduleName: 'templates' 45 | }, 46 | 47 | // test results reporter to use 48 | // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' 49 | reporters: ['progress', 'coverage', 'junit'], 50 | 51 | coverageReporter: { 52 | type: 'html', 53 | dir: 'target/coverage/' 54 | }, 55 | 56 | junitReporter: { 57 | outputFile: 'target/coverage/cobertura.unit.xml' 58 | }, 59 | 60 | // web server port 61 | port: 9876, 62 | 63 | 64 | // enable / disable colors in the output (reporters and logs) 65 | colors: true, 66 | 67 | 68 | // level of logging 69 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 70 | logLevel: config.LOG_INFO, 71 | 72 | 73 | // enable / disable watching file and executing tests whenever any file changes 74 | autoWatch: true, 75 | 76 | 77 | // Start these browsers, currently available: 78 | // - Chrome 79 | // - ChromeCanary 80 | // - Firefox 81 | // - Opera 82 | // - Safari (only Mac) 83 | // - PhantomJS 84 | // - IE (only Windows) 85 | browsers: ['PhantomJS'], 86 | 87 | 88 | // If browser does not capture in given timeout [ms], kill it 89 | captureTimeout: 60000, 90 | 91 | 92 | // Continuous Integration mode 93 | // if true, it capture browsers, run tests and exit 94 | singleRun: false 95 | }); 96 | }; 97 | -------------------------------------------------------------------------------- /test/linkedin-login-spec.js: -------------------------------------------------------------------------------- 1 | describe("linkedinLogin", function () { 2 | var $rootScope, 3 | $compile, 4 | $scope, 5 | el, 6 | getScriptSpy, 7 | INinitSpy, 8 | INUserIsAuthorizedSpy, 9 | INUserAuthorizeSpy, 10 | INAPIProfileSpy, 11 | $body = $('body'), 12 | fullHtml = '
', 13 | authOnlyHtml = '
', 14 | linkedinProfileData = { 15 | "_total": 1, 16 | "values": [{ 17 | "_key": "~", 18 | "emailAddress": "james@jamesroberts.name", 19 | "firstName": "James", 20 | "headline": "Lead Developer at Honest Buildings", 21 | "id": "1234", 22 | "industry": "Marketing and Advertising", 23 | "lastName": "Roberts", 24 | "location": { 25 | "country": {"code": "us"}, 26 | "name": "Greater Seattle Area" 27 | }, 28 | "pictureUrls": { 29 | "_total": 1, 30 | "values": ["http://m.c.lnkd.licdn.com/mpr/mprx/0_1p_n01148nEr8WTGldCZyt-V8bnrbMSGlfjRJ-3qDtcP8Z0u12GsU4iYx0V"] 31 | } 32 | }] 33 | }, 34 | transformedUserData = { 35 | "user_email":"james@jamesroberts.name", 36 | "first_name":"James", 37 | "last_name":"Roberts", 38 | "industry":"Marketing and Advertising", 39 | "headline":"Lead Developer at Honest Buildings", 40 | "linkedin_id":"1234", 41 | "location":"Greater Seattle Area", 42 | "country_code":"us", 43 | "thumb_url":"http://m.c.lnkd.licdn.com/mpr/mprx/0_1p_n01148nEr8WTGldCZyt-V8bnrbMSGlfjRJ-3qDtcP8Z0u12GsU4iYx0V" 44 | }; 45 | 46 | window.IN = { 47 | init: function(params){ 48 | window[params.onLoad]([]); 49 | }, 50 | User: { 51 | isAuthorized: function(){ 52 | return false; 53 | }, 54 | authorize: function(authCallback){ 55 | authCallback(true); 56 | } 57 | }, 58 | API: { 59 | Profile: function(name){ 60 | return { 61 | fields: function(f){ 62 | return { 63 | result: function(resCallback){ 64 | resCallback(linkedinProfileData); 65 | return { 66 | error: function(errCallback){ 67 | errCallback({message: 'some error'}); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | }; 74 | } 75 | } 76 | }; 77 | 78 | beforeEach(function () { 79 | 80 | //Instantiate module 81 | angular.module('linkedinExample'); 82 | 83 | inject(function ($injector, _$compile_) { 84 | $rootScope = $injector.get('$rootScope'); 85 | $compile = _$compile_; 86 | $scope = $rootScope.$new(); 87 | $scope.linkedinMsg = {successMsg:null}; 88 | $scope.onAuthorized = jasmine.createSpy("onAuthorized"); 89 | $scope.onProfileData = jasmine.createSpy("onProfileData"); 90 | getScriptSpy = spyOn($, 'getScript').andCallFake(function(url, s){ 91 | s(); 92 | }); 93 | INinitSpy = spyOn(window.IN, 'init').andCallThrough(); 94 | INUserIsAuthorizedSpy = spyOn(IN.User, 'isAuthorized').andCallThrough(); 95 | INUserAuthorizeSpy = spyOn(IN.User, 'authorize').andCallThrough(); 96 | INAPIProfileSpy = spyOn(IN.API, 'Profile').andCallThrough(); 97 | el = $compile(angular.element(fullHtml))($scope); 98 | }); 99 | 100 | $body.append(el); 101 | $rootScope.$digest(); 102 | }); 103 | 104 | afterEach(function () { 105 | $body.empty(); 106 | }); 107 | 108 | describe("compile time", function () { 109 | it("Should throw an error if the element is compiled without an 'linkedin-authorize' or 'linkedin-profile-data' attribute", function () { 110 | expect(function () { 111 | $compile(angular.element('
'))($scope); 112 | $scope.$digest(); 113 | }).toThrow(); 114 | }); 115 | 116 | it("Should initialize LinkedIn 'IN' on the window object and set linkedinLibInitialized to true",function(){ 117 | expect(getScriptSpy).toHaveBeenCalled(); 118 | expect(INinitSpy).toHaveBeenCalledWith({ onLoad : 'linkedinLibInit', api_key : 'LINKEDIN_API_KEY', credentials_cookie : true }); 119 | expect(window.linkedinLibInit).toBeTruthy(); 120 | }); 121 | 122 | 123 | }); 124 | 125 | describe("link time", function () { 126 | var myScope; 127 | beforeEach(function () { 128 | myScope = $scope.$$childTail; 129 | }); 130 | 131 | it("Should go through authorization and return profile data when scope.onLinkedinAuthClick() is called",function(){ 132 | myScope.onLinkedinAuthClick(); 133 | expect(INUserIsAuthorizedSpy).toHaveBeenCalled(); 134 | expect(INUserAuthorizeSpy).toHaveBeenCalled(); 135 | expect(INAPIProfileSpy).toHaveBeenCalled(); 136 | expect($scope.onProfileData).toHaveBeenCalledWith(transformedUserData); 137 | }); 138 | 139 | it("Should only call onAuthorized when onProfileData attribute is not set", function(){ 140 | el = $compile(angular.element(authOnlyHtml))($scope); 141 | $scope.$digest(); 142 | myScope = $scope.$$childTail; 143 | myScope.onLinkedinAuthClick(); 144 | expect(INUserIsAuthorizedSpy).toHaveBeenCalled(); 145 | expect(INUserAuthorizeSpy).toHaveBeenCalled(); 146 | expect(INAPIProfileSpy).not.toHaveBeenCalled(); 147 | expect($scope.onAuthorized).toHaveBeenCalledWith({auth:true}); 148 | }); 149 | 150 | it("Should call authorized directly and return profile data when already authenticated.",function(){ 151 | 152 | IN.User.isAuthorized = function(){ return true; }; 153 | INUserIsAuthorizedSpy = spyOn(IN.User, 'isAuthorized').andCallThrough(); 154 | el = $compile(angular.element(authOnlyHtml))($scope); 155 | $scope.$digest(); 156 | myScope = $scope.$$childTail; 157 | myScope.onLinkedinAuthClick(); 158 | expect(INUserIsAuthorizedSpy).toHaveBeenCalled(); 159 | expect(INUserAuthorizeSpy).not.toHaveBeenCalled(); 160 | expect(INAPIProfileSpy).not.toHaveBeenCalled(); 161 | expect($scope.onAuthorized).toHaveBeenCalledWith({auth:true}); 162 | 163 | }); 164 | 165 | it("Should set scope.linkedInErrorMsg when trying to transform bad data from LinkedIn.",function(){ 166 | 167 | IN.User.isAuthorized = function(){ return true; }; 168 | INUserIsAuthorizedSpy = spyOn(IN.User, 'isAuthorized').andCallThrough(); 169 | linkedinProfileData = null; 170 | el = $compile(angular.element(fullHtml))($scope); 171 | $scope.$digest(); 172 | myScope = $scope.$$childTail; 173 | myScope.onLinkedinAuthClick(); 174 | expect(INUserIsAuthorizedSpy).toHaveBeenCalled(); 175 | expect(INAPIProfileSpy).toHaveBeenCalled(); 176 | expect(myScope.linkedinMsg.errorMsg).toEqual('Unable to get LinkedIn profile information. Please re-authorize.'); 177 | 178 | }); 179 | 180 | 181 | }); 182 | 183 | describe("iOS", function () { 184 | it("Should set linkedinMsg.successMsg to true, call onAuthorized and return if userAgent is iOS", function(){ 185 | BrowserUtil.iOS = function(){return true;}; 186 | el = $compile(angular.element(authOnlyHtml))($scope); 187 | $scope.$digest(); 188 | expect($scope.linkedinMsg.successMsg).toBeTruthy(); 189 | expect($scope.onAuthorized).toHaveBeenCalledWith({ hideLinkedin : true }); 190 | }); 191 | it("Should set linkedinMsg.successMsg to true, call onProfileData and return if userAgent is iOS", function(){ 192 | var profileDataOnlyHtml = '
'; 193 | BrowserUtil.iOS = function(){return true;}; 194 | el = $compile(angular.element(profileDataOnlyHtml))($scope); 195 | $scope.$digest(); 196 | expect($scope.linkedinMsg.successMsg).toBeTruthy(); 197 | expect($scope.onProfileData).toHaveBeenCalledWith({ hideLinkedin : true }); 198 | }); 199 | 200 | }); 201 | 202 | }); 203 | -------------------------------------------------------------------------------- /src/directives/angular-linkedin-login.js: -------------------------------------------------------------------------------- 1 | angular.module('linkedinExample').directive('linkedinLogin', 2 | ['$rootScope', '$interval', 3 | function ($rootScope, $interval) { 4 | return { 5 | restrict: 'AE', 6 | replace: true, 7 | templateUrl: '/src/directives/angular-linkedin-login-ptl.html', 8 | scope: true, 9 | compile: function (tElem, tAttrs) { 10 | 11 | var linkedinLibLoaded = false, 12 | linkedinLibInitialized = false; 13 | 14 | window.linkedinLibInit = function(){ 15 | linkedinLibInitialized = true; 16 | }; 17 | 18 | if(!linkedinLibLoaded){ 19 | 20 | linkedinLibLoaded = true; 21 | 22 | $.getScript("//platform.linkedin.com/in.js?async=true", function success() { 23 | IN.init({ 24 | onLoad: "linkedinLibInit", 25 | api_key: "LINKEDIN_API_KEY", 26 | credentials_cookie: true 27 | }); 28 | }); 29 | 30 | } 31 | 32 | return function (scope, elem, attrs) { 33 | 34 | scope._buttonText = tAttrs.linkedinButtonText || 'Connect'; 35 | var _authorizedHandlerName = tAttrs.linkedinAuthorized || null; 36 | var _authorizedHandler = _authorizedHandlerName ? scopescope[_authorizedHandlerName] : null; 37 | var _profileDataHandlerName = tAttrs.linkedinProfileData || null; 38 | var _profileDataHandler = _profileDataHandlerName ? scope[_profileDataHandlerName] : null; 39 | var _successMsg = tAttrs.linkedinSuccessMsg || 'Linkedin Connection Authorized'; 40 | var ua = navigator.userAgent || 'unknown'; 41 | var _iOS = BrowserUtil.iOS(); 42 | var _iOSinterval = null; 43 | 44 | if(!_authorizedHandler && !_profileDataHandler){ 45 | throw "You must provide a 'linkedin-authorize' or 'linkedin-profile-data' on the scope."; 46 | } 47 | if(_iOS){ 48 | // hide linkedin button for iOS because the LinkedIn JS API does not work, argh... 49 | scope.linkedinMsg = scope.linkedinMsg || {}; 50 | scope.linkedinMsg.successMsg = true; 51 | if(_profileDataHandler && typeof _profileDataHandler == 'function'){ 52 | scope[_profileDataHandlerName]({hideLinkedin:true}); 53 | }else{ 54 | scope[_authorizedHandlerName]({hideLinkedin:true}); 55 | } 56 | return; 57 | } 58 | 59 | scope.linkedinMsg = scope.linkedinMsg || {}; 60 | scope.linkedinMsg.loaded = false; 61 | scope.linkedinMsg.showButton = true; 62 | scope.linkedinMsg.message = tAttrs.linkedinMsg || null; 63 | scope.linkedinMsg.loading = false; 64 | scope.linkedinMsg.errorMsg = null; 65 | scope.linkedinMsg.successMsg = null; 66 | 67 | scope.onLinkedinAuthClick = function($ev){ 68 | authorizeLinkedin(); 69 | }; 70 | 71 | var authorizeLinkedin = function(){ 72 | scope.linkedinMsg.loading = true; 73 | if(IN.User.isAuthorized()){ 74 | linkedinAuthorized(); 75 | }else{ 76 | IN.User.authorize(linkedinAuthorized); 77 | /* 78 | if(_iOS){ 79 | _iOSinterval = $interval(function(count){ 80 | var linkedinCookieFound = false; 81 | var cookies = document.cookie.split(';'); 82 | for(var i=0;i= 9){ 92 | $interval.cancel(_iOSinterval); 93 | linkedinAuthorized(); 94 | } 95 | }, 200, 10); 96 | } 97 | */ 98 | } 99 | }; 100 | 101 | var linkedinAuthorized = function(){ 102 | if(_profileDataHandler && typeof _profileDataHandler == 'function'){ 103 | IN.API.Profile("me") 104 | .fields('id','first-name','last-name','location','industry','headline','picture-urls::(original)','email-address') 105 | .result(function(data){ 106 | linkedinDataTransform(data); 107 | }) 108 | .error(function(err){ 109 | scope.linkedinMsg.loading = false 110 | scope.linkedinMsg.errorMsg = 'Unable to get LinkedIn profile information. Please re-authorize.'; 111 | 112 | }); 113 | }else{ 114 | scope.linkedinMsg.loading = false; 115 | scope.linkedinMsg.successMsg = _successMsg; 116 | } 117 | if(_authorizedHandlerName && typeof scope[_authorizedHandlerName] == 'function') 118 | scope.$apply(scope[_authorizedHandlerName]({auth:true})); 119 | }; 120 | 121 | var linkedinDataTransform = function(linData){ 122 | var linUser = ( (linData && linData.values) ? linData.values[0] : null ); 123 | if(linUser){ 124 | scope.linkedinMsg.showButton = false; 125 | scope.linkedinMsg.successMsg = _successMsg; 126 | var data = { 127 | user_email: linUser.emailAddress, 128 | first_name: linUser.firstName, 129 | last_name: linUser.lastName, 130 | industry: linUser.industry, 131 | headline: linUser.headline, 132 | linkedin_id: linUser.id, 133 | location: (linUser.location ? linUser.location.name : ''), 134 | country_code: (linUser.location ? linUser.location.country.code : ''), 135 | headline: linUser.headline, 136 | thumb_url: ((linUser.pictureUrls && linUser.pictureUrls._total > 0) ? linUser.pictureUrls.values[0] : '') 137 | }; 138 | if(_profileDataHandlerName && typeof scope[_profileDataHandlerName] == 'function'){ 139 | scope.$apply(scope[_profileDataHandlerName](data)); 140 | } 141 | }else{ 142 | scope.linkedinMsg.loading = false; 143 | scope.linkedinMsg.successMsg = 'Unable to get LinkedIn profile information. Please re-authorize.'; 144 | } 145 | }; 146 | 147 | } 148 | } 149 | } 150 | } 151 | ]); 152 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. --------------------------------------------------------------------------------