kopia lustrzana https://github.com/nextcloud/social
Merge pull request #661 from StCyr/stcyr_fix656
Uses hashtag-regex to rewrite hashtag's href rather than linkifyjs.pull/664/head
commit
2dcdedd3de
|
@ -129,6 +129,7 @@ class Note extends Stream implements JsonSerializable {
|
|||
parent::import($data);
|
||||
|
||||
$this->importAttachments($this->getArray('attachment', $data, []));
|
||||
$this->fillHashtags();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6800,6 +6800,11 @@
|
|||
"minimalistic-assert": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"hashtag-regex": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hashtag-regex/-/hashtag-regex-2.0.0.tgz",
|
||||
"integrity": "sha512-6qWo1g10ggwyorTjMEswX/z8DkODD1XnfjBjndIAj7rnUOgVlwYQz4UPQU9yBz2jBGd3Im1D1wlzzI/o6Q1Ptw=="
|
||||
},
|
||||
"he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"vue-masonry-css": "^1.0.3",
|
||||
"hashtag-regex": "^2.0.0",
|
||||
"linkifyjs": "^2.1.8",
|
||||
"nextcloud-axios": "^0.2.0",
|
||||
"nextcloud-vue": "^0.11.4",
|
||||
|
|
|
@ -52,16 +52,16 @@
|
|||
<script>
|
||||
import Avatar from 'nextcloud-vue/dist/Components/Avatar'
|
||||
import * as linkify from 'linkifyjs'
|
||||
import pluginTag from 'linkifyjs/plugins/hashtag'
|
||||
import pluginMention from 'linkifyjs/plugins/mention'
|
||||
import 'linkifyjs/string'
|
||||
import popoverMenu from './../mixins/popoverMenu'
|
||||
import currentUser from './../mixins/currentUserMixin'
|
||||
import PostAttachment from './PostAttachment'
|
||||
|
||||
pluginTag(linkify)
|
||||
pluginMention(linkify)
|
||||
|
||||
const hashtagRegex = require('hashtag-regex')
|
||||
|
||||
export default {
|
||||
name: 'TimelinePost',
|
||||
components: {
|
||||
|
@ -102,21 +102,19 @@ export default {
|
|||
return Date.parse(this.item.published)
|
||||
},
|
||||
formatedMessage() {
|
||||
let message = this.item.content
|
||||
var message = this.item.content
|
||||
if (typeof message === 'undefined') {
|
||||
return ''
|
||||
}
|
||||
message = message.replace(/(?:\r\n|\r|\n)/g, '<br />')
|
||||
message = message.linkify({
|
||||
formatHref: {
|
||||
hashtag: function(href) {
|
||||
return OC.generateUrl('/apps/social/timeline/tags/' + href.substring(1))
|
||||
},
|
||||
mention: function(href) {
|
||||
return OC.generateUrl('/apps/social/@' + href.substring(1))
|
||||
}
|
||||
}
|
||||
})
|
||||
message = this.mangleHashtags(message)
|
||||
message = this.$twemoji.parse(message)
|
||||
return message
|
||||
},
|
||||
|
@ -140,6 +138,15 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
mangleHashtags(msg) {
|
||||
// Replace hashtag's href parameter with local ones
|
||||
const regex = hashtagRegex()
|
||||
msg = msg.replace(regex, function(matched) {
|
||||
var a = '<a href="' + OC.generateUrl('/apps/social/timeline/tags/' + matched.substring(1)) + '">' + matched + '</a>'
|
||||
return a
|
||||
})
|
||||
return msg
|
||||
},
|
||||
userDisplayName(actorInfo) {
|
||||
return actorInfo.name !== '' ? actorInfo.name : actorInfo.preferredUsername
|
||||
},
|
||||
|
|
|
@ -144,10 +144,10 @@ const actions = {
|
|||
postUnlike(context, { post, parentAnnounce }) {
|
||||
return axios.delete(OC.generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
|
||||
context.commit('unlikePost', { post, parentAnnounce })
|
||||
// Remove post from list if we are in the 'liked' timeline
|
||||
if (state.type === 'liked') {
|
||||
context.commit('removePost', post)
|
||||
}
|
||||
// Remove post from list if we are in the 'liked' timeline
|
||||
if (state.type === 'liked') {
|
||||
context.commit('removePost', post)
|
||||
}
|
||||
}).catch((error) => {
|
||||
OC.Notification.showTemporary('Failed to unlike post')
|
||||
console.error('Failed to unlike post', error)
|
||||
|
|
Ładowanie…
Reference in New Issue