2015-02-08 09:36:37 -05:00
|
|
|
#= require app/searcher
|
|
|
|
|
|
2013-10-24 20:25:52 +02:00
|
|
|
class app.models.Entry extends app.Model
|
|
|
|
|
# Attributes: name, type, path
|
|
|
|
|
|
|
|
|
|
constructor: ->
|
|
|
|
|
super
|
2016-08-20 15:29:28 -04:00
|
|
|
@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
|
2013-10-24 20:25:52 +02:00
|
|
|
|
|
|
|
|
fullPath: ->
|
|
|
|
|
@doc.fullPath if @isIndex() then '' else @path
|
|
|
|
|
|
2015-01-04 17:19:38 -05:00
|
|
|
dbPath: ->
|
|
|
|
|
@path.replace /#.*/, ''
|
|
|
|
|
|
2013-10-24 20:25:52 +02:00
|
|
|
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) ->
|
2014-12-31 15:53:35 -05:00
|
|
|
app.db.load(@, onSuccess, onError)
|
2015-07-26 22:34:06 -04:00
|
|
|
|
|
|
|
|
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 =
|
2016-08-20 15:29:28 -04:00
|
|
|
'angular': 'ng'
|
2015-07-26 22:34:06 -04:00
|
|
|
'angular.js': 'ng'
|
2016-08-20 15:29:28 -04:00
|
|
|
'backbone.js': 'bb'
|
2015-07-26 22:34:06 -04:00
|
|
|
'c++': 'cpp'
|
|
|
|
|
'coffeescript': 'cs'
|
2017-09-04 09:25:16 -04:00
|
|
|
'crystal': 'cr'
|
2016-02-05 13:32:02 +08:00
|
|
|
'elixir': 'ex'
|
2015-07-26 22:34:06 -04:00
|
|
|
'javascript': 'js'
|
|
|
|
|
'jquery': '$'
|
|
|
|
|
'knockout.js': 'ko'
|
2015-11-21 11:19:17 -05:00
|
|
|
'less': 'ls'
|
2015-07-26 22:34:06 -04:00
|
|
|
'lodash': '_'
|
2016-03-26 15:14:12 -04:00
|
|
|
'marionette': 'mn'
|
2015-07-26 22:34:06 -04:00
|
|
|
'markdown': 'md'
|
2015-11-21 11:19:17 -05:00
|
|
|
'modernizr': 'mdr'
|
|
|
|
|
'moment.js': 'mt'
|
2017-04-30 18:35:57 -04:00
|
|
|
'openjdk': 'java'
|
2015-11-21 11:19:17 -05:00
|
|
|
'nginx': 'ngx'
|
2016-09-03 10:33:45 -04:00
|
|
|
'numpy': 'np'
|
2016-09-15 23:48:10 +02:00
|
|
|
'pandas': 'pd'
|
2015-07-26 22:34:06 -04:00
|
|
|
'postgresql': 'pg'
|
2015-10-12 11:13:33 -04:00
|
|
|
'python': 'py'
|
2015-11-21 11:19:17 -05:00
|
|
|
'ruby.on.rails': 'ror'
|
|
|
|
|
'ruby': 'rb'
|
2017-07-30 08:05:39 -04:00
|
|
|
'rust': 'rs'
|
2015-07-26 22:34:06 -04:00
|
|
|
'sass': 'scss'
|
2016-09-03 10:33:45 -04:00
|
|
|
'tensorflow': 'tf'
|
2016-09-18 09:21:34 -04:00
|
|
|
'typescript': 'ts'
|
2015-07-26 22:34:06 -04:00
|
|
|
'underscore.js': '_'
|