<commit_before>import Ember from 'ember';
import $ from 'jquery';

function remoteFilename(filename) {
  return '/' + filename.match(/\.tmp\/(.*)$/)[1].trim();
}

function localFilename(filename) {
  let match = filename.match(/^(.*)\/tmp\/.*\.tmp\/(.*)$/);
  return (match[1] + '/' + match[2]).trim();
}

export default Ember.Route.extend({
  model() {
    return $.get('/docs/data.json').then(function (docs) {
      docs.classitems.forEach(function (classitem) {
        docs.classes[classitem.class].classitems.push(classitem);
        docs.classes[classitem.class].file = remoteFilename(classitem.file);
      });

      return {
        components: Ember.A(Object.values(docs.elements)),
        services: Ember.A(Object.values(docs.classes).filter(function (service) {
          return service.file.indexOf('/services/') !== -1;
        })),
        objects: Ember.A(Object.values(docs.classes).filter(function (service) {
          return service.file.indexOf('/services/') === -1;
        })),
        helpers: Ember.A(Object.values(docs.classitems).filter(function (method) {
          return method.file.indexOf('/helpers/') !== -1;
        })),
        warnings: docs.warnings.map(function (warning) {
          warning.line = localFilename(warning.line);
          warning.file = warning.line.replace(/:\d+$/, '');
          return warning;
        })
      };
    });
  }
});
<commit_msg>fix loading docs in github<commit_after>import Ember from 'ember';
import $ from 'jquery';

function remoteFilename(filename) {
  return '/' + filename.match(/\.tmp\/(.*)$/)[1].trim();
}

function localFilename(filename) {
  let match = filename.match(/^(.*)\/tmp\/.*\.tmp\/(.*)$/);
  return (match[1] + '/' + match[2]).trim();
}

export default Ember.Route.extend({
  model() {
    return $.get(`${location.pathname}docs/data.json`).then(function (docs) {
      docs.classitems.forEach(function (classitem) {
        docs.classes[classitem.class].classitems.push(classitem);
        docs.classes[classitem.class].file = remoteFilename(classitem.file);
      });

      return {
        components: Ember.A(Object.values(docs.elements)),
        services: Ember.A(Object.values(docs.classes).filter(function (service) {
          return service.file.indexOf('/services/') !== -1;
        })),
        objects: Ember.A(Object.values(docs.classes).filter(function (service) {
          return service.file.indexOf('/services/') === -1;
        })),
        helpers: Ember.A(Object.values(docs.classitems).filter(function (method) {
          return method.file.indexOf('/helpers/') !== -1;
        })),
        warnings: docs.warnings.map(function (warning) {
          warning.line = localFilename(warning.line);
          warning.file = warning.line.replace(/:\d+$/, '');
          return warning;
        })
      };
    });
  }
});

{'fraction_non_alphanumeric': 0.19217207334273625, 'fraction_numerical': 0.004231311706629055, 'mean_word_length': 2.77762982689747, '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': '5805947', 'n_tokens_mistral': 878, 'n_tokens_neox': 863, 'n_words': 126}