From 2691579ab7ee5bd34dfe57a4c0f10c34cb46726f Mon Sep 17 00:00:00 2001
From: Roger Braun <rbraun@Bobble.local>
Date: Wed, 22 Nov 2017 16:28:05 +0100
Subject: [PATCH] Make default path configurable.

---
 src/main.js        | 71 +++++++++++++++++++++++-----------------------
 static/config.json |  3 +-
 2 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/src/main.js b/src/main.js
index b6544a5a..6c5bf83e 100644
--- a/src/main.js
+++ b/src/main.js
@@ -63,54 +63,55 @@ const store = new Vuex.Store({
   strict: process.env.NODE_ENV !== 'production'
 })
 
-const routes = [
-  { name: 'root', path: '/', redirect: '/main/all' },
-  { path: '/main/all', component: PublicAndExternalTimeline },
-  { path: '/main/public', component: PublicTimeline },
-  { path: '/main/friends', component: FriendsTimeline },
-  { path: '/tag/:tag', component: TagTimeline },
-  { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
-  { name: 'user-profile', path: '/users/:id', component: UserProfile },
-  { name: 'mentions', path: '/:username/mentions', component: Mentions },
-  { name: 'settings', path: '/settings', component: Settings },
-  { name: 'registration', path: '/registration', component: Registration },
-  { name: 'user-settings', path: '/user-settings', component: UserSettings }
-]
-
-const router = new VueRouter({
-  mode: 'history',
-  routes,
-  scrollBehavior: (to, from, savedPosition) => {
-    if (to.matched.some(m => m.meta.dontScroll)) {
-      return false
-    }
-    return savedPosition || { x: 0, y: 0 }
-  }
-})
-
 const i18n = new VueI18n({
   locale: currentLocale,
   fallbackLocale: 'en',
   messages
 })
 
-/* eslint-disable no-new */
-new Vue({
-  router,
-  store,
-  i18n,
-  el: '#app',
-  render: h => h(App)
-})
-
 window.fetch('/static/config.json')
   .then((res) => res.json())
-  .then(({name, theme, background, logo, registrationOpen}) => {
+  .then((data) => {
+    const {name, theme, background, logo, registrationOpen} = data
     store.dispatch('setOption', { name: 'name', value: name })
     store.dispatch('setOption', { name: 'theme', value: theme })
     store.dispatch('setOption', { name: 'background', value: background })
     store.dispatch('setOption', { name: 'logo', value: logo })
     store.dispatch('setOption', { name: 'registrationOpen', value: registrationOpen })
+
+    const routes = [
+      { name: 'root', path: '/', redirect: data['defaultPath'] || '/main/all' },
+      { path: '/main/all', component: PublicAndExternalTimeline },
+      { path: '/main/public', component: PublicTimeline },
+      { path: '/main/friends', component: FriendsTimeline },
+      { path: '/tag/:tag', component: TagTimeline },
+      { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
+      { name: 'user-profile', path: '/users/:id', component: UserProfile },
+      { name: 'mentions', path: '/:username/mentions', component: Mentions },
+      { name: 'settings', path: '/settings', component: Settings },
+      { name: 'registration', path: '/registration', component: Registration },
+      { name: 'user-settings', path: '/user-settings', component: UserSettings }
+    ]
+
+    const router = new VueRouter({
+      mode: 'history',
+      routes,
+      scrollBehavior: (to, from, savedPosition) => {
+        if (to.matched.some(m => m.meta.dontScroll)) {
+          return false
+        }
+        return savedPosition || { x: 0, y: 0 }
+      }
+    })
+
+    /* eslint-disable no-new */
+    new Vue({
+      router,
+      store,
+      i18n,
+      el: '#app',
+      render: h => h(App)
+    })
   })
 
 window.fetch('/static/terms-of-service.html')
diff --git a/static/config.json b/static/config.json
index 8b596992..b186246b 100644
--- a/static/config.json
+++ b/static/config.json
@@ -3,5 +3,6 @@
   "theme": "pleroma-dark",
   "background": "/static/bg.jpg",
   "logo": "/static/logo.png",
-  "registrationOpen": false
+  "registrationOpen": false,
+  "defaultPath": "/main/all"
 }