diff --git a/assets/javascripts/models/doc.coffee b/assets/javascripts/models/doc.coffee index b61db7cf..642fa1ff 100644 --- a/assets/javascripts/models/doc.coffee +++ b/assets/javascripts/models/doc.coffee @@ -39,10 +39,13 @@ class app.models.Doc extends app.Model "#{app.indexHost()}/#{@slug}/#{app.config.index_filename}?#{@mtime}" toEntry: -> - @entry ||= new app.models.Entry + return @entry if @entry + @entry = new app.models.Entry doc: @ name: @fullName path: 'index' + @entry.addAlias(@name) if @version + @entry findEntryByPathAndHash: (path, hash) -> if hash and entry = @entries.findBy 'path', "#{path}##{hash}" diff --git a/assets/javascripts/models/entry.coffee b/assets/javascripts/models/entry.coffee index 9d4d40e7..50dbca4c 100644 --- a/assets/javascripts/models/entry.coffee +++ b/assets/javascripts/models/entry.coffee @@ -5,8 +5,13 @@ class app.models.Entry extends app.Model constructor: -> super - @text = app.Searcher.normalizeString(@name) - @text = applyAliases(@text) + @text = applyAliases(app.Searcher.normalizeString(@name)) + + addAlias: (name) -> + text = applyAliases(app.Searcher.normalizeString(name)) + @text = [@text] unless Array.isArray(@text) + @text.push(if Array.isArray(text) then text[1] else text) + return fullPath: -> @doc.fullPath if @isIndex() then '' else @path @@ -45,8 +50,9 @@ class app.models.Entry extends app.Model return string @ALIASES = ALIASES = + 'angular': 'ng' 'angular.js': 'ng' - 'backbone': 'bb' + 'backbone.js': 'bb' 'c++': 'cpp' 'coffeescript': 'cs' 'elixir': 'ex'