Sfoglia il codice sorgente

:recyle: cleaning up cruft | fixing up home page | adding better comments

tags/0.9.0
j 5 anni fa
parent
commit
cd6bce14fb

+ 4
- 11
vue-theme/src/app.vue Vedi File

8
 </template>
8
 </template>
9
 
9
 
10
 <script>
10
 <script>
11
-import navigation from '@/components/navigation/navigation'
12
-import hero from '@/components/hero'
13
-import footer from '@/components/footer'
11
+import ciaNav from '@/components/navigation/navigation'
12
+import ciaHero from '@/components/hero'
13
+import ciaFooter from '@/components/footer'
14
 
14
 
15
 import '@/sss'
15
 import '@/sss'
16
 
16
 
17
 export default {
17
 export default {
18
-    components: {
19
-        'cia-nav': navigation,
20
-        'cia-hero': hero,
21
-        'cia-footer': footer,
22
-    },
23
-    data () {
24
-        return {}
25
-    }
18
+    components: { ciaNav, ciaHero, ciaFooter }
26
 }
19
 }
27
 </script>
20
 </script>
28
 
21
 

+ 12
- 14
vue-theme/src/pages/index.vue Vedi File

3
 .page--index.f-row.between
3
 .page--index.f-row.between
4
     article.f-grow
4
     article.f-grow
5
         .f-row
5
         .f-row
6
-            section(v-if="allEpisodesLoaded && allEpisodes.length").shadow
6
+            section(v-if="allEpisodesLoaded").shadow
7
                 router-link(:to="`./episodes`")
7
                 router-link(:to="`./episodes`")
8
                     h4.t-cap episodes
8
                     h4.t-cap episodes
9
-                router-link(:to="{ path: `/episodes/${Object.values(allEpisodes)[0].slug}` }")
10
-                    p {{ Object.values(allEpisodes)[0].title }}
9
+                    p(v-if="Object.values(allEpisodes).length > 0") {{ Object.values(allEpisodes)[0].slug }}
10
+                    p(v-else) no episodes
11
 
11
 
12
-            section(v-if="allArtistsLoaded && allArtists.length").shadow
12
+            section(v-if="allArtistsLoaded").shadow
13
                 router-link(:to="`./artists`")
13
                 router-link(:to="`./artists`")
14
                     h4.t-cap artists
14
                     h4.t-cap artists
15
-                router-link(:to="{ path: `/artists/${Object.values(allArtists)[0].slug}` }")
16
-                    p {{ Object.values(allArtists)[0].title }}
17
-                    
18
-            section(v-if="allPagesLoaded && allPages.length").shadow
15
+                    p(v-if="Object.values(allArtists).length > 0") {{ Object.values(allArtists)[0].slug}}
16
+                    p(v-else) no artists
17
+
18
+            section(v-if="allPagesLoaded").shadow
19
                 h4.t-cap pages
19
                 h4.t-cap pages
20
-                router-link(:to="{ path: `/pages/${Object.values(allPages)[0].slug}` }")
21
-                    p {{ Object.values(allPages)[0].title }}
22
-        
20
+                    p(v-if="Object.values(allPages).length > 0") {{ Object.values(allPages)[0].slug }}
21
+                    p(v-else) no pages
23
         .f-row
22
         .f-row
24
-            section(v-if="allPostsLoaded && allPosts.length").shadow
23
+            section(v-if="allPostsLoaded").shadow
25
                 router-link(:to="`./posts`")
24
                 router-link(:to="`./posts`")
26
                     h4.t-cap posts
25
                     h4.t-cap posts
27
-                router-link(:to="{ path: `/posts/${Object.values(allPosts)[0].slug}` }")
28
-                    p {{ Object.values(allPosts)[0].title }}
26
+                    p(v-if="Object.values(allPosts).length > 0") {{ Object.values(allPosts)[0].slug }}
29
      
27
      
30
         .f-row
28
         .f-row
31
             footer.f-row
29
             footer.f-row

+ 49
- 17
vue-theme/src/pages/single.vue Vedi File

13
                     li(v-for="(imageID, j) in post.galleries[block.gallery].ids" :class="`gallery-${i}--image-${j+1}`" :key="`block-${i}-${j}`")
13
                     li(v-for="(imageID, j) in post.galleries[block.gallery].ids" :class="`gallery-${i}--image-${j+1}`" :key="`block-${i}-${j}`")
