<commit_before>export default Ember.ObjectController.extend({
  themes   : null,
  isSending: false,
  success  : false,
  error    : null,
  customUrl: '',

  actions: {
    downloadPreset: function (theme) {

      this.setProperties({
        success: false,
        error: null
      });

      this.set('isSending', true);
      window.ENV.sendGruntCommand('preset:' + theme.url, function(data) {

        if (Ember.isNone(data.data) && Ember.isNone(data.contentType)) {
          data = { contentType: data };
        }

        window.ENV.firebase.update(data, function(err) {
          window.ENV.sendGruntCommand('build', function() {
            this.set('isSending', false);
            this.send('notify', 'success', 'Theme installation complete.');
            this.transitionToRoute('wh');
          }.bind(this));
        }.bind(this));
      }.bind(this));
    },

    downloadCustom: function () {

      this.setProperties({
        success: false,
        error: null
      });

      if(!this.get('customUrl')) {
        this.set('error', { message: 'Please provide a custom URL.' });
        return;
      }

      this.set('isSending', true);
      window.ENV.sendGruntCommand('preset:' + this.get('customUrl'), function(data) {

        if (Ember.isNone(data.data) && Ember.isNone(data.contentType)) {
          data = { contentType: data };
        }

        window.ENV.firebase.update(data, function(err) {
          window.ENV.sendGruntCommand('build', function() {
            this.set('isSending', false);
            this.send('notify', 'success', 'Theme installation complete.');
            this.transitionToRoute('wh');
          }.bind(this));
        }.bind(this));
      }.bind(this));
    },

    localThemeSelected: function (file) {

      var reader = new FileReader();

      reader.onload = function(e) {
        window.ENV.sendGruntCommand('preset_local:' + e.target.result, function () {
          window.console.log(arguments);
        });
      };

      reader.readAsText(file);

    }
  }
});
<commit_msg>use data url to create base64 string<commit_after>export default Ember.ObjectController.extend({
  themes   : null,
  isSending: false,
  success  : false,
  error    : null,
  customUrl: '',

  actions: {
    downloadPreset: function (theme) {

      this.setProperties({
        success: false,
        error: null
      });

      this.set('isSending', true);
      window.ENV.sendGruntCommand('preset:' + theme.url, function(data) {

        if (Ember.isNone(data.data) && Ember.isNone(data.contentType)) {
          data = { contentType: data };
        }

        window.ENV.firebase.update(data, function(err) {
          window.ENV.sendGruntCommand('build', function() {
            this.set('isSending', false);
            this.send('notify', 'success', 'Theme installation complete.');
            this.transitionToRoute('wh');
          }.bind(this));
        }.bind(this));
      }.bind(this));
    },

    downloadCustom: function () {

      this.setProperties({
        success: false,
        error: null
      });

      if(!this.get('customUrl')) {
        this.set('error', { message: 'Please provide a custom URL.' });
        return;
      }

      this.set('isSending', true);
      window.ENV.sendGruntCommand('preset:' + this.get('customUrl'), function(data) {

        if (Ember.isNone(data.data) && Ember.isNone(data.contentType)) {
          data = { contentType: data };
        }

        window.ENV.firebase.update(data, function(err) {
          window.ENV.sendGruntCommand('build', function() {
            this.set('isSending', false);
            this.send('notify', 'success', 'Theme installation complete.');
            this.transitionToRoute('wh');
          }.bind(this));
        }.bind(this));
      }.bind(this));
    },

    localThemeSelected: function (file) {

      var reader = new window.FileReader();

      reader.onload = function(e) {

        // strip off 'data:application/zip;base64,'
        var base64Data = e.target.result.split(',').slice(1).join(',');

        window.ENV.sendGruntCommand('preset_local:' + base64Data, function () {
          window.console.log(arguments);
        });
      };

      reader.readAsDataURL(file);

    }
  }
});

{'fraction_non_alphanumeric': 0.1572769953051643, 'fraction_numerical': 0.002112676056338028, 'mean_word_length': 2.267638036809816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2192481', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1246, 'n_words': 218}