SIGN IN SIGN UP
#= require app/searcher
2013-10-24 20:25:52 +02:00
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
2013-10-24 20:25:52 +02:00
fullPath: ->
@doc.fullPath if @isIndex() then '' else @path
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) ->
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 =
'angular': 'ng'
2015-07-26 22:34:06 -04:00
'angular.js': 'ng'
'backbone.js': 'bb'
2015-07-26 22:34:06 -04:00
'c++': 'cpp'
'coffeescript': 'cs'
'crystal': 'cr'
'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': '_'
'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'
'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'
'typescript': 'ts'
2015-07-26 22:34:06 -04:00
'underscore.js': '_'