Add Micropub Like
This commit is contained in:
parent
aaa8f82c7b
commit
fc7fddc574
3
TODO.txt
3
TODO.txt
|
@ -2,6 +2,9 @@ Some features that need to be implemented
|
||||||
|
|
||||||
- Get Microsub endpoint from homepage of user
|
- Get Microsub endpoint from homepage of user
|
||||||
- Micropub
|
- Micropub
|
||||||
|
- Like
|
||||||
|
- Reply
|
||||||
|
- Repost
|
||||||
- Infinite scrolling
|
- Infinite scrolling
|
||||||
- Scrolling backward and forward
|
- Scrolling backward and forward
|
||||||
- Preview
|
- Preview
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
<figure class="image is-48x48">
|
<figure class="image is-48x48">
|
||||||
<img :src="item.author.photo"/>
|
<img :src="author_photo"/>
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
this.$emit('debug', this.item)
|
this.$emit('debug', this.item)
|
||||||
},
|
},
|
||||||
like() {
|
like() {
|
||||||
this.$emit('like', this.item)
|
this.$store.dispatch('micropubLike', this.item)
|
||||||
},
|
},
|
||||||
repost() {
|
repost() {
|
||||||
this.$emit('repost', this.item)
|
this.$emit('repost', this.item)
|
||||||
|
@ -96,13 +96,25 @@
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
author_name() {
|
author_name() {
|
||||||
|
if (!this.item.author) {
|
||||||
|
return 'anonymouse';
|
||||||
|
}
|
||||||
if (!this.item.author.name) {
|
if (!this.item.author.name) {
|
||||||
return new URL(this.item.author.url).hostname
|
return new URL(this.item.author.url).hostname
|
||||||
}
|
}
|
||||||
return this.item.author.name
|
return this.item.author.name
|
||||||
},
|
},
|
||||||
author_url() {
|
author_url() {
|
||||||
|
if (!this.item.author) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return this.item.author.url
|
return this.item.author.url
|
||||||
|
},
|
||||||
|
author_photo() {
|
||||||
|
if (!this.item.author) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return this.item.author.photo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
})
|
})
|
||||||
micropub.getAuthUrl().then(url => {
|
micropub.getAuthUrl().then(url => {
|
||||||
let options = {
|
let options = {
|
||||||
|
micropubEndpoint: micropub.options.micropubEndpoint,
|
||||||
tokenEndpoint: micropub.options.tokenEndpoint,
|
tokenEndpoint: micropub.options.tokenEndpoint,
|
||||||
loginState: state
|
loginState: state
|
||||||
}
|
}
|
||||||
|
|
15
src/store.js
15
src/store.js
|
@ -1,5 +1,6 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
|
import Micropub from 'micropub-helper';
|
||||||
|
|
||||||
const baseurl = "https://microsub.stuifzandapp.com/microsub"
|
const baseurl = "https://microsub.stuifzandapp.com/microsub"
|
||||||
|
|
||||||
|
@ -18,12 +19,12 @@ export default new Vuex.Store({
|
||||||
};
|
};
|
||||||
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
|
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
|
||||||
if (loginData) {
|
if (loginData) {
|
||||||
newState = { ...newState, ...loginData }
|
newState = {...newState, ...loginData}
|
||||||
newState.logged_in = loginData.access_token && loginData.access_token.length > 0
|
newState.logged_in = loginData.access_token && loginData.access_token.length > 0
|
||||||
}
|
}
|
||||||
let endpoints = JSON.parse(window.localStorage.getItem('endpoints'))
|
let endpoints = JSON.parse(window.localStorage.getItem('endpoints'))
|
||||||
if (endpoints) {
|
if (endpoints) {
|
||||||
newState = { ...newState, ...endpoints}
|
newState = {...newState, ...endpoints}
|
||||||
}
|
}
|
||||||
return newState
|
return newState
|
||||||
},
|
},
|
||||||
|
@ -105,6 +106,16 @@ export default new Vuex.Store({
|
||||||
'Authorization': 'Bearer ' + this.state.access_token
|
'Authorization': 'Bearer ' + this.state.access_token
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
micropubLike(_, item) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
let micropub = new Micropub({
|
||||||
|
token: this.state.access_token,
|
||||||
|
micropubEndpoint: this.state.micropubEndpoint
|
||||||
|
})
|
||||||
|
micropub.postMicropub({
|
||||||
|
'like-of': [item.url]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user