14
                         img(@click="openGallery(i - 1, imageID)" :src="post.attached[imageID]['thumbnail']")
14
                         img(@click="openGallery(i - 1, imageID)" :src="post.attached[imageID]['thumbnail']")
15
                         button(@click="openGallery(i - 1, imageID)") gallery: {{ i }} image: {{ imageID }}
15
                         button(@click="openGallery(i - 1, imageID)") gallery: {{ i }} image: {{ imageID }}
16
-                //- Fullscreen gallery
16
+                //- Fullscreen gallery component for every gallery block
17
                 gallery(
17
                 gallery(
18
                     v-if="activeGalleryIndex == (i - 1)"
18
                     v-if="activeGalleryIndex == (i - 1)"
19
                     :activeImageIndex="activeImageIndex"
19
                     :activeImageIndex="activeImageIndex"
21
                     :images="imagesInGallery"
21
                     :images="imagesInGallery"
22
                 )
22
                 )
23
 
23
 
24
-            //- Just a regular block
24
+            //- Just a regular block (html or img)
25
             .block(v-else v-html="block")
25
             .block(v-else v-html="block")
26
 
26
 
27
     sidebar(v-if="sidebar" :type="`${type}`")
27
     sidebar(v-if="sidebar" :type="`${type}`")
40
 
40
 
41
 export default {
41
 export default {
42
     props: {
42
     props: {
43
-        sidebar: {
44
-            type: Boolean
45
-        }
43
+        sidebar: { type: Boolean }
46
     },
44
     },
47
     components: { sidebar, gallery },
45
     components: { sidebar, gallery },
48
     data() {
46
     data() {
49
         return {
47
         return {
50
-            images: [], 
48
+            // Gallery control
51
             activeGalleryIndex: -1,
49
             activeGalleryIndex: -1,
52
             activeImageID: -1
50
             activeImageID: -1
53
         }
51
         }
54
     },
52
     },
55
     computed: {
53
     computed: {
56
-        post() {
57
-            return this.posts[this.$route.params.slug]
58
-        },
59
         ...mapGetters({
54
         ...mapGetters({
60
             allPages: 'allPages',
55
             allPages: 'allPages',
61
             allPagesLoaded: 'allPagesLoaded',
56
             allPagesLoaded: 'allPagesLoaded',
72
         type() { // Checks for type and fixes Episodes route edge case 
67
         type() { // Checks for type and fixes Episodes route edge case 
73
             return typeFromRoute(this.$route)
68
             return typeFromRoute(this.$route)
74
         },
69
         },
70
+
71
+        /**
72
+         * We get the actual post data using the slug
73
+         */
74
+        post() {
75
+            return this.posts[this.$route.params.slug]
76
+        },
77
+        /**
78
+         * We grab posts using the type derived from
79
+         * the route (See typeFromRoute() helper) and
80
+         * create a map keyed by post slug 
81
+         */
75
         posts() {
82
         posts() {
76
             let type = convertTitleCase(this.type)
83
             let type = convertTitleCase(this.type)
77
             
84
             
83
                 return postsMap
90
                 return postsMap
84
             }, {})
91
             }, {})
85
         },
92
         },
93
+
94
+        /**
95
+         * We need a convenient way to get all the images
96
+         * broken down by gallery. We use the active gallery
97
+         * image IDs to create a map. We match the ID to the
98
+         * image size and url information returned by post.attached
99
+         */
86
         imagesInGallery() {
100
         imagesInGallery() {
87
             if(!this.activeGalleryIndex < 0) return {}
101
             if(!this.activeGalleryIndex < 0) return {}
88
-            
102
+            // Create a map of images by their ID
103
+            // {
104
+            //     imageId: { 'thumbnail': url, 'large': url }
105
+            // }
89
             return this.post.galleries[this.activeGalleryIndex].ids.reduce((imageMap, id) => {
106
             return this.post.galleries[this.activeGalleryIndex].ids.reduce((imageMap, id) => {
90
                 imageMap[id] = this.post.attached[id]
107
                 imageMap[id] = this.post.attached[id]
91
                 return imageMap
108
                 return imageMap
96
         }
113
         }
97
     },
114
     },
98
     methods: {
115
     methods: {
116
+        /**
117
+         * We set the active gallery to the index.
118
+         * Everything kicks off when activeGallery
119
+         * is set. We also need to set the activeImageID
120
+         * to the image clicked
121
+         * @param {number} galleryIndex
122
+         * @param {string} imageID 
123
+         */
99
         openGallery(galleryIndex, imageID) {
124
         openGallery(galleryIndex, imageID) {
100
             this.activeGalleryIndex = galleryIndex
125
             this.activeGalleryIndex = galleryIndex
101
             this.activeImageID = imageID ? imageID : 0
126
             this.activeImageID = imageID ? imageID : 0
102
         },
127
         },
128
+
129
+        /**
130
+         * Everytime the posts object changes
131
+         * we use this to set a new HERO
132
+         * in vuex
133
+         * @param {object} posts 
134
+         */
103
         checkAndSetHero(posts) {
135
         checkAndSetHero(posts) {
104
             const post = posts[this.$route.params.slug]
136
             const post = posts[this.$route.params.slug]
105
             if(!post || !post.hero) return
137
             if(!post || !post.hero) return
110
     },
142
     },
111
     watch: {
143
     watch: {
112
         posts(newVal, oldVal) {
144
         posts(newVal, oldVal) {
113
-            // Loads images from the DOM
114
-            // this.checkForImages(newVal)
115
-            
116
             this.checkAndSetHero(newVal)
145
             this.checkAndSetHero(newVal)
117
         }
146
         }
118
     },
147
     },
119
     created() {
148
     created() {
120
-        let type = convertTitleCase(this.$route.params.type)
121
-        
122
-        if(!this[`all{type}Loaded`]) {
149
+        /**
150
+         * Conditionally load based on post type
151
+         * which is derived from the route
152
+         * !: posts watcher fires when this finishes
153
+         */
154
+        let type = convertTitleCase(this.type)
155
+        if(!this[`all${type}Loaded`]) {
123
             // console.log('Retrieving...', type)
156
             // console.log('Retrieving...', type)
124
             this.$store.dispatch(`getAll${type}`)
157
             this.$store.dispatch(`getAll${type}`)
125
-            // posts watcher will fire after this
126
         }
158
         }
127
     }
159
     }
128
 }
160
 }

+ 1
- 3
vue-theme/src/store/index.js Vedi File

9
 import post from './modules/post'
9
 import post from './modules/post'
10
 import artist from './modules/artist'
10
 import artist from './modules/artist'
11
 import episode from './modules/episode'
11
 import episode from './modules/episode'
12
-import media from './modules/media'
13
 
12
 
14
 const debug = process.env.NODE_ENV !== 'production'
13
 const debug = process.env.NODE_ENV !== 'production'
15
 
14
 
45
       post,
44
       post,
46
       page,
45
       page,
47
       artist,
46
       artist,
48
-      episode,
49
-      media
47
+      episode
50
   },
48
   },
51
   strict: debug,
49
   strict: debug,
52
 })
50
 })

