<commit_before>cleverNote.Views.Sidebar = Backbone.CompositeView.extend({
  tagName: 'nav',
  className: 'navbar navbar-default navbar-static-top',
  attributes: {role: 'navigation', style: 'margin-bottom: 0'},
  template: JST['sidebar'],


  initialize: function (options) {
    this.notebooks = options.notebooks;
    this.tags = options.tags;
    this.addNavLinks();
    this.addIndexView(this.notebooks);
    this.addIndexView(this.tags);
    //TODO: need to add a logout button
  },

  logOut: function () {
    $.ajax({
      url: "/session",
      method: "delete",
    });
    window.location.replace('session/new');
  },

  addNavLinks: function () {
    var homeParams = {
      title: 'Home',
      destination: '#'
    };
    var newNoteParams = {
      title: 'New Note',
      destination: '#notes/new'
    };
    _([homeParams, newNoteParams]).each(this.addItemView.bind(this));
  },

  addIndexView: function(items) {
    var subview = new cleverNote.Views.noteContainerIndex({ collection: items });
    this.addSubview('ul.metismenu', subview);
  },

  addItemView: function(params) {
    var subview = new cleverNote.Views.notesContainerIndexItem(params);
    this.addSubview('ul.metismenu', subview);
  },


  removeItemView: function(item) {
    this.rmeoveModelSubview('ul.meismenu', item);
  },

  onRender: function () {
    $('#side-menu').metisMenu();
  },

  render: function () {
    var content = this.template();
    this.$el.html(content);
    this.attachSubviews();
    this.onRender();
    return this;
  }
});<commit_msg>Add logout link to the new sidebar<commit_after>cleverNote.Views.Sidebar = Backbone.CompositeView.extend({
  tagName: 'nav',
  className: 'navbar navbar-default navbar-static-top',
  attributes: {role: 'navigation', style: 'margin-bottom: 0'},
  template: JST['sidebar'],

  events: {
    'click a.logout': 'logOut'
  },

  initialize: function (options) {
    this.notebooks = options.notebooks;
    this.tags = options.tags;
    this.addNavLinks();
    this.addIndexView(this.notebooks);
    this.addIndexView(this.tags);
    //TODO: need to add a logout button
  },

  logOut: function (e) {
    e.preventDefault();
    $.ajax({
      url: "/session",
      method: "delete",
    });
    window.location.replace('session/new');
  },

  addNavLinks: function () {
    var homeParams = {
      title: 'Home',
      destination: '#'
    };
    var newNoteParams = {
      title: 'New Note',
      destination: '#notes/new'
    };
    _([homeParams, newNoteParams]).each(this.addItemView.bind(this));
  },

  addIndexView: function(items) {
    var subview = new cleverNote.Views.noteContainerIndex({ collection: items });
    this.addSubview('ul.metismenu', subview);
  },

  addItemView: function(params) {
    var subview = new cleverNote.Views.notesContainerIndexItem(params);
    this.addSubview('ul.metismenu', subview);
  },


  removeItemView: function(item) {
    this.rmeoveModelSubview('ul.meismenu', item);
  },

  onRender: function () {
    $('#side-menu').metisMenu();
    var logoutEl = $('<li>', {
      'class': 'container-list-item',
      'html': '<a href="#" class="logout">Log Out</a>'
    });
    this.$('ul.nav').append(logoutEl);
  },

  render: function () {
    var content = this.template();
    this.$el.html(content);
    this.attachSubviews();
    this.onRender();
    return this;
  }
});
{'fraction_non_alphanumeric': 0.16483842276904834, 'fraction_numerical': 0.0005929439667951378, 'mean_word_length': 3.281725888324873, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '1545239', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1102, 'n_words': 207}