<commit_before>
function applyAngularPromiseHack(constructor, rootScope) {
  function apply(f) {
    return function() {
      var args = Array.prototype.slice.call(arguments);
      return rootScope.$apply(function() {
        return f.apply(this, args);
      });
    };
  }
  return function() {
    var promise = constructor.apply(this, arguments);
    var oldThen = promise.then;
    promise.then = function(_success, _failure) {
      var success = _success, failure = _failure;
      var angularPhase = rootScope.$$phase;
      if(angularPhase !== '$apply' &&
         angularPhase !== '$digest') {
        if(typeof(_success) === 'function') {
          success = apply(_success);
        }
        if(typeof(_failure) === 'function') {
          failure = apply(_failure);
        }
      }
      return oldThen(success, failure);
    };
    return promise;
  };
}

function initRemoteStorage($scope) {
  if(typeof($scope) !== 'undefined') {
    remoteStorage.util.getPromise = applyAngularPromiseHack(
      remoteStorage.util.getPromise, $scope.$root
    );
    promising = applyAngularPromiseHack(promising, $scope.$root);
  }
  remoteStorage.util.silenceAllLoggers();
  remoteStorage.defineModule('sockethub', function(privateClient, publicClient) {
    privateClient.declareType('config', {
      "description" : "sockethub config file",
      "type" : "object",
      "properties": {
        "host": {
          "type": "string",
          "description": "the hostname to connect to",
          "format": "uri",
          "required": true
        },
        "port": {
          "type": "number",
          "description": "the port number to connect to",
          "required": true
        },
        "secret": {
          "type": "string",
          "description": "the secret to identify yourself with the sockethub server",
          "required": true
        }
      }
    });

    return {
      exports: {
        getConfig: function() {
          return privateClient.getObject('config.json');
        },
        writeConfig: function(data) {
          //console.log(' [RS] writeConfig()');
          return privateClient.storeObject('config', 'config.json', data);
        }
      }
    };
  });

  remoteStorage.claimAccess('sockethub', 'rw').then(function() {
    remoteStorage.displayWidget('remotestorage-connect', {
      redirectUri: window.location.origin + '/rscallback.html'
    });
  });
}

<commit_msg>removed apply shim for now, to ease debugging woes<commit_after>

function initRemoteStorage($scope) {
  remoteStorage.util.silenceAllLoggers();
  remoteStorage.defineModule('sockethub', function(privateClient, publicClient) {
    privateClient.declareType('config', {
      "description" : "sockethub config file",
      "type" : "object",
      "properties": {
        "host": {
          "type": "string",
          "description": "the hostname to connect to",
          "format": "uri",
          "required": true
        },
        "port": {
          "type": "number",
          "description": "the port number to connect to",
          "required": true
        },
        "secret": {
          "type": "string",
          "description": "the secret to identify yourself with the sockethub server",
          "required": true
        }
      }
    });

    return {
      exports: {
        getConfig: function() {
          return privateClient.getObject('config.json');
        },
        writeConfig: function(data) {
          //console.log(' [RS] writeConfig()');
          return privateClient.storeObject('config', 'config.json', data);
        }
      }
    };
  });

  remoteStorage.claimAccess('sockethub', 'rw').then(function() {
    remoteStorage.displayWidget('remotestorage-connect', {
      redirectUri: window.location.origin + '/rscallback.html'
    });
  });
}


{'fraction_non_alphanumeric': 0.14450261780104712, 'fraction_numerical': 0.0, 'mean_word_length': 2.3934280639431615, 'pattern_counts': {'":': 28, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3041301', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1058, 'n_words': 221}