<commit_before>/** @jsx m */

"use strict";
require("./SearchPage.scss");

var _ = require("underscore");

var OnUnload = require("../utils/OnUnload.js");
var Layout = require("../layouts/DefaultLayout.js");
var SearchResults = require("../components/SearchResults.js");
var Spinner = require("../components/Spinner.js");

var SearchPage = {};

SearchPage.controller = function(options) {
  OnUnload(this);
  options = _.extend({id: "SearchPage"}, options);
  this.controllers.layout = new Layout.controller(options);
  this.controllers.searchResults = new SearchResults.controller({user: options.user});
  this.sortBy = m.prop("relevance");
  var _this = this;
  this.setSort = function(sortBy) {
    return function(e) {
      _this.sortBy(sortBy);
    };
  }
};

function route(path) {
  return function(e) {
    return m.route(path);
  };
};

SearchPage.view = function(ctrl) {
  var results = ctrl.controllers.searchResults.results;
  var content;
  if (results.loading) {
    content = Spinner.view();
  } else {
    var count = "" + results.total + " Results";
    content = (
      <table className="filterAndResults">
        <thead>
          <tr>
            <th>
              {count}
              <div className="pull_right">
                <button type="button" className="btn" onclick={route("/articles/new")}>
                  <span className="glyphicon glyphicon-plus"></span>
                  <span> Add article</span>
                </button>
                &nbsp;
                <span class="glyphicon glyphicon-info-sign tooltip" title="Cannot find an article or replication? Click &quot;Add Article&quot; to add a missing article or replication."></span>
              </div>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>
              {new SearchResults.view(ctrl.controllers.searchResults)}
            </td>
          </tr>
        </tbody>
      </table>
    );
  }

  return new Layout.view(ctrl.controllers.layout, content);
};

module.exports = SearchPage;<commit_msg>hide Add Article button from SearchPage<commit_after>/** @jsx m */

"use strict";
require("./SearchPage.scss");

var _ = require("underscore");

var OnUnload = require("../utils/OnUnload.js");
var Layout = require("../layouts/DefaultLayout.js");
var SearchResults = require("../components/SearchResults.js");
var Spinner = require("../components/Spinner.js");

var SearchPage = {};

SearchPage.controller = function(options) {
  OnUnload(this);
  options = _.extend({id: "SearchPage"}, options);
  this.controllers.layout = new Layout.controller(options);
  this.controllers.searchResults = new SearchResults.controller({user: options.user});
  this.sortBy = m.prop("relevance");
  var _this = this;
  this.setSort = function(sortBy) {
    return function(e) {
      _this.sortBy(sortBy);
    };
  }
};

function route(path) {
  return function(e) {
    return m.route(path);
  };
};

SearchPage.view = function(ctrl) {
  var results = ctrl.controllers.searchResults.results;
  var content;
  var addArticleButton;
  if (ctrl.controllers.layout.user){
    addArticleButton = (
      <div className="pull_right">
                <button type="button" className="btn" onclick={route("/articles/new")}>
                  <span className="glyphicon glyphicon-plus"></span>
                  <span> Add article</span>
                </button>
                &nbsp;
                <span class="glyphicon glyphicon-info-sign tooltip" title="Cannot find an article or replication? Click &quot;Add Article&quot; to add a missing article or replication."></span>
              </div>
    );
  }
  if (results.loading) {
    content = Spinner.view();
  } else {
    var count = "" + results.total + " Results";
    content = (
      <table className="filterAndResults">
        <thead>
          <tr>
            <th>
              {count}
              {addArticleButton}
            </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>
              {new SearchResults.view(ctrl.controllers.searchResults)}
            </td>
          </tr>
        </tbody>
      </table>
    );
  }

  return new Layout.view(ctrl.controllers.layout, content);
};

module.exports = SearchPage;
{'fraction_non_alphanumeric': 0.14875645236977944, 'fraction_numerical': 0.0, 'mean_word_length': 2.4131305044035227, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, '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': '6687751', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1239, 'n_words': 266}