article_edit.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {{ define "admin/custom_bottom_static" }}
  2. <script>
  3. tinymce.init({
  4. selector: 'textarea#editor-text',
  5. height: 800,
  6. language: 'ru',
  7. statusbar: false,
  8. promotion: false,
  9. plugins: "code"
  10. });
  11. tinymce.init({
  12. selector: 'textarea#editor-preview',
  13. height: 200,
  14. language: 'ru',
  15. statusbar: false,
  16. promotion: false,
  17. plugins: "code"
  18. });
  19. </script>
  20. {{ end }}
  21. <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
  22. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 border-bottom">
  23. <h2 class="h2">{{ .title }}</h2>
  24. </div>
  25. <form method="post" class="mb-5">
  26. <div class="row mb-3 mt-3">
  27. <label class="col-sm-2 col-form-label">Статья активна</label>
  28. <div class="col-sm-10">
  29. <div class="form-check form-switch pt-2">
  30. <input class="form-check-input" type="checkbox" name="is_active" {{ if .form.IsActive }}checked{{ end }}>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="row mb-3 mt-3">
  35. <label class="col-sm-2 col-form-label">Название</label>
  36. <div class="col-sm-10">
  37. {{ $titleErr := index .errors "ArticleForm.Title" }}
  38. <input type="text" class="form-control {{ if $titleErr }}is-invalid{{ end }}" name="title" value="{{ .form.Title }}">
  39. {{ if $titleErr }}
  40. <div class="invalid-feedback">
  41. {{ $titleErr }}
  42. </div>
  43. {{ end }}
  44. </div>
  45. </div>
  46. <div class="row mb-3 mt-3">
  47. <label class="col-sm-2 col-form-label">Картинка</label>
  48. <div class="col-sm-10">
  49. {{ $imageErr := index .errors "ArticleForm.Image" }}
  50. <input type="text" class="form-control {{ if $imageErr }}is-invalid{{ end }}" name="title" value="{{ .form.Image }}">
  51. {{ if $imageErr }}
  52. <div class="invalid-feedback">
  53. {{ $imageErr }}
  54. </div>
  55. {{ end }}
  56. </div>
  57. </div>
  58. <div class="row mb-3 mt-3">
  59. <label class="col-sm-2 col-form-label">URL</label>
  60. <div class="col-sm-10">
  61. {{ $urlErr := index .errors "ArticleForm.URL" }}
  62. <input type="text" class="form-control {{ if $urlErr }}is-invalid{{ end }}" name="url" value="{{ .form.URL }}">
  63. {{ if $urlErr }}
  64. <div class="invalid-feedback">
  65. {{ $urlErr }}
  66. </div>
  67. {{ end }}
  68. </div>
  69. </div>
  70. <div class="row mb-3 mt-3">
  71. <label class="col-sm-2 col-form-label">Дата публикации</label>
  72. <div class="col-sm-10">
  73. {{ $dateErr := index .errors "ArticleForm.PublishTime" }}
  74. <input type="date" class="form-control col-auto {{ if $dateErr }}is-invalid{{ end }}" name="publish_time" value="{{ .form.PublishTime }}">
  75. {{ if $dateErr }}
  76. <div class="invalid-feedback">
  77. {{ $dateErr }}
  78. </div>
  79. {{ end }}
  80. </div>
  81. </div>
  82. <div class="row mb-3 mt-3">
  83. <label class="col-sm-2 col-form-label">Краткий текст</label>
  84. <div class="col-sm-10">
  85. {{ $ptErr := index .errors "ArticleForm.PreviewText" }}
  86. <textarea id="editor-preview" class="form-control {{ if $ptErr }}is-invalid{{ end }}" name="preview_text">{{ .form.PreviewText }}</textarea>
  87. {{ if $ptErr }}
  88. <div class="invalid-feedback">
  89. {{ $ptErr }}
  90. </div>
  91. {{ end }}
  92. </div>
  93. </div>
  94. <div class="row mb-3 mt-3">
  95. <label class="col-sm-2 col-form-label">Текст</label>
  96. <div class="col-sm-10">
  97. {{ $tErr := index .errors "ArticleForm.Text" }}
  98. <textarea id="editor-text" class="form-control {{ if $tErr }}is-invalid{{ end }}" name="text">{{ .form.Text }}</textarea>
  99. {{ if $tErr }}
  100. <div class="invalid-feedback">
  101. {{ $tErr }}
  102. </div>
  103. {{ end }}
  104. </div>
  105. </div>
  106. <div class="row mb-3 mt-3">
  107. <label class="col-sm-2 col-form-label">Meta keywords</label>
  108. <div class="col-sm-10">
  109. {{ $mkErr := index .errors "ArticleForm.MetaKeywords" }}
  110. <input type="text" class="form-control {{ if $mkErr }}is-invalid{{ end }}" name="meta_keywords" value="{{ .form.MetaKeywords }}">
  111. {{ if $mkErr }}
  112. <div class="invalid-feedback">
  113. {{ $mkErr }}
  114. </div>
  115. {{ end }}
  116. </div>
  117. </div>
  118. <div class="row mb-3 mt-3">
  119. <label class="col-sm-2 col-form-label">Meta description</label>
  120. <div class="col-sm-10">
  121. {{ $mdErr := index .errors "ArticleForm.MetaDescription" }}
  122. <input type="text" class="form-control {{ if $mdErr }}is-invalid{{ end }}" name="meta_description" value="{{ .form.MetaDescription }}">
  123. {{ if $mdErr }}
  124. <div class="invalid-feedback">
  125. {{ $mdErr }}
  126. </div>
  127. {{ end }}
  128. </div>
  129. </div>
  130. <div class="row mb-3 mt-3 border-bottom">
  131. <label class="col-sm-2 col-form-label">Теги</label>
  132. <div class="col-sm-10">
  133. {{ $tags := .form.Tags }}
  134. {{ range .tags }}
  135. <div class="form-check">
  136. <input class="form-check-input" type="checkbox" name="tag{{ .ID }}" {{ if index $tags .ID }}checked{{ end }}>
  137. <label class="form-check-label">
  138. {{ .Tag }}
  139. </label>
  140. </div>
  141. {{ end }}
  142. </div>
  143. </div>
  144. <a href="/admin" class="btn btn-secondary">Назад</a>
  145. <button type="submit" class="btn btn-primary">Сохранить</button>
  146. </form>
  147. </main>