Index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <Layout>
  3. <!-- introductions -->
  4. <div class="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="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" />
  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 hyphenopoly = document.createElement('script'),
  141. hyph = document.createElement('script');
  142. hyphenopoly.setAttribute('src', 'lib/Hyphenopoly-master/Hyphenopoly_Loader.js')
  143. hyph.setAttribute('src', 'lib/hyph.js')
  144. document.head.appendChild(hyph)
  145. document.head.appendChild(hyphenopoly)
  146. hyph.onload = () => {
  147. Hyphenopoly.handleEvent = {
  148. hyphenopolyEnd: (e) => {
  149. let previewer = new Previewer();
  150. previewer.preview();
  151. }
  152. };
  153. };
  154. });
  155. });
  156. });
  157. }
  158. };
  159. </script>
  160. <page-query>
  161. query {
  162. sections: allSections {
  163. edges {
  164. node {
  165. id
  166. Titre
  167. Contenu
  168. Ordre
  169. espace
  170. }
  171. }
  172. }
  173. chapitres: allChapitres {
  174. edges {
  175. node {
  176. id
  177. Titre
  178. Contenu
  179. alternatif
  180. Rubrique
  181. }
  182. }
  183. }
  184. introductions: allIntroductions {
  185. edges {
  186. node {
  187. id
  188. contenu
  189. }
  190. }
  191. }
  192. credits: allCredits {
  193. edges {
  194. node {
  195. id
  196. Role
  197. Nom
  198. }
  199. }
  200. }
  201. }
  202. </page-query>
  203. <static-query>
  204. query {
  205. metadata {
  206. title
  207. subtitle
  208. authors
  209. }
  210. }
  211. </static-query>