Coder Social home page Coder Social logo

jreisdorff / music-explorer-app Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 276 KB

App that allows you to look at bands you've liked on Facebook.

Home Page: https://8b904121b1b5257dfac23ab517c097c985b809c1.googledrive.com/host/0ByHlBhlCyVS9Z2pkRE51UWFpM00/index.html

CSS 30.37% JavaScript 69.63%

music-explorer-app's Introduction

#Introduction

App that allows you to look at bands you've liked on Facebook.

Written using AngularJS, Facebook Graph API, and Twitter Bootstrap using test driven methodology.

#General

##js/app.js

This is where I've layed out the angularJS code which makes calls to the Facebook graph API.

Angular service functions:

##getMusic(FB, pagingUrl)

Arguments: FB - Used to check login status, then make the API call

pagingUrl - Used to get more recently liked bands

This function, when the pagingUrl variable is not present (on the first call), returns the user's 27 most recently liked Facebook music pages via the following graph API call (The number 27 is hardcoded simply for demonstration purposes):

###/v2.0/me?fields=music.limit(27)

The music field that is returned is an array that has the name, category, and id of each band.

If the user has more than 27 bands liked, the data returned on the first call includes a paging URL. Calling that paging URL retrieves the next 27 most recently liked bands. Both the initial call and each paging call use this same function to call the graph API.

Once returned, this data is set to the music scope. To access values in this scope we can simply write the following:

music.data.name (retrieves band name) or music.data.category (retrieves band category)

##getMusicDetails(FB, bandId)

This function is used to retrieve details about a particular band/musician. The following graph API call is used:

###/v2.0/bandId?fields=about,name,cover

The fields returned by this call include about (usually a short description/tagline of the band), name (again), and cover array which includes a cover photo id, and a field called source which is a direct link to that pages cover photo.

The results are then set to the details scope, which we access in the html via:

details.about details.cover.source (the direct link to the cover photo)

###Directive

I've created a directive called backImg that allows me to easily change the background image on the fly of the element in which it is placed. In this case, the method modifies the css of the div in which it is referenced.

##index.html

The page style was adapted from this twitter bootstrap example: http://getbootstrap.com/examples/jumbotron/. I had spent a lot of time trying to write the css for this page on my own, then realized that I could use bootstrap to allow myself more time to focus on working with Angular and the Graph API. Another great benefit of using bootstrap is that it takes advantage of responsive design, allowing the page to load well in a variety of platforms, from desktop to mobile.

In this html, I used ng-show and ng-hide to dynamically show or hide elements on the page, depending on which data is available from the graph API calls at the time. I'm using the ng-repeat directive and looping via "m in music.data" to dynamically create the div for each band.

Scripts are placed at the bottom of the document for quick page load times.

music-explorer-app's People

Contributors

jakemh avatar jreisdorff avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.