Improve reposted and liked entries

This commit is contained in:
Peter Stuifzand 2018-09-01 11:39:05 +02:00
parent 22309fe91e
commit f510c35b62

View File

@ -16,16 +16,17 @@
</div> </div>
<div class="content"> <div class="content">
<div v-if="isRef"> <div v-if="isRef">
<div><a :href="author_url">{{ author_name }}</a> reposted:</div> <div><small><a :href="outside_author_url">{{ outside_author_name }}</a>&nbsp;<span v-text="refText"></span>:</small></div>
<Entry :item="innerRef" :isMainEntry="false"></Entry>
</div> </div>
<div v-else> <div>
<div><a :href="author_url">{{ author_name }}</a></div> <div><a :href="author_url">{{ author_name }}</a>
&middot;
<a :href="currentItem.url" target="_new"><span class="published" v-html="niceTime"></span></a>
</div>
<h3 class="title is-6" v-if="item.name" v-text="item.name"></h3> <h3 class="title is-6" v-if="currentItem.name" v-text="currentItem.name"></h3>
<div class="content" v-html="main_content"></div> <div class="content" v-html="main_content"></div>
<div class="photos"> <div class="photos">
@ -42,9 +43,7 @@
&middot; <a @click.prevent="openReply">Reply</a> &middot; <a @click.prevent="openReply">Reply</a>
&middot; <a @click.prevent="repost">Repost</a> &middot; <a @click.prevent="repost">Repost</a>
&middot; <a @click.prevent="debug">Debug</a> &middot; <a @click.prevent="debug">Debug</a>
&middot; </span>
</span><a :href="item.url" target="_new">
<span class="published" v-html="niceTime"></span></a>
</small> </small>
</p> </p>
</div> </div>
@ -74,7 +73,7 @@
export default { export default {
name: "Entry", name: "Entry",
props: ['item', 'is-main-entry'], props: ['item'],
data() { data() {
return { return {
@ -133,12 +132,19 @@
}, },
mounted() { mounted() {
this.showFooterButtons = this.isMainEntry this.showFooterButtons = true
}, },
computed: { computed: {
currentItem() {
if (this.isRef) {
return this.innerRef
} else {
return this.item
}
},
niceTime() { niceTime() {
return moment(this.item.published).fromNow() return moment(this.currentItem.published).fromNow()
}, },
refNiceTime() { refNiceTime() {
return moment(this.innerRef.published).fromNow() return moment(this.innerRef.published).fromNow()
@ -167,8 +173,17 @@
isRepost() { isRepost() {
return this.hasRef('repost-of') return this.hasRef('repost-of')
}, },
refText() {
if (this.isLike) {
return 'liked'
}
if (this.isRepost) {
return 'reposted'
}
return ''
},
main_content() { main_content() {
let content = this.item.content let content = this.currentItem.content
if (content) { if (content) {
if (content.html) { if (content.html) {
return content.html return content.html
@ -177,7 +192,7 @@
} }
return content return content
} }
content = this.item.summary content = this.currentItem.summary
if (content) { if (content) {
if (content.html) { if (content.html) {
return content.html return content.html
@ -188,18 +203,18 @@
} }
}, },
photo_first() { photo_first() {
if (this.item.photo && this.item.photo.length >= 1) { if (this.currentItem.photo && this.currentItem.photo.length >= 1) {
return this.item.photo[0] return this.currentItem.photo[0]
} }
return false return false
}, },
photo_rest() { photo_rest() {
if (this.item.photo && this.item.photo.length > 1) { if (this.currentItem.photo && this.currentItem.photo.length > 1) {
return this.item.photo.slice(1) return this.currentItem.photo.slice(1)
} }
return [] return []
}, },
author_name() { outside_author_name() {
if (!this.item.author) { if (!this.item.author) {
return 'anonymouse'; return 'anonymouse';
} }
@ -210,7 +225,7 @@
} }
return this.item.author.name return this.item.author.name
}, },
author_url() { outside_author_url() {
if (!this.item.author) { if (!this.item.author) {
return ''; return '';
} }
@ -219,14 +234,34 @@
} }
return this.item.author.url return this.item.author.url
}, },
author_name() {
if (!this.currentItem.author) {
return 'anonymouse';
}
if (!this.currentItem.author.name) {
if (this.currentItem.author.url) {
return new URL(this.currentItem.author.url).hostname
}
}
return this.currentItem.author.name
},
author_url() {
if (!this.currentItem.author) {
return '';
}
if (!this.currentItem.author.url) {
return '';
}
return this.currentItem.author.url
},
author_photo() { author_photo() {
if (!this.item.author) { if (!this.currentItem.author) {
return ''; return '';
} }
if (!this.item.author.photo) { if (!this.currentItem.author.photo) {
return ''; return '';
} }
return this.item.author.photo return this.currentItem.author.photo
} }
} }
} }