The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
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.

ViewPost.cshtml 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. @model Teknik.Areas.Blog.ViewModels.PostViewModel
  2. @using Teknik.Helpers
  3. <script>
  4. // We need to define the action URLs for the script
  5. var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';
  6. var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
  7. var getPostTitleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostTitle" })';
  8. var getPostArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostArticle" })';
  9. var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';
  10. var addPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreatePost" })';
  11. var editPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditPost" })';
  12. var deletePostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeletePost" })';
  13. var getCommentsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetComments" })';
  14. var getCommentArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetCommentArticle" })';
  15. var addCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreateComment" })';
  16. var editCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditComment" })';
  17. var deleteCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeleteComment" })';
  18. </script>
  19. @Styles.Render("~/Content/blog")
  20. @Scripts.Render("~/bundles/blog")
  21. <div class="container">
  22. @if (Model != null)
  23. {
  24. if (User.IsInRole("Admin") || Model.Blog.User.Username == User.Identity.Name)
  25. {
  26. <div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
  27. <div class="modal-dialog">
  28. <div class="modal-content">
  29. <form class="form" action="##" method="post" id="editPostForm">
  30. <div class="modal-header">
  31. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  32. <h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
  33. </div>
  34. <div class="modal-body">
  35. <input name="edit_blog_userid" id="edit_blog_userid" type="hidden" value="@Model.Blog.User.UserId" />
  36. <input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
  37. <div class="row">
  38. <div class="form-group col-sm-12">
  39. <label for="edit_blog_title"><h4>Title</h4></label>
  40. <input class="form-control" name="edit_blog_title" id="edit_blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
  41. </div>
  42. </div>
  43. <div class="row">
  44. <div class="form-group col-sm-12">
  45. <label for="edit_blog_post"><h4>Article</h4></label>
  46. <textarea class="form-control" name="edit_blog_post" id="edit_blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="modal-footer">
  51. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  52. <button type="button" class="btn btn-primary" id="edit_submit">Save</button>
  53. </div>
  54. </form>
  55. </div>
  56. </div>
  57. </div>
  58. }
  59. <ol class="breadcrumb">
  60. <li><a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = (Model.System) ? string.Empty : Model.Blog.User.Username })">@((Model.System) ? Model.Config.BlogConfig.Title : (string.IsNullOrEmpty(Model.Blog.User.BlogSettings.Title) ? string.Format("{0}'s Blog", Model.Blog.User.Username) : Model.Blog.User.BlogSettings.Title))</a></li>
  61. <li class="active"><a href="#">@Model.Title</a></li>
  62. </ol>
  63. @Html.Partial("../../Areas/Blog/Views/Blog/Post", Model)
  64. if (Request.IsAuthenticated)
  65. {
  66. <div class="row">
  67. <div class="col-sm-10 col-sm-offset-1">
  68. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newComment">Add Comment</button>
  69. </div>
  70. </div>
  71. <br />
  72. <div class="modal fade" id="newComment" tabindex="-1" role="dialog" aria-labelledby="newCommentLabel" aria-hidden="true">
  73. <div class="modal-dialog">
  74. <div class="modal-content">
  75. <form class="form" action="##" method="post" id="publishComment">
  76. <div class="modal-header">
  77. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  78. <h4 class="modal-title" id="newCommentLabel">Add a New Comment</h4>
  79. </div>
  80. <div class="modal-body">
  81. <input name="post_id" id="post_id" type="hidden" value="@Model.PostId" />
  82. <div class="row">
  83. <div class="form-group col-sm-12">
  84. <label for="comment_post"><h4>Comment</h4></label>
  85. <textarea class="form-control wmd-input" name="comment_post" id="comment_post" placeholder="Nice post!" title="enter what you think about the post." data-provide="markdown" rows="10"></textarea>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="modal-footer">
  90. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  91. <button type="button" class="btn btn-primary" id="comment_submit">Publish</button>
  92. </div>
  93. </form>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel" aria-hidden="true">
  98. <div class="modal-dialog">
  99. <div class="modal-content">
  100. <form class="form" action="##" method="post" id="editCommentForm">
  101. <div class="modal-header">
  102. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  103. <h4 class="modal-title" id="editCommentLabel">Edit Your Comment</h4>
  104. </div>
  105. <div class="modal-body">
  106. <input name="edit_comment_postid" id="edit_comment_postid" type="hidden" />
  107. <div class="row">
  108. <div class="form-group col-sm-12">
  109. <label for="edit_comment_post"><h4>Comment</h4></label>
  110. <textarea class="form-control" name="edit_comment_post" id="edit_comment_post" placeholder="What an interesting article!" title="enter what you thought about the article." data-provide="markdown" rows="10"></textarea>
  111. </div>
  112. </div>
  113. </div>
  114. <div class="modal-footer">
  115. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  116. <button type="button" class="btn btn-primary" id="edit_comment_submit">Save</button>
  117. </div>
  118. </form>
  119. </div>
  120. </div>
  121. </div>
  122. }
  123. <a name="replies"></a>
  124. <div class="post-comments" id="@Model.PostId"></div>
  125. <script>
  126. linkPostDelete('.delete_post');
  127. linkPostPublish('.publish_post');
  128. linkPostUnpublish('.unpublish_post');
  129. var posts = @(Model.Config.BlogConfig.CommentsToLoad);
  130. var start_post = 0;
  131. var view_post_id = @(Model.PostId);
  132. loadMoreComments(start_post, posts);
  133. start_post = start_post + posts;
  134. </script>
  135. }
  136. else
  137. {
  138. <div class="row">
  139. <div class="col-sm-12 text-center">
  140. <h2>That post does not exist</h2>
  141. </div>
  142. </div>
  143. }
  144. </div>