homepage.hamlet 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <div .masthead>
  2. <div .container>
  3. <div .row>
  4. <h1 .header>
  5. Yesod—a modern framework for blazing fast websites
  6. <h2>
  7. Fast, stable & spiced with great community
  8. <a href="http://www.yesodweb.com/book/" .btn.btn-info.btn-lg>
  9. Read the Book
  10. <div .container>
  11. <!-- Starting
  12. ================================================== -->
  13. <div .bs-docs-section>
  14. <div .row>
  15. <div .col-lg-12>
  16. <div .page-header>
  17. <h1 #start>Starting
  18. <p>
  19. Now that you have a working project you should use the
  20. <a href=http://www.yesodweb.com/book/>Yesod book</a> to learn more.
  21. <p>
  22. You can also use this scaffolded site to explore some concepts, and best practices.
  23. <ul .list-group>
  24. <li .list-group-item>
  25. This page was generated by the <tt>#{handlerName}</tt> handler in
  26. <tt>Handler/Home.hs</tt>.
  27. <li .list-group-item>
  28. The <tt>#{handlerName}</tt> handler is set to generate your
  29. site's home screen in Routes file
  30. <tt>config/routes
  31. <li .list-group-item>
  32. We can link to other handlers, like the <a href="@{ProfileR}">Profile</a>.
  33. Try it out as an anonymous user and see the access denied.
  34. Then, try to <a href="@{AuthR LoginR}">login</a> with the dummy authentication added
  35. while in development.
  36. <li .list-group-item>
  37. The HTML you are seeing now is actually composed by a number of <em>widgets</em>, #
  38. most of them are brought together by the <tt>defaultLayout</tt> function which #
  39. is defined in the <tt>Foundation.hs</tt> module, and used by <tt>#{handlerName}</tt>. #
  40. All the files for templates and wigdets are in <tt>templates</tt>.
  41. <li .list-group-item>
  42. A Widget's Html, Css and Javascript are separated in three files with the
  43. <tt>.hamlet</tt>, <tt>.lucius</tt> and <tt>.julius</tt> extensions.
  44. <li .list-group-item ##{aDomId}>
  45. If you had javascript enabled then you wouldn't be seeing this.
  46. <hr>
  47. <!-- Forms
  48. ================================================== -->
  49. <div .bs-docs-section>
  50. <div .row>
  51. <div .col-lg-12>
  52. <div .page-header>
  53. <h1 #forms>Forms
  54. <p>
  55. This is an example of a form. Read the
  56. <a href="http://www.yesodweb.com/book/forms">Forms chapter</a> #
  57. on the yesod book to learn more about them.
  58. <div .row>
  59. <div .col-lg-6>
  60. <div .bs-callout bs-callout-info well>
  61. <form .form-horizontal method=post action=@{HomeR}#forms enctype=#{formEnctype}>
  62. ^{formWidget}
  63. <button .btn.btn-primary type="submit">
  64. Upload it!
  65. <div .col-lg-4.col-lg-offset-1>
  66. <div .bs-callout.bs-callout-info.upload-response>
  67. $maybe (FileForm info con) <- submission
  68. Your file type is <em>#{fileContentType info}</em>. You say it has: <em>#{con}</em>
  69. $nothing
  70. File upload result will be here...
  71. <hr>
  72. <!-- JSON
  73. ================================================== -->
  74. <div .bs-docs-section>
  75. <div .row>
  76. <div .col-lg-12>
  77. <div .page-header>
  78. <h1 #json>JSON
  79. <p>
  80. Yesod has JSON support baked-in.
  81. The form below makes an AJAX request with Javascript,
  82. then updates the page with your submission.
  83. (see <tt>Handler/Comment.hs</tt>, <tt>templates/homepage.julius</tt>,
  84. and <tt>Handler/Home.hs</tt> for the implementation).
  85. <div .row>
  86. <div .col-lg-6>
  87. <div .bs-callout.bs-callout-info.well>
  88. <form .form-horizontal ##{commentFormId}>
  89. <div .field>
  90. <textarea rows="2" ##{commentTextareaId} placeholder="Your comment here..." required></textarea>
  91. <button .btn.btn-primary type=submit>
  92. Create comment
  93. <div .col-lg-4.col-lg-offset-1>
  94. <div .bs-callout.bs-callout-info>
  95. <small>
  96. Your comments will appear here. You can also open the
  97. console log to see the raw response from the server.
  98. <ul ##{commentListId}>
  99. $forall comment <- allComments
  100. <li>#{commentMessage $ entityVal comment}
  101. <hr>
  102. <!-- Testing
  103. ================================================== -->
  104. <div .bs-docs-section>
  105. <div .row>
  106. <div .col-lg-12>
  107. <div .page-header>
  108. <h1 #test>Testing
  109. <p>
  110. And last but not least, Testing. In <tt>test/Spec.hs</tt> you will find a #
  111. test suite that performs tests on this page.
  112. <p>
  113. You can run your tests by doing: <code>stack test</code>