show.blade.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. @extends('layouts.app')
  2. @section('title', isset($article->title) ? $article->title : '博文')
  3. @section('style')
  4. <style type="text/css">
  5. .blog.grid.container.main {
  6. display: block;
  7. }
  8. .blog.grid.container.main .sidebar {
  9. font-size: 14px;
  10. padding-right:6px;
  11. }
  12. .ui.top.menu {
  13. margin-bottom: 30px;
  14. }
  15. .tocify-header{
  16. padding: 0 !important;
  17. }
  18. </style>
  19. @endsection
  20. @section('content')
  21. <div class="ui centered grid container main stackable blog">
  22. <div class="js-computed-height-right twelve wide column pull-right main main-column">
  23. {{-- 文章 --}}
  24. <div class="ui segment article-content">
  25. {{-- 右侧工具条 --}}
  26. <div class="right ui rail hide-on-mobile">
  27. <div class="ui sticky topic-operation">
  28. <div class="ui vertical icon menu border-0">
  29. <a class="item text-mute ui action topic-vote popover rm-link-color text-mute"
  30. data-position="left center"
  31. id="article-vote"
  32. href="javascript:;"
  33. data-html="点赞">
  34. <i class="thumbs up icon fs-large "></i>
  35. <span class="count vote-count fs-small mt-2 display-inline-block">{{ $article->vote_count }}</span>
  36. </a>
  37. <a class="item text-mute ui action collect popover rm-link-color text-mute"
  38. data-position="left center"
  39. id="article-collection"
  40. href="javascript:;"
  41. data-html="收藏">
  42. <i class="heart icon fs-large "></i>
  43. </a>
  44. <a class="item text-mute ui action popover rm-link-color text-mute"
  45. data-position="left center"
  46. href="#replies"
  47. onclick="scrollToAnchor('replies')" title="评论">
  48. <i class="comments icon fs-large"></i>
  49. <span class="fs-small mt-2 display-inline-block">0</span>
  50. </a>
  51. <a class="item ui popover rm-link-color text-mute"
  52. data-position="left center" href="#topnav"
  53. onclick="scrollToAnchor('topnav')" title="返回顶部">
  54. <i class="angle double up icon fs-large fw-bold"></i>
  55. </a>
  56. </div>
  57. </div>
  58. </div>
  59. {{-- 博文 --}}
  60. <div class="extra-padding" style="padding-bottom:4px">
  61. {{-- 标题 --}}
  62. <h1 style="margin-bottom: 15px;">
  63. <span style="line-height: 34px;">{{ $article->title }}</span>
  64. </h1>
  65. {{-- 信息工具条 --}}
  66. <div class="book-article-meta" style="margin-bottom: 10px;">
  67. <a class="" data-inverted="" data-tooltip="{{ $article->created_at }}">
  68. 创建于 <span title="{{ $article->created_at }}">{{ $article->created_at->diffForHumans() }}</span>
  69. </a>
  70. <span class="divider">/</span>
  71. <a>阅读数 {{ $article->view_count }}</a>
  72. <span class="divider">/</span>
  73. <a>评论数 {{ $article->reply_count }}</a>
  74. <span class="divider">/</span>
  75. <a class="" data-inverted="" data-tooltip="2019-02-15 17:37:49">{{ $article->updated_at->diffForHumans() }}</a>
  76. @can('update', $article)
  77. <span style="font-size: 13px;color: #adb1af;">
  78. <a href="{{ route('blog.articles.edit', $article->id) }}"><i class="icon edit"></i>编辑</a>
  79. <span class="divider">|</span>
  80. <a class="top-admin-operation ml-0"
  81. href="javascript:;"
  82. data-method="delete"
  83. data-url="{{ route('blog.articles.destroy', $article->id) }}" style="cursor: pointer;">
  84. <i class=" trash icon"></i>删除
  85. {{--<form action="{{ route('blog.articles.destroy', $article->id) }}" method="POST" style="display:none">
  86. {{ csrf_field() }}
  87. {{ method_field('DELETE') }}
  88. </form>--}}
  89. </a>
  90. </span>
  91. @endcan
  92. </div>
  93. {{-- 分割线 --}}
  94. <div class="ui divider"></div>
  95. {{-- 文章详情 --}}
  96. <div class="ui readme markdown-body content-body fluidbox-content">
  97. {!! $article->body !!}
  98. </div>
  99. </div>
  100. </div>
  101. {{-- 回复 --}}
  102. @include('pages.replies._reply_list')
  103. @include('pages.replies._reply_box', ['input_model'=> \App\Models\BlogArticle::class ])
  104. {{--@includeWhen(Auth::check(), 'pages.blog_articles._reply_box')--}}
  105. </div>
  106. @include('pages.blog_articles._sidebar')
  107. </div>
  108. @endsection
  109. @section('script')
  110. <script type="text/javascript">
  111. // 发表回复
  112. var markdown = new Markdown();
  113. markdown.init({
  114. 'textarea': {
  115. 'id': 'markdown-editor'
  116. },
  117. 'interval': false,
  118. 'markdown': {
  119. status: false,
  120. toolbar: false,
  121. },
  122. 'events': {
  123. change: function (html) {
  124. if ($.trim(html) !== '') {
  125. $("#preview-box").html(html).fadeIn();
  126. } else {
  127. $("#preview-box").fadeOut();
  128. }
  129. }
  130. }
  131. });
  132. </script>
  133. <script type="text/javascript">
  134. // 删除评论
  135. LearnkuNew.axiosDeleteForm(function (btn) {
  136. $(btn).closest('.comment').remove();
  137. })
  138. </script>
  139. <script type="text/javascript">
  140. var auth = Boolean("{{ Auth::check() }}");
  141. // 发表评论
  142. $("#comment-composing-form").submit(function () {
  143. if (auth) {
  144. axios({
  145. method: $(this).attr('method'),
  146. url: $(this).attr('action'),
  147. data: $(this).serialize(),
  148. }).then((res)=> {
  149. Swal.fire({
  150. type: 'success',
  151. title: '评论发表成功 . . .',
  152. text: '请耐心等待管理员审核',
  153. });
  154. // 重置 markdown
  155. window['markdown_markdown-editor'].value('');
  156. }).catch(function (error) {
  157. window.public.axios_catch(error);
  158. });
  159. } else {
  160. window.location.href = "{{ route('login') }}";
  161. }
  162. });
  163. </script>
  164. <script type="text/javascript">
  165. /**
  166. * 点赞
  167. */
  168. $('#article-vote').click(function () {
  169. var self = this;
  170. var icon = $(self).find('i');
  171. icon.addClass("spinner loading").removeClass("thumbs up");
  172. axios({
  173. url: "{{ route('api.blog.articles.upvote', $article->id) }}",
  174. type: 'get'
  175. }).then((res)=> {
  176. icon.addClass("thumbs up").removeClass("spinner loading");
  177. if (res.data.status) {
  178. $(self).find('span').text(res.data.vote_count);
  179. } else {
  180. Swal.fire({
  181. position: 'top-end',
  182. type: 'error',
  183. title: res.data.msg,
  184. showConfirmButton: false,
  185. timer: 2000
  186. })
  187. }
  188. })
  189. });
  190. /**
  191. * 收藏
  192. */
  193. $('#article-collection').click(function () {
  194. Swal.fire({
  195. title: '开小差 ~',
  196. text: "程序员开小差啦~ 暂未开发此功能",
  197. type: 'warning',
  198. showConfirmButton: false,
  199. timer: 2000
  200. });
  201. });
  202. </script>
  203. @endsection