<commit_before>var async = require('async');
var _ = require('@sailshq/lodash');

module.exports = function(self, options) {

  // Render the editor for page settings
  self.route('post', 'editor', function(req, res) {
    var type = self.apos.launder.string(req.body.type);
    var verb = self.apos.launder.string(req.body.verb);
    var id = self.apos.launder.id(req.body.id);
    var manager = self.apos.docs.getManager(type);
    if (!manager) {
      res.statusCode = 404;
      return res.send('not found');
    }
    var schema;
    var parentPage;
    if (verb === 'update') {
      var trash = self.apos.docs.trashInSchema ? null : false;
      return self.find(req, { _id: id }).ancestors(true).permission('publish-doc').trash(trash).toObject(function(err, page) {
        if (err) {
          return fail(err);
        }
        if (!page) {
          return fail('notfound');
        }
        var parentPage = page._ancestors && page._ancestors.length && page._ancestors[page._ancestors.length - 1];
        if (!parentPage) {
          // convert 0 to null
          parentPage = null;
        }
        schema = self.allowedSchema(req, page, parentPage);
        // We modified it, we have to bless the new version
        self.apos.schemas.bless(req, schema);
        return succeed();
      });
    } else if (verb === 'copy') {
      // id supplied was that of a peer
      return self.find(req, { _id: id }).ancestors(true).toObject(function(err, peerPage) {
        if (err) {
          return fail(err);
        }
        if (!peerPage) {
          return fail('notfound');
        }
        parentPage = peerPage._ancestors && peerPage._ancestors[0] && peerPage._ancestors[peerPage._ancestors.length - 1 ];
        var child = self.newChild(parentPage);<commit_msg>eslint<commit_after>var async = require('async');
var _ = require('@sailshq/lodash');

module.exports = function(self, options) {

  // Render the editor for page settings
  self.route('post', 'editor', function(req, res) {
    var type = self.apos.launder.string(req.body.type);
    var verb = self.apos.launder.string(req.body.verb);
    var id = self.apos.launder.id(req.body.id);
    var manager = self.apos.docs.getManager(type);
    if (!manager) {
      res.statusCode = 404;
      return res.send('not found');
    }
    var schema;
    var parentPage;
    if (verb === 'update') {
      var trash = self.apos.docs.trashInSchema ? null : false;
      return self.find(req, { _id: id }).ancestors(true).permission('publish-doc').trash(trash).toObject(function(err, page) {
        if (err) {
          return fail(err);
        }
        if (!page) {
          return fail('notfound');
        }
        var parentPage = page._ancestors && page._ancestors.length && page._ancestors[page._ancestors.length - 1];
        if (!parentPage) {
          // convert 0 to null
          parentPage = null;
        }
        schema = self.allowedSchema(req, page, parentPage);
        // We modified it, we have to bless the new version
        self.apos.schemas.bless(req, schema);
        return succeed();
      });
    } else if (verb === 'copy') {
      // id supplied was that of a peer
      return self.find(req, { _id: id }).ancestors(true).toObject(function(err, peerPage) {
        if (err) {
          return fail(err);
        }
        if (!peerPage) {
          return fail('notfound');
        }
        parentPage = peerPage._ancestors && peerPage._ancestors[0] && peerPage._ancestors[peerPage._ancestors.length - 1];
        var child = self.newChild(parentPage);
{'fraction_non_alphanumeric': 0.1435782389231632, 'fraction_numerical': 0.003925967470555244, 'mean_word_length': 2.4036259541984735, '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': '1447957', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1117, 'n_words': 255}