Repository navigation
Expand file tree
/
Copy pathentry.coffee
More file actions
81 lines (68 loc) · 1.77 KB
/
Copy pathentry.coffee
File metadata and controls
81 lines (68 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#= require app/searcher
class app.models.Entry extends app.Model
# Attributes: name, type, path
constructor: ->
super
@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
dbPath: ->
@path.replace /#.*/, ''
filePath: ->
@doc.fullPath @_filePath()
fileUrl: ->
@doc.fileUrl @_filePath()
_filePath: ->
result = @path.replace /#.*/, ''
result += '.html' unless result[-5..-1] is '.html'
result
isIndex: ->
@path is 'index'
getType: ->
@doc.types.findBy 'name', @type
loadFile: (onSuccess, onError) ->
app.db.load(@, onSuccess, onError)
applyAliases = (string) ->
if ALIASES.hasOwnProperty(string)
return [string, ALIASES[string]]
else
words = string.split('.')
for word, i in words when ALIASES.hasOwnProperty(word)
words[i] = ALIASES[word]
return [string, words.join('.')]
return string
@ALIASES = ALIASES =
'angular': 'ng'
'angular.js': 'ng'
'backbone.js': 'bb'
'c++': 'cpp'
'coffeescript': 'cs'
'crystal': 'cr'
'elixir': 'ex'
'javascript': 'js'
'jquery': '$'
'knockout.js': 'ko'
'less': 'ls'
'lodash': '_'
'marionette': 'mn'
'markdown': 'md'
'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': '_'