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.

216 lines
8.0KB

  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 resource['bookUrl'] %}
  24. <tr>
  25. <th>
  26. URL:
  27. </th>
  28. <td>
  29. <a href="{{ resource['bookUrl'] }}">{{ resource['bookUrl'] }}</a>
  30. </td>
  31. </tr>
  32. {% endif %}
  33. {% if book %}
  34. <!-- fields for books from isbntools -->
  35. {% if book['Title'] %}
  36. <tr>
  37. <th>
  38. Title:
  39. </th>
  40. <td>
  41. {{ book['Title'] }}
  42. </td>
  43. </tr>
  44. {% endif %}
  45. {% if book['Authors'] %}
  46. <tr>
  47. {% if book['Authors']|length > 1 %}
  48. <th>
  49. Authors:
  50. </th>
  51. <td>
  52. {% for author in book['Authors'] %}
  53. {{ author }}</br>
  54. {% endfor %}
  55. </td>
  56. {% else %}
  57. <th>
  58. Author:
  59. </th>
  60. <td>
  61. {% for author in book['Authors'] %}
  62. {{ author }}
  63. {% endfor %}
  64. </td>
  65. {% endif %}
  66. </tr>
  67. {% endif %}
  68. {% if book['ISBN-13'] %}
  69. <tr>
  70. <th>
  71. ISBN-13:
  72. </th>
  73. <td>
  74. {{ book['ISBN-13'] }}
  75. </td>
  76. </tr>
  77. {% endif %}
  78. {% if book['Year'] %}
  79. <tr>
  80. <th>
  81. Publication year:
  82. </th>
  83. <td>
  84. {{ book['Year'] }}
  85. </td>
  86. </tr>
  87. {% endif %}
  88. {% if book['Publisher'] %}
  89. <tr>
  90. <th>
  91. Publisher:
  92. </th>
  93. <td>
  94. {{ book['Publisher'] }}
  95. </td>
  96. </tr>
  97. {% endif %}
  98. {% if book['desc'] %}
  99. <tr>
  100. <th>
  101. Summary:
  102. </th>
  103. <td>
  104. {{ book['desc'] }}
  105. </td>
  106. </tr>
  107. {% else %}
  108. {% if resource['description'] %}
  109. <tr>
  110. <th>
  111. Summary:
  112. </th>
  113. <td>
  114. {{ resource['description'] }}
  115. </td>
  116. </tr>
  117. {% endif %}
  118. {% endif %}
  119. {% else %}
  120. <!-- fields for books from database -->
  121. {% if resource['name'] %}
  122. <tr>
  123. <th>
  124. Title:
  125. </th>
  126. <td>
  127. {{ resource['name'] }}
  128. </td>
  129. </tr>
  130. {% endif %}
  131. {% if resource['author'] %}
  132. <tr>
  133. <th>
  134. Author:
  135. </th>
  136. <td>
  137. {{ resource['author'] }}
  138. </td>
  139. </tr>
  140. {% endif %}
  141. {% if resource['year'] %}
  142. <tr>
  143. <th>
  144. Publication year:
  145. </th>
  146. <td>
  147. {{ resource['year'] }}
  148. </td>
  149. </tr>
  150. {% endif %}
  151. {% if resource['description'] %}
  152. <tr>
  153. <th>
  154. Summary:
  155. </th>
  156. <td>
  157. {{ resource['description'] }}
  158. </td>
  159. </tr>
  160. {% endif %}
  161. {% endif %}
  162. </tbody>
  163. </table>
  164. </div>
  165. </div>
  166. {% if relationships %}
  167. <div class="row">
  168. <div class="col">
  169. <h2 class="text-center">Linked resources:</h2>
  170. </div>
  171. </div>
  172. <div class="row">
  173. {% for relationship in relationships %}
  174. <div class="col-md-4 col-sm-6 py-3">
  175. {% if relationship['type'] == 'tool' %}
  176. <div class="card text-dark bg-tool mb-3">
  177. <div class="card-body">
  178. <a href="{{ url_for('tool.show_tool', tool_id=relationship['id']) }}">
  179. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  180. </a>
  181. <p class="card-text">
  182. {{ relationship['description']|truncate(100) }}
  183. </p>
  184. </div>
  185. </div>
  186. {% elif relationship['type'] == 'practice' %}
  187. <div class="card text-dark bg-practice mb-3">
  188. <div class="card-body">
  189. <a href="{{ url_for('practice.show_practice', practice_id=relationship['id']) }}">
  190. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  191. </a>
  192. <p class="card-text">
  193. {{ relationship['description']|truncate(100) }}
  194. </p>
  195. </div>
  196. </div>
  197. {% elif relationship['type'] == 'book' %}
  198. <div class="card text-dark bg-book mb-3">
  199. <div class="card-body">
  200. <a href="{{ url_for('book.show_book', book_id=relationship['id']) }}">
  201. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  202. </a>
  203. <p class="card-text">
  204. {{ relationship['description']|truncate(100) }}
  205. </p>
  206. </div>
  207. </div>
  208. {% endif %}
  209. </div>
  210. {% endfor %}
  211. </div>
  212. {% endif %}
  213. {% endblock %}