category.html 7.1 KB

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