History

Move docs_aliases to class App

Simon Legner committed 1 year ago

Commit 050022b1 parent ed116eb4 files · +43 −49Browse files

Showing the changes to assets/javascripts (2 of 4 files). Show all

Unified · Split

2 files
  1. assets/javascripts/app/config.js.erb +1 −0
  2. assets/javascripts/models/entry.js +5 −40
assets/javascripts/app/config.js.erb+1−0
@@ -1,6 +1,7 @@
11 app.config = {
22 db_filename: 'db.json',
33 default_docs: <%= App.default_docs.to_json %>,
4+ docs_aliases: <%= App.docs_aliases.to_json %>,
45 docs_origin: '<%= App.docs_origin %>',
56 env: '<%= App.environment %>',
67 history_cache_size: 10,
assets/javascripts/models/entry.js+5−40
@@ -2,14 +2,15 @@ · 1 unmodified line
22
33 app.models.Entry = class Entry extends app.Model {
44 static applyAliases(string) {
5− if (Entry.ALIASES.hasOwnProperty(string)) {
6− return [string, Entry.ALIASES[string]];
5+ const aliases = app.config.docs_aliases;
6+ if (aliases.hasOwnProperty(string)) {
7+ return [string, aliases[string]];
78 } else {
89 const words = string.split(".");
910 for (let i = 0; i < words.length; i++) {
1011 var word = words[i];
11− if (Entry.ALIASES.hasOwnProperty(word)) {
12− words[i] = Entry.ALIASES[word];
12+ if (aliases.hasOwnProperty(word)) {
13+ words[i] = aliases[word];
1314 return [string, words.join(".")];
1415 }
1516 }
@@ -17,43 +18,7 @@ app.models.Entry = class Entry extends app.Model { · 1 unmodified line
1718 return string;
1819 }
1920
20− static ALIASES = {
21− angular: "ng",
22− "angular.js": "ng",
23− "backbone.js": "bb",
24− "c++": "cpp",
25− coffeescript: "cs",
26− crystal: "cr",
27− elixir: "ex",
28− javascript: "js",
29− julia: "jl",
30− jquery: "$",
31− "knockout.js": "ko",
32− kubernetes: "k8s",
33− less: "ls",
34− lodash: "_",
35− löve: "love",
36− marionette: "mn",
37− markdown: "md",
38− matplotlib: "mpl",
39− modernizr: "mdr",
40− "moment.js": "mt",
41− openjdk: "java",
42− nginx: "ngx",
43− numpy: "np",
44− pandas: "pd",
45− postgresql: "pg",
46− python: "py",
47− "ruby.on.rails": "ror",
48− ruby: "rb",
49− rust: "rs",
50− sass: "scss",
51− tensorflow: "tf",
52− typescript: "ts",
53− "underscore.js": "_",
54− };
5521 // Attributes: name, type, path
56−
5722 constructor() {
5823 super(...arguments);
5924 this.text = Entry.applyAliases(app.Searcher.normalizeString(this.name));