lib/tumblrrr.js
function tumblr(hostname, key, secret, access_key, access_secret) {
  if (!(this instanceof tumblr)) return new tumblr(hostname, key, secret, access_key, access_secret);

  var obj = (typeof hostname !== 'object') ? {
    hostname : hostname,
    secret : secret,
    key : key,
    access_secret : access_secret,
    access_key : access_key
  } : hostname;

  // reference
  if (obj && obj.hostname) this.hostname = !/\./.test(obj.hostname) ? obj.hostname + '.tumblr.com' : obj.hostname;
  this.key = obj.key;
  this.secret = obj.secret;
  this.access_key = obj.access_key;
  this.access_secret = obj.access_secret;

  // output the log to console
  this.debug = false;

  // keeping the logs even if debug is false
  this.log = [];

  // caching requests
  this.caches = false;
  this._cache = {};

  // oauth access
  this._oauth_access = this.access_key && this.access_secret;

  // if response should omit "meta"
  this.onlyResponse = true;

  if (this.key && this.secret && this._oauth_access) {
    this._oa = oa = new OAuth('http://www.tumblr.com/oauth/request_token',
                              'http://www.tumblr.com/oauth/access_token',
                              this.key, this.secret, '1.0A',
                              null, 'HMAC-SHA1');

    var self = this;
    oa.getOAuthRequestToken(function(err, req_key, req_secret, res) {
      if (!err) {
        var url = ['http://www.tumblr.com/oauth/authorize/?oauth_token=', req_key].join('');
        self.OAuthAuthorizationURL = url;
        self._oa.session = self._oa.session || {};
        self._oa.session.key = req_key;
        self._oa.session.secret = req_secret;
      }
      else {
        debug(err);
      }
    });
  }
  return this;
}
function tumblr(hostname, key, secret, access_key, access_secret) {
  if (!(this instanceof tumblr)) return new tumblr(hostname, key, secret, access_key, access_secret);

  var obj = (typeof hostname !== 'object') ? {
    hostname : hostname,
    secret : secret,
    key : key,
    access_secret : access_secret,
    access_key : access_key
  } : hostname;

  // reference
  if (obj && obj.hostname) this.hostname = !/\./.test(obj.hostname) ? obj.hostname + '.tumblr.com' : obj.hostname;
  this.key = obj.key;
  this.secret = obj.secret;
  this.access_key = obj.access_key;
  this.access_secret = obj.access_secret;

  // output the log to console
  this.debug = false;

  // keeping the logs even if debug is false
  this.log = [];

  // caching requests
  this.caches = false;
  this._cache = {};

  // oauth access
  this._oauth_access = this.access_key && this.access_secret;

  // if response should omit "meta"
  this.onlyResponse = true;

  if (this.key && this.secret && this._oauth_access) {
    this._oa = oa = new OAuth('http://www.tumblr.com/oauth/request_token',
                              'http://www.tumblr.com/oauth/access_token',
                              this.key, this.secret, '1.0A',
                              null, 'HMAC-SHA1');

    var self = this;
    oa.getOAuthRequestToken(function(err, req_key, req_secret, res) {
      if (!err) {
        var url = ['http://www.tumblr.com/oauth/authorize/?oauth_token=', req_key].join('');
        self.OAuthAuthorizationURL = url;
        self._oa.session = self._oa.session || {};
        self._oa.session.key = req_key;
        self._oa.session.secret = req_secret;
      }
      else {
        debug(err);
      }
    });
  }
  return this;
}
function tumblr ( hostname , key , secret , access_key , access_secret ) { if ( ! ( this instanceof tumblr ) ) return new tumblr ( hostname , key , secret , access_key , access_secret ) ; var obj = ( typeof hostname !== 'object' ) ? { hostname : hostname , secret : secret , key : key , access_secret : access_secret , access_key : access_key } : hostname ; // reference if ( obj && obj . hostname ) this . hostname = ! / \. / . test ( obj . hostname ) ? obj . hostname + '.tumblr.com' : obj . hostname ; this . key = obj . key ; this . secret = obj . secret ; this . access_key = obj . access_key ; this . access_secret = obj . access_secret ; // output the log to console this . debug = false ; // keeping the logs even if debug is false this . log = [ ] ; // caching requests this . caches = false ; this . _cache = { } ; // oauth access this . _oauth_access = this . access_key && this . access_secret ; // if response should omit "meta" this . onlyResponse = true ; if ( this . key && this . secret && this . _oauth_access ) { this . _oa = oa = new OAuth ( 'http://www.tumblr.com/oauth/request_token' , 'http://www.tumblr.com/oauth/access_token' , this . key , this . secret , '1.0A' , null , 'HMAC-SHA1' ) ; var self = this ; oa . getOAuthRequestToken ( function ( err , req_key , req_secret , res ) { if ( ! err ) { var url = [ 'http://www.tumblr.com/oauth/authorize/?oauth_token=' , req_key ] . join ( '' ) ; self . OAuthAuthorizationURL = url ; self . _oa . session = self . _oa . session || { } ; self . _oa . session . key = req_key ; self . _oa . session . secret = req_secret ; } else { debug ( err ) ; } } ) ; } return this ; }
first argument can be string or object
first argument can be string or object