<commit_before>/*******************************************************
 * todo-mvc implementation based on ALPS doc
 * cj representor (server)
 * May 2015
 * <NAME> (@mamund)
 * Soundtrack : Complete Collection : B.B. Kind (2008)
 *******************************************************/

// json representor
module.exports = cj;

function cj(object, root) {

  console.log(JSON.stringify(object, null, 2));
  
  var rtn = {};
  rtn.collection = {};

  rtn.collection.version = "1.0";
  rtn.collection.href = root;
  rtn.collection.title = "ToDo MVC";

  // hacked.
  for(var o in object) {
    rtn.collection.links = getLinks(object[o].actions);
    rtn.collection.items = getItems(object[o].data);
    rtn.collection.queries = getQueries(object[o].actions);
    rtn.collection.template = getTemplate(object[o].actions)
  
    if(object.error) {
      rtn.collection.error = buildError(object.error);
    }
  }
  
  return JSON.stringify(rtn, null, 2);
}

function getLinks(obj, root) {
  var link, rtn, i, x;

  rtn = [];<commit_msg>add support for cj title<commit_after>/*******************************************************
 * todo-mvc implementation based on ALPS doc
 * cj representor (server)
 * May 2015
 * <NAME> (@mamund)
 * Soundtrack : Complete Collection : B.B. Kind (2008)
 *******************************************************/

// json representor
module.exports = cj;

function cj(object, root) {

  console.log(JSON.stringify(object, null, 2));
  
  var rtn = {};
  rtn.collection = {};

  rtn.collection.version = "1.0";
  rtn.collection.href = root;

  // hacked.
  for(var o in object) {
    
    rtn.collection.title = getTitle(object[o]);
    rtn.collection.links = getLinks(object[o].actions);
    rtn.collection.items = getItems(object[o].data);
    rtn.collection.queries = getQueries(object[o].actions);
    rtn.collection.template = getTemplate(object[o].actions)
  
    if(object.error) {
      rtn.collection.error = buildError(object.error);
    }
  }
  
  return JSON.stringify(rtn, null, 2);
}

function getTitle(obj) {
  return obj.prompt||"Cj Browser";
}

function getLinks(obj, root) {
  var link, rtn, i, x;

  rtn = [];
{'fraction_non_alphanumeric': 0.23774283071230343, 'fraction_numerical': 0.011100832562442183, 'mean_word_length': 3.8066666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7417251', 'n_tokens_mistral': 738, 'n_tokens_neox': 702, 'n_words': 146}