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);
|
||||
$data = [
|
||||
'id' => $postId,
|
||||
'item' => $stream
|
||||
'item' => $stream,
|
||||
'serverData' => [
|
||||
'public' => true,
|
||||
],
|
||||
'application' => 'Social'
|
||||
];
|
||||
|
||||
return new TemplateResponse(Application::APP_NAME, 'stream', $data);
|
||||
|
|
|
@ -202,7 +202,7 @@ export default {
|
|||
// importing server data into the store
|
||||
const serverDataElmt = document.getElementById('serverData')
|
||||
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) {
|
||||
|
|
|
@ -97,16 +97,14 @@ export default {
|
|||
methods: {
|
||||
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
|
||||
if (e.target.tagName === 'A' || e.target.tagName === 'IMG' || e.target.className.startsWith('post-author')) {
|
||||
Logger.debug('will not call single-post', { event: e })
|
||||
return
|
||||
}
|
||||
|
||||
// Display external posts
|
||||
// Display internal or external post
|
||||
if (!this.item.local) {
|
||||
|
||||
if (this.item.type === 'Note') {
|
||||
window.open(this.item.id)
|
||||
} else if (this.item.type === 'Announce') {
|
||||
|
@ -114,21 +112,17 @@ export default {
|
|||
} else {
|
||||
Logger.warn("Don't know what to do with posts of type " + this.item.type, { post: this.item })
|
||||
}
|
||||
|
||||
return
|
||||
} else {
|
||||
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) {
|
||||
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: {
|
||||
default: TimelineSinglePost
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
</style>
|
||||
|
||||
<script>
|
||||
import Logger from '../logger'
|
||||
import TimelineEntry from './../components/TimelineEntry.vue'
|
||||
import TimelineList from './../components/TimelineList.vue'
|
||||
|
||||
|
@ -40,12 +41,24 @@ export default {
|
|||
beforeMount: function() {
|
||||
|
||||
// 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', {
|
||||
type: this.$route.params.type,
|
||||
params: this.$route.params
|
||||
type: 'single-post',
|
||||
params: params
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<pre>
|
||||
<?php p($_['id']); ?>
|
||||
</pre>
|
||||
<br />
|
||||
<br />
|
||||
<pre>
|
||||
<?php p(json_encode($_['item'], JSON_PRETTY_PRINT)); ?>
|
||||
</pre>
|
||||
<?php
|
||||
script('social', 'social');
|
||||
style('social', 'style');
|
||||
?>
|
||||
<span id="postData" data-server="<?php p(json_encode($_['item']));?>"></span>
|
||||
<span id="serverData" data-server="<?php p(json_encode($_['serverData']));?>"></span>
|
||||
<div id="vue-content"></div>
|
||||
|
|
Ładowanie…
Reference in New Issue