Add bookmarking and syndication targets
This commit is contained in:
parent
cf65818eb4
commit
8aa4f6882a
|
@ -42,6 +42,7 @@
|
||||||
<a @click="like">Like</a>
|
<a @click="like">Like</a>
|
||||||
· <a @click.prevent="openReply">Reply</a>
|
· <a @click.prevent="openReply">Reply</a>
|
||||||
· <a @click.prevent="repost">Repost</a>
|
· <a @click.prevent="repost">Repost</a>
|
||||||
|
· <a @click.prevent="openBookmark">Bookmark</a>
|
||||||
· <a @click.prevent="$emit('followFeed', author_url)" title="Try to follow the feed this item comes from">Follow</a>
|
· <a @click.prevent="$emit('followFeed', author_url)" title="Try to follow the feed this item comes from">Follow</a>
|
||||||
· <a @click.prevent="debug">Debug</a>
|
· <a @click.prevent="debug">Debug</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -64,23 +65,53 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="media" v-if="bookmarking">
|
||||||
|
<div class="media-content">
|
||||||
|
<div class="field">
|
||||||
|
<div class="control">
|
||||||
|
<input type="text" class="input" placeholder="Title" v-model="bookmarkTitle">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">Add a note</label>
|
||||||
|
<div class="control">
|
||||||
|
<textarea class="textarea" v-model="bookmarkDescription"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<syndication-buttons v-model="selected" :targets="targets"/>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-primary" @click="bookmark">Bookmark</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
import SyndicationButtons from "@/components/SyndicationButtons";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Entry",
|
name: "Entry",
|
||||||
|
components: {SyndicationButtons},
|
||||||
props: ['item'],
|
props: ['item'],
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
'replying': false,
|
'replying': false,
|
||||||
'replyText': '',
|
'replyText': '',
|
||||||
'showFooterButtons': true
|
'showFooterButtons': true,
|
||||||
|
bookmarking: false,
|
||||||
|
bookmarkTitle: '',
|
||||||
|
bookmarkDescription: '',
|
||||||
|
targets: [],
|
||||||
|
selected: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -122,6 +153,30 @@
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
openBookmark() {
|
||||||
|
this.bookmarking = true
|
||||||
|
this.bookmarkTitle = this.author_name + ' - ' + this.currentItem.name
|
||||||
|
this.bookmarkDescription = ''
|
||||||
|
this.selected = []
|
||||||
|
this.$store.dispatch('fetchSyndicationTargets')
|
||||||
|
.then(res => this.targets = res['syndicate-to'])
|
||||||
|
},
|
||||||
|
bookmark() {
|
||||||
|
this.$store.dispatch('micropubPost', {
|
||||||
|
'type': ['h-entry'],
|
||||||
|
'properties': {
|
||||||
|
'bookmark-of': [this.currentItem.url],
|
||||||
|
'name': [this.bookmarkTitle],
|
||||||
|
'content': [this.bookmarkDescription ],
|
||||||
|
'mp-syndicate-to': this.selected
|
||||||
|
},
|
||||||
|
}).then(() => {
|
||||||
|
this.bookmarkTitle = '';
|
||||||
|
this.bookmarkDescription = '';
|
||||||
|
this.selected = []
|
||||||
|
this.bookmarking = false
|
||||||
|
})
|
||||||
|
},
|
||||||
hasRef(key) {
|
hasRef(key) {
|
||||||
if (this.item.hasOwnProperty(key) && this.item.hasOwnProperty('refs')) {
|
if (this.item.hasOwnProperty(key) && this.item.hasOwnProperty('refs')) {
|
||||||
if (this.item.refs.hasOwnProperty(this.item[key])) {
|
if (this.item.refs.hasOwnProperty(this.item[key])) {
|
||||||
|
@ -289,4 +344,5 @@
|
||||||
.is-pre {
|
.is-pre {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -11,6 +11,9 @@
|
||||||
<textarea class="textarea" v-model="newPost"></textarea>
|
<textarea class="textarea" v-model="newPost"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<syndication-buttons v-model="selectedTargets" :targets="targets"/>
|
||||||
|
</div>
|
||||||
<div class="level">
|
<div class="level">
|
||||||
<div class="level-left">
|
<div class="level-left">
|
||||||
<div class="level-item">
|
<div class="level-item">
|
||||||
|
@ -33,20 +36,30 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import SyndicationButtons from "@/components/SyndicationButtons";
|
||||||
export default {
|
export default {
|
||||||
name: "NewPost",
|
name: "NewPost",
|
||||||
|
components:{
|
||||||
|
SyndicationButtons
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
newPost: '',
|
newPost: '',
|
||||||
tags: [{name:"twitter"},{name:"instagram"}]
|
targets: [],
|
||||||
|
selectedTargets: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$store.dispatch('fetchSyndicationTargets')
|
||||||
|
.then(res => this.targets = res['syndicate-to'])
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
post() {
|
post() {
|
||||||
this.$store.dispatch('micropubPost', {
|
this.$store.dispatch('micropubPost', {
|
||||||
'type': ['h-entry'],
|
'type': ['h-entry'],
|
||||||
'properties': {
|
'properties': {
|
||||||
'content': [this.newPost]
|
'content': [this.newPost],
|
||||||
|
'mp-syndicate-to': this.selectedTargets,
|
||||||
},
|
},
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.newPost = '';
|
this.newPost = '';
|
||||||
|
|
43
src/components/SyndicationButtons.vue
Normal file
43
src/components/SyndicationButtons.vue
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div v-for="(target, i) in targets" :key="i" style="display: inline-block; margin: 0 3px 3px 0">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="is-hidden cb-target" v-model="selected" :value="target.uid"/>
|
||||||
|
<span class="tag is-light" v-text="target.name"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'syndication-buttons',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selected: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: [],
|
||||||
|
targets: {}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.selected = this.value
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
selected(newSelection) {
|
||||||
|
this.$emit('update', newSelection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-target:checked + .tag {
|
||||||
|
background-color: #23d160;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -178,6 +178,13 @@ export default new Vuex.Store({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
fetchSyndicationTargets() {
|
||||||
|
let micropub = new Micropub({
|
||||||
|
token: this.state.access_token,
|
||||||
|
micropubEndpoint: this.state.micropubEndpoint
|
||||||
|
})
|
||||||
|
return micropub.query('syndicate-to')
|
||||||
|
},
|
||||||
micropubPost(_, mf2post) {
|
micropubPost(_, mf2post) {
|
||||||
let micropub = new Micropub({
|
let micropub = new Micropub({
|
||||||
token: this.state.access_token,
|
token: this.state.access_token,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user