Index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <Layout>
  3. <!-- introductions -->
  4. <div class="no-folio v-center grow">
  5. <div v-for="edge in $page.introductions.edges.slice().reverse()" :key="`introductions${edge.node.id}`">
  6. <VueMarkdown class="intro">{{edge.node.contenu}}
  7. </VueMarkdown>
  8. </div>
  9. </div>
  10. <div class="blank-page no-folio fill-motif-cross-left" />
  11. <!-- Auteurs, titre, sous-titre -->
  12. <div class="column no-folio">
  13. <div class="fill-motif-cross-right layer-1">
  14. </div>
  15. <div class="column layer-2">
  16. <div class="bold center" v-for="auteur in $static.metadata.authors">
  17. {{auteur}}
  18. </div>
  19. <div class="v-center grow">
  20. <div class="center">
  21. <h1 class="main-title center highlight-white" v-html="$static.metadata.title" />
  22. </br>
  23. <h2 class="main-pre-title center highlight-white" v-html="$static.metadata.subtitle" />
  24. </div>
  25. </div>
  26. <div class="center">
  27. <img src="/logo_popsu.png" alt="" style="width:2cm;">
  28. </div>
  29. </div>
  30. </div>
  31. <!-- Page de fond -->
  32. <div class="column image-cover image-bleed" v-bind:style='{ backgroundImage: `url(https://popsu-rouen-en.strapi.figli.io/uploads/50424a6a43e44551a4faa699f8ef3caa.JPEG)`, }' />
  33. <!-- Sommaire -->
  34. <div class="no-folio column">
  35. <div class="section-title still">
  36. Sommaire
  37. </div>
  38. <div class="column justify-end table-of-content">
  39. <span v-for="edge in $page.chapitres.edges.slice().reverse()" :key="`sommaire${edge.node.id}`">
  40. <a v-if="edge.node.alternatif" v-html="edge.node.alternatif" :href="'#chapitres'+edge.node.id">
  41. </a>
  42. <a v-else :href="'#chapitres'+edge.node.id">
  43. {{ edge.node.Titre }}
  44. </a>
  45. </span>
  46. </div>
  47. </div>
  48. <!-- Chapitres -->
  49. <div v-for="(edge,index) in $page.chapitres.edges.slice().reverse()" :key="`chapitre${edge.node.id}`">
  50. <div class="blank-page no-folio breakBeforeLeft" />
  51. <div v-if="edge.node.Rubrique">
  52. <div class="section-title">
  53. {{edge.node.Rubrique}}
  54. </div>
  55. <VueMarkdown :id="`chapitres${edge.node.id}`" class="chapter-title ">{{edge.node.Titre}}</VueMarkdown>
  56. </div>
  57. <div v-else>
  58. <VueMarkdown :id="`chapitres${edge.node.id}`" class="chapter-title">{{edge.node.Titre}}</VueMarkdown>
  59. </div>
  60. <VueMarkdown lang="en-us" class="hyphen chapter-content justify">{{edge.node.Contenu}}
  61. </VueMarkdown>
  62. </div>
  63. <!-- Page blanche -->
  64. <div class="blank-page no-folio" />
  65. <!-- Sections -->
  66. <div v-for="edge in orderBy($page.sections.edges,'node.Ordre')">
  67. <div v-if="edge.node.espace" class="blank-page no-folio breakBeforeLeft" />
  68. <h2 :id="`chapitres${edge.node.id}`" class="section-title canbreak still">{{edge.node.Titre}}</h2>
  69. <VueMarkdown class="section-content">{{edge.node.Contenu}}
  70. </VueMarkdown>
  71. </div>
  72. <!-- Credits -->
  73. <div class="credits canbreak">
  74. <div class="credit" v-for="(edge,index) in $page.credits.edges.slice().reverse()" :key="`credits-${edge.node.id}`">
  75. <h4 v-html="edge.node.Role" />
  76. <VueMarkdown class="section-content">{{ edge.node.Nom }}</VueMarkdown>
  77. </div>
  78. </div>
  79. <div class="blank-page no-folio fill-green" />
  80. </Layout>
  81. </template>
  82. <script>
  83. const axios = require('axios'),
  84. path = require('path'),
  85. param = require(`../../param.JSON`);
  86. import {
  87. Previewer
  88. } from 'pagedjs'
  89. import VueMarkdown from 'vue-markdown'
  90. import Vue2Filters from 'vue2-filters'
  91. export default {
  92. mixins: [Vue2Filters.mixin],
  93. components: {
  94. VueMarkdown
  95. },
  96. mounted() {
  97. // Ajouter les citations
  98. let citations = Array.from(document.querySelectorAll("blockquote"));
  99. citations.forEach((c, index) => {
  100. c.id = `citation-${index}`;
  101. });
  102. // Ajouter les images
  103. let docImages = Array.from(
  104. document.querySelectorAll("img")
  105. )
  106. let toLoad = docImages.filter(img => img.alt === "insert");
  107. let imgSource;
  108. axios.get(path.join(param.source, "images")).then(r => {
  109. imgSource = r.data;
  110. let allPromises = [];
  111. toLoad.forEach(img => {
  112. let img_id = img.src.split("/").pop();
  113. let found = imgSource.find(element => element.id == img_id);
  114. img.src = path.join(param.source, found.images.url);
  115. img.id = `image-${img_id}`;
  116. img.parentNode.classList.add("breakBefore");
  117. let promise = new Promise((resolve, reject) => {
  118. img.onload = function() {
  119. let legend = document.createElement("p");
  120. legend.classList.add("breakAfter");
  121. legend.classList.add("legend");
  122. legend.innerHTML = found.legende;
  123. legend.id = `legend-${img_id}`;
  124. if (found.double) {
  125. let clone = img.parentNode.cloneNode(true);
  126. clone.classList.add("breakBefore");
  127. clone.querySelector("img").id += "-end";
  128. img.parentNode.insertBefore(clone, img.previousSibling);
  129. clone.parentNode.insertBefore(legend, clone.nextSibling);
  130. } else {
  131. img.parentNode.insertBefore(legend, img.nextSibling);
  132. }
  133. resolve();
  134. }
  135. });
  136. allPromises.push(promise);
  137. });
  138. this.$nextTick(function() {
  139. Promise.all(allPromises).then(() => {
  140. let previewer = new Previewer();
  141. previewer.preview().then((flow) => {
  142. let layouts = Array.from(document.querySelectorAll(".layout"));
  143. layouts.forEach(l => {
  144. l.classList.add("full-layout");
  145. });
  146. // Centrer les citations
  147. let citations = Array.from(document.querySelectorAll("blockquote"));
  148. citations.forEach((citation, i) => {
  149. let l = citation.closest(".layout");
  150. l.classList.add("pagequote");
  151. });
  152. // Suppression des pages vides
  153. let pages = Array.from(document.querySelectorAll(".pagedjs_blank_page"));
  154. pages.forEach((page, i) => {
  155. let nextPage = document.querySelector(`.pagedjs_page[data-page-number='${parseInt(page.dataset.pageNumber) + 1}']`);
  156. if (nextPage.querySelector(".blank-page") !== null &&
  157. nextPage.classList.contains("pagedjs_left_page")
  158. ) {
  159. nextPage.parentNode.removeChild(nextPage);
  160. }
  161. page.parentNode.removeChild(page);
  162. });
  163. let empty = layouts.filter(l=>{
  164. if(l.firstChild){
  165. if(l.firstChild.innerHTML.length == 0 && l.firstChild.classList.length == 0) return true;
  166. }
  167. if(l.innerHTML.length != 0) return false;
  168. return true;
  169. });
  170. empty.forEach((item, i) => {
  171. let page = item.closest(".pagedjs_page");
  172. page.parentNode.removeChild(page);
  173. });
  174. // Chercher le dernier paragraphe
  175. let p = Array.from(document.querySelectorAll(".chapter-content"));
  176. p[p.length-1].classList.add("last-chapter-p");
  177. });
  178. });
  179. });
  180. });
  181. }
  182. };
  183. </script>
  184. <page-query>
  185. query {
  186. sections: allSections {
  187. edges {
  188. node {
  189. id
  190. Titre
  191. Contenu
  192. Ordre
  193. espace
  194. }
  195. }
  196. }
  197. chapitres: allChapitres {
  198. edges {
  199. node {
  200. id
  201. Titre
  202. Contenu
  203. alternatif
  204. Rubrique
  205. }
  206. }
  207. }
  208. introductions: allIntroductions {
  209. edges {
  210. node {
  211. id
  212. contenu
  213. }
  214. }
  215. }
  216. credits: allCredits {
  217. edges {
  218. node {
  219. id
  220. Role
  221. Nom
  222. }
  223. }
  224. }
  225. }
  226. </page-query>
  227. <static-query>
  228. query {
  229. metadata {
  230. title
  231. subtitle
  232. authors
  233. }
  234. }
  235. </static-query>