From 7a92cf157420a558e054dfd92bebc81896da018f Mon Sep 17 00:00:00 2001 From: Cyrille Bollu Date: Mon, 16 Sep 2019 17:10:30 +0200 Subject: [PATCH] Single post timeline can be displayed to non logged in users. Signed-off-by: Cyrille Bollu --- lib/Controller/SocialPubController.php | 6 +++++- src/App.vue | 2 +- src/components/TimelineEntry.vue | 26 ++++++++++---------------- src/router.js | 2 +- src/views/TimelineSinglePost.vue | 21 +++++++++++++++++---- templates/stream.php | 15 +++++++-------- 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/lib/Controller/SocialPubController.php b/lib/Controller/SocialPubController.php index 851ec86b..6194a209 100644 --- a/lib/Controller/SocialPubController.php +++ b/lib/Controller/SocialPubController.php @@ -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); diff --git a/src/App.vue b/src/App.vue index 0266d5f7..51287119 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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) { diff --git a/src/components/TimelineEntry.vue b/src/components/TimelineEntry.vue index 221f91ff..66876a90 100644 --- a/src/components/TimelineEntry.vue +++ b/src/components/TimelineEntry.vue @@ -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 diff --git a/src/router.js b/src/router.js index aab02912..e99e0b42 100644 --- a/src/router.js +++ b/src/router.js @@ -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 }, diff --git a/src/views/TimelineSinglePost.vue b/src/views/TimelineSinglePost.vue index 250c20c0..b5ac5c0d 100644 --- a/src/views/TimelineSinglePost.vue +++ b/src/views/TimelineSinglePost.vue @@ -19,6 +19,7 @@