選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

book.html 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. {% extends 'base.html' %}
  2. {% block content %}
  3. {% if book['thumbnail'] %}
  4. <img class="img-fluid mx-auto d-block py-3" src={{ book['thumbnail'] }} alt="cover for {{ book['Title'] }}">
  5. {% else %}
  6. <div class="row">
  7. <div class="col">
  8. <h1 class="text-center">{% block title %} {{ book['Title'] or resource['name'] }} {% endblock %}</h1>
  9. </div>
  10. </div>
  11. {% endif %}
  12. {% if current_user.is_authenticated %}
  13. <div class="row text-center py-3">
  14. <a href="{{ url_for('book.edit_book', book_id=resource['id']) }}">
  15. <span class="badge bg-dark">Edit</span>
  16. </a>
  17. </div>
  18. {% endif %}
  19. <div class="row">
  20. <div class="col">
  21. <table class="table table-hover">
  22. <tbody>
  23. {% if book %}
  24. <!-- fields for books from isbntools -->
  25. {% if book['Title'] %}
  26. <tr>
  27. <th>
  28. Title:
  29. </th>
  30. <td>
  31. {{ book['Title'] }}
  32. </td>
  33. </tr>
  34. {% endif %}
  35. {% if book['Authors'] %}
  36. <tr>
  37. {% if book['Authors']|length > 1 %}
  38. <th>
  39. Authors:
  40. </th>
  41. <td>
  42. {% for author in book['Authors'] %}
  43. {{ author }}
  44. {% endfor %}
  45. </td>
  46. {% else %}
  47. <th>
  48. Author:
  49. </th>
  50. <td>
  51. {% for author in book['Authors'] %}
  52. {{ author }}
  53. {% endfor %}
  54. </td>
  55. {% endif %}
  56. </tr>
  57. {% endif %}
  58. {% if book['ISBN-13'] %}
  59. <tr>
  60. <th>
  61. ISBN-13:
  62. </th>
  63. <td>
  64. {{ book['ISBN-13'] }}
  65. </td>
  66. </tr>
  67. {% endif %}
  68. {% if book['Year'] %}
  69. <tr>
  70. <th>
  71. Publication year:
  72. </th>
  73. <td>
  74. {{ book['Year'] }}
  75. </td>
  76. </tr>
  77. {% endif %}
  78. {% if book['Publisher'] %}
  79. <tr>
  80. <th>
  81. Publisher:
  82. </th>
  83. <td>
  84. {{ book['Publisher'] }}
  85. </td>
  86. </tr>
  87. {% endif %}
  88. {% if book['desc'] %}
  89. <tr>
  90. <th>
  91. Summary:
  92. </th>
  93. <td>
  94. {{ book['desc'] }}
  95. </td>
  96. </tr>
  97. {% endif %}
  98. {% else %}
  99. <!-- fields for books from database -->
  100. {% if resource['name'] %}
  101. <tr>
  102. <th>
  103. Title:
  104. </th>
  105. <td>
  106. {{ resource['name'] }}
  107. </td>
  108. </tr>
  109. {% endif %}
  110. {% if resource['author'] %}
  111. <tr>
  112. <th>
  113. Author:
  114. </th>
  115. <td>
  116. {{ resource['author'] }}
  117. </td>
  118. </tr>
  119. {% endif %}
  120. {% endif %}
  121. </tbody>
  122. </table>
  123. </div>
  124. </div>
  125. {% if relationships %}
  126. <div class="row">
  127. <div class="col">
  128. <h2 class="text-center">Linked resources:</h2>
  129. </div>
  130. </div>
  131. <div class="row">
  132. {% for relationship in relationships %}
  133. <div class="col-md-4 col-sm-6 py-3">
  134. {% if relationship['type'] == 'tool' %}
  135. <div class="card text-dark bg-tool mb-3">
  136. <div class="card-body">
  137. <a href="{{ url_for('tool.show_tool', tool_id=relationship['id']) }}">
  138. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  139. </a>
  140. <p class="card-text">
  141. {{ relationship['description']|truncate(100) }}
  142. </p>
  143. </div>
  144. </div>
  145. {% elif relationship['type'] == 'practice' %}
  146. <div class="card text-dark bg-practice mb-3">
  147. <div class="card-body">
  148. <a href="{{ url_for('practice.show_practice', practice_id=relationship['id']) }}">
  149. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  150. </a>
  151. <p class="card-text">
  152. {{ relationship['description']|truncate(100) }}
  153. </p>
  154. </div>
  155. </div>
  156. {% elif relationship['type'] == 'book' %}
  157. <div class="card text-dark bg-book mb-3">
  158. <div class="card-body">
  159. <a href="{{ url_for('book.show_book', book_id=relationship['id']) }}">
  160. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  161. </a>
  162. <p class="card-text">
  163. {{ relationship['description']|truncate(100) }}
  164. </p>
  165. </div>
  166. </div>
  167. {% endif %}
  168. </div>
  169. {% endfor %}
  170. </div>
  171. {% endif %}
  172. {% endblock %}