mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.2 KiB
60 lines
1.2 KiB
#= require app/searcher
|
|
|
|
class app.models.Entry extends app.Model
|
|
# Attributes: name, type, path
|
|
|
|
constructor: ->
|
|
super
|
|
@text = app.Searcher.normalizeString(@name)
|
|
@text = applyAliases(@text)
|
|
|
|
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.js': 'ng'
|
|
'backbone': 'bb'
|
|
'c++': 'cpp'
|
|
'coffeescript': 'cs'
|
|
'javascript': 'js'
|
|
'jquery': '$'
|
|
'knockout.js': 'ko'
|
|
'lodash': '_'
|
|
'markdown': 'md'
|
|
'postgresql': 'pg'
|
|
'sass': 'scss'
|
|
'underscore.js': '_'
|