create.blade.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. @extends('theme::layout.public')
  2. @section('seo_title')撰写文章 - {{ Setting()->get('website_name') }}@endsection
  3. @section('css')
  4. <link href="{{ asset('/static/js/summernote/summernote.css')}}" rel="stylesheet">
  5. <link href="{{ asset('/static/js/select2/css/select2.min.css')}}" rel="stylesheet">
  6. <link href="{{ asset('/static/js/select2/css/select2-bootstrap.min.css')}}" rel="stylesheet">
  7. @endsection
  8. @section('content')
  9. <div class="row mt-10">
  10. <ol class="breadcrumb">
  11. <li><a href="{{ route('website.blog') }}">文章</a></li>
  12. <li class="active">撰写文章</li>
  13. </ol>
  14. <div class="col-md-12 main widget-form">
  15. <form id="article_form" method="POST" role="form" enctype="multipart/form-data" action="{{ route('blog.article.store') }}">
  16. <input type="hidden" id="editor_token" name="_token" value="{{ csrf_token() }}">
  17. <input type="hidden" id="tags" name="tags" value="" />
  18. <div class="form-group @if($errors->has('title')) has-error @endif ">
  19. <label for="title">文章标题:</label>
  20. <input id="title" type="text" name="title" class="form-control input-lg" placeholder="" value="{{ old('title',$formData['subject']) }}" />
  21. @if($errors->has('title')) <p class="help-block">{{ $errors->first('title') }}</p> @endif
  22. </div>
  23. <div class="form-group @if($errors->has('logo')) has-error @endif">
  24. <label>文章封面</label>
  25. <input type="file" name="logo"/>
  26. @if($errors->has('logo')) <p class="help-block">{{ $errors->first('logo') }}</p> @else <p class="help-block">建议尺寸200*120</p> @endif
  27. </div>
  28. <div class="form-group @if($errors->has('content')) has-error @endif">
  29. <label for="article_editor">文章正文:</label>
  30. <div id="article_editor">{!! old('content',$formData['content']) !!}</div>
  31. @if($errors->has('content')) <p class="help-block">{{ $errors->first('content') }}</p> @endif
  32. </div>
  33. <div class="form-group">
  34. <label for="editor">文章导读:</label>
  35. <textarea name="summary" class="form-control" placeholder="文章摘要">{{ old('summary','') }}</textarea>
  36. </div>
  37. <div class="row">
  38. <div class="col-xs-4">
  39. <select name="category_id" id="category_id" class="form-control">
  40. <option value="0">请选择分类</option>
  41. @include('admin.category.option',['type'=>'articles','select_id'=>old('category_id',0)])
  42. </select>
  43. </div>
  44. <div class="col-xs-8">
  45. <select id="select_tags" name="select_tags" class="form-control" multiple="multiple" >
  46. @foreach(array_filter(explode(",",old('select_tags',''))) as $tag)
  47. <option selected="selected">{{ $tag }}</option>
  48. @endforeach
  49. </select>
  50. </div>
  51. </div>
  52. <div class="row mt-20">
  53. <div class="col-xs-12 col-md-10">
  54. <ul class="list-inline">
  55. @if( Setting()->get('code_create_article') )
  56. <li class="pull-right">
  57. @include('theme::layout.auth_captcha')
  58. </li>
  59. @endif
  60. </ul>
  61. </div>
  62. <div class="col-xs-12 col-md-2">
  63. <input type="hidden" id="article_editor_content" name="content" value="{{ old('content',$formData['content']) }}" />
  64. <span class="text-muted" id="draftStatus"></span>
  65. <button type="submit" class="btn btn-primary pull-right editor-submit">发布文章</button>
  66. </div>
  67. </div>
  68. </form>
  69. </div>
  70. </div>
  71. @endsection
  72. @section('script')
  73. <script src="{{ asset('/static/js/summernote/summernote.min.js') }}"></script>
  74. <script src="{{ asset('/static/js/summernote/lang/summernote-zh-CN.min.js') }}"></script>
  75. <script type="text/javascript" src="{{ asset('/static/js/tipask/summernote-ext-attach.js') }}"></script>
  76. <script src="{{ asset('/static/js/select2/js/select2.min.js')}}"></script>
  77. <script type="text/javascript">
  78. $(document).ready(function() {
  79. $('#article_editor').summernote({
  80. lang: 'zh-CN',
  81. height: 350,
  82. placeholder:'撰写文章',
  83. toolbar: [ {!! config('tipask.summernote.blog') !!} ],
  84. callbacks: {
  85. onChange:function (contents, $editable) {
  86. var code = $(this).summernote("code");
  87. $("#article_editor_content").val(code);
  88. $("#draftStatus").html('保存中...');
  89. $.post("{{ route('auth.draft.create',['type'=>'article']) }}",$("#article_form").serialize(),function(msg){
  90. $("#draftStatus").html('已保存草稿');
  91. });
  92. },
  93. onImageUpload: function(files) {
  94. upload_editor_image(files[0],'article_editor');
  95. }
  96. }
  97. });
  98. });
  99. </script>
  100. @endsection