<commit_before>function Entry(data,host)
{
  this.host = host;

  this.message = data.message;
  this.ref = data.ref;
  this.timestamp = data.timestamp;
  this.id = data.id;
  this.editstamp = data.editstamp;
  this.media = data.media;
  this.target = data.target;
  this.whisper = data.whisper;

  if(this.target && !(this.target instanceof Array)){
    if(this.target.dat){ this.target = [this.target.dat]; }
    else{ this.target = [this.target ? this.target : ""]; }
  }

  this.quote = data.quote;
  if(data.quote && this.target && this.target[0]){
    var dummy_portal = {"url":this.target[0],"json":{"name":r.escape_html(portal_from_hash(this.target[0].toString())).substring(1)}};
    this.quote = new Entry(data.quote, dummy_portal);
  }
  this.expanded = false;

  this.is_seed = this.host ? r.home.portal.json.port.indexOf(this.host.url) > -1 : false;

  this.element = null;
  this.element_html = null;

  this.to_element = function(timeline, c, cmin, cmax)
  {
    if (c < cmin || cmax <= c) {
      // Out of bounds - remove if existing, don't add.
      if (this.element != null)
          timeline.removeChild(this.element);
      this.element = null;
      this.element_html = null;
      return null;
    }

    var html = this.to_html();
    if (this.element_html != html) {
      if (this.element == null) {
        // Thin wrapper required.
        this.element = document.createElement('div');
        this.element.className = 'thin-wrapper';
      }
      this.element.innerHTML = html;
      this.element_html = html;
    }
    // Always append as last.
    timeline.appendChild(this.element);
    return this.element;
  }

  this.to_json = function()
  {
    var quote_json = this.quote ? this.quote.to_json() : this.quote;
    return {message:this.message,timestamp:this.timestamp,editstamp:this.editstamp,media:this.media,target:this.target,ref:this.ref,quote:quote_json,whisper:this.whisper};
  }

  this.to_html = function()
  {
    var html = "";

    html += this.icon();
    html += this.header();
    html += this.body();
    if(this.quote){
      var thread_id = r.escape_html(this.host.json.name)+"-"+this.id;
      html += "<div class='thread'>"+this.quote.thread(this.expanded, thread_id)+"</div>";
    }
    html += this.rmc();

    return "<div class='entry "+(this.whisper ? 'whisper' : '')+" "+(this.is_mention ? 'mention' : '')+"'>"+html+"<hr/></div>";
  }

  this.icon = function()
  {
    return "<a href='"+this.host.url+"'><img class='icon' src='"+this.host.url+"/media/content/icon.svg'></a>";
  }

  this.header = function()
  {
    var html = ""

    html += "<t class='portal'><a href='"+this.host.url+"'>"+this.host.relationship()+r.escape_html(this.host.json.name)+"</a> "+this.rune()+" ";

    if(!this.expanded){
      for(i in this.target){
        if(this.target[i]){
          html += "<a href='" + r.escape_attr(this.target[i]) + "'>" + r.escape_html(portal_from_hash(this.target[i].toString())) + "</a>";
        }else{
          html += "...";
        }
        if(i != this.target.length-1){
          html += ", ";
        }
      }
    }

    html += "</t><t class='link' data-operation='filter:"+r.escape_attr(this.host.json.name)+"-"+this.id+"'>•</t>";

    var operation = '';
    if(this.host.json.name == r.home.portal.json.name)
      operation = 'edit:'+this.id+' '+this.message.replace(/\'/g,"&apos;");
    else if(this.whisper)
      operation = "whisper:"+this.host.json.name+" ";
    else
      operation = "quote:"+this.host.json.name+"-"+this.id+" ";

    html += this.editstamp ? "<c class='editstamp' data-operation='"+r.escape_attr(operation)+"' title='"+this.localtime()+"'>edited "+timeSince(this.editstamp)+" ago</c>" : "<c class='timestamp' data-operation='"+operation+"' title='"+this.localtime()+"'>"+timeSince(this.timestamp)+" ago</c>";

    html += this.host.json.name == r.home.portal.json.name && r.is_owner ? "<t class='tools'><t data-operation='delete:"+this.id+"'>del</t></t>" : "";

    return html+"<hr />";
  }

  this.body = function()
  {
    var html = "";
    html += "<t class='message' dir='auto'>"+(this.formatter(this.message))+"</t><br/>";
    return html;
  }

  this.thread = function(recursive, thread_id)
  {
    var html = "";
    if(recursive){
      html += "<div class='entry "+(this.whisper ? 'whisper' : '')+" "+(this.is_mention ? 'mention' : '')+"'>";
      html += this.icon();
      html += "<t class='portal'><a href='"+this.host.url+"'>"+r.escape_html(portal_from_hash(this.host.url.toString()))+"</a> "+this.rune()+" </t>";
      html += "<c class='timestamp' title='"+this.localtime()+"'>"+timeSince(this.timestamp)+" ago</c><hr />";
      html += "<t class='message' dir='auto'>"+(this.formatter(this.message))+"</t><br/></div>";
      if(this.quote){ html += this.quote.thread(recursive, thread_id); }
      else{ html += "<t class='expand' data-operation='collapse:"+thread_id+"' data-validate='true'>▲ collapse quotes</t><br/>"; }
    }
    else {
      html += "<t class='message' dir='auto'>"+(this.formatter(this.message))+"</t><br/>";
      var length = this.thread_length();
      if(length > 0){
        html += "<t class='expand' data-operation='expand:"+thread_id+"' data-validate='true'>▼ expand "+(length+1)+" quotes</t><br/>";
      }
    }
    return html;
  }

  this.rmc = function() // Rich Media Content
  {
    var html = "";
    if(this.media){
      // We hope that the URI's already encoded.
      // We can't encode it here as that'd break previously encoded URIs (see: operator.commands.say).
      var media = this.media;
      if (media.startsWith("/"))
        media = media.substring(1);
      else if (media.startsWith("%2F"))
        media = media.substring(3);
      if (media.startsWith("media/content/"))
        media = media.substring("media/content/".length);
      else if (media.startsWith("media%2Fcontent%2F"))
        media = media.substring("media%2Fcontent%2F".length);
      var parts = media.split(".")
      extension = parts[parts.length-1].toLowerCase();
      if (parts.length === 1) {
        media += ".jpg";
        extension = "jpg";
      } // support og media uploads
      audiotypes = ["m4a", "mp3", "oga", "ogg", "opus"];
      videotypes = ["mp4", "ogv", "webm"];
      imagetypes = ["apng", "gif", "jpg", "jpeg", "jpe", "png", "svg", "svgz", "tiff", "tif", "webp"];

      var origin = this.quote && this.target ? this.target : this.host.url;
      origin += origin.toString().slice(-1) == "/" ? "" : "/";

      if(audiotypes.indexOf(extension) > -1){ html += "<audio class='media' src='"+origin+"media/content/"+this.media+"' controls />"; }
      else if(videotypes.indexOf(extension) > -1){ html += "<video class='media' src='"+origin+"media/content/"+this.media+"' controls />"; }
      else if(imagetypes.indexOf(extension) > -1){ html += "<img class='media' src='"+origin+"media/content/"+this.media+"'/>"; }
      else{ html +="<a class='media' href='"+origin+"media/content/"+this.media+"'>&gt;&gt; "+this.media+"</a>"; }
    }
    return html;
  }

  this.rune = function()
  {
    if(this.whisper){
      return create_rune("feed", "whisper");<commit_msg>solved conflicts pt2<commit_after>function Entry(data,host)
{
  this.host = host;

  this.message = data.message;
  this.ref = data.ref;
  this.timestamp = data.timestamp;
  this.id = data.id;
  this.editstamp = data.editstamp;
  this.media = data.media;
  this.target = data.target;
  this.whisper = data.whisper;

  if(this.target && !(this.target instanceof Array)){
    if(this.target.dat){ this.target = [this.target.dat]; }
    else{ this.target = [this.target ? this.target : ""]; }
  }

  this.quote = data.quote;
  if(data.quote && this.target && this.target[0]){
    var dummy_portal = {"url":this.target[0],"json":{"name":r.escape_html(portal_from_hash(this.target[0].toString())).substring(1)}};
    this.quote = new Entry(data.quote, dummy_portal);
  }
  this.expanded = false;

  this.is_seed = this.host ? r.home.portal.json.port.indexOf(this.host.url) > -1 : false;

  this.element = null;
  this.element_html = null;

  this.to_element = function(timeline, c, cmin, cmax)
  {
    if (c < cmin || cmax <= c) {
      // Out of bounds - remove if existing, don't add.
      if (this.element != null)
          timeline.removeChild(this.element);
      this.element = null;
      this.element_html = null;
      return null;
    }

    var html = this.to_html();
    if (this.element_html != html) {
      if (this.element == null) {
        // Thin wrapper required.
        this.element = document.createElement('div');
        this.element.className = 'thin-wrapper';
      }
      this.element.innerHTML = html;
      this.element_html = html;
    }
    // Always append as last.
    timeline.appendChild(this.element);
    return this.element;
  }

  this.to_json = function()
  {
    var quote_json = this.quote ? this.quote.to_json() : this.quote;
    return {message:this.message,timestamp:this.timestamp,editstamp:this.editstamp,media:this.media,target:this.target,ref:this.ref,quote:quote_json,whisper:this.whisper};
  }

  this.to_html = function()
  {
    var html = "";

    html += this.icon();
    html += this.header();
    html += this.body();
    if(this.quote){
      var thread_id = r.escape_html(this.host.json.name)+"-"+this.id;
      html += "<div class='thread'>"+this.quote.thread(this.expanded, thread_id)+"</div>";
    }
    html += this.rmc();

    return "<div class='entry "+(this.whisper ? 'whisper' : '')+" "+(this.is_mention ? 'mention' : '')+"'>"+html+"<hr/></div>";
  }

  this.icon = function()
  {
    return "<a href='"+this.host.url+"'><img class='icon' src='"+this.host.url+"/media/content/icon.svg'></a>";
  }

  this.header = function()
  {
    var html = ""

    html += "<t class='portal'><a href='"+this.host.url+"'>"+this.host.relationship()+r.escape_html(this.host.json.name)+"</a> "+this.rune()+" ";

    if(!this.expanded){
      for(i in this.target){
        if(this.target[i]){
          html += "<a href='" + r.escape_attr(this.target[i]) + "'>" + r.escape_html(portal_from_hash(this.target[i].toString())) + "</a>";
        }else{
          html += "...";
        }
        if(i != this.target.length-1){
          html += ", ";
        }
      }
    }

    html += "</t><t class='link' data-operation='filter:"+r.escape_attr(this.host.json.name)+"-"+this.id+"'>•</t>";

    var operation = '';
    if(this.host.json.name == r.home.portal.json.name)
      operation = 'edit:'+this.id+' '+this.message.replace(/\'/g,"&apos;");
    else if(this.whisper)
      operation = "whisper:"+this.host.json.name+" ";
    else
      operation = "quote:"+this.host.json.name+"-"+this.id+" ";

    html += this.editstamp ? "<c class='editstamp' data-operation='"+r.escape_attr(operation)+"' title='"+this.localtime()+"'>edited "+timeSince(this.editstamp)+" ago</c>" : "<c class='timestamp' data-operation='"+operation+"' title='"+this.localtime()+"'>"+timeSince(this.timestamp)+" ago</c>";

    html += this.host.json.name == r.home.portal.json.name && r.is_owner ? "<t class='tools'><t data-operation='delete:"+this.id+"'>del</t></t>" : "";

    return html+"<hr />";
  }

  this.body = function()
  {
    var html = "";
    html += "<t class='message' dir='auto'>"+(this.formatter(this.message))+"</t><br/>";
    return html;
  }

  this.thread = function(recursive, thread_id)
  {
    var html = "";
    if(recursive){
      html += "<div class='entry "+(this.whisper ? 'whisper' : '')+" "+(this.is_mention ? 'mention' : '')+"'>";
      html += this.icon();
      html += "<t class='portal'><a href='"+this.host.url+"'>"+r.escape_html(portal_from_hash(this.host.url.toString()))+"</a> "+this.rune()+" </t>";
      html += "<c class='timestamp' title='"+this.localtime()+"'>"+timeSince(this.timestamp)+" ago</c><hr />";
      html += "<t class='message' dir='auto'>"+(this.formatter(this.message))+"</t><br/></div>";
      if(this.quote){ html += this.quote.thread(recursive, thread_id); }
      else{ html += "<t class='expand' data-operation='collapse:"+thread_id+"' data-validate='true'>▲ collapse quotes</t><br/>"; }
    }
    else {
      html += "<t class='message' dir='auto'>"+(this.formatter(this.message))+"</t><br/>";
      var length = this.thread_length();
      if(length > 0){
        html += "<t class='expand' data-operation='expand:"+thread_id+"' data-validate='true'>▼ expand "+(length+1)+" quotes</t><br/>";
      }
    }
    return html;
  }

  this.rmc = function() // Rich Media Content
  {
    var html = "";
    if(this.media){
      // We hope that the URI's already encoded.
      // We can't encode it here as that'd break previously encoded URIs (see: operator.commands.say).
      var media = this.media;
      if (media.startsWith("/"))
        media = media.substring(1);
      else if (media.startsWith("%2F"))
        media = media.substring(3);
      if (media.startsWith("media/content/"))
        media = media.substring("media/content/".length);
      else if (media.startsWith("media%2Fcontent%2F"))
        media = media.substring("media%2Fcontent%2F".length);
      var parts = media.split(".")
      extension = parts[parts.length-1].toLowerCase();
      if (parts.length === 1) {
        media += ".jpg";
        extension = "jpg";
      } // support og media uploads
      audiotypes = ["m4a", "mp3", "oga", "ogg", "opus"];
      videotypes = ["mp4", "ogv", "webm"];
      imagetypes = ["apng", "gif", "jpg", "jpeg", "jpe", "png", "svg", "svgz", "tiff", "tif", "webp"];

      var origin = this.quote && this.target ? this.target : this.host.url;
      origin += origin.toString().slice(-1) == "/" ? "" : "/";

      if(audiotypes.indexOf(extension) > -1){ html += "<audio class='media' src='"+origin+"media/content/"+media+"' controls />"; }
      else if(videotypes.indexOf(extension) > -1){ html += "<video class='media' src='"+origin+"media/content/"+media+"' controls />"; }
      else if(imagetypes.indexOf(extension) > -1){ html += "<img class='media' src='"+origin+"media/content/"+media+"'/>"; }
      else{ html +="<a class='media' href='"+origin+"media/content/"+media+"'>&gt;&gt; "+media+"</a>"; }
    }
    return html;
  }

  this.rune = function()
  {
    if(this.whisper){
      return create_rune("feed", "whisper");
{'fraction_non_alphanumeric': 0.21810670774401344, 'fraction_numerical': 0.003430892031928301, 'mean_word_length': 3.1836555360281196, 'pattern_counts': {'":': 6, '<': 115, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1152337', 'n_tokens_mistral': 4989, 'n_tokens_neox': 4908, 'n_words': 843}