entry.coffee 660 B

12345678910111213141516171819202122232425262728293031323334
  1. #= require app/searcher
  2. class app.models.Entry extends app.Model
  3. # Attributes: name, type, path
  4. constructor: ->
  5. super
  6. @text = app.Searcher.normalizeString(@name)
  7. fullPath: ->
  8. @doc.fullPath if @isIndex() then '' else @path
  9. dbPath: ->
  10. @path.replace /#.*/, ''
  11. filePath: ->
  12. @doc.fullPath @_filePath()
  13. fileUrl: ->
  14. @doc.fileUrl @_filePath()
  15. _filePath: ->
  16. result = @path.replace /#.*/, ''
  17. result += '.html' unless result[-5..-1] is '.html'
  18. result
  19. isIndex: ->
  20. @path is 'index'
  21. getType: ->
  22. @doc.types.findBy 'name', @type
  23. loadFile: (onSuccess, onError) ->
  24. app.db.load(@, onSuccess, onError)