History

Fix search aliases not applying properly on versioned docs

Fixes #461.

Thibaut Courouble committed 10 years ago

Commit c63be681 parent fd562622 files · +13 −4Browse files

Unified · Split

2 files
  1. assets/javascripts/models/doc.coffee +4 −1
  2. assets/javascripts/models/entry.coffee +9 −3
assets/javascripts/models/doc.coffee+4−1
@@ -39,10 +39,13 @@ class app.models.Doc extends app.Model · 38 unmodified lines
39 "#{app.indexHost()}/#{@slug}/#{app.config.index_filename}?#{@mtime}"39 "#{app.indexHost()}/#{@slug}/#{app.config.index_filename}?#{@mtime}"
40 40
41 toEntry: ->41 toEntry: ->
42 @entry ||= new app.models.Entry42 return @entry if @entry
43 @entry = new app.models.Entry
43 doc: @44 doc: @
44 name: @fullName45 name: @fullName
45 path: 'index'46 path: 'index'
47 @entry.addAlias(@name) if @version
48 @entry
46 49
47 findEntryByPathAndHash: (path, hash) ->50 findEntryByPathAndHash: (path, hash) ->
48 if hash and entry = @entries.findBy 'path', "#{path}##{hash}"51 if hash and entry = @entries.findBy 'path', "#{path}##{hash}"
assets/javascripts/models/entry.coffee+9−3
@@ -5,8 +5,13 @@ class app.models.Entry extends app.Model · 4 unmodified lines
5 5
6 constructor: ->6 constructor: ->
7 super7 super
8 @text = app.Searcher.normalizeString(@name)8 @text = applyAliases(app.Searcher.normalizeString(@name))
9 @text = applyAliases(@text)9
10 addAlias: (name) ->
11 text = applyAliases(app.Searcher.normalizeString(name))
12 @text = [@text] unless Array.isArray(@text)
13 @text.push(if Array.isArray(text) then text[1] else text)
14 return
10 15
11 fullPath: ->16 fullPath: ->
12 @doc.fullPath if @isIndex() then '' else @path17 @doc.fullPath if @isIndex() then '' else @path
@@ -45,8 +50,9 @@ class app.models.Entry extends app.Model · 32 unmodified lines
45 return string50 return string
46 51
47 @ALIASES = ALIASES =52 @ALIASES = ALIASES =
53 'angular': 'ng'
48 'angular.js': 'ng'54 'angular.js': 'ng'
49 'backbone': 'bb'55 'backbone.js': 'bb'
50 'c++': 'cpp'56 'c++': 'cpp'
51 'coffeescript': 'cs'57 'coffeescript': 'cs'
52 'elixir': 'ex'58 'elixir': 'ex'

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t