From dfc5f170c6977039bd8704723fcfbb86dd7bf702 Mon Sep 17 00:00:00 2001 From: tsukada-ecsec Date: Fri, 24 Aug 2018 18:46:14 +0900 Subject: [PATCH 1/5] update --- src/main.js | 118 +++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 51 deletions(-) diff --git a/src/main.js b/src/main.js index 06f8a6ec..f8144fac 100644 --- a/src/main.js +++ b/src/main.js @@ -93,63 +93,79 @@ window.fetch('/api/statusnet/config.json') store.dispatch('setOption', { name: 'server', value: server }) }) -window.fetch('/static/config.json') +window.fetch('/api/statusnet/config.json') .then((res) => res.json()) .then((data) => { - const {theme, background, logo, showWhoToFollowPanel, whoToFollowProvider, whoToFollowLink, showInstanceSpecificPanel, scopeOptionsEnabled, collapseMessageWithSubject} = data - 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: 'showWhoToFollowPanel', value: showWhoToFollowPanel }) - store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider }) - store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink }) - store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel }) - store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled }) - store.dispatch('setOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject }) - if (data['chatDisabled']) { - store.dispatch('disableChat') - } + var apiStatusnetConfigSitePleromafe = data.site.pleromafe + window.fetch('/static/sonfig.json') + .then((data) => { + var staticConfig = data - const routes = [ - { name: 'root', - path: '/', - redirect: to => { - var redirectRootLogin = data['redirectRootLogin'] - var redirectRootNoLogin = data['redirectRootNoLogin'] - return (store.state.users.currentUser ? redirectRootLogin : redirectRootNoLogin) || '/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: 'registration', path: '/registration/:token', component: Registration }, - { name: 'friend-requests', path: '/friend-requests', component: FollowRequests }, - { name: 'user-settings', path: '/user-settings', component: UserSettings } - ] + var theme = (apiStatusnetConfigSitePleromafe.theme || staticConfig.theme) + var background = (apiStatusnetConfigSitePleromafe.background || staticConfig.background) + var logo = (apiStatusnetConfigSitePleromafe.logo || staticConfig.logo) + var redirectRootNoLogin = (apiStatusnetConfigSitePleromafe.redirectRootNoLogin || staticConfig.redirectRootNoLogin) + var redirectRootLogin = (apiStatusnetConfigSitePleromafe.redirectRootLogin || staticConfig.redirectRootLogin) + var chatDisabled = (apiStatusnetConfigSitePleromafe.chatDisabled || staticConfig.chatDisabled) + var showWhoToFollowPanel = (apiStatusnetConfigSitePleromafe.showWhoToFollowPanel || staticConfig.showWhoToFollowPanel) + var whoToFollowProvider = (apiStatusnetConfigSitePleromafe.whoToFollowProvider || staticConfig.whoToFollowProvider) + var whoToFollowLink = (apiStatusnetConfigSitePleromafe.whoToFollowLink || staticConfig.whoToFollowLink) + var showInstanceSpecificPanel = (apiStatusnetConfigSitePleromafe.showInstanceSpecificPanel || staticConfig.showInstanceSpecificPanel) + var scopeOptionsEnabled = (apiStatusnetConfigSitePleromafe.scopeOptionsEnabled || staticConfig.scopeOptionsEnabled) + var collapseMessageWithSubject = (apiStatusnetConfigSitePleromafe.collapseMessageWithSubject || staticConfig.collapseMessageWithSubject) - 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 } + 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: 'showWhoToFollowPanel', value: showWhoToFollowPanel }) + store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider }) + store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink }) + store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel }) + store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled }) + store.dispatch('setOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject }) + if (chatDisabled) { + store.dispatch('disableChat') } - }) - /* eslint-disable no-new */ - new Vue({ - router, - store, - i18n, - el: '#app', - render: h => h(App) + const routes = [ + { name: 'root', + path: '/', + redirect: to => { + return (store.state.users.currentUser ? redirectRootLogin : redirectRootNoLogin) || '/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: 'registration', path: '/registration/:token', component: Registration }, + { name: 'friend-requests', path: '/friend-requests', component: FollowRequests }, + { 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) + }) }) }) From a81c3b1324f496d8571ca4372299c9bb4a263d1a Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Sun, 26 Aug 2018 06:54:03 +0900 Subject: [PATCH 2/5] fix typo --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index f8144fac..e4a96c55 100644 --- a/src/main.js +++ b/src/main.js @@ -97,7 +97,7 @@ window.fetch('/api/statusnet/config.json') .then((res) => res.json()) .then((data) => { var apiStatusnetConfigSitePleromafe = data.site.pleromafe - window.fetch('/static/sonfig.json') + window.fetch('/static/config.json') .then((data) => { var staticConfig = data From a3cc78115ce36d1db7ff6fdad65683ebd28f133c Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Sun, 26 Aug 2018 06:56:52 +0900 Subject: [PATCH 3/5] rename apiStatusnetConfigSitePleromafe to apiConfig --- src/main.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main.js b/src/main.js index e4a96c55..8681e960 100644 --- a/src/main.js +++ b/src/main.js @@ -96,23 +96,23 @@ window.fetch('/api/statusnet/config.json') window.fetch('/api/statusnet/config.json') .then((res) => res.json()) .then((data) => { - var apiStatusnetConfigSitePleromafe = data.site.pleromafe + var apiConfig = data.site.pleromafe window.fetch('/static/config.json') .then((data) => { var staticConfig = data - var theme = (apiStatusnetConfigSitePleromafe.theme || staticConfig.theme) - var background = (apiStatusnetConfigSitePleromafe.background || staticConfig.background) - var logo = (apiStatusnetConfigSitePleromafe.logo || staticConfig.logo) - var redirectRootNoLogin = (apiStatusnetConfigSitePleromafe.redirectRootNoLogin || staticConfig.redirectRootNoLogin) - var redirectRootLogin = (apiStatusnetConfigSitePleromafe.redirectRootLogin || staticConfig.redirectRootLogin) - var chatDisabled = (apiStatusnetConfigSitePleromafe.chatDisabled || staticConfig.chatDisabled) - var showWhoToFollowPanel = (apiStatusnetConfigSitePleromafe.showWhoToFollowPanel || staticConfig.showWhoToFollowPanel) - var whoToFollowProvider = (apiStatusnetConfigSitePleromafe.whoToFollowProvider || staticConfig.whoToFollowProvider) - var whoToFollowLink = (apiStatusnetConfigSitePleromafe.whoToFollowLink || staticConfig.whoToFollowLink) - var showInstanceSpecificPanel = (apiStatusnetConfigSitePleromafe.showInstanceSpecificPanel || staticConfig.showInstanceSpecificPanel) - var scopeOptionsEnabled = (apiStatusnetConfigSitePleromafe.scopeOptionsEnabled || staticConfig.scopeOptionsEnabled) - var collapseMessageWithSubject = (apiStatusnetConfigSitePleromafe.collapseMessageWithSubject || staticConfig.collapseMessageWithSubject) + var theme = (apiConfig.theme || staticConfig.theme) + var background = (apiConfig.background || staticConfig.background) + var logo = (apiConfig.logo || staticConfig.logo) + var redirectRootNoLogin = (apiConfig.redirectRootNoLogin || staticConfig.redirectRootNoLogin) + var redirectRootLogin = (apiConfig.redirectRootLogin || staticConfig.redirectRootLogin) + var chatDisabled = (apiConfig.chatDisabled || staticConfig.chatDisabled) + var showWhoToFollowPanel = (apiConfig.showWhoToFollowPanel || staticConfig.showWhoToFollowPanel) + var whoToFollowProvider = (apiConfig.whoToFollowProvider || staticConfig.whoToFollowProvider) + var whoToFollowLink = (apiConfig.whoToFollowLink || staticConfig.whoToFollowLink) + var showInstanceSpecificPanel = (apiConfig.showInstanceSpecificPanel || staticConfig.showInstanceSpecificPanel) + var scopeOptionsEnabled = (apiConfig.scopeOptionsEnabled || staticConfig.scopeOptionsEnabled) + var collapseMessageWithSubject = (apiConfig.collapseMessageWithSubject || staticConfig.collapseMessageWithSubject) store.dispatch('setOption', { name: 'theme', value: theme }) store.dispatch('setOption', { name: 'background', value: background }) From 8b9e973a557ab9c30c677c3ba5e8a966555cc1e9 Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Sun, 26 Aug 2018 07:00:23 +0900 Subject: [PATCH 4/5] save /api/statusnet/config.json connection --- src/main.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.js b/src/main.js index 8681e960..a988f66c 100644 --- a/src/main.js +++ b/src/main.js @@ -91,11 +91,7 @@ window.fetch('/api/statusnet/config.json') store.dispatch('setOption', { name: 'registrationOpen', value: (registrationClosed === '0') }) store.dispatch('setOption', { name: 'textlimit', value: parseInt(textlimit) }) store.dispatch('setOption', { name: 'server', value: server }) - }) -window.fetch('/api/statusnet/config.json') - .then((res) => res.json()) - .then((data) => { var apiConfig = data.site.pleromafe window.fetch('/static/config.json') .then((data) => { From c6913e3909e089225ade7aa4874bd1acbca5a5e4 Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Sun, 26 Aug 2018 07:01:56 +0900 Subject: [PATCH 5/5] correct /static/config.json decoding --- src/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.js b/src/main.js index a988f66c..48022c41 100644 --- a/src/main.js +++ b/src/main.js @@ -93,7 +93,9 @@ window.fetch('/api/statusnet/config.json') store.dispatch('setOption', { name: 'server', value: server }) var apiConfig = data.site.pleromafe + window.fetch('/static/config.json') + .then((res) => res.json()) .then((data) => { var staticConfig = data