diff --git a/src/App.vue b/src/App.vue index 4d21d436d99f242503d87784717428dd7af06ea3..1494752473f6262fdd67b337809e7af6b00102fd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -35,7 +35,6 @@ export default { created: function () { this.$http.get(global.api + 'languages').then(function (response) { var languagesData = JSON.parse(response.bodyText) - console.log('languages', languagesData) var languagesOrder = [ { @@ -98,8 +97,6 @@ export default { }) }) - console.log('new lang data', languagesData) - global.languages = languagesData }) } diff --git a/src/components/ParcoursAllComponent.vue b/src/components/ParcoursAllComponent.vue index 8fbed1c3934fb7fcf61f0d4b1aecadfd9b0a21ab..92e5c2adc5b7420957d4dfeff3e1875c8dca7a7a 100644 --- a/src/components/ParcoursAllComponent.vue +++ b/src/components/ParcoursAllComponent.vue @@ -26,7 +26,7 @@ <div class="vertical-list-container"> <div class="vertical-list-wrapper"> <h3 v-for="parcours in parcoursAll"> - <router-link :to="{ name: 'parcoursIndex', params: { parcoursId: parcours.id_keyword, parcoursSlug: '-' + slugify(parcours.versions[0].title) } }"> + <router-link :to="{ name: 'parcoursIndex', params: { parcoursId: parcours.id_keyword } }"> <span class="bg"></span>{{ parcours.versions[0].title }} <sup>{{ parcours.entities.length | romanize }}</sup> </router-link> </h3> @@ -34,7 +34,7 @@ <ul> <li v-for="(epigram, index) in parcours.entities" v-track-by="index"> - <router-link :to="{ name: 'parcoursSingle', params: { parcoursId: parcours.id_keyword, parcoursSlug: '-' + slugify(parcours.versions[0].title), epigramIndex: index + 1 }}">Épigramme {{ index + 1 }}</router-link> + <router-link :to="{ name: 'parcoursSingle', params: { parcoursId: parcours.id_keyword, epigramIndex: index + 1 }}">Épigramme {{ index + 1 }}</router-link> </li> </ul> --> @@ -75,48 +75,28 @@ export default { methods: { getParcoursData: function () { var self = this -// this.$http.get(global.apiAuth).then(function (response) { -// self.$set('token', response.data.access_token) - self.$http.get(global.api + 'keywords?category=' + global.parcoursKeywordId /* + filterFr + 'access_token=' + self.token*/, {progress () { - }}).then(function (response) { - var parcoursAll = JSON.parse(response.bodyText) - console.log('GET parcours', parcoursAll) + self.$http.get(global.api + 'keywords?category=' + global.parcoursKeywordId).then(function (response) { + var parcoursAllData = JSON.parse(response.bodyText) - parcoursAll.forEach(function (parcours, i) { + parcoursAllData.forEach(function (parcours, i) { if (!parcours.versions || !parcours.versions.length) { parcours.versions.push({title: 'Sans titre'}) } }) // Sort Parcours by most epigrams first - parcoursAll.sort(function (a, b) { + parcoursAllData.sort(function (a, b) { return a.entities.length < b.entities.length }) - self.$set(this, 'parcoursAll', parcoursAll) - }, function (response) { - console.log('Error retrieving parcours', response) + self.$set(this, 'parcoursAll', parcoursAllData) + }, function (err) { + console.error('Error retrieving parcours', err) }).finally(function () { // Processing should be finished at this point // Fade the loader out $('.loader').fadeOut() }) -// }, function (response) { -// console.log('global error: ' + response.status) -// }) - }, - slugify: function (text) { - if (!text) return '' - - return text.toString() - .toLowerCase() - .replace('/[éèê]/g', 'e') - .replace('/à /g', 'a') - .replace(/\s+/g, '-') // Replace spaces with - - .replace(/[^\w-]+/g, '') // Remove all non-word chars - .replace(/--+/g, '-') // Replace multiple - with single - - .replace(/^-+/, '') // Trim - from start of text - .replace(/-+$/, '') // Trim - from end of text } } } diff --git a/src/components/ParcoursIndexComponent.vue b/src/components/ParcoursIndexComponent.vue index 2e71b18d77e0ca19a00fd197c1e0aa79fd0755e9..da14ff4a8dca32a26c86ec8068fc754a149dbdc4 100644 --- a/src/components/ParcoursIndexComponent.vue +++ b/src/components/ParcoursIndexComponent.vue @@ -33,7 +33,6 @@ <router-link :to="{ name: 'parcoursSingle', params: { parcoursId: parcours.id_keyword, - parcoursSlug: '-' + slugify(parcours.versions[0].title), epigramIndex: index + 1 } }"> <span class="bg"></span>{{ entity.title }} <sup>{{ index + 1 | romanize }}</sup> @@ -42,7 +41,6 @@ <!-- <index-nav v-bind:list-items="parcours.entities" v-bind:item-id="parcoursId" - v-bind:item-slug="'-' + slugify(parcours.versions[0].title)" route-name="parcoursSingle" ></index-nav> --> @@ -148,19 +146,6 @@ export default { $(self.$el).addClass('loaded') }) - }, - slugify: function (text) { - if (!text) return '' - - return text.toString() - .toLowerCase() - .replace('/[éèê]/g', 'e') - .replace('/à /g', 'a') - .replace(/\s+/g, '-') // Replace spaces with - - .replace(/[^\w-]+/g, '') // Remove all non-word chars - .replace(/--+/g, '-') // Replace multiple - with single - - .replace(/^-+/, '') // Trim - from start of text - .replace(/-+$/, '') // Trim - from end of text } } } diff --git a/src/components/ParcoursSingleComponent.vue b/src/components/ParcoursSingleComponent.vue index 53f2dd0cb8879524e7f5bd985436c73b7663987c..95b13cf38c7d2e15be9324fbe0dab89fdd45749c 100644 --- a/src/components/ParcoursSingleComponent.vue +++ b/src/components/ParcoursSingleComponent.vue @@ -2,15 +2,13 @@ <div class="parcours-single"> <loader></loader> - <div class="content-wrapper"> - <div class="page-title-container" - v-if="parcours && parcours.versions"> + <div class="content-wrapper" + v-if="epigramLoaded"> + <div class="page-title-container"> <h1>{{ versionLanguage(parcours.versions).title }}</h1> </div> - <div class="row" - v-if="parcours && parcours.versions" - > + <div class="row"> <div class="col-md-9 col-md-offset-1"> <div class="inner-links"> <router-link :to="{ name: 'parcoursIndex', params: { parcoursId: parcoursId, parcoursName: $route.parcoursName } }"> @@ -24,9 +22,9 @@ <div class="row"> <div class="col-md-3 col-md-offset-1"> - <translation v-if="epigramLoaded" - :epigram="epigram" + <translation :epigram="epigram" :parcours-title="parseVersion(parcours.versions).title" + :authors="authors" ></translation> </div> @@ -80,8 +78,7 @@ </header> <div class="scroll carousel__container"> <article class="carousel__wrapper"> - <a v-if="epigram" - v-for="(ref, index) in epigram.externalRef" + <a v-for="(ref, index) in epigram.externalRef" class="carousel__item -link" v-on:click="openFancybox(index, $event)" v-bind:href="ref.url" @@ -156,6 +153,7 @@ export default { }, data () { return { + authors: [], epigram: {}, parcours: {}, parcoursId: 0, @@ -169,22 +167,17 @@ export default { return this.parcours.entities.length } }, - created: function () { + mounted: function () { var self = this - this.$nextTick(function () { - // ensure elements are in-document - // immediately show loader - $('.loader').fadeIn() - $('.content-wrapper').css({opacity: 0}) - }) + $('.loader').fadeIn() self.parcoursId = self.$route.params.parcoursId self.epigramIndex = self.$route.params.epigramIndex - 1 self.getParcours() .then(function (parcoursData) { - self.$set(self, 'parcours', parcoursData) + self.parcours = parcoursData var epigramId if (parcoursData.entities[self.epigramIndex]) { @@ -194,15 +187,27 @@ export default { .then(function (epigramData) { self.$set(self, 'epigram', epigramData) + // We have the epigram; + // however, the `authors` object is incomplete + var incompleteAuthors = self.epigram.authors + + incompleteAuthors.forEach(function (author) { + self.getAuthorData(author.id_author) + }) + // Epigram loaded, initialize other components - console.log('this is epigram loaded -----', self.epigram) - self.$set(self, 'epigramLoaded', true) + self.epigramLoaded = true + $('.loader').fadeOut() + self.$nextTick(function () { + setTimeout(function () { + $('.parcours-single').addClass('loaded') + }, 100) + }) }) } }) }, destroyed: function () { - this.$off() $.fancybox.destroy() }, methods: { @@ -221,12 +226,24 @@ export default { $('.manuscript-popin img').removeClass('big') $('.manuscript-popin').fadeOut() }, + getAuthorData (authorId) { + var self = this + + self.$http.get(global.api + 'authors/' + authorId).then(function (response) { + var authorData = JSON.parse(response.bodyText) + if (!self.authors) { + self.authors = [] + } + self.authors.push(authorData) + }, function (err) { + console.error('Error retrieving author', err) + }) + }, getParcours () { var self = this return self.$http.get(global.api + 'keywords/' + self.parcoursId).then(function (response) { var parcoursData = JSON.parse(response.bodyText) - return parcoursData }, function (err) { console.error('Error retrieving parcours (keyword) data', err) @@ -240,11 +257,6 @@ export default { var epigramData = JSON.parse(response.bodyText) return epigramData - // console.log('SORTED EPIGRAM', global.versionLanguage(self.epigram.versions).id_entity) - }) - .finally(function () { - $('.loader').fadeOut() - $('.content-wrapper').css({opacity: 1}) }) } else { self.getEpigram() @@ -287,8 +299,6 @@ export default { } }, beforeLoad (instance, slide) { - console.log('beforeload slide', slide) - var regexps = { https: /^https:/i, http: /^http:/i, @@ -310,9 +320,7 @@ export default { } else { // App is on http page, all is OK } - if (regexps.youtube.test(slide.src)) { - console.log('---', slide.src.replace(regexps.youtube, '$4')) slide.src = slide.src.replace(regexps.youtube, 'https://youtube.com/embed/$4') } }, @@ -321,24 +329,20 @@ export default { } }) - console.log('fancyboxInstance', fancyboxInstance) - fancyboxInstance.jumpTo(index) }, prev () { - console.log('call prev') var self = this var prevIndex = self.epigramIndex - self.$router.push({ name: 'parcoursSingle', params: { parcoursId: self.$route.params.parcoursId, parcourSlug: self.$route.params.parcoursSlug, epigramIndex: prevIndex } }) + self.$router.push({ name: 'parcoursSingle', params: { parcoursId: self.$route.params.parcoursId, epigramIndex: prevIndex } }) }, next () { - console.log('call next') var self = this var nextIndex = self.epigramIndex + 2 - self.$router.push({ name: 'parcoursSingle', params: { parcoursId: self.$route.params.parcoursId, parcourSlug: self.$route.params.parcoursSlug, epigramIndex: nextIndex } }) + self.$router.push({ name: 'parcoursSingle', params: { parcoursId: self.$route.params.parcoursId, epigramIndex: nextIndex } }) } } } @@ -392,9 +396,12 @@ $hover: .5s all ease-out display: flex flex-direction: column justify-content: space-around - opacity: 0 transition: opacity 1s + opacity: 0 +.loaded + .content-wrapper + opacity: 1 .epigram-row //position: absolute //top: 100px diff --git a/src/components/partials/DiscoverNav.vue b/src/components/partials/DiscoverNav.vue index 32d3cb15e87a6e348abfc33a6b5a0bf0811ab478..37440140aaf00ac308e86956b05b3e1884b46084 100644 --- a/src/components/partials/DiscoverNav.vue +++ b/src/components/partials/DiscoverNav.vue @@ -1,4 +1,7 @@ <template> +<!-- +============ OBSOLETE FILE ============ +--> <div class="discover-nav"> <nav class="navbar navbar-default"> <ul class="nav"> @@ -9,7 +12,7 @@ tag="li" @mouseover="addClass" > - <router-link :to="{ name: 'theme', params: { theme: theme.slug, themeId: theme.id }}" + <router-link :to="{ name: 'theme', params: { themeId: theme.id }}" v-bind:data-id="theme.id"> <span class="dash"> <span class="inner-dash"></span> diff --git a/src/components/partials/IndexNav.vue b/src/components/partials/IndexNav.vue index 00c7747db6ca0ae9a87d5ae631e5d1f3633193f4..9d23305205fcdc3936bb55c976133febb364b486 100644 --- a/src/components/partials/IndexNav.vue +++ b/src/components/partials/IndexNav.vue @@ -7,7 +7,7 @@ v-track-by="index" @mouseover="addClass" > - <router-link :to="{ name: routeName, params: { parcoursId: itemId, parcoursSlug: itemSlug, epigramIndex: index + 1 }}"> + <router-link :to="{ name: routeName, params: { parcoursId: itemId, epigramIndex: index + 1 }}"> <span class="dash"> <span class="inner-dash"></span> </span> @@ -28,7 +28,6 @@ export default { props: { listItems: {}, itemId: 0, - itemSlug: '', routeName: '' }, created: function () { @@ -38,19 +37,6 @@ export default { $(e.target).addClass('active') $(e.target).parent().siblings().children().removeClass('active') } - }, - slugify: function (text) { - if (!text) return '' - - return text.toString() - .toLowerCase() - .replace('/[éèê]/g', 'e') - .replace('/à /g', 'a') - .replace(/\s+/g, '-') // Replace spaces with - - .replace(/[^\w-]+/g, '') // Remove all non-word chars - .replace(/--+/g, '-') // Replace multiple - with single - - .replace(/^-+/, '') // Trim - from start of text - .replace(/-+$/, '') // Trim - from end of text } } </script> diff --git a/src/components/partials/parcours/Pagination.vue b/src/components/partials/parcours/Pagination.vue index 23faa4fe3241b0033f7df990513ae5c13d030b4f..2072485ae1bcc8743402955c46db1a448799446e 100644 --- a/src/components/partials/parcours/Pagination.vue +++ b/src/components/partials/parcours/Pagination.vue @@ -56,7 +56,6 @@ export default { } }, created: function () { - console.log('created with props', this.current, this.total) }, methods: { prev () { diff --git a/src/components/partials/parcours/Translation.vue b/src/components/partials/parcours/Translation.vue index fafa6e3454962cf1ebdfd3ac29f1b6b755acd04d..265ffa8dbd032e5dddf4bd70c55d186aea9b836a 100644 --- a/src/components/partials/parcours/Translation.vue +++ b/src/components/partials/parcours/Translation.vue @@ -34,12 +34,15 @@ <div class="text-content"> <p v-html="customLanguageSelect(epigram.versions).text_translated"></p> </div> - <div class="text-author" v-if="epigram.authors"> + <div class="text-author"> <div v-for="author in authors"> <span class="dash"></span> <p><router-link :to="{ name: 'authorSingle', params: { id: author.versions[0].id_author} }">{{ customLanguageSelect(author.versions).name }}</router-link></p> </div> </div> + <div v-if="!authors.length"> + <span class="dash"></span> + </div> </div> </div> </template> @@ -60,13 +63,15 @@ export default { var self = this var returnVersions = [] - self.epigram.versions.forEach(function (version) { - for (var i = 0; i < global.languages.length; i++) { - if (global.languages[i].id_language === version.id_language) { - returnVersions.push(global.languages[i]) + if (self.epigram) { + self.epigram.versions.forEach(function (version) { + for (var i = 0; i < global.languages.length; i++) { + if (global.languages[i].id_language === version.id_language) { + returnVersions.push(global.languages[i]) + } } - } - }) + }) + } return returnVersions } @@ -78,14 +83,6 @@ export default { // Set the language self.setCustomLanguage(self.parseVersion(self.epigram.versions).id_language) - - self.$nextTick(function () { - var incompleteAuthors = self.epigram.authors - - incompleteAuthors.forEach(function (author) { - self.getAuthorData(author.id_author) - }) - }) }, methods: { versionLanguage (versions, options) { @@ -146,21 +143,6 @@ export default { frenchMute.removeClass('glyphicon-volume-off').addClass('glyphicon-volume-up') } } - }, - getAuthorData (authorId) { - var self = this - - self.$http.get(global.api + 'authors/' + authorId).then(function (response) { - var authorData = JSON.parse(response.bodyText) - - if (!self.authors) { - self.authors = [] - } - - self.authors.push(authorData) - }, function (err) { - console.error('Error retrieving author', err) - }) } } } diff --git a/src/router/index.js b/src/router/index.js index e94f551cba59402cc4fb4acc6902f52706efcf92..8d12c8535060d1fb9dbf8fd00ff2d1ac70e5fef7 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -14,11 +14,11 @@ import ParcoursIndex from '../components/ParcoursIndexComponent' import ParcoursSingle from '../components/ParcoursSingleComponent' import EpigramApi from '../components/EpigramApiComponent' import AuthorSingle from '../components/AuthorSingleComponent' -//import SearchGenreComponent from '../components/SearchGenreComponent' -//import SearchAuthorComponent from '../components/SearchAuthorComponent' -//import SearchEraComponent from '../components/SearchEraComponent' -//import SearchCityComponent from '../components/SearchCityComponent' -//import SearchCharacterComponent from '../components/SearchCharacterComponent' +// import SearchGenreComponent from '../components/SearchGenreComponent' +// import SearchAuthorComponent from '../components/SearchAuthorComponent' +// import SearchEraComponent from '../components/SearchEraComponent' +// import SearchCityComponent from '../components/SearchCityComponent' +// import SearchCharacterComponent from '../components/SearchCharacterComponent' import NotFound from '../components/404Component' Vue.use(VueRouter) @@ -75,12 +75,12 @@ export default new VueRouter({ name: 'parcoursAll' }, { - path: '/parcours/:parcoursId:parcoursSlug?', + path: '/parcours/:parcoursId', component: ParcoursIndex, name: 'parcoursIndex' }, { - path: '/parcours/:parcoursId:parcoursSlug?/:epigramIndex', + path: '/parcours/:parcoursId/:epigramIndex', component: ParcoursSingle, name: 'parcoursSingle' },