<commit_before>var template = require('./template.ejs');
var entryModel = require('../../../Entriex/Entry/model');
var attachmentModel = require('../../../Attachments/Attachment/model');
var bus = require('tresdb-bus');
var ui = require('tresdb-ui');

module.exports = function (entry) {
  // Parameters:
  //   entry
  //     entry object.

  var route = null;

  // Public methods

  this.bind = function ($mount) {
    $mount.html(template({
      entry: entry,
    }));

    var route = bus.on(
      'location_entry_changed',
      entryModel.handlerFor(entry, function (ev) {
        // If entry still has an image, replace the image.
        var firstImage = entryModel.getImage(entry);
        if (firstImage) {
          var $img = $mount.find('img');
          $img.attr('src', attachmentModel.getThumbUrl(firstImage));
          $img.attr('title', attachmentModel.getFileName(firstImage));
        } else {
          // No image anymore. Hide.
          ui.hide($mount);
        }
      })
    );
  };

  this.unbind = function () {
    bus.off(route);
  };
};
<commit_msg>Use entryModel.bus<commit_after>var template = require('./template.ejs');
var entryModel = require('../../../Entriex/Entry/model');
var attachmentModel = require('../../../Attachments/Attachment/model');
var ui = require('tresdb-ui');

module.exports = function (entry) {
  // Parameters:
  //   entry
  //     entry object.
  //
  var route = null;
  var bus = entryModel.bus(entry);

  // Public methods

  this.bind = function ($mount) {
    $mount.html(template({
      entry: entry,
    }));

    bus.on('location_entry_changed', function (ev) {
      // If entry still has an image, replace the image.
      var firstImage = entryModel.getImage(entry);
      if (firstImage) {
        var $img = $mount.find('img');
        $img.attr('src', attachmentModel.getThumbUrl(firstImage));
        $img.attr('title', attachmentModel.getFileName(firstImage));
      } else {
        // No image anymore. Hide.
        ui.hide($mount);
      }
    });
  };

  this.unbind = function () {
    bus.off();
  };
};

{'fraction_non_alphanumeric': 0.1701720841300191, 'fraction_numerical': 0.0, 'mean_word_length': 2.4199346405228757, 'pattern_counts': {'":': 0, '<': 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': '6612179', 'n_tokens_mistral': 641, 'n_tokens_neox': 636, 'n_words': 137}