Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Playing around with the Instagram API to power a page #2

Merged
merged 2 commits into from
May 21, 2016
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 84 additions & 3 deletions _assets/styles/site.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@import 'skeleton.less';

@mobile-width: 550px;


// Main Site CSS

Expand Down Expand Up @@ -78,7 +80,7 @@
}

// Restrict site width larger than mobile
@media (min-width: 550px) {
@media (min-width: @mobile-width) {
.main-header,
.main-footer,
.main-content-feed,
Expand All @@ -103,7 +105,7 @@
.margin-lr;
}

@media (min-width: 550px) {
@media (min-width: @mobile-width) {
.main-header-title,
.main-header-description,
.main-header-nav,
Expand Down Expand Up @@ -141,7 +143,7 @@
.navigation-item;
}

@media (min-width: 550px) {
@media (min-width: @mobile-width) {
.main-header-image {
height: 16rem;
}
Expand Down Expand Up @@ -215,6 +217,20 @@
}
}

.page-title,
.page-subtitle {
display: inline;
}

.page-title {

}

.page-subtitle {
font-size: 80%;
color: #666;
}

// Main footer
.main-footer {
.u-text-center;
Expand All @@ -229,3 +245,68 @@
.main-footer-nav-item {
.navigation-item;
}


// Custom pages

// Check-ins page
#checkin_map {
height: 46rem;
margin-top: 2rem;
margin-left: -2rem;
margin-right: -2rem;
transition: opacity .2s ease;
}

@media (min-width: @mobile-width) {
#checkin_map {
height: 60rem;
margin-top: 4rem;
}
}

// Instagram page
#instagram_images {
min-height: 46rem;
margin-top: 2rem;
margin-left: -2rem;
margin-right: -2rem;
transition: opacity .2s ease;
}

.instagram-post {

}

.instagram-link {
display: inline-block;
}

.instagram-image {
width: 100vw;
}

.instagram-caption {
padding-top: 2rem;
padding-right: 2rem;
padding-bottom: 2rem;
padding-left: 2rem;
}

.instagram-tag {

}

@media (min-width: @mobile-width) {
#instagram_images {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}

.instagram-post {
width: calc(50% - 4rem);
margin-right: 2rem;
margin-bottom: 2rem;
}
}
48 changes: 47 additions & 1 deletion _includes/foot.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/picturefill/3.0.1/picturefill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/1.3.1/lazysizes.min.js"></script>

{% if page.title == 'Check-Ins' %}
{% if page.page_id == 'checkins' %}
<script>
function formatDate (timestamp) {
var a = new Date(timestamp * 1000)
Expand Down Expand Up @@ -98,3 +98,49 @@
.then(generateMapMarkers)
</script>
{% endif %}

{% if page.page_id == 'mk7gti' %}
<script>
var generateImages = function (results) {
var images_div = document.getElementById('instagram_images')

for (var imageId in results) {
var data = results[imageId]
caption = data.caption.replace(/\S*#(\S+)/gi, '<a href="https://instagram.com/explore/tags/$1" class="instagram-tag">#$1</a>')

if (data.type === 'image') {
images_div.innerHTML += ' \
<div class="instagram-post"> \
<a href="' + data.url + '" class="instagram-link"> \
<img src="' + data.image + '" class="instagram-image" /> \
</a> \
<div class="instagram-caption"> \
' + caption + ' \
</div> \
</div>'
}
// TODO: UNTESTED!
// else if (data.type === 'video') {
// images_div.innerHTML += ' \
// <div class="instagram-post"> \
// <video width="480" height="480" controls> \
// <source src="' + data.video + '" type="video/mp4"/> \
// </video> \
// <div class="instagram-caption"> \
// ' + caption + ' \
// </div> \
// </div>'
// }
}

images_div.style.opacity = '1.0'
}

// Get Swarm checkins
fetch('/api/instagram.json')
.then(function (response) {
return response.json()
})
.then(generateImages)
</script>
{% endif %}
17 changes: 1 addition & 16 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,7 @@

<script async src="https://assets.codepen.io/assets/embed/ei.js"></script>

{% if page.title == 'Check-Ins' %}
{% if page.page_id == 'checkins' %}
<script src='https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.css' rel='stylesheet' />
<style>
#checkin_map {
transition: opacity .1s ease;
height: 46rem;
margin-top: 2rem;
margin-left: -2rem;
margin-right: -2rem;
}
@media (min-width: 550px) {
#checkin_map {
height: 60rem;
margin-top: 4rem;
}
}
</style>
{% endif %}
2 changes: 1 addition & 1 deletion _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---

<article class="main-content-page">
<h2>
<h2 class="page-title">
{{ page.title }}
</h2>

Expand Down
1 change: 1 addition & 0 deletions _pages/checkins.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
layout: page
title: Check-Ins
page_id: checkins
include_in_nav: true
---

Expand Down
12 changes: 12 additions & 0 deletions _pages/mk7-gti.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
layout: page
title: My MK7 GTI
page_id: mk7gti
include_in_nav: false
---

<h5 class="page-subtitle">
Powered by <a href="https://instagram.com/_vigti/">Instagram</a>
</h5>

<div id="instagram_images" style="opacity:0;"></div>
5 changes: 4 additions & 1 deletion gulp_tasks/tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ gulp.task('default', (callback) => {
runSequence(
'build:dev',
'browser-sync',
'foursquare:dev',
[
'foursquare:dev',
'instagram:dev'
],
'watch',
callback
)
Expand Down
10 changes: 8 additions & 2 deletions gulp_tasks/tasks/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ gulp.task('deploy', (callback) => {
],
'inlinesource',
'optimize:html',
'foursquare:prod',
[
'foursquare:prod',
'instagram:prod'
],
callback
)
} else {
Expand All @@ -88,7 +91,10 @@ gulp.task('deploy', (callback) => {
],
'inlinesource',
'optimize:html',
'foursquare:prod',
[
'foursquare:prod',
'instagram:prod'
],
'surge-deploy',
's3-deploy',
callback
Expand Down
Loading