kopia lustrzana https://github.com/nextcloud/social
Single post timeline can be displayed to non logged in users.
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>pull/730/head
rodzic
6d6fa8a527
commit
7a92cf1574
|
@ -214,7 +214,11 @@ class SocialPubController extends Controller {
|
||||||
$stream = $this->streamService->getStreamById($postId, false);
|
$stream = $this->streamService->getStreamById($postId, false);
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $postId,
|
'id' => $postId,
|
||||||
'item' => $stream
|
'item' => $stream,
|
||||||
|
'serverData' => [
|
||||||
|
'public' => true,
|
||||||
|
],
|
||||||
|
'application' => 'Social'
|
||||||
];
|
];
|
||||||
|
|
||||||
return new TemplateResponse(Application::APP_NAME, 'stream', $data);
|
return new TemplateResponse(Application::APP_NAME, 'stream', $data);
|
||||||
|
|
|
@ -202,7 +202,7 @@ export default {
|
||||||
// importing server data into the store
|
// importing server data into the store
|
||||||
const serverDataElmt = document.getElementById('serverData')
|
const serverDataElmt = document.getElementById('serverData')
|
||||||
if (serverDataElmt !== null) {
|
if (serverDataElmt !== null) {
|
||||||
this.$store.commit('setServerData', JSON.parse(document.getElementById('serverData').dataset.server))
|
this.$store.commit('setServerData', JSON.parse(serverDataElmt.dataset.server))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.serverData.public) {
|
if (!this.serverData.public) {
|
||||||
|
|
|
@ -97,16 +97,14 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
getSinglePostTimeline(e) {
|
getSinglePostTimeline(e) {
|
||||||
|
|
||||||
Logger.debug('Clicked on post', { post: this.item })
|
|
||||||
// Do not call the single-post view when clicking on a link, a post attachment miniature or the post's author
|
// Do not call the single-post view when clicking on a link, a post attachment miniature or the post's author
|
||||||
if (e.target.tagName === 'A' || e.target.tagName === 'IMG' || e.target.className.startsWith('post-author')) {
|
if (e.target.tagName === 'A' || e.target.tagName === 'IMG' || e.target.className.startsWith('post-author')) {
|
||||||
Logger.debug('will not call single-post', { event: e })
|
Logger.debug('will not call single-post', { event: e })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display external posts
|
// Display internal or external post
|
||||||
if (!this.item.local) {
|
if (!this.item.local) {
|
||||||
|
|
||||||
if (this.item.type === 'Note') {
|
if (this.item.type === 'Note') {
|
||||||
window.open(this.item.id)
|
window.open(this.item.id)
|
||||||
} else if (this.item.type === 'Announce') {
|
} else if (this.item.type === 'Announce') {
|
||||||
|
@ -114,21 +112,17 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
Logger.warn("Don't know what to do with posts of type " + this.item.type, { post: this.item })
|
Logger.warn("Don't know what to do with posts of type " + this.item.type, { post: this.item })
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return
|
this.$router.push({ name: 'single-post',
|
||||||
|
params: {
|
||||||
|
account: this.item.actor_info.preferredUsername,
|
||||||
|
id: this.item.id,
|
||||||
|
localId: this.item.id.split('/')[this.item.id.split('/').length - 1],
|
||||||
|
type: 'single-post'
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display internal posts
|
|
||||||
let account = this.item.local ? this.item.actor_info.preferredUsername : this.item.actor_info.account
|
|
||||||
let postId = this.item.id.split('/')[this.item.id.split('/').length - 1]
|
|
||||||
this.$router.push({ name: 'single-post',
|
|
||||||
params: {
|
|
||||||
account: account,
|
|
||||||
id: this.item.id,
|
|
||||||
localId: postId,
|
|
||||||
type: 'single-post'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
userDisplayName(actorInfo) {
|
userDisplayName(actorInfo) {
|
||||||
return actorInfo.name !== '' ? actorInfo.name : actorInfo.preferredUsername
|
return actorInfo.name !== '' ? actorInfo.name : actorInfo.preferredUsername
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default new Router({
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/:index(index.php/)?apps/social/:account/:localId',
|
path: '/:index(index.php/)?apps/social/@:account/:localId',
|
||||||
components: {
|
components: {
|
||||||
default: TimelineSinglePost
|
default: TimelineSinglePost
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Logger from '../logger'
|
||||||
import TimelineEntry from './../components/TimelineEntry.vue'
|
import TimelineEntry from './../components/TimelineEntry.vue'
|
||||||
import TimelineList from './../components/TimelineList.vue'
|
import TimelineList from './../components/TimelineList.vue'
|
||||||
|
|
||||||
|
@ -40,12 +41,24 @@ export default {
|
||||||
beforeMount: function() {
|
beforeMount: function() {
|
||||||
|
|
||||||
// Get data of post clicked on
|
// Get data of post clicked on
|
||||||
this.mainPost = this.$store.getters.getPostFromTimeline(this.$route.params.id)
|
if (typeof this.$route.params.id === 'undefined') {
|
||||||
|
Logger.debug('displaying the single post timeline for a non logged-in user')
|
||||||
|
this.mainPost = JSON.parse(document.getElementById('postData').dataset.server)
|
||||||
|
} else {
|
||||||
|
this.mainPost = this.$store.getters.getPostFromTimeline(this.$route.params.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set params for the TimelineList component
|
||||||
|
let params = {
|
||||||
|
account: window.location.href.split('/')[window.location.href.split('/').length - 2].substr(1),
|
||||||
|
id: window.location.href,
|
||||||
|
localId: window.location.href.split('/')[window.location.href.split('/').length - 1],
|
||||||
|
type: 'single-post'
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare to display main post's replies in TimelineList component
|
|
||||||
this.$store.dispatch('changeTimelineType', {
|
this.$store.dispatch('changeTimelineType', {
|
||||||
type: this.$route.params.type,
|
type: 'single-post',
|
||||||
params: this.$route.params
|
params: params
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<pre>
|
<?php
|
||||||
<?php p($_['id']); ?>
|
script('social', 'social');
|
||||||
</pre>
|
style('social', 'style');
|
||||||
<br />
|
?>
|
||||||
<br />
|
<span id="postData" data-server="<?php p(json_encode($_['item']));?>"></span>
|
||||||
<pre>
|
<span id="serverData" data-server="<?php p(json_encode($_['serverData']));?>"></span>
|
||||||
<?php p(json_encode($_['item'], JSON_PRETTY_PRINT)); ?>
|
<div id="vue-content"></div>
|
||||||
</pre>
|
|
||||||
|
|
Ładowanie…
Reference in New Issue