From a4201b8ed2f3dcb0e60a2965552015c28e261063 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Sat, 8 Aug 2015 11:09:45 -0700 Subject: [PATCH] Adds initial attempt at shimming Dug.js --- _templates/collection.hbs | 5 ++-- package.json | 14 +++++++++--- src/js/instagram.js | 48 +++++++++++++++++++++------------------ 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/_templates/collection.hbs b/_templates/collection.hbs index 663823c..74fc23b 100644 --- a/_templates/collection.hbs +++ b/_templates/collection.hbs @@ -73,8 +73,7 @@ {{!-- --}} -{{!-- TODO Obviously, move this. --}} - - + + {{> footer }} diff --git a/package.json b/package.json index 52ec8db..88e0c17 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "bourbon-neat": "1.7.2", "browser-sync": "2.7.13", "browserify": "11.0.1", + "browserify-shim": "3.8.10", "cheerio": "0.19.0", + "dug.js": "kennethormandy/dug.js", "fg-loadcss": "0.1.6", "fg-loadjs": "0.2.0", "figment": "git://github.com/kennethormandy/figment.git#v0.6.2", @@ -57,6 +59,12 @@ "travis-ci": "2.0.3", "typogr": "kennethormandy/typogr.js#ko-wrapWidont" }, + "browserify": { + "transform": [ "browserify-shim" ] + }, + "browserify-shim": { + "./node_modules/dug/dug.js": { "exports": "dug" } + }, "standard": { "global": [ "loadCSS", @@ -68,17 +76,17 @@ ] }, "scripts": { - "postinstall": "cp ./node_modules/normalize.css/normalize.css ./node_modules/normalize.css/normalize.scss && cp ./node_modules/losttype-contributors/index.json ./src/authors.json", + "postinstall": "napa && cp ./node_modules/normalize.css/normalize.css ./node_modules/normalize.css/normalize.scss && cp ./node_modules/losttype-contributors/index.json ./src/authors.json", "lint": "standard src/js/*.js", "test": "echo \"Error: no test specified…yet! Pull requests on https://github.com/losttype/blog.losttype.com are greatly appreciated.\" && exit 0", "posttest": "npm run lint", "build-html": "node_modules/metalsmith/bin/metalsmith", "build-css": "node-sass src/css/index.scss | autoprefixer > build/css/index.css", - "build-js": "browserify src/js/index.js -o build/js/index.js", + "build-js": "browserify src/js/index.js -o build/js/index.js && browserify src/js/instagram.js -o build/js/instagram.js", "build": "npm run build-html && npm run build-css && npm run build-js", "watch-html": "onchange './_templates/*.hbs' './_includes/*.hbs' 'src/**/*.md' 'src/**/*.html' -- npm run build-html", "watch-css": "onchange './src/**/*.scss' -- npm run build-css", - "watch-js": "onchange './src/**/*.js' -- npm run build-js -- -dv", + "watch-js": "onchange './src/js/*' -- npm run build-js -- -dv", "sync": "browser-sync start --files './build/css/*.css' --server \"build\" --no-open", "start": "npm run build && npm run watch-html & npm run watch-css & npm run watch-js & npm run sync", "styleguide": "kss-node --source ./src/css --destination ./build/styleguide --css /css/index.css --placeholder=\"\" --homepage README.md", diff --git a/src/js/instagram.js b/src/js/instagram.js index 886805c..45ba7d2 100644 --- a/src/js/instagram.js +++ b/src/js/instagram.js @@ -1,26 +1,30 @@ var instaId = 'js-instagram' var instaEl = document.getElementById(instaId) var instaHashtag = instaEl.getAttribute('data-hashtag') || 'losttypecoop' +require('../../node_modules/dug.js/dug') -dug({ - target: instaId, - cacheExpire: '3600000', - endpoint: 'https://api.instagram.com/v1/tags/' + instaHashtag + '/media/recent?client_id=fad5f6d6043a4c9b9e456c7b0e0b359e', - beforeRender: function (feed) { - // feed.data.forEach(function (gram, i) { - // if(gram.user.username = 'rileycran' || (gram.location && gram.location.name === 'The Main') || (typeof gram.location === 'undefined' && gram.tags.length <= 3)) { - // } else { - // feed.data.splice(i, 1) - // } - // }) - // return feed - }, - template: '' + - '{{#data}}' + - '
  • ' + - '' + - '' + - '' + - '
  • ' + - '{{/data}}' - }) +console.log(dug()) + + +// dug({ +// target: instaId, +// cacheExpire: '3600000', +// endpoint: 'https://api.instagram.com/v1/tags/' + instaHashtag + '/media/recent?client_id=fad5f6d6043a4c9b9e456c7b0e0b359e', +// beforeRender: function (feed) { +// // feed.data.forEach(function (gram, i) { +// // if(gram.user.username = 'rileycran' || (gram.location && gram.location.name === 'The Main') || (typeof gram.location === 'undefined' && gram.tags.length <= 3)) { +// // } else { +// // feed.data.splice(i, 1) +// // } +// // }) +// // return feed +// }, +// template: '' + +// '{{#data}}' + +// '
  • ' + +// '' + +// '' + +// '' + +// '
  • ' + +// '{{/data}}' +// })