diff --git a/lib/app.rb b/lib/app.rb index 939eab47..89fe6cf0 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -33,46 +33,11 @@ class App < Sinatra::Application set :default_docs, %w(css dom html http javascript) set :news_path, File.join(root, assets_prefix, 'javascripts', 'news.json') - set :docs_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' => '_', - } - set :csp, false require 'docs' Docs.generate_manifest + set :docs_aliases, Docs.aliases Dir[docs_path, root.join(assets_prefix, '*/')].each do |path| sprockets.append_path(path) diff --git a/lib/docs.rb b/lib/docs.rb index abea0915..f8ab6a03 100644 --- a/lib/docs.rb +++ b/lib/docs.rb @@ -108,6 +108,44 @@ module Docs store_class.new(store_path) end + def self.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' => '_', + } + end + extend Instrumentable def self.install_report(*names) diff --git a/lib/docs/core/manifest.rb b/lib/docs/core/manifest.rb index 134bb9e3..b9744ca2 100644 --- a/lib/docs/core/manifest.rb +++ b/lib/docs/core/manifest.rb @@ -20,7 +20,7 @@ module Docs if doc.options[:attribution].is_a?(String) json[:attribution] = doc.options[:attribution].strip end - json[:alias] = App.docs_aliases[json["slug"].try(:to_sym)] + json[:alias] = Docs.aliases[json["slug"].try(:to_sym)] result << json end end