category.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. {% extends "_common/base.html" %}
  2. {% block css %}
  3. {% load avatar_tags %}{% load day_util %}
  4. {% load page_tag %}
  5. /* class to hide content visually leaving it available to screenreaders.
  6. See notes in cookbook recipe.
  7. https://github.com/h5bp/html5-boilerplate/issues/1985#issuecomment-394096182
  8. https://medium.com/@matuzo/writing-css-with-accessibility-in-mind-8514a0007939
  9. */
  10. .visuallyhidden {
  11. border: 0;
  12. clip: rect(0 0 0 0);
  13. height: auto;
  14. margin: 0;
  15. overflow: hidden;
  16. padding: 0;
  17. position: absolute;
  18. width: 1px;
  19. white-space: nowrap;
  20. }
  21. nav {
  22. display: flex;
  23. justify-content: right;
  24. border-top: 1px solid #eee;
  25. margin-top: 1em;
  26. padding-top: .5em;
  27. }
  28. .pagination {
  29. list-style: none;
  30. margin: 0;
  31. padding: 0;
  32. display: flex;
  33. }
  34. .pagination li {
  35. margin: 0 1px;
  36. }
  37. .pagination a {
  38. display: block;
  39. padding: .5em 1em;
  40. border: 1px solid #999;
  41. border-radius: .2em;
  42. text-decoration: none;
  43. }
  44. .pagination a[aria-current="page"] {
  45. background-color: #333;
  46. color: #fff;
  47. }
  48. {% endblock %}
  49. {% block container %}
  50. <div class="ui grid stackable container">
  51. <div class="row" id="article">
  52. <div class="eleven wide column">
  53. <div class="ui feed">
  54. <h2>{{ current_category }}</h2>
  55. <nav aria-label="pagination">
  56. <ul class="pagination">
  57. {% if articles.number > 1 %}
  58. <li><a href="?page={{ articles.number|add:-1 }}"><span aria-hidden="true">«</span><span
  59. class="visuallyhidden">previous set of pages</span></a>
  60. </li>
  61. {% else %}
  62. <li><a href=""><span aria-hidden="true">«</span><span class="visuallyhidden">previous set of pages</span></a>
  63. </li>
  64. {% endif %}
  65. {% for page in articles.paginator.page_range %}
  66. {% circle_page_index articles.number page %}
  67. {% endfor %}
  68. {% if articles.number < articles.paginator.num_pages %}
  69. <li><a href="?page={{ articles.number | add:1 }}"><span class="visuallyhidden">next set of pages</span><span
  70. aria-hidden="true">»</span></a></li>
  71. {% else %}
  72. <li><a href=""><span class="visuallyhidden">next set of pages</span><span
  73. aria-hidden="true">»</span></a></li>
  74. {% endif %}
  75. </ul>
  76. </nav>
  77. {% for item in articles %}
  78. {% if item.status == 1 %}
  79. {% if item.type == 1 %}
  80. <div class="event">
  81. <div class="label">
  82. <img src="/user_avatar/{{ item.user_id }}">
  83. </div>
  84. <div class="content">
  85. <div class="date"
  86. style="font-size: 1.1em">{{ item.created_time | days_until }}</div>
  87. <div class="summary"><a>
  88. {{ item.user__first_name }}{{ item.user__last_name }}</a>
  89. 发布了{{ item.category__name }}:<a
  90. href="/article/{{ item.id }}.html">{{ item.title }}</a>
  91. {% if is_login %}
  92. <a title="置顶" href="/article/show_show_index/{{ item.id }}"><i class="icon home"></i></a>
  93. {% endif %}</div>
  94. <div class="extra text">{{ item.intro }}
  95. &nbsp;&nbsp;&nbsp;Tags:
  96. {% for tag in item.tags %}
  97. <a href="/tag/{{ tag }}?page=1"><span
  98. class="label label-success">{{ tag }}</span></a>
  99. {% endfor %}</div>
  100. </div>
  101. </div>
  102. {% elif item.type == 2 %}
  103. <div class="event">
  104. <div class="label">
  105. <img src="/user_avatar/{{ item.user_id }}">
  106. </div>
  107. <div class="content">
  108. <div class="date"
  109. style="font-size: 1.1em">{{ item.created_time | days_until }}</div>
  110. <div class="summary"><a>
  111. {{ item.user__first_name }}{{ item.user__last_name }}</a>
  112. 发布了{{ item.category__name }}:<a
  113. href="/article/{{ item.id }}.html">{{ item.title }}</a>
  114. {% if is_login %}
  115. <a title="置顶" href="/article/show_show_index/{{ item.id }}"><i class="icon home"></i></a>
  116. {% endif %}</div>
  117. {% autoescape off %}
  118. <div class="extra images">
  119. {{ item.html_text }}
  120. </div>
  121. {% endautoescape %}
  122. </div>
  123. </div>
  124. {% endif %}
  125. {% endif %}
  126. {% endfor %}
  127. </div>
  128. </div>
  129. <div class="four wide right floated column">
  130. <h4 class="ui header">搜索</h4>
  131. <div id="search" class="ui category search">
  132. <div class="ui icon input">
  133. <input class="prompt" type="text" placeholder="搜索">
  134. <i class="search icon"></i>
  135. </div>
  136. </div>
  137. <h4 class="ui header">归档</h4>
  138. <div class="ui list">
  139. {% for record in records %}
  140. <a class="item" href="/date/{{ record.datetime }}?page=1">{{ record.datetime }}
  141. ({{ record.count }})</a>
  142. {% endfor %}
  143. </div>
  144. <h4 class="ui header">Top</h4>
  145. <div class="ui list">
  146. {% for tag in tags %}
  147. <a class="item" href="/tag/{{ tag.name }}?page=1">{{ tag.name }} ({{ tag.count }})</a>
  148. {% endfor %}
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. {% endblock %}
  154. {% block js %}
  155. <script>
  156. function submit() {
  157. let formData = new FormData()
  158. formData.append('title', $("input[name='title']").val())
  159. formData.append('intro', editor.getText())
  160. formData.append('category', 6)
  161. formData.append('html', editor.getHtml())
  162. formData.append('markdown', editor.getText())
  163. formData.append('type', 2)
  164. formData.append('tags', '')
  165. formData.append('status', 1)
  166. formData.append('is_top', 1)
  167. formData.append('csrfmiddlewaretoken', $("input[name='csrfmiddlewaretoken']").val())
  168. $.ajax('/management/article/add_article', {
  169. method: 'post',
  170. data: formData,
  171. contentType: false,
  172. processData: false,
  173. success: function (res) {
  174. window.location.href = '/'
  175. },
  176. error: function (err) {
  177. }
  178. })
  179. }
  180. </script>
  181. {% endblock %}
  182. {% load static %}