mirror of https://github.com/freeCodeCamp/devdocs
parent
0585d8300d
commit
35b38b796f
@ -1,121 +1,105 @@
|
|||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Sanity-check the conversion and remove this comment.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS206: Consider reworking classes to avoid initClass
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
//= require app/searcher
|
//= require app/searcher
|
||||||
|
|
||||||
(function () {
|
app.models.Entry = class Entry extends app.Model {
|
||||||
let applyAliases = undefined;
|
static applyAliases(string) {
|
||||||
app.models.Entry = class Entry extends app.Model {
|
if (Entry.ALIASES.hasOwnProperty(string)) {
|
||||||
static initClass() {
|
return [string, Entry.ALIASES[string]];
|
||||||
let ALIASES;
|
} else {
|
||||||
applyAliases = function (string) {
|
const words = string.split(".");
|
||||||
if (ALIASES.hasOwnProperty(string)) {
|
for (let i = 0; i < words.length; i++) {
|
||||||
return [string, ALIASES[string]];
|
var word = words[i];
|
||||||
} else {
|
if (Entry.ALIASES.hasOwnProperty(word)) {
|
||||||
const words = string.split(".");
|
words[i] = Entry.ALIASES[word];
|
||||||
for (let i = 0; i < words.length; i++) {
|
return [string, words.join(".")];
|
||||||
var word = words[i];
|
|
||||||
if (ALIASES.hasOwnProperty(word)) {
|
|
||||||
words[i] = ALIASES[word];
|
|
||||||
return [string, words.join(".")];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return string;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
this.ALIASES = ALIASES = {
|
|
||||||
angular: "ng",
|
|
||||||
"angular.js": "ng",
|
|
||||||
"backbone.js": "bb",
|
|
||||||
"c++": "cpp",
|
|
||||||
coffeescript: "cs",
|
|
||||||
crystal: "cr",
|
|
||||||
elixir: "ex",
|
|
||||||
javascript: "js",
|
|
||||||
julia: "jl",
|
|
||||||
jquery: "$",
|
|
||||||
"knockout.js": "ko",
|
|
||||||
kubernetes: "k8s",
|
|
||||||
less: "ls",
|
|
||||||
lodash: "_",
|
|
||||||
löve: "love",
|
|
||||||
marionette: "mn",
|
|
||||||
markdown: "md",
|
|
||||||
matplotlib: "mpl",
|
|
||||||
modernizr: "mdr",
|
|
||||||
"moment.js": "mt",
|
|
||||||
openjdk: "java",
|
|
||||||
nginx: "ngx",
|
|
||||||
numpy: "np",
|
|
||||||
pandas: "pd",
|
|
||||||
postgresql: "pg",
|
|
||||||
python: "py",
|
|
||||||
"ruby.on.rails": "ror",
|
|
||||||
ruby: "rb",
|
|
||||||
rust: "rs",
|
|
||||||
sass: "scss",
|
|
||||||
tensorflow: "tf",
|
|
||||||
typescript: "ts",
|
|
||||||
"underscore.js": "_",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
// Attributes: name, type, path
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
static ALIASES = {
|
||||||
super(...arguments);
|
angular: "ng",
|
||||||
this.text = applyAliases(app.Searcher.normalizeString(this.name));
|
"angular.js": "ng",
|
||||||
}
|
"backbone.js": "bb",
|
||||||
|
"c++": "cpp",
|
||||||
|
coffeescript: "cs",
|
||||||
|
crystal: "cr",
|
||||||
|
elixir: "ex",
|
||||||
|
javascript: "js",
|
||||||
|
julia: "jl",
|
||||||
|
jquery: "$",
|
||||||
|
"knockout.js": "ko",
|
||||||
|
kubernetes: "k8s",
|
||||||
|
less: "ls",
|
||||||
|
lodash: "_",
|
||||||
|
löve: "love",
|
||||||
|
marionette: "mn",
|
||||||
|
markdown: "md",
|
||||||
|
matplotlib: "mpl",
|
||||||
|
modernizr: "mdr",
|
||||||
|
"moment.js": "mt",
|
||||||
|
openjdk: "java",
|
||||||
|
nginx: "ngx",
|
||||||
|
numpy: "np",
|
||||||
|
pandas: "pd",
|
||||||
|
postgresql: "pg",
|
||||||
|
python: "py",
|
||||||
|
"ruby.on.rails": "ror",
|
||||||
|
ruby: "rb",
|
||||||
|
rust: "rs",
|
||||||
|
sass: "scss",
|
||||||
|
tensorflow: "tf",
|
||||||
|
typescript: "ts",
|
||||||
|
"underscore.js": "_",
|
||||||
|
};
|
||||||
|
// Attributes: name, type, path
|
||||||
|
|
||||||
addAlias(name) {
|
constructor() {
|
||||||
const text = applyAliases(app.Searcher.normalizeString(name));
|
super(...arguments);
|
||||||
if (!Array.isArray(this.text)) {
|
this.text = Entry.applyAliases(app.Searcher.normalizeString(this.name));
|
||||||
this.text = [this.text];
|
}
|
||||||
}
|
|
||||||
this.text.push(Array.isArray(text) ? text[1] : text);
|
|
||||||
}
|
|
||||||
|
|
||||||
fullPath() {
|
addAlias(name) {
|
||||||
return this.doc.fullPath(this.isIndex() ? "" : this.path);
|
const text = Entry.applyAliases(app.Searcher.normalizeString(name));
|
||||||
|
if (!Array.isArray(this.text)) {
|
||||||
|
this.text = [this.text];
|
||||||
}
|
}
|
||||||
|
this.text.push(Array.isArray(text) ? text[1] : text);
|
||||||
|
}
|
||||||
|
|
||||||
dbPath() {
|
fullPath() {
|
||||||
return this.path.replace(/#.*/, "");
|
return this.doc.fullPath(this.isIndex() ? "" : this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath() {
|
dbPath() {
|
||||||
return this.doc.fullPath(this._filePath());
|
return this.path.replace(/#.*/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUrl() {
|
filePath() {
|
||||||
return this.doc.fileUrl(this._filePath());
|
return this.doc.fullPath(this._filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
_filePath() {
|
fileUrl() {
|
||||||
let result = this.path.replace(/#.*/, "");
|
return this.doc.fileUrl(this._filePath());
|
||||||
if (result.slice(-5) !== ".html") {
|
}
|
||||||
result += ".html";
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
isIndex() {
|
_filePath() {
|
||||||
return this.path === "index";
|
let result = this.path.replace(/#.*/, "");
|
||||||
|
if (result.slice(-5) !== ".html") {
|
||||||
|
result += ".html";
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
getType() {
|
isIndex() {
|
||||||
return this.doc.types.findBy("name", this.type);
|
return this.path === "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
loadFile(onSuccess, onError) {
|
getType() {
|
||||||
return app.db.load(this, onSuccess, onError);
|
return this.doc.types.findBy("name", this.type);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
app.models.Entry.initClass();
|
loadFile(onSuccess, onError) {
|
||||||
return app.models.Entry;
|
return app.db.load(this, onSuccess, onError);
|
||||||
})();
|
}
|
||||||
|
};
|
||||||
|
Loading…
Reference in new issue