+
+
+
+
diff --git a/src/main.js b/src/main.js
index bf06512c..1186c72a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -19,9 +19,25 @@
* along with this program. If not, see .
*
*/
+import '@babel/polyfill'
import Vue from 'vue'
+import { sync } from 'vuex-router-sync'
+
import App from './App'
+import store from './store'
+import router from './router'
+
+sync(store, router)
+
+// CSP config for webpack dynamic chunk loading
+// eslint-disable-next-line
+__webpack_nonce__ = btoa(OC.requestToken)
+
+// Correct the root of the app for chunk loading
+// OC.linkTo matches the apps folders
+// eslint-disable-next-line
+__webpack_public_path__ = OC.linkTo('social', 'js/')
Vue.prototype.t = t
Vue.prototype.n = n
@@ -30,5 +46,7 @@ Vue.prototype.OCA = OCA
/* eslint-disable-next-line no-new */
new Vue({
- render: h => h(App)
-}).$mount('#content')
+ router: router,
+ render: h => h(App),
+ store: store
+}).$mount('#vue-content')
diff --git a/src/router.js b/src/router.js
new file mode 100644
index 00000000..e14127ea
--- /dev/null
+++ b/src/router.js
@@ -0,0 +1,87 @@
+/**
+ * @copyright Copyright (c) 2018 Julius Härtl
+ * @copyright Copyright (c) 2018 John Molakvoæ
+ *
+ * @author Julius Härtl
+ * @author John Molakvoæ
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+import Vue from 'vue'
+import Router from 'vue-router'
+
+// Dynamic loading
+const Timeline = () => import('./views/Timeline')
+const Profile = () => import('./views/Profile')
+const ProfileTimeline = () => import('./views/ProfileTimeline')
+const ProfileFollowers = () => import('./views/ProfileFollowers')
+
+Vue.use(Router)
+
+export default new Router({
+ mode: 'history',
+ // if index.php is in the url AND we got this far, then it's working:
+ // let's keep using index.php in the url
+ base: OC.generateUrl(''),
+ linkActiveClass: 'active',
+ routes: [
+ {
+ path: '/:index(index.php/)?apps/social/',
+ components: {
+ default: Timeline
+ },
+ props: true,
+ name: 'timeline'
+ },
+ {
+ path: '/:index(index.php/)?apps/social/account/:account',
+ components: {
+ default: Profile
+ },
+ props: true,
+ name: 'profile',
+ children: [
+ {
+ path: '',
+ components: {
+ details: ProfileTimeline
+ }
+ },
+ {
+ path: 'followers',
+ components: {
+ default: Profile,
+ details: ProfileFollowers
+ }
+ },
+ {
+ path: 'following',
+ components: {
+ default: Profile,
+ details: ProfileFollowers
+ }
+ }
+ ]
+ },
+ {
+ path: '/:index(index.php/)?apps/social/:account',
+ component: Profile,
+ props: true,
+ name: 'public'
+ }
+ ]
+})
diff --git a/src/store/account.js b/src/store/account.js
new file mode 100644
index 00000000..6af8ab14
--- /dev/null
+++ b/src/store/account.js
@@ -0,0 +1,47 @@
+/*
+ * @copyright Copyright (c) 2018 Julius Härtl
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import axios from 'nextcloud-axios'
+import Vue from 'vue'
+
+const state = {
+ accounts: {}
+}
+const mutations = {
+ addAccount(state, { uid, data }) {
+ Vue.set(state.accounts, uid, data)
+ }
+}
+const getters = {
+ getAccount(state) {
+ return (uid) => state.accounts[uid]
+ }
+}
+const actions = {
+ fetchAccountInfo(context, uid) {
+ axios.get(OC.generateUrl('apps/social/local/account/' + uid)).then((response) => {
+ context.commit('addAccount', { uid: uid, data: response.data })
+ })
+ }
+}
+
+export default { state, mutations, getters, actions }
diff --git a/src/store/index.js b/src/store/index.js
new file mode 100644
index 00000000..4076bff7
--- /dev/null
+++ b/src/store/index.js
@@ -0,0 +1,41 @@
+/*
+ * @copyright Copyright (c) 2018 John Molakvoæ
+ *
+ * @author John Molakvoæ
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import Vue from 'vue'
+import Vuex from 'vuex'
+import timeline from './timeline'
+import account from './account'
+import settings from './settings'
+
+Vue.use(Vuex)
+
+const debug = process.env.NODE_ENV !== 'production'
+
+export default new Vuex.Store({
+ modules: {
+ timeline,
+ account,
+ settings
+ },
+ strict: debug
+})
diff --git a/src/store/settings.js b/src/store/settings.js
new file mode 100644
index 00000000..75ac7972
--- /dev/null
+++ b/src/store/settings.js
@@ -0,0 +1,38 @@
+/*
+ * @copyright Copyright (c) 2018 Julius Härtl
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+const state = {
+ serverData: {}
+}
+const mutations = {
+ setServerData(state, data) {
+ state.serverData = data
+ }
+}
+const getters = {
+ getServerData(state) {
+ return state.serverData
+ }
+}
+const actions = {}
+
+export default { state, mutations, getters, actions }
diff --git a/src/store/timeline.js b/src/store/timeline.js
new file mode 100644
index 00000000..2d1a28ee
--- /dev/null
+++ b/src/store/timeline.js
@@ -0,0 +1,40 @@
+/*
+ * @copyright Copyright (c) 2018 Julius Härtl
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+const state = {
+ timeline: []
+}
+const mutations = {
+ addToTimeline(state, data) {
+ for (let item in data) {
+ state.timeline.push(data[item])
+ }
+ }
+}
+const getters = {
+ getTimeline(state) {
+ return state.timeline
+ }
+}
+const actions = {}
+
+export default { state, mutations, getters, actions }
diff --git a/src/views/Profile.vue b/src/views/Profile.vue
new file mode 100644
index 00000000..83a4b693
--- /dev/null
+++ b/src/views/Profile.vue
@@ -0,0 +1,156 @@
+
+
+
+
🎉{{ t('social', 'Nextcloud becomes part of the federated social networks!') }}
+
+ {{ t('social', 'We have automatically created a social account for you. Your social id is the same as the federated cloud id:') }}
+ {{ socialId }}
+