<commit_before>App = Ember.Application.create({
    //  LOG_STACKTRACE_ON_DEPRECATION : true,
    // LOG_BINDINGS                  : true,
    LOG_TRANSITIONS               : true,
    LOG_TRANSITIONS_INTERNAL      : false,
    // LOG_VIEW_LOOKUPS              : true,
    // LOG_ACTIVE_GENERATION         : true 
});

App.Router.map(function() {
  this.route("catchme", { path: "*:"});
  this.resource("instagram");
  this.resource("instagramauth");
});

App.IndexRoute = Ember.Route.extend({ 
    redirect: function() {
      this.transitionTo('instagram');
  }
});

App.CatchmeRoute = Em.Route.extend({
  setupController: function() {
    localStorage.instagramtoken = window.location.hash.split("=")[1];
    console.log("access_token: " + localStorage.instagramtoken);
    this.transitionTo('instagram');
  }
});



App.InstagramauthRoute = Em.Route.extend({
	model: function() { 
    console.log("in model: of authroute");
    var redirect_uri = 'http://sandalsoft.com/Oauth-demo/index.html%23/instagramauth';
    var client_id = '0bc1b880b6934131be1aba1d76423980';
    var url = 'https://instagram.com/oauth/authorize/?client_id=' + client_id + '&redirect_uri=' + redirect_uri + '&response_type=token';
    return url;
	}
});

App.InstagramController = Em.ArrayController.extend({
  instagramtoken: localStorage.instagramtoken,
  instagramtokenChanged: function() {
      localStorage.instagramtoken = this.get('instagramtoken');
   }.observes('instagramtoken'),

});

App.InstagramRoute = Ember.Route.extend({
  events: {
      error: function(reason, transition) {
          if (reason.code === 400) {
              console.log('in evetns hook.  Unauthorized, redirecting to: Instagramauth');
  
              this.transitionTo('instagramauth');
          } else {
              console.log('err.  reason.code: ' + JSON.stringify(reason));
          }
      }
  },
  model: function(params, transition) {
      var promise = new Ember.RSVP.Promise(function(resolve, reject){
        console.log("token: " + localStorage.instagramtoken);
          $.ajax({
            url:"https://api.instagram.com/v1/users/1574083/media/recent?access_token=" + localStorage.instagramtoken,
            // url:"https://api.instagram.com/v1/media/popular?client_id=<KEY>",
            type:'GET',
            dataType:'JSONP',
            }).then(function(json){
                if (json.meta.code ===400) {
                    console.log("reject json: " + JSON.stringify(json));
                    reject(json.meta);
                }
                else {
                    // console.log("RESOLVE json: " + JSON.stringify(json));
                    resolve(json.data);
                }   
        });
      })
      return promise;
  }
});

App.LoadingRoute = Ember.Route.extend({});


// App.Instagram = Em.Object.extend({

// });

// App.Instagram.reopenClass ({
// 	clientId: '<KEY>',
// 	redirectUri: 'http://sandalsoft.com/Oauth-demo/index.html#/instagram',
// 	authURL: 'https://instagram.com/oauth/authorize/?client_id=' + '<KEY>' + '&redirect_uri=' + 'file:///Users/Eric/Development/Projects/js/_Ember/Oauth-demo/index.html#/instagram' + '&response_type=token',
// 	token: localStorage.Instagram_token,
// 	tokenChanged: function() {
// 	   localStorage.token = this.get('Instagram_token');
// 	 }.observes('token')
// });<commit_msg>- auth is working, still need to get token farming from url sorted out with the proper routes and such. - make display page make more sense with its' layout - work on redirects and modals for auth<commit_after>App = Ember.Application.create({
    //  LOG_STACKTRACE_ON_DEPRECATION : true,
    // LOG_BINDINGS                  : true,
    LOG_TRANSITIONS               : true,
    LOG_TRANSITIONS_INTERNAL      : false,
    // LOG_VIEW_LOOKUPS              : true,
    // LOG_ACTIVE_GENERATION         : true 
});

App.Router.map(function() {
  this.route("catchme", { path: "*:"});
  this.resource("instagram");
  this.resource("instagramauth");
});

App.IndexRoute = Ember.Route.extend({ 
    redirect: function() {
      this.transitionTo('instagram');
  }
});

App.CatchmeRoute = Em.Route.extend({
  setupController: function() {
    localStorage.instagramtoken = window.location.hash.split("=")[1];
    console.log("access_token: " + localStorage.instagramtoken);
    this.transitionTo('instagram');
  }
});



App.InstagramauthRoute = Em.Route.extend({
	model: function() { 
    console.log("in model: of authroute");
    var redirect_uri = 'http://sandalsoft.com/Oauth-demo/index.html%23/instagramauth';
    var client_id = '0bc1b880b6934131be1aba1d76423980';
    var url = 'https://instagram.com/oauth/authorize/?client_id=' + client_id + '&redirect_uri=' + redirect_uri + '&response_type=token';
    return url;
	}
});

App.InstagramController = Em.ArrayController.extend({
  instagramtoken: localStorage.instagramtoken,
  instagramtokenChanged: function() {
      localStorage.instagramtoken = this.get('instagramtoken');
   }.observes('instagramtoken'),

});

App.InstagramRoute = Ember.Route.extend({
  events: {
      error: function(reason, transition) {
          if (reason.code === 400) {
              console.log('in evetns hook.  Unauthorized, redirecting to: Instagramauth');
  
              this.transitionTo('instagramauth');
          } else {
              console.log('err.  reason.code: ' + JSON.stringify(reason));
          }
      }
  },
  model: function(params, transition) {
      var promise = new Ember.RSVP.Promise(function(resolve, reject){
        console.log("token: " + localStorage.instagramtoken);
          $.ajax({
            url:"https://api.instagram.com/v1/users/1574083/media/recent?access_token=" + localStorage.instagramtoken,
            // url:"https://api.instagram.com/v1/media/popular?client_id=<KEY>",
            type:'GET',
            dataType:'JSONP',
            }).then(function(json){
                if (json.meta.code ===400) {
                    console.log("reject json: " + JSON.stringify(json));
                    reject(json.meta);
                }
                else {
                    // console.log("RESOLVE json: " + JSON.stringify(json)); 
                    resolve(json.data);
                }   
        });
      })
      return promise;
  }
});

App.LoadingRoute = Ember.Route.extend({});


// App.Instagram = Em.Object.extend({

// });

// App.Instagram.reopenClass ({
// 	clientId: '<KEY>',
// 	redirectUri: 'http://sandalsoft.com/Oauth-demo/index.html#/instagram',
// 	authURL: 'https://instagram.com/oauth/authorize/?client_id=' + '<KEY>' + '&redirect_uri=' + 'file:///Users/Eric/Development/Projects/js/_Ember/Oauth-demo/index.html#/instagram' + '&response_type=token',
// 	token: localStorage.Instagram_token,
// 	tokenChanged: function() {
// 	   localStorage.token = this.get('Instagram_token');
// 	 }.observes('token')
// });
{'fraction_non_alphanumeric': 0.15836972343522562, 'fraction_numerical': 0.011644832605531296, 'mean_word_length': 2.6450928381962866, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3450832', 'n_tokens_mistral': 2228, 'n_tokens_neox': 2143, 'n_words': 313}