Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_STORE
.DS_Store
node_modules/
58 changes: 29 additions & 29 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
/*global module:false*/
module.exports = function(grunt) {

module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
pkg: grunt.file.readJSON("package.json"),
meta: {
banner: '/*! Kaltura Embed Code Generator - v<%= pkg.version %> - ' +
banner:
"/*! Kaltura Embed Code Generator - v<%= pkg.version %> - " +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* https://github.com/kaltura/EmbedCodeGenerator\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
'Ran Yefet; Licensed MIT */\n'
"* https://github.com/kaltura/EmbedCodeGenerator\n" +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Kaltura Inc. */',
},
handlebars: {
compile: {
options: {
namespace: "Handlebars.templates"
namespace: "Handlebars.templates",
},
files: {
'lib/templates.js': 'templates/*'
}
}
"lib/templates.js": "templates/*",
},
},
},
concat: {
options: {
banner: '<%= meta.banner %>'
banner: "<%= meta.banner %>",
},
dist: {
src: [
'lib/handlebars.runtime.js',
'lib/handlebars.helpers.js',
'lib/templates.js',
'lib/utils.js',
'lib/EmbedCodeGenerator.js'
"lib/handlebars.runtime-v4.7.7.js",
"lib/handlebars.helpers.js",
"lib/templates.js",
"lib/utils.js",
"lib/EmbedCodeGenerator.js",
],
dest: 'dist/<%= pkg.name %>.js'
}
dest: "dist/<%= pkg.config.distFilename %>.js",
},
},
uglify: {
options: {
banner: '<%= meta.banner %>'
banner: "<%= meta.banner %>",
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
}
"dist/<%= pkg.config.distFilename %>.min.js": [
"<%= concat.dist.dest %>",
],
},
},
},
});

// Add grunt plugins
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks("grunt-contrib-handlebars");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-uglify");

// Default task.
grunt.registerTask('default', ['handlebars', 'concat', 'uglify:dist']);

grunt.registerTask("default", ["handlebars", "concat", "uglify:dist"]);
};
131 changes: 63 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,88 +6,83 @@ It was designed to easiliy create embed codes on-the-fly for your projects.

## Quick Start

1. Include ```KalturaEmbedCodeGenerator.js``` to your page.

```html
<script src="/{path_to_script}/KalturaEmbedCodeGenerator.js"></script>
```

2. Create a new instance of the generator, pass in configuration object and call ```getCode``` method.

```html
<textarea id="code"></textarea>
<script>
var gen = new kEmbedCodeGenerator({
partnerId: 0000,
uiConfId: 999,
entryId: '0_xsd34g3'
});
document.getElementById('code').innerHTML = gen.getCode();
</script>
```
1. Include `KalturaEmbedCodeGenerator.js` to your page.

```html
<script src="/{path_to_script}/KalturaEmbedCodeGenerator.js"></script>
```

2. Create a new instance of the generator, pass in configuration object and call `getCode` method.

```html
<textarea id="code"></textarea>
<script>
var gen = new kEmbedCodeGenerator({
partnerId: 0000,
uiConfId: 999,
entryId: "0_xsd34g3",
});
document.getElementById("code").innerHTML = gen.getCode();
</script>
```

## Configuration

| Option | Description | Default |
| ------------- | ------------------------ | ------------- |
| embedType ```string``` | Embed code type to generate. Can we one of: 'auto', 'dynamic', 'thumb', 'iframe', 'legacy' | "auto" |
| playerId ```string``` | The player element Id to generate | "kaltura_player" |
| protocol ```string``` | Embed HTTP protocol to use | "http" |
| host ```string``` | Host for loading html5 library & kdp swf | "www.kaltura.com" |
| securedHost ```string``` | Secured host for loading html5 library & kdp swf | "www.kaltura.com" |
| widgetId ```string``` | Kaltura Widget Id | _{partnerId} |
| partnerId ```int``` | Kaltura Partner Id | null |
| cacheSt ```int``` | Add cacheSt parameter to bust cache. Should be future timestamp | null |
| uiConfId ```int``` | Kaltura UiConf Id | null |
| entryId ```string``` | Kaltura Entry Id | null |
| entryMeta ```object``` | Entry Metadata object. Example: {name: "Foo", description: "Bar", thumbnailUrl: "http://foo.bar.com/img.jpg"} | null |
| width ```int``` | Set player width | 400 |
| height ```int``` | Set player height | 330 |
| attributes ```object``` | Adds additonal attributes to embed code. Example: { "class": "player" } | {} (empty object) |
| flashVars ```object``` | Adds flashVars to player. Example: { "autoPlay": "true" } | {} (empty object) |
| includeKalturaLinks ```boolean``` | Include Kaltura SEO links | true |
| includeSeoMetadata ```boolean``` | Include Entry SEO Metadata ( taken from {entryMeta} option ) | false |
| includeHtml5Library ```boolean``` | Inclde HTML5 Library in legacy embed type | true |

