update 59

This commit is contained in:
Alex Corbi 2016-10-05 11:37:13 +02:00
parent 4850be2d20
commit 4a9c384437
18 changed files with 1897 additions and 0 deletions

View file

@ -0,0 +1,45 @@
/*global require, module */
/*jslint node: true*/
'use strict';
module.exports = function (grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> Copyright (C) 2014 <%= pkg.author %>, <%= pkg.homepage %> */\n'
},
lib: {
files: {
'js/picbook.min.js': ['js/picbook.js']
}
}
},
jshint: {
options: {
reporter: require('jshint-stylish'),
curly: true,
eqeqeq: true,
eqnull: true,
browser: true
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['js/picbook.js']
}
},
});
grunt.registerTask('default', ['jshint','uglify']);
};

View file

@ -0,0 +1,12 @@
License
-------
The MIT License (MIT)
Copyright © 2014 [Henrique Alves](https://github.com/henriquea)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,87 @@
picbookJs
-------
A simple Javascript library to display album photos from a Facebook Page.
## Why?
The library was made because we wanted to easily "embed" photos from a Facebook page to our church's [website](http://hillsong.co.uk). Also this would be managed by people with basic understanding of HTML, this is why I tried to keep it simple and without dependencies.
## Installation
- [Download](https://github.com/henriquea/picbookjs/archive/master.zip) ZIP
- Bower: `bower install picbookjs`
## Getting Started
This is the simple way to get the ball rolling.
### Basic usage
Include the `picbook.min.js` before the `</body>` tag. Then initialise the library:
```html
<div class="picbook"></div>
<script type="text/javascript" src="picbook.min.js"></script>
<script type="text/javascript">
(function($)){
var picbook = new picbookJs({
albumId: '10150167782373951'
});
})(jQuery);
</script>
```
### Options
Those are the options avaliable when you initialise the library:
| Parameter | Description |
| ----------------- | ---------------------------------------------------------------------- |
| _albumId_ | The Facebook album ID (required) |
| _albumLoaded_ | Provide a callback as soon the album is loaded. |
| _photosLoaded_ | Callback a function when the photos are loaded. |
| _limit_ | Number of photos to be loaded. The maximum allower by Facebook is 100. |
Example:
```javascript
var options = {
albumId: '10150167782373951',
limit: 10,
albumLoaded: function() { /* do something */ },
photosLoaded: function() { /* do something else */ }
};
var picbook = new picbookJs(options);
```
## Questions
#### Where do I get the album ID?
Go to an album page and copy the _ID_ from the address bar URL:
![Image](http://f.cl.ly/items/2s0L3f430q2l1I11101K/fb-album-id.gif)
#### How about retrieve an album that belongs to a user?
Not possible. The `user_photo` [permission](https://developers.facebook.com/docs/reference/login/#permissions) is required, which means you would have to create a Facebook app and implement the Facebook Login.
#### How about pagination?
This is in my _TODO_ list. For now you can set a `limit` to 100 (maximum allowed by Facebook).
## License
The MIT License (MIT)
Copyright © 2014 [Henrique Alves](https://github.com/henriquea)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,6 @@
TODO
-------
- Add model layer for album and photos object
- Create one static page to retrieve the album ID from a given URL
- Paginating

View file

@ -0,0 +1,26 @@
{
"name": "picbookjs",
"version": "0.3.0",
"homepage": "http://henriquea.github.io/picbookjs/",
"authors": [
"Henrique Alves <henriquea@gmail.com>"
],
"description": "A simple Javascript library to display album photos from a Facebook Page",
"main": [
"js/picbook.js",
"css/picbook.css"
],
"keywords": [
"facebook",
"javascript",
"photos"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

View file

@ -0,0 +1,8 @@
http_path = "/"
css_dir = "css"
sass_dir = "scss"
# output_style = :expanded or :nested or :compact or :compressed
output_style = :expanded
line_comments = false

View file

@ -0,0 +1,27 @@
.picbook .album-title {
font-size: 1.6em;
font-weight: 300;
}
.picbook .photo-list {
padding: 0;
margin: 0;
}
.picbook .photo-list .photo-list-item {
list-style-type: none;
display: inline-block;
}
.picbook .photo-list .photo-list-item .item-thumb {
cursor: pointer;
display: block;
margin: 3px;
width: 206px;
height: 206px;
background-size: cover;
background-position: 50% 25%;
transition: all 199ms ease;
vertical-align: top;
opacity: .73;
}
.picbook .photo-list .photo-list-item .item-thumb:hover {
opacity: 1;
}

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>picbookJs</title>
<meta charset="utf-8">
<meta name="description" content="A Simple Javascript Library To Display Album Photos From A Facebook Page.">
<meta name="keywords" content="library,open source, github, javascript, js,facebook, album, photos">
<link rel="stylesheet" type="text/css" href="css/picbook.css">
<script type="text/javascript" src="js/picbook.js"></script>
</head>
<body>
<div class="picbook"></div>
<script type="text/javascript">
var picbook = new picbookJs({
limit: 30,
albumId: '10151871660806681'
});
</script>
</body>
</html>

View file

@ -0,0 +1,161 @@
/* picbookJs 0.3.0 | Copyright (C) 2014 Henrique Alves, http://henriquea.github.io/picbookjs */
var _picbookOptions = null;
var picbookJs = (function(document){
'use strict';
function picbookJs(options) {
/*jslint validthis: true */
this.options = this.extend(this._options, options);
this.init();
_picbookOptions = this.options;
}
picbookJs.prototype = {
count: 0,
loaded: false,
dom: {},
_options: {
graph: 'https://graph.facebook.com/',
limit: 10,
},
init: function() {
this.loaded = false;
this.getAlbum({
callback: 'picbookJs.prototype.albumComplete'
});
// Setup DOM
this.dom.wrapper = document.querySelector('.picbook');
this.dom.title = document.createElement('h3');
this.dom.title.classList.add('album-title');
this.dom.photos = document.createElement('ul');
this.dom.photos.classList.add('photo-list');
this.dom.wrapper.appendChild(this.dom.title);
this.dom.wrapper.appendChild(this.dom.photos);
},
getAlbum: function(params) {
var js = document.createElement('script'),
options = _picbookOptions || this.options,
url = options.graph + options.albumId,
s;
js.type = 'text/javascript';
js.async = true;
js.src = url + '?callback=' + params.callback;
s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(js, s.nextSibling);
},
// TODO: adpated the method for paging the data
getPhotos: function(params) {
var js = document.createElement('script'),
options = _picbookOptions || this.options,
url = options.graph + options.albumId + '/photos',
s;
js.type = 'text/javascript';
js.async = true;
js.src = url + '?limit=' + options.limit + '&callback=' + params.callback;
s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(js, s.nextSibling);
},
// https://developers.facebook.com/docs/reference/api/album
albumComplete: function(response) {
var options = _picbookOptions || this.options;
this.album = response;
this.count = response.count;
this.getPhotos({
callback: 'picbookJs.prototype.photosComplete'
});
if (typeof options.albumLoaded === 'function') {
options.albumLoaded();
}
this.dom.title.innerHTML = response.name;
},
// https://developers.facebook.com/docs/graph-api/reference/photo
photosComplete: function(response) {
var options = _picbookOptions || this.options;
this.photos = response.data;
this.loaded = true;
this.createPhotos();
if (typeof options.photosLoaded === 'function') {
options.photosLoaded();
}
},
createPhotos: function() {
var arrUrl = [], imgSrc, i, len, image, li, a, link;
for (i=0, len = this.photos.length; i < len; i++) {
image = this.photos[i].images[0];
// Check if photo has public permission
if (!image.source.match(/oh=/)) {
link = this.photos[i].link.replace(/graph.facebook/gi, 'www.facebook');
li = document.createElement('li');
a = document.createElement('a');
li.classList.add('photo-list-item');
this.dom.photos.appendChild(li);
li.appendChild(a);
a.classList.add('item-thumb');
arrUrl = image.source.split('/').splice(0);
arrUrl.splice(5,0,'p206x206');
imgSrc = arrUrl.join('/');
a.setAttribute('href', link);
a.setAttribute('style', 'background-image: url('+ imgSrc +')');
}
}
},
extend: function(a, b) {
for (var key in b) {
if (b.hasOwnProperty(key)) {
a[key] = b[key];
}
}
return a;
}
};
return picbookJs;
})(document);

View file

@ -0,0 +1,2 @@
/*! picbookJs 0.3.0 Copyright (C) 2014 Henrique Alves, http://henriquea.github.io/picbookjs */
var _picbookOptions=null,picbookJs=function(a){"use strict";function b(a){this.options=this.extend(this._options,a),this.init(),_picbookOptions=this.options}return b.prototype={count:0,loaded:!1,dom:{},_options:{graph:"https://graph.facebook.com/",limit:10},init:function(){this.loaded=!1,this.getAlbum({callback:"picbookJs.prototype.albumComplete"}),this.dom.wrapper=a.querySelector(".picbook"),this.dom.title=a.createElement("h3"),this.dom.title.classList.add("album-title"),this.dom.photos=a.createElement("ul"),this.dom.photos.classList.add("photo-list"),this.dom.wrapper.appendChild(this.dom.title),this.dom.wrapper.appendChild(this.dom.photos)},getAlbum:function(b){var c,d=a.createElement("script"),e=_picbookOptions||this.options,f=e.graph+e.albumId;d.type="text/javascript",d.async=!0,d.src=f+"?callback="+b.callback,c=a.getElementsByTagName("script")[0],c.parentNode.insertBefore(d,c.nextSibling)},getPhotos:function(b){var c,d=a.createElement("script"),e=_picbookOptions||this.options,f=e.graph+e.albumId+"/photos";d.type="text/javascript",d.async=!0,d.src=f+"?limit="+e.limit+"&callback="+b.callback,c=a.getElementsByTagName("script")[0],c.parentNode.insertBefore(d,c.nextSibling)},albumComplete:function(a){var b=_picbookOptions||this.options;this.album=a,this.count=a.count,this.getPhotos({callback:"picbookJs.prototype.photosComplete"}),"function"==typeof b.albumLoaded&&b.albumLoaded(),this.dom.title.innerHTML=a.name},photosComplete:function(a){var b=_picbookOptions||this.options;this.photos=a.data,this.loaded=!0,this.createPhotos(),"function"==typeof b.photosLoaded&&b.photosLoaded()},createPhotos:function(){var b,c,d,e,f,g,h,i=[];for(c=0,d=this.photos.length;d>c;c++)e=this.photos[c].images[0],e.source.match(/oh=/)||(h=this.photos[c].link.replace(/graph.facebook/gi,"www.facebook"),f=a.createElement("li"),g=a.createElement("a"),f.classList.add("photo-list-item"),this.dom.photos.appendChild(f),f.appendChild(g),g.classList.add("item-thumb"),i=e.source.split("/").splice(0),i.splice(5,0,"p206x206"),b=i.join("/"),g.setAttribute("href",h),g.setAttribute("style","background-image: url("+b+")"))},extend:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}},b}(document);

View file

@ -0,0 +1,36 @@
{
"name": "picbookjs",
"version": "0.3.0",
"description": "A simple Javascript library to display album photos from a Facebook Page",
"main": "js/picbook.js",
"directories": {
"example": "examples"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/henriquea/picbookjs.git"
},
"keywords": [
"facebook",
"album",
"photo"
],
"author": "Henrique Alves",
"homepage": "http://henriquea.github.io/picbookjs",
"license": "MIT",
"bugs": {
"url": "https://github.com/henriquea/picbookjs/issues"
},
"devDependencies": {
"bower": "~1.2.8",
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.7.0",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.0",
"jshint-stylish": "~0.1.3",
"grunt-contrib-uglify": "~0.3.2"
}
}

View file

@ -0,0 +1,45 @@
$thumb-margin: 3px;
$thumb-width: 206px;
$thumb-height: 206px;
.picbook {
.album-title {
font-size: 1.6em;
font-weight: 300;
}
.photo-list {
padding: 0;
margin: 0;
.photo-list-item {
list-style-type: none;
display: inline-block;
.item-thumb {
cursor: pointer;
display: block;
margin: $thumb-margin;
width: $thumb-width;
height: $thumb-height;
background-size: cover;
background-position: 50% 25%;
transition: all 199ms ease;
vertical-align: top;
opacity: .73;
&:hover {
opacity: 1;
}
}
}
}
}

BIN
_site/images/gajek.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

File diff suppressed because it is too large Load diff