Selaa lähdekoodia

unsure of this

tags/0.9.0
Alej 6 vuotta sitten
vanhempi
commit
98713611d7

+ 3
- 0
plugins/cia-endpoints/includes/class.make-endpoint.php Näytä tiedosto

@@ -61,6 +61,9 @@ class Make_Endpoint_For extends WP_REST_Controller {
61 61
         $filtered[content] = $item->post_content;
62 62
         $filtered[blocks] = get_rearrange_blocks($item->blocks);
63 63
         
64
+        // Log the request with PHP Console
65
+        if ( class_exists( 'PC' ) ) PC::debug( $item, 'Blocks' );
66
+        
64 67
         return $filtered;
65 68
         // return $item;
66 69
     }

+ 1
- 0
plugins/cia-endpoints/includes/reformat-blocks.php Näytä tiedosto

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
     function get_rearrange_blocks($blocks) {
3 3
         $parsed_blocks = array();
4
+
4 5
         foreach( $blocks as $block ) {
5 6
             if(sizeof($block[innerBlocks]) < 1 && $block[innerHTML] !== "\n\n") {
6 7
                 array_push($parsed_blocks, $block[innerHTML]);

+ 0
- 1
plugins/cia-post-types/cia-post-types.php Näytä tiedosto

@@ -65,4 +65,3 @@ foreach ($custom_types as $type):
65 65
     $icon = get_icon($type);
66 66
     add_action( 'init', [ new PostType($type, $icon), 'register_post_type' ] );
67 67
 endforeach;
68
-

+ 57
- 23
vue-theme/src/components/gallery.vue Näytä tiedosto

@@ -1,14 +1,14 @@
1 1
 <template lang="pug">
2 2
 .gallery.f-col.center(v-if="fullscreengallery")
3
-    button(@click="hideGallery") hide
3
+    button(@click="hideGallery").hide hide
4 4
     ul
5
-        li(v-for="image of images")
6
-                div
7
-                    h1 {{ image }}
8
-
5
+        li(v-for="(image, i) of images" :class="{ active: i === selected }")
6
+            .image-wrapper.f-col.center
7
+                img(:src="image")
9 8
     .controls.f-row
10
-        button(@click="hideGallery") <<<
11
-        button(@click="hideGallery") >>>
9
+        button(@click="prev") <
10
+        .f-grow
11
+        button(@click="next") >
12 12
 </template>
13 13
 
14 14
 <script>
@@ -17,10 +17,40 @@ export default {
17 17
         images: { type: Array },
18 18
         fullscreengallery: { type: Boolean }
19 19
     },
20
+    data() { 
21
+        return {
22
+            selected: 0
23
+        }
24
+    },
20 25
     methods: {
26
+        prev() {
27
+            this.selected > 0 ? this.selected-- : this.selected = this.images.length - 1
28
+        },
29
+        next() {
30
+            this.selected < this.images.length - 1 ? this.selected++ : this.selected = 0
31
+        },
21 32
         hideGallery() {
22 33
             this.$emit('close')
34
+        },
35
+        interpretKeypress(e) {
36
+            switch (e.key) {
37
+                case 'ArrowRight':
38
+                    this.next()
39
+                    break
40
+                case 'ArrowLeft':
41
+                    this.prev()
42
+                    break
43
+                case 'Escape':
44
+                    this.hideGallery()
45
+                    break
46
+            }
23 47
         }
48
+    },
49
+    mounted() {
50
+        window.addEventListener('keydown', this.interpretKeypress)
51
+    },
52
+    destroyed() {
53
+        window.removeEventListener('keydown', this.interpretKeypress)
24 54
     }
25 55
 }
26 56
 </script>
@@ -31,27 +61,31 @@ export default {
31 61
     top: 0
32 62
     left: 0
33 63
     width: 100%
34
-    height: 100vh
35
-    background-color: blue
36
-    opacity: 75%
64
+    height: 100%
65
+    background-color: black
37 66
     z-index: 1001
38 67
     > *
39 68
         opacity: 100%
40 69
         position: relative
41 70
         z-index: 1011
71
+    button.hide
72
+        z-index: 1100
42 73
     ul
43 74
         list-style: none
44
-        div
45
-            position: inherit
46
-            width: 90vw
47
-            height: 80vh        
48
-            background: #00FF0A
49
-            border: 15px solid #e2e2e2
50
-            padding: 5px
51
-            box-sizing: border-box
52
-        h1
53
-            text-box:right
54
-            text-align: inherit
55
-            color: green
56
-            position: inherit
75
+        li
76
+            display: none
77
+            &.active
78
+                display: block
79
+            .image-wrapper
80
+                height: 100%
81
+                width: 50vw
82
+                background-color: yellow
83
+            h1
84
+                color: green
85
+    .controls
86
+        position: absolute
87
+        width: 100vw
88
+        button
89
+            height: 100vw
90
+            padding: 1vw
57 91
 </style>

+ 28
- 4
vue-theme/src/pages/single.vue Näytä tiedosto

@@ -1,11 +1,11 @@
1 1
 <template lang="pug">
2
-.page--single.f-row.between
3
-    gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = false" :images="['hi','hello','it works']")
2
+.page--single.f-row.between(v-if="$route.params.slug")
3
+    gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = false" :images="images")
4 4
     article.f-grow.shadow
5 5
         header
6 6
             h1 {{ type }}:{{ $route.params.slug }} single
7 7
             button(@click="fullscreengallery = true") fullscreen
8
-        section
8
+        section(v-if="posts[$route.params.slug]")
9 9
             h4 {{ posts[$route.params.slug].title }}
10 10
             .block-wrapper(v-for="block in posts[$route.params.slug].blocks" v-html="block")
11 11
     sidebar(v-if="sidebar" :type="`${type}`")
@@ -32,6 +32,7 @@ export default {
32 32
     },
33 33
     data() {
34 34
         return {
35
+            images: [], 
35 36
             fullscreengallery: false
36 37
         }
37 38
     },
@@ -62,8 +63,31 @@ export default {
62 63
             }, {})
63 64
         },
64 65
     },
66
+    methods: {
67
+        checkForImages(posts) {
68
+            const allBlocks = posts[this.$route.params.slug].blocks.map(block => {
69
+                if(block) return block
70
+            })
71
+            allBlocks.forEach(block => {
72
+                if(!block) return
73
+                const doc = new DOMParser().parseFromString(block, 'text/html')
74
+                const gallery = doc.querySelectorAll('.blocks-gallery-item img')
75
+                if(gallery) {
76
+                    this.images = [].slice.call(gallery).map(item => { 
77
+                        return item.src }
78
+                    )
79
+                }
80
+            })
81
+        }
82
+    },
83
+    watch: {
84
+        posts(newVal, oldVal) { 
85
+            // Loads images from the DOM
86
+            this.checkForImages(newVal)
87
+        }
88
+    },
65 89
     mounted() {
66
-        // TODO: this should be conditional after checking vuex state
90
+        // TODO: Only makes req if this hasn't been loaded yet
67 91
         let type = this.$route.params.type
68 92
         type = type.charAt(0).toUpperCase() + type.slice(1)
69 93
         this.$store.dispatch(`getAll${type}`)

+ 0
- 1
vue-theme/src/store/modules/artist.js Näytä tiedosto

@@ -17,7 +17,6 @@ const getters = {
17 17
     artistContent: state => id => {
18 18
         let field = typeof id === 'number' ? 'id' : 'slug'
19 19
         let artist = state.all.filter(artist => artist[field] === id)
20
-
21 20
         return (artist[0]) ? artist[0].content.rendered : false
22 21
     },
23 22
     someArtists: state => limit => {

Loading…
Peruuta
Tallenna