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.

Blog.cshtml 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. @model Teknik.Areas.Blog.ViewModels.BlogViewModel
  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.Error)
  23. {
  24. <div class="row">
  25. <div class="col-sm-12 blog-heading">
  26. <h1 class="blog-title text-center">@Model.Title</h1>
  27. <p class="lead blog-description text-center text-muted">@Model.Description</p>
  28. </div>
  29. </div>
  30. <div class="row">
  31. <div class="col-sm-12 text-center">
  32. <p>
  33. <a href="@Url.SubRouteUrl("rss", "RSS.Blog", new { username = (Model.BlogId == Constants.SERVERBLOGID) ? string.Empty : Model.User.Username })"><i class="fa fa-rss fa-2x fa-border"></i></a>
  34. </p>
  35. </div>
  36. </div>
  37. if (Model.User.Username == User.Identity.Name)
  38. {
  39. <div class="row">
  40. <div class="col-sm-12 text-center">
  41. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newPost">Create Post</button>
  42. </div>
  43. </div>
  44. <div class="modal fade" id="newPost" tabindex="-1" role="dialog" aria-labelledby="newPostLabel" aria-hidden="true">
  45. <div class="modal-dialog">
  46. <div class="modal-content">
  47. <form class="form" action="##" method="post" id="publishPost">
  48. <div class="modal-header">
  49. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  50. <h4 class="modal-title" id="newPostLabel">Create a New Post</h4>
  51. </div>
  52. <div class="modal-body">
  53. <input name="blog_blogid" id="blog_blogid" type="hidden" value="@Model.BlogId" />
  54. <div class="row">
  55. <div class="form-group col-sm-12">
  56. <label for="blog_title"><h4>Title</h4></label>
  57. <input class="form-control" name="blog_title" id="blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
  58. </div>
  59. </div>
  60. <div class="row">
  61. <div class="form-group col-sm-12">
  62. <label for="blog_post"><h4>Article</h4></label>
  63. <textarea class="form-control wmd-input" name="blog_post" id="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>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="modal-footer">
  68. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  69. <button type="button" class="btn btn-primary" id="blog_submit">Create</button>
  70. </div>
  71. </form>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
  76. <div class="modal-dialog">
  77. <div class="modal-content">
  78. <form class="form" action="##" method="post" id="editPostForm">
  79. <div class="modal-header">
  80. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  81. <h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
  82. </div>
  83. <div class="modal-body">
  84. <input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
  85. <div class="row">
  86. <div class="form-group col-sm-12">
  87. <label for="edit_blog_title"><h4>Title</h4></label>
  88. <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" />
  89. </div>
  90. </div>
  91. <div class="row">
  92. <div class="form-group col-sm-12">
  93. <label for="edit_blog_post"><h4>Article</h4></label>
  94. <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>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="modal-footer">
  99. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  100. <button type="button" class="btn btn-primary" id="edit_submit">Save</button>
  101. </div>
  102. </form>
  103. </div>
  104. </div>
  105. </div>
  106. }
  107. if (Model.HasPosts)
  108. {
  109. <div class="blog-main" id="@Model.BlogId"></div>
  110. <script>
  111. var posts = @Model.Config.BlogConfig.PostsToLoad;
  112. var start_post = 0;
  113. loadMorePosts(start_post, posts);
  114. start_post = start_post + posts;
  115. </script>
  116. }
  117. else
  118. {
  119. <div class="row">
  120. <div class="col-sm-12 text-center">
  121. <h2>There are currently no articles.</h2>
  122. </div>
  123. </div>
  124. }
  125. }
  126. else
  127. {
  128. <div class="row">
  129. <div class="col-sm-12 text-center">
  130. <h2>That blog does not exist!</h2>
  131. </div>
  132. </div>
  133. }
  134. </div>