summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrille Bollu <cyrpub@bollu.be>2019-09-16 17:10:30 +0200
committerMaxence Lange <maxence@artificial-owl.com>2019-09-25 14:11:10 +0200
commit7a92cf157420a558e054dfd92bebc81896da018f (patch)
treeb08c9026a2a8730140936147ae07a0e9edd9a2c1
parent6d6fa8a527e856d4dc5783f9dc60a5acc9756b48 (diff)
Single post timeline can be displayed to non logged in users.
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
-rw-r--r--lib/Controller/SocialPubController.php6
-rw-r--r--src/App.vue2
-rw-r--r--src/components/TimelineEntry.vue26
-rw-r--r--src/router.js2
-rw-r--r--src/views/TimelineSinglePost.vue21
-rw-r--r--templates/stream.php15
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 @@
</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: {
diff --git a/templates/stream.php b/templates/stream.php
index 934d91e7..39620085 100644
--- a/templates/stream.php
+++ b/templates/stream.php
@@ -1,8 +1,7 @@
-<pre>
- <?php p($_['id']); ?>
-</pre>
-&nbsp;<br />
-&nbsp;<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>