Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcorgan committed Nov 20, 2013
1 parent 9d097c2 commit ae88c6c
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
22 changes: 22 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,22 @@
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

uglify: {
options: {
mangle: false
},
my_target: {
files: {
'angular-gist.min.js': ['angular-gist.js']
}
}
}

});

grunt.loadNpmTasks('grunt-contrib-uglify');

// // Tasks
grunt.registerTask('build', ['uglify']);
};
34 changes: 34 additions & 0 deletions README.md
Expand Up @@ -2,3 +2,37 @@ angular-gist
============

AngularJS directive for embedding Github gists.

## Install

Bower

```
bower install angular-gist --save
```

NPM

```
npm install angular-gist --save
```

## Usage

Inject module

```js
angular.module('myApp', ['gist']);
```

Use as directive

```html
<gist id="1234556"></gist>
```

## Options

####id

Gist ID
27 changes: 27 additions & 0 deletions angular-gist.js
@@ -0,0 +1,27 @@
angular.module('gist')
.directive('gist', function () {
return {
restrict: 'E',
replace: true,
template: '<div></div>',
link: function(scope, elm, attrs) {
var gistId = attrs.id;

var iframe = document.createElement('iframe');
iframe.setAttribute('width', '100%');
iframe.setAttribute('frameborder', '0');
iframe.id = "gist-" + gistId;
elm[0].appendChild(iframe);

var iframeHtml = '<html><head><base target="_parent"><style>table{font-size:12px;}</style></head><body onload="parent.document.getElementById(\'' + iframe.id + '\').style.height=document.body.scrollHeight + \'px\'"><scr' + 'ipt type="text/javascript" src="https://gist.github.com/' + gistId + '.js"></sc'+'ript></body></html>';

var doc = iframe.document;
if (iframe.contentDocument) doc = iframe.contentDocument;
else if (iframe.contentWindow) doc = iframe.contentWindow.document;

doc.open();
doc.writeln(iframeHtml);
doc.close();
}
};
});
1 change: 1 addition & 0 deletions angular-gist.min.js

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

26 changes: 26 additions & 0 deletions bower.json
@@ -0,0 +1,26 @@
{
"name": "angular-gist",
"version": "0.1.0",
"homepage": "https://github.com/scottcorgan/angular-gist",
"authors": [
"Scott Corgan <scottcorgan@gmail.com>"
],
"description": "AngularJS directive for embedding Github gists",
"main": "dist/angular-gist.min.js",
"keywords": [
"angular",
"github",
"gist"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"Gruntfile.js",
".gitignore",
"package.json"
]
}
27 changes: 27 additions & 0 deletions package.json
@@ -0,0 +1,27 @@
{
"name": "angular-gist",
"version": "0.1.0",
"description": "AngularJS directive for embedding Github gists",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/scottcorgan/angular-gist.git"
},
"keywords": [
"angular",
"gist",
"github"
],
"author": "Scott Corgan",
"license": "MIT",
"bugs": {
"url": "https://github.com/scottcorgan/angular-gist/issues"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.7"
}
}

0 comments on commit ae88c6c

Please sign in to comment.