error_tmpl.coffee 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. error = (title, text = '', links = '') ->
  2. text = """<p class="_error-text">#{text}</p>""" if text
  3. links = """<p class="_error-links">#{links}</p>""" if links
  4. """<div class="_error"><h1 class="_error-title">#{title}</h1>#{text}#{links}</div>"""
  5. back = '<a href="#" data-behavior="back" class="_error-link">Go back</a>'
  6. app.templates.notFoundPage = ->
  7. error """ Page not found. """,
  8. """ It may be missing from the source documentation or this could be a bug. """,
  9. back
  10. app.templates.pageLoadError = ->
  11. error """ The page failed to load. """,
  12. """ It may be missing from the server (try reloading the app) or you could be offline.<br>
  13. If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
  14. """ #{back} &middot; <a href="/##{location.pathname}" target="_top" class="_error-link">Reload</a>
  15. &middot; <a href="#" class="_error-link" data-retry>Retry</a> """
  16. app.templates.bootError = ->
  17. error """ The app failed to load. """,
  18. """ Check your Internet connection and try <a href="#" data-behavior="reload">reloading</a>.<br>
  19. If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """
  20. app.templates.offlineError = (reason, exception) ->
  21. if reason is 'cookie_blocked'
  22. return error """ Cookies must be enabled to use offline mode. """
  23. reason = switch reason
  24. when 'not_supported'
  25. """ DevDocs requires IndexedDB to cache documentations for offline access.<br>
  26. Unfortunately your browser either doesn't support IndexedDB or doesn't make it available. """
  27. when 'buggy'
  28. """ DevDocs requires IndexedDB to cache documentations for offline access.<br>
  29. Unfortunately your browser's implementation of IndexedDB contains bugs that prevent DevDocs from using it. """
  30. when 'private_mode'
  31. """ Your browser appears to be running in private mode.<br>
  32. This prevents DevDocs from caching documentations for offline access."""
  33. when 'exception'
  34. """ An error occurred when trying to open the IndexedDB database:<br>
  35. <code class="_label">#{exception.name}: #{exception.message}</code> """
  36. when 'cant_open'
  37. """ An error occurred when trying to open the IndexedDB database:<br>
  38. <code class="_label">#{exception.name}: #{exception.message}</code><br>
  39. This could be because you're browsing in private mode or have disallowed offline storage on the domain. """
  40. when 'version'
  41. """ The IndexedDB database was modified with a newer version of the app.<br>
  42. <a href="#" data-behavior="reload">Reload the page</a> to use offline mode. """
  43. when 'empty'
  44. """ The IndexedDB database appears to be corrupted. Try <a href="#" data-behavior="reset">resetting the app</a>. """
  45. error 'Offline mode is unavailable.', reason
  46. app.templates.unsupportedBrowser = """
  47. <div class="_fail">
  48. <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
  49. <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:
  50. <ul class="_fail-list">
  51. <li>Recent versions of Chrome and Firefox
  52. <li>Safari 5.1+
  53. <li>Opera 12.1+
  54. <li>Internet Explorer 10+
  55. <li>iOS 6+
  56. <li>Android 4.1+
  57. <li>Windows Phone 8+
  58. </ul>
  59. <p class="_fail-text">
  60. If you're unable to upgrade, I apologize.
  61. I decided to prioritize speed and new features over support for older browsers.
  62. <p class="_fail-text">
  63. Note: if you're already using one of the browsers above, check your settings and add-ons.
  64. The app uses feature detection, not user agent sniffing.
  65. <p class="_fail-text">
  66. &mdash; Thibaut <a href="https://twitter.com/DevDocs" class="_fail-link">@DevDocs</a>
  67. </div>
  68. """