You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
5.5 KiB

4 years ago
  1. {% from 'macros.html' import follow_area with context %}
  2. <nav aria-label="Page navigation">
  3. <ul class="pagination">
  4. <li class="page-item">
  5. <a class="page-link" href="{{ url_for('.photo_previous', photo_id=photo.id) }}">&larr;Previous</a>
  6. </li>
  7. <li class="page-item">
  8. <a class="page-link" href="{{ url_for('.photo_next', photo_id=photo.id) }}">Next&rarr;</a>
  9. </li>
  10. </ul>
  11. </nav>
  12. <div class="card bg-light mb-3 w-100 sidebar-card">
  13. <div class="card-body">
  14. <div class="row">
  15. <a href="{{ url_for('user.index', username=photo.author.username) }}">
  16. <img class="sidebar-avatar rounded avatar-m"
  17. src="{{ url_for('main.get_avatar', filename=photo.author.avatar_m) }}">
  18. </a>
  19. <div class="sidebar-profile">
  20. <h6 class="card-title">
  21. <a href="{{ url_for('user.index', username=photo.author.username) }}">{{ photo.author.name }}</a>
  22. </h6>
  23. <p class="card-subtitle mb-2 text-muted">{{ photo.author.username }}</p>
  24. {{ follow_area(photo.author) }}
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="card bg-light mb-3 w-100">
  30. <div class="card-body">
  31. <div id="description">
  32. <p>
  33. {% if photo.description %}
  34. {{ photo.description }}
  35. {% endif %}
  36. {% if current_user == photo.author %}
  37. <a id="description-btn" href="#!">
  38. <small><span class="oi oi-pencil"></span> 编辑简介</small>
  39. </a>
  40. {% endif %}
  41. </p>
  42. </div>
  43. {% if current_user == photo.author %}
  44. <div id="description-form">
  45. <form action="{{ url_for('.edit_description', photo_id=photo.id) }}" method="post">
  46. {{ description_form.csrf_token }}
  47. {{ render_field(description_form.description) }}
  48. <a class="btn btn-light btn-sm" id="cancel-description">取消</a>
  49. {{ render_field(description_form.submit, class='btn btn-success btn-sm') }}
  50. </form>
  51. </div>
  52. {% endif %}
  53. <div id="tags">
  54. <p>
  55. {% if photo.tags %}
  56. {% for tag in photo.tags %}
  57. <a class="badge badge-light"
  58. href="{{ url_for('.show_tag', tag_id=tag.id) }}" target="_blank"><span
  59. class="oi oi-tag"></span> {{ tag.name }}</a>
  60. {% endfor %}
  61. {% endif %}
  62. {% if current_user == photo.author %}
  63. <a id="tag-btn" href="#!">
  64. <small><span class="oi oi-pencil"></span> 编辑标签</small>
  65. </a>
  66. {% endif %}
  67. </p>
  68. </div>
  69. {% if current_user == photo.author %}
  70. <div id="tag-form">
  71. <form action="{{ url_for('.new_tag', photo_id=photo.id) }}" method="post">
  72. {{ tag_form.csrf_token }}
  73. {{ render_field(tag_form.tag) }}
  74. <a class="btn btn-light btn-sm" id="cancel-tag">取消</a>
  75. {{ render_field(tag_form.submit, class='btn btn-success btn-sm') }}
  76. </form>
  77. {% if photo.tags %}
  78. <hr>
  79. {% for tag in photo.tags %}
  80. <a class="dead-link" href="#!"
  81. data-href="{{ url_for('.delete_tag', photo_id=photo.id, tag_id=tag.id) }}"
  82. data-toggle="modal" data-target="#confirm-delete" title="删除标签">
  83. <span class="badge badge-danger">
  84. {{ tag.name }} <span class="oi oi-trash" aria-hidden="true"></span>
  85. </span>
  86. </a>
  87. {% endfor %}
  88. {% endif %}
  89. </div>
  90. {% endif %}
  91. {% if current_user.is_authenticated %}
  92. {% if current_user.is_collecting(photo) %}
  93. <form class="inline" method="post"
  94. action="{{ url_for('main.uncollect', photo_id=photo.id) }}">
  95. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  96. <button type="submit" class="btn btn-outline-secondary btn-sm">
  97. <span class="oi oi-x"></span> 取消收藏
  98. </button>
  99. </form>
  100. {% else %}
  101. <form class="inline" method="post"
  102. action="{{ url_for('main.collect', photo_id=photo.id) }}">
  103. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  104. <button type="submit" class="btn btn-outline-primary btn-sm">
  105. <span class="oi oi-star"></span> 收藏
  106. </button>
  107. </form>
  108. {% endif %}
  109. {% else %}
  110. <form class="inline" method="post" action="{{ url_for('main.collect', photo_id=photo.id) }}">
  111. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  112. <button type="submit" class="btn btn-primary btn-sm">
  113. <span class="oi oi-star"></span> 收藏
  114. </button>
  115. </form>
  116. {% endif %}
  117. {% if photo.collectors %}
  118. <a href="{{ url_for('main.show_collectors', photo_id=photo.id) }}">{{ photo.collectors|length }}
  119. 收藏者</a>
  120. {% endif %}
  121. </div>
  122. </div>