You can set the configuration options when creating a new instance to set the defaults
and you can also set the configuration when calling ```getCode``` method.

Any option that sets on ```getCode``` will override options that were set when creating the instance.
| Option | Description | Default |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------- |
| embedType `string` | Embed code type to generate. Can we one of: 'auto', 'dynamic', 'thumb', 'iframe', 'legacy' | "auto" |
| playerId `string` | The player element Id to generate | "kaltura_player" |
| protocol `string` | Embed HTTP protocol to use | "http" |
| host `string` | Host for loading html5 library & kdp swf | "www.kaltura.com" |
| securedHost `string` | Secured host for loading html5 library & kdp swf | "www.kaltura.com" |
| widgetId `string` | Kaltura Widget Id | \_{partnerId} |
| partnerId `int` | Kaltura Partner Id | null |
| cacheSt `int` | Add cacheSt parameter to bust cache. Should be future timestamp | null |
| uiConfId `int` | Kaltura UiConf Id | null |
| entryId `string` | Kaltura Entry Id | null |
| entryMeta `object` | Entry Metadata object. Example: {name: "Foo", description: "Bar", thumbnailUrl: "http://foo.bar.com/img.jpg"} | null |
| width `int` | Set player width | 400 |
| height `int` | Set player height | 330 |
| attributes `object` | Adds additonal attributes to embed code. Example: { "class": "player" } | {} (empty object) |
| flashVars `object` | Adds flashVars to player. Example: { "autoPlay": "true" } | {} (empty object) |
| includeKalturaLinks `boolean` | Include Kaltura SEO links | true |
| includeSeoMetadata `boolean` | Include Entry SEO Metadata ( taken from {entryMeta} option ) | false |
| includeHtml5Library `boolean` | Inclde HTML5 Library in legacy embed type | true |

You can set the configuration options when creating a new instance to set the defaults
and you can also set the configuration when calling `getCode` method.

Any option that sets on `getCode` will override options that were set when creating the instance.

```javascript
var gen = new kEmbedCodeGenerator({
'host': 'cdnapi.kaltura.com',
'partnerId': 1111,
'widgetId': 1111,
'width': 680,
'height': 420
host: "cdnapi.kaltura.com",
partnerId: 1111,
widgetId: 1111,
width: 680,
height: 420,
});
console.log(gen.getCode({
'uiConfId': 0000000,
'entryId': 'x_0000000',
'height': 300 // Will generate embed with "height" of 300px
}));
console.log(
gen.getCode({
uiConfId: 0000000,
entryId: "x_0000000",
height: 300, // Will generate embed with "height" of 300px
})
);
```

If you like to play with all the different options you're welcome to try out the [demo](http://kaltura.github.com/EmbedCodeGenerator/demo/)
If you like to play with all the different options you're welcome to try out the [demo](https://kaltura.github.com/EmbedCodeGenerator/demo/)

## Dependencies

This library uses [Handlebars](http://handlebarsjs.com/) to manage the embed code templates and includes ```handlebars.runtime.js``` library.
If your project already uses handlebars, you can remove that file from ```grunt.js``` file.

This library also uses ```JSON.strinify``` method which is supported nativaliy in modern browsers.
If you need to support older browsers, please add the following code.

```html
<!--[if lt IE 9]>
<script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<![endif]-->
```
This library uses [Handlebars](http://handlebarsjs.com/) to manage the embed code templates and includes `handlebars.runtime.js` library.
If your project already uses handlebars, you can remove that file from `grunt.js` file.

## Build minified version

Just run:

```
grunt
npm install
npm run build
```

Loading