<commit_before>var _ = require('underscore');
var DocumentNode = require('../node/node');

// Substance.Contributor
// -----------------
//

var Contributor = function(node, doc) {
  DocumentNode.call(this, node, doc);
};


// Type definition
// -----------------
//

Contributor.type = {
  "id": "contributor",
  "parent": "content",
  "properties": {
    "source_id": "string",
    "name": "string", // full author name
    "role": "string",
    "organization": "string",
    "image": "string", // optional
    "email": "string",
    "contribution": "string"
  }
};

// This is used for the auto-generated docs
// -----------------
//

Contributor.description = {
  "name": "Contributor",
  "remarks": [
    "Describes an article contributor such as an author or editor.",
  ],
  "properties": {
    "name": "Full name.",
  }
};

// Example Video
// -----------------
//

Contributor.example = {
  "id": "contributor_1",
  "type": "contributor",
  "role": "author",
  "name": "<NAME>",
  "image": "http://john.com/doe.png",
  "email": "<EMAIL>",
  "contribution": "Revising the article, data cleanup"
};


Contributor.Prototype = function() {
  this.getAffiliations = function() {
    return _.map(this.properties.affiliations, function(affId) {
      return this.document.get(affId);
    }, this);
  };
};

Contributor.Prototype.prototype = DocumentNode.prototype;
Contributor.prototype = new Contributor.Prototype();
Contributor.prototype.constructor = Contributor;

Contributor.prototype.defineProperties();

// Property aliases
// ----

Object.defineProperties(Contributor.prototype, {
  "header": {
    get: function() { return this.properties.name; },
    set: function() { throw new Error("This is a read-only alias property."); }
  }
});

module.exports = Contributor;<commit_msg>Blob support for collab images.<commit_after>var _ = require('underscore');
var DocumentNode = require('../node/node');

// Substance.Contributor
// -----------------
//

var Contributor = function(node, doc) {
  DocumentNode.call(this, node, doc);
};


// Type definition
// -----------------
//

Contributor.type = {
  "id": "contributor",
  "parent": "content",
  "properties": {
    "source_id": "string",
    "name": "string", // full author name
    "role": "string",
    "organization": "string",
    "image": "blob", // optional
    "url": "string", // TODO: rename to image_url
    "email": "string",
    "contribution": "string"
  }
};

// This is used for the auto-generated docs
// -----------------
//

Contributor.description = {
  "name": "Contributor",
  "remarks": [
    "Describes an article contributor such as an author or editor.",
  ],
  "properties": {
    "name": "Full name.",
  }
};

// Example Video
// -----------------
//

Contributor.example = {
  "id": "contributor_1",
  "type": "contributor",
  "role": "author",
  "name": "<NAME>",
  "image": "http://john.com/doe.png",
  "email": "<EMAIL>",
  "contribution": "Revising the article, data cleanup"
};


Contributor.Prototype = function() {
  this.getAffiliations = function() {
    return _.map(this.properties.affiliations, function(affId) {
      return this.document.get(affId);
    }, this);
  };

  this.getBlob = function() {
    return this.document.getBlob(this.properties.image);
  };

  // Depending on wheter there is a blob it returns either the blob url or a regular image url
  // --------
  // 

  this.getUrl = function() {
    var blob = this.getBlob();
    if (blob) {
      return window.URL.createObjectURL(blob);
    } else {
      return this.properties.url || "styles/contributor-image-placeholder.png";
    }
  };
};

Contributor.Prototype.prototype = DocumentNode.prototype;
Contributor.prototype = new Contributor.Prototype();
Contributor.prototype.constructor = Contributor;

Contributor.prototype.defineProperties();

// Property aliases
// ----

Object.defineProperties(Contributor.prototype, {
  "header": {
    get: function() { return this.properties.name; },
    set: function() { throw new Error("This is a read-only alias property."); }
  }
});

module.exports = Contributor;
{'fraction_non_alphanumeric': 0.2032819005633113, 'fraction_numerical': 0.0004898359049718344, 'mean_word_length': 2.9382835101253617, 'pattern_counts': {'":': 45, '<': 7, '<?xml version=': 0, '>': 7, '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': '7635186', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1248, 'n_words': 290}