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.

base.html 13KB

1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
3 jaren geleden
3 jaren geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
3 jaren geleden
1 jaar geleden
3 jaren geleden
3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <!--
  2. # @name: base.html
  3. # @version: 0.1
  4. # @creation_date: 2021-10-20
  5. # @license: The MIT License <https://opensource.org/licenses/MIT>
  6. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  7. # @purpose: Basic layout for all pages
  8. # @acknowledgements:
  9. # https://www.digitalocean.com/community/tutorials/how-to-make-a-web-application-using-flask-in-python-3
  10. # Bootstrap 5.1.3: https://getbootstrap.com/
  11. # Flask-Moment: https://flask-moment.readthedocs.io/en/latest/
  12. # Boostrap select: https://stackoverflow.com/questions/67942546/bootstrap-5-select-dropdown-with-the-multiple-attribute-collapsed
  13. -->
  14. {% macro relationships_links(relationships) %}
  15. {% if relationships %}
  16. {% for relationship in relationships %}
  17. {{ resource_lead(relationship)}}
  18. {% endfor %}
  19. {% endif %}
  20. {% endmacro %}
  21. {% macro book_with_related(resource, loop, relationships, pre_title='', post_title='Related') %}
  22. <div class="w-full overflow-x-scroll my-8 pb-12 border-b-2 border-black">
  23. <div class="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" >
  24. <div class=" w-40 pl-16 pt-4 row-start-1 ">
  25. {% if pre_title == '' %}
  26. <p>{{loop.index}} / {{count}}</p>
  27. {% else %}
  28. <p>{{ pre_title }}</p>
  29. {% endif %}
  30. </div>
  31. <div class="w-[32rem] shrink-0 row-start-1 row-span-3">
  32. {{ resource_lead(resource) }}
  33. </div>
  34. <div class=" w-52 pl-24 pt-4 row-start-1 ">
  35. {{ post_title }}
  36. </div>
  37. <div class="h-12">
  38. </div>
  39. {% if resource['name'] != 'practice' %}
  40. <div class="w-52 pl-24 pt-4 ">
  41. Related practices
  42. </div>
  43. {% endif %}
  44. {% for relationship in relationships %}
  45. <div class="shrink-0 min-w-[32rem] row-start-1">
  46. {{ resource_lead(relationship) }}
  47. </div>
  48. {% endfor %}
  49. <!-- <div class=""></div>
  50. <div class="cell practice">
  51. <h2>Collaborative writing</h2>
  52. </div>
  53. <div class="shrink-0 min-w-[32rem] row-start-1">
  54. {{ resource_lead(resource) }}
  55. </div>
  56. <div class="shrink-0 min-w-[32rem] row-start-1">
  57. {{ resource_lead(resource) }}
  58. </div> -->
  59. </div>
  60. </div>
  61. {% endmacro %}
  62. {% macro resource_with_related(resource, loop, pre_title='', post_title='Related') %}
  63. <div class="w-full overflow-x-scroll my-8 pb-12 border-b-2 border-black">
  64. <div class="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" >
  65. <div class=" w-40 pl-16 pt-4 row-start-1 ">
  66. {% if pre_title == '' %}
  67. <p>{{loop.index}} / {{count}}</p>
  68. {% else %}
  69. <p>{{ pre_title }}</p>
  70. {% endif %}
  71. </div>
  72. <div class="w-[32rem] shrink-0 row-start-1 row-span-3">
  73. {{ resource_lead(resource) }}
  74. </div>
  75. <div class=" w-52 pl-24 pt-4 row-start-1 ">
  76. {{ post_title }}
  77. </div>
  78. <div class="h-12">
  79. </div>
  80. {% if resource['name'] != 'practice' %}
  81. <div class="w-52 pl-24 pt-4 ">
  82. Related practices
  83. </div>
  84. {% endif %}
  85. <div class="shrink-0 min-w-[32rem] row-start-1">
  86. {{ resource_lead(resource) }}
  87. </div>
  88. <div class=""></div>
  89. <div class="cell practice">
  90. <h2>Collaborative writing</h2>
  91. </div>
  92. <div class="shrink-0 min-w-[32rem] row-start-1">
  93. {{ resource_lead(resource) }}
  94. </div>
  95. <div class="shrink-0 min-w-[32rem] row-start-1">
  96. {{ resource_lead(resource) }}
  97. </div>
  98. </div>
  99. </div>
  100. {% endmacro %}
  101. {% macro popup_link(title,url) %}
  102. <a href="{{ url }}" class="nav-link">
  103. {{ title }}
  104. </a>
  105. {% endmacro %}
  106. {% macro resource_lead(resource) %}
  107. <div class="relative cell ">
  108. <a
  109. class="block h-full hover:opacity-60 transition-opacity cursor-pointer "
  110. {% if resource['type'] == 'book' %}
  111. href="{{ url_for('book.show_book', book_id=resource['id']) }}"
  112. {% endif %}
  113. {% if resource['type'] == 'tool' %}
  114. href="{{ url_for('tool.show_tool', tool_id=resource['id']) }}"
  115. {% endif %}
  116. {% if resource['type'] == 'practice' %}
  117. href="{{ url_for('practice.show_practice', practice_id=resource['id']) }}"
  118. {% endif %}
  119. hx-target="#modal-content"
  120. hx-select="main"
  121. hx-swap="innerHTML"
  122. @click="openModal()"
  123. >
  124. {% if (resource['type'] == 'book') %}
  125. <img class="w-20 h-20 object-contain float-right mt-4 ml-4 mb-4 grayscale rotate-[15deg]" src="https://dummyimage.com/4:5x70" alt="cover for {{ resource['name'] }}">
  126. {% endif %}
  127. <h2 class="{{ resource['type'] }} mb-2">{{ resource['name'] }}</h2>
  128. {% if resource['year'] %}
  129. <div class=" text-sm">
  130. {{ resource['year'] }}{% if resource['author'] %}, {{ resource['author'] }}{% endif%}
  131. </div>
  132. {% endif %}
  133. <div class="text-xl mb-[1em]">
  134. {{ resource['description'] | truncate(150) }}
  135. </div>
  136. </a>
  137. {% if current_user.is_authenticated %}
  138. <div class="">
  139. {% if resource['type'] == 'tool' %}
  140. <a href="{{ url_for('tool.edit_tool', tool_id=resource['id']) }}">
  141. <span class="absolute top-0 left-0 text-xs">Edit</span>
  142. </a>
  143. {% elif resource['type'] == 'practice' %}
  144. <a href="{{ url_for('practice.edit_practice', practice_id=resource['id']) }}">
  145. <span class="absolute top-0 left-0 text-xs">Edit</span>
  146. </a>
  147. {% elif resource['type'] == 'book' %}
  148. <a href="{{ url_for('book.edit_book', book_id=resource['id']) }}">
  149. <span class="absolute top-0 left-0 text-xs">Edit</span>
  150. </a>
  151. {% endif %}
  152. </div>
  153. {% endif %}
  154. </div>
  155. {% endmacro %}
  156. <!DOCTYPE html>
  157. <html>
  158. <head>
  159. {{ moment.include_moment() }}
  160. <meta charset="utf-8">
  161. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  162. <meta name="viewport" content="width=device-width, initial-scale=1">
  163. <script src="https://unpkg.com/htmx.org@1.8.6"></script>
  164. <script src="//unpkg.com/alpinejs" defer></script>
  165. <title>ExPub Compendium</title>
  166. <link href="{{ url_for('static',filename='styles/main.css') }}" rel="stylesheet">
  167. <script>
  168. // htmx.on('htmx:beforeRequest', e=> {
  169. // console.log(e)
  170. // })
  171. // htmx.logAll()
  172. function base() {
  173. return {
  174. menuOpen: false,
  175. modalOpen: false,
  176. showRelated: false,
  177. home: '/',
  178. hideIfBase() {
  179. let str = document.location.toString();
  180. str = str.replace('http://', '');
  181. str = str.replace('https://', '');
  182. let l = str.split('/').length - 1;
  183. if (l < 2) {
  184. this.modalOpen = false;
  185. }
  186. return l;
  187. },
  188. init() {
  189. this.$watch('document.location', (value, oldValue) => {
  190. console.log('new url', value);
  191. });
  192. window.addEventListener('popstate', e => {
  193. this.hideIfBase();
  194. });
  195. },
  196. hideOverlay() {
  197. this.modalOpen = false;
  198. // window.history.pushState({}, '', this.home);
  199. },
  200. openModal() {
  201. // this.$refs.modal.innerHTML = '';
  202. this.modalOpen = true;
  203. let mc = document.querySelector('#modal-content');
  204. mc.scrollTo(0, 0);
  205. }
  206. }
  207. }
  208. </script>
  209. </head>
  210. <body
  211. class="text-base overflow-y-scroll"
  212. x-data="base()"
  213. hx-boost="true"
  214. hx-select="#all"
  215. hx-target="#all"
  216. hx-swap="outerHTML"
  217. hx-indicator="body"
  218. >
  219. <div id="loading" class="loading pointer-events-none fixed top-0 left-0 w-full h-screen z-50">
  220. </div>
  221. <div id="all">
  222. <header class="sticky top-0 z-10 bg-white std-padding border-b-[2px] border-black">
  223. <nav class=" lg:flex justify-between">
  224. <a class="link inline-block w-40" href="{{ url_for('main.index') }}">ExPub<br>Compendium</a>
  225. <div class="mr-8">
  226. <h2><a href="{{ url_for('tool.get_tools') }}" class="tool link align-bottom">Tools</a></h2>
  227. </div>
  228. <div class="mr-8">
  229. <h2>
  230. <a href="{{ url_for('practice.get_practices') }}" class="practice link">
  231. Practices
  232. </a>
  233. </h2>
  234. </div>
  235. <div class="mr-8">
  236. <h2>
  237. <a href="{{ url_for('book.get_books') }}" class="book link">
  238. Books
  239. </a>
  240. </h2>
  241. </div>
  242. <!-- <div class="mr-8">
  243. <h2 class="">
  244. <a href="{{ url_for('practice.get_practices') }}" class="practice link">
  245. Typologies
  246. </a>
  247. </h2>
  248. </div> -->
  249. <div class="mr-8">
  250. <a href="{{ url_for('main.about') }}"
  251. class="{{ 'active' if request.path == url_for('main.about') }} ml-auto link mr-auto">
  252. About<br>ExPub
  253. </a>
  254. </div>
  255. <div class="ml-auto mr-2">
  256. {% if current_user.is_authenticated %}
  257. <a href="{{ url_for('create.create_resource') }}" class="block link">
  258. Add resource
  259. </a>
  260. {% endif %}
  261. {% if current_user.is_authenticated %}
  262. <a href="{{ url_for('main.profile') }}" class="block link">
  263. Profile
  264. </a>
  265. {% endif %}
  266. {% if not current_user.is_authenticated %}
  267. <a href="{{ url_for('auth.login') }}" class="block link">
  268. Login
  269. </a>
  270. <a href="{{ url_for('auth.signup') }}" class="block link">
  271. Sign Up
  272. </a>
  273. {% endif %}
  274. {% if current_user.is_authenticated %}
  275. <a href="{{ url_for('auth.logout') }}" class="block link">
  276. Logout
  277. </a>
  278. {% endif %}
  279. </div>
  280. <input class=" text-base border-2 border-black p-1 " type="text" placeholder="Search">
  281. </nav>
  282. </header>
  283. <!-- Begin page content -->
  284. <main>
  285. {% with messages = get_flashed_messages() %}
  286. {% if messages %}
  287. <div class="alert alert-danger">
  288. {{ messages[0] }}
  289. </div>
  290. {% endif %}
  291. {% endwith %}
  292. {% block content %}
  293. {% endblock %}
  294. </main>
  295. </div>
  296. <div id="modal" x-show="modalOpen" class="modal h-screen w-full fixed top-0 z-20 p-4 bg-black/20 overscroll-none">
  297. <div class="cross cursor-pointer absolute top-10 right-10 w-10 h-10" @click="hideOverlay()">
  298. <svg width="100%" height="100%" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  299. <path d="M2 2L18 18M18 2L2 18" stroke="black" stroke-width="1"></path>
  300. </svg>
  301. </div>
  302. <div id="modal-content" @click.outside="hideOverlay()" x-ref="modal" class="content w-full overflow-y-scroll h-full bg-white " style="box-shadow:0 0 4rem rgba(0,0,0,0.3)">
  303. </div>
  304. </div>
  305. <!-- Sticky footer-->
  306. <footer class="std-margin mt-20 text-sm">
  307. <div class="container">
  308. <span class="">© 2022–{{ moment().format('YYYY') }} <a href="https://copim.ac.uk/">COPIM</a> and licensed under a <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License (CC BY 4.0)</a>.</span>
  309. </div>
  310. </footer>
  311. <!-- JavaScript -->
  312. <!-- jQuery first, then Popper JS, then Bootstrap JS -->
  313. <script src="{{ url_for('static',filename='js/main.js') }}"></script>
  314. </body>
  315. </html>