+ 0
- 35
vue-theme/src/store/modules/media.js Vedi File

1
-import api from '../../utils/api'
2
-
3
-const state = {
4
-    all: [],
5
-    loaded: false,
6
-}
7
-
8
-const getters = {
9
-    allMedia: state => state.all,
10
-    allMediaLoaded: state => state.loaded,
11
-}
12
-
13
-const actions = {
14
-    async getMediaById({ commit }, ids) {
15
-        commit('CLEAR_MEDIA')
16
-        commit('MEDIA_LOADED', false)
17
-        
18
-        const p = ids.map(async id => {
19
-            return await api.getSingleMedia(id, media => {
20
-                commit('STORE_FETCHED_MEDIA', { media })
21
-            })
22
-        })
23
-        console.log(p)
24
-        await Promise.all(p)
25
-        commit('MEDIA_LOADED', true) 
26
-    }
27
-}
28
-
29
-const mutations = {
30
-    STORE_FETCHED_MEDIA(state, { media }) { state.all.push() },
31
-    CLEAR_MEDIA(state) { state.all = [] },
32
-    MEDIA_LOADED(state, val) { state.loaded = val },
33
-}
34
-
35
-export default { state, getters, actions, mutations }

+ 0
- 4
vue-theme/src/utils/post-types.js Vedi File

1
-export default [
2
-    'posts',
3
-    'pages'
4
-]

Loading…
Annulla
Salva