mirror of
https://github.com/pinry/pinry.git
synced 2025-11-17 18:30:39 +01:00
Feature: Add pins for user and pins for tag
This commit is contained in:
committed by
Isaac Bythewood
parent
84cdd68a60
commit
9f39fe104a
@@ -16,7 +16,7 @@ export default {
|
|||||||
// Import Bulma and Buefy styles
|
// Import Bulma and Buefy styles
|
||||||
@import "~bulma";
|
@import "~bulma";
|
||||||
@import "~buefy/src/scss/buefy";
|
@import "~buefy/src/scss/buefy";
|
||||||
#app {
|
html {
|
||||||
background-color: #F5F5EB;
|
background-color: #F5F5EB;
|
||||||
}
|
}
|
||||||
.body {
|
.body {
|
||||||
|
|||||||
@@ -25,13 +25,18 @@
|
|||||||
<img class="avatar" :src="item.avatar" alt="">
|
<img class="avatar" :src="item.avatar" alt="">
|
||||||
</div>
|
</div>
|
||||||
<div class="pin-info">
|
<div class="pin-info">
|
||||||
<span class="dim">pined by <span><router-link to="/">{{ item.author }}</router-link></span>
|
<span class="dim">pined by
|
||||||
|
<span>
|
||||||
|
<router-link
|
||||||
|
:to="{ name: 'user', params: {user: item.author} }">
|
||||||
|
{{ item.author }}
|
||||||
|
</router-link>
|
||||||
|
</span>
|
||||||
<template v-if="item.tags.length > 0">
|
<template v-if="item.tags.length > 0">
|
||||||
in
|
in
|
||||||
<template v-for="tag in item.tags">
|
<template v-for="tag in item.tags">
|
||||||
<span v-bind:key="tag" class="pin-tag">
|
<span v-bind:key="tag" class="pin-tag">
|
||||||
|
<router-link :to="{ name: 'tag', params: {tag: tag} }" params="{tag: tag}">{{ tag }}</router-link>
|
||||||
<router-link to="/tags/">{{ tag }}</router-link>
|
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -73,8 +78,20 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
blocks: [],
|
blocks: [],
|
||||||
|
offset: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
pinFilters: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {
|
||||||
|
tagFilter: null,
|
||||||
|
userFilter: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildBlocks(results) {
|
buildBlocks(results) {
|
||||||
const blocks = [];
|
const blocks = [];
|
||||||
@@ -100,14 +117,25 @@ export default {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
fetchMore() {
|
||||||
created() {
|
let promise;
|
||||||
API.fetchPins(0).then(
|
if (this.pinFilters.tagFilter) {
|
||||||
|
promise = API.fetchPins(this.offset, this.pinFilters.tagFilter);
|
||||||
|
} else if (this.pinFilters.userFilter) {
|
||||||
|
promise = API.fetchPins(this.offset, null, this.pinFilters.userFilter);
|
||||||
|
} else {
|
||||||
|
promise = API.fetchPins(this.offset);
|
||||||
|
}
|
||||||
|
promise.then(
|
||||||
(resp) => {
|
(resp) => {
|
||||||
this.blocks = this.buildBlocks(resp.data.results);
|
this.blocks = this.buildBlocks(resp.data.results);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.fetchMore();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -153,6 +181,9 @@ $avatar-height: 30px;
|
|||||||
width: $avatar-width;
|
width: $avatar-width;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
.pin-tag {
|
||||||
|
margin-right: 0.2rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.pin-footer {
|
.pin-footer {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from 'vue-router';
|
||||||
import Home from '../views/Home.vue';
|
import Home from '../views/Home.vue';
|
||||||
|
import Pins4Tag from '../views/Pins4Tag.vue';
|
||||||
|
import Pins4User from '../views/Pins4User.vue';
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
@@ -10,6 +12,16 @@ const routes = [
|
|||||||
name: 'home',
|
name: 'home',
|
||||||
component: Home,
|
component: Home,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/pins/tags/:tag',
|
||||||
|
name: 'tag',
|
||||||
|
component: Pins4Tag,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pins/users/:user',
|
||||||
|
name: 'user',
|
||||||
|
component: Pins4User,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
|
|||||||
40
pinry-spa/src/views/Pins4Tag.vue
Normal file
40
pinry-spa/src/views/Pins4Tag.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<div class="home">
|
||||||
|
<PHeader></PHeader>
|
||||||
|
<Pins :pin-filters="filters"></Pins>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PHeader from '../components/PHeader.vue';
|
||||||
|
import Pins from '../components/Pins.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'p-header',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
filters: { tagFilter: null },
|
||||||
|
};
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
PHeader,
|
||||||
|
Pins,
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initializeTag();
|
||||||
|
},
|
||||||
|
beforeRouteUpdate(to, from, next) {
|
||||||
|
this.initializeTag();
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initializeTag() {
|
||||||
|
this.filters.tagFilter = this.$route.params.tag;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||||
|
<style scoped lang="scss">
|
||||||
|
</style>
|
||||||
40
pinry-spa/src/views/Pins4User.vue
Normal file
40
pinry-spa/src/views/Pins4User.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<div class="home">
|
||||||
|
<PHeader></PHeader>
|
||||||
|
<Pins :pin-filters="filters"></Pins>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PHeader from '../components/PHeader.vue';
|
||||||
|
import Pins from '../components/Pins.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'p-header',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
filters: { userFilter: null },
|
||||||
|
};
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
PHeader,
|
||||||
|
Pins,
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initializeUser();
|
||||||
|
},
|
||||||
|
beforeRouteUpdate(to, from, next) {
|
||||||
|
this.initializeUser();
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initializeUser() {
|
||||||
|
this.filters.userFilter = this.$route.params.user;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||||
|
<style scoped lang="scss">
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user