Skip to content

Commit b1d33e0

Browse files
committed
completed demo
1 parent 4b307b7 commit b1d33e0

9 files changed

+128
-0
lines changed

build.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
System.config({
2+
"paths": {
3+
"*": "*.js",
4+
"app/*": "lib/*.js",
5+
"github:*": "jspm_packages/github/*.js",
6+
"npm:*": "jspm_packages/npm/*.js"
7+
}
8+
});
9+
10+
System.config({
11+
"map": {
12+
"jsonp": "npm:[email protected]",
13+
"github:jspm/[email protected]": {
14+
"assert": "npm:[email protected]",
15+
"fs": "github:jspm/[email protected]"
16+
},
17+
"github:jspm/[email protected]": {
18+
"process": "npm:[email protected]"
19+
},
20+
"github:jspm/[email protected]": {
21+
"tty-browserify": "npm:[email protected]"
22+
},
23+
"github:jspm/[email protected]": {
24+
"util": "npm:[email protected]"
25+
},
26+
27+
"util": "npm:[email protected]"
28+
},
29+
30+
"fs": "github:jspm/[email protected]",
31+
"ms": "npm:[email protected]",
32+
"net": "github:jspm/[email protected]",
33+
"process": "github:jspm/[email protected]",
34+
"tty": "github:jspm/[email protected]",
35+
"util": "github:jspm/[email protected]"
36+
},
37+
38+
"util": "github:jspm/[email protected]"
39+
},
40+
41+
"debug": "npm:[email protected]"
42+
},
43+
44+
"inherits": "npm:[email protected]",
45+
"process": "github:jspm/[email protected]"
46+
}
47+
}
48+
});
49+

index.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>LoopGIFs</title>
6+
<style>
7+
body {
8+
margin: 0;
9+
}
10+
#gifs > img {
11+
display: block;
12+
float: left;
13+
width: 50vw;
14+
height: 50vh;
15+
object-fit: cover;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<div id="gifs">
21+
<h1>GIFS GO HERE!!</h1>
22+
</div>
23+
24+
<!--<script src="jspm_packages/system.js"></script>-->
25+
<!--<script src="config.js"></script>-->
26+
<!--<script>-->
27+
<!--System.import('lib/main')-->
28+
<!--</script>-->
29+
<script src="jspm_packages/traceur-runtime.js"></script>
30+
<script src="build.js"></script>
31+
</body>
32+
</html>

lib/display-gifs.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default (urls) => {
2+
var elem = document.querySelector('#gifs')
3+
elem.innerHTML = urls.map(url => `<img src="${url}">`).join("\n")
4+
}

lib/extract-gifs.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default (posts) => {
2+
return posts
3+
.filter(post => !post.data.over_18)
4+
.map(post => post.data.url)
5+
.filter(url => /gifv?$/.exec(url))
6+
.map(url => url.replace(/v$/,''))
7+
}

lib/main.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import RedditApi from './reddit-api'
2+
import ExtractGifs from './extract-gifs'
3+
import DisplayGifs from './display-gifs'
4+
5+
RedditApi.load()
6+
.then(ExtractGifs)
7+
.then(DisplayGifs)
8+
9+
export default {}

lib/reddit-api.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import jsonp from 'jsonp'
2+
3+
class RedditApi {
4+
constructor() {
5+
this.redditURL = "http://www.reddit.com/r/perfectloops/top.json?sort=top&t=week"
6+
}
7+
8+
load() {
9+
return new Promise((resolve, reject) => {
10+
jsonp(this.redditURL, {param: 'jsonp'}, (err, data) => {
11+
err ? reject(err) : resolve(data.data.children)
12+
})
13+
})
14+
}
15+
}
16+
17+
export default new RedditApi()

0 commit comments

Comments
 (0)