category.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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>{{ item.user__first_name }}{{ item.user__last_name }}</a>
  88. 发布了{{ item.category__name }}:&nbsp;<a href="/article/{{ item.id }}.html">{{ item.title }}</a></div>
  89. <div class="extra text">{{ item.intro }}
  90. &nbsp;&nbsp;&nbsp;Tags:
  91. {% for tag in item.tags %}
  92. <a href="/tag/{{ tag }}?page=1"><span
  93. class="label label-success">{{ tag }}</span></a>
  94. {% endfor %}</div>
  95. </div>
  96. </div>
  97. {% elif item.type == 2 %}
  98. <div class="event">
  99. <div class="label">
  100. <img src="/user_avatar/{{ item.user_id }}">
  101. </div>
  102. <div class="content">
  103. <div class="date"
  104. style="font-size: 1.1em">{{ item.created_time | days_until }}</div>
  105. <div class="summary"><a>{{ item.user__first_name }}{{ item.user__last_name }}</a>
  106. 发布了{{ item.category__name }}:&nbsp;<a href="/article/{{ item.id }}.html">{{ item.title }}</a></div>
  107. {% autoescape off %}
  108. <div class="extra images">
  109. {{ item.html_text }}
  110. </div>
  111. {% endautoescape %}
  112. </div>
  113. </div>
  114. {% endif %}
  115. {% endif %}
  116. {% endfor %}
  117. </div>
  118. </div>
  119. <div class="four wide right floated column">
  120. <h4 class="ui header">归档</h4>
  121. <div class="ui list">
  122. {% for record in records %}
  123. <a class="item" href="/date/{{ record.datetime }}?page=1">{{ record.datetime }} ({{ record.count }})</a>
  124. {% endfor %}
  125. </div>
  126. <h4 class="ui header">Top</h4>
  127. <div class="ui list">
  128. {% for tag in tags %}
  129. <a class="item" href="/tag/{{ tag.name }}?page=1">{{ tag.name }} ({{ tag.count }})</a>
  130. {% endfor %}
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. {% endblock %}
  136. {% block js %}
  137. <script>
  138. function submit() {
  139. let formData = new FormData()
  140. formData.append('title', $("input[name='title']").val())
  141. formData.append('intro', editor.getText())
  142. formData.append('category', 6)
  143. formData.append('html', editor.getHtml())
  144. formData.append('markdown', editor.getText())
  145. formData.append('type', 2)
  146. formData.append('tags', '')
  147. formData.append('status', 1)
  148. formData.append('is_top', 1)
  149. formData.append('csrfmiddlewaretoken', $("input[name='csrfmiddlewaretoken']").val())
  150. $.ajax('/management/article/add_article', {
  151. method: 'post',
  152. data: formData,
  153. contentType: false,
  154. processData: false,
  155. success: function (res) {
  156. window.location.href = '/'
  157. },
  158. error: function (err) {
  159. }
  160. })
  161. }
  162. </script>
  163. {% endblock %}
  164. {% load static %}