diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index 1a6f6015..a117b76f 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -4,7 +4,8 @@ const LoginForm = { authError: false }), computed: { - loggingIn () { return this.$store.state.users.loggingIn } + loggingIn () { return this.$store.state.users.loggingIn }, + registrationOpen () { return this.$store.state.config.registrationOpen } }, methods: { submit () { diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue index b2fa5341..d6291148 100644 --- a/src/components/login_form/login_form.vue +++ b/src/components/login_form/login_form.vue @@ -15,7 +15,10 @@
Your current avatar:
+ +Set new avatar:
+ + +All notices containing these words will be muted, one per line
@@ -52,6 +64,24 @@ width: 100%; height: 100px; } + + .old-avatar { + width: 128px; + border-radius: 5px; + } + + .new-avatar { + object-fit: cover; + width: 128px; + height: 128px; + border-radius: 5px; + } + + .btn { + margin-top: 1em; + min-height: 28px; + width: 10em; + } } .setting-list { list-style-type: none; diff --git a/src/main.js b/src/main.js index e5ecf228..4b7891ed 100644 --- a/src/main.js +++ b/src/main.js @@ -9,6 +9,7 @@ import ConversationPage from './components/conversation-page/conversation-page.v import Mentions from './components/mentions/mentions.vue' import UserProfile from './components/user_profile/user_profile.vue' import Settings from './components/settings/settings.vue' +import Registration from './components/registration/registration.vue' import statusesModule from './modules/statuses.js' import usersModule from './modules/users.js' @@ -60,7 +61,8 @@ const routes = [ { 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: 'settings', path: '/settings', component: Settings }, + { name: 'registration', path: '/registration', component: Registration } ] const router = new VueRouter({ @@ -84,9 +86,16 @@ new Vue({ window.fetch('/static/config.json') .then((res) => res.json()) - .then(({name, theme, background, logo}) => { + .then(({name, theme, background, logo, registrationOpen}) => { 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 }) + }) + +window.fetch('/static/terms-of-service.html') + .then((res) => res.text()) + .then((html) => { + store.dispatch('setOption', { name: 'tos', value: html }) }) diff --git a/src/modules/users.js b/src/modules/users.js index 22e0133c..b68f67e6 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -24,7 +24,7 @@ export const mutations = { set(user, 'muted', muted) }, setCurrentUser (state, user) { - state.currentUser = user + state.currentUser = merge(state.currentUser || {}, user) }, beginLogin (state) { state.loggingIn = true diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 59e3a1c3..e848d076 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -17,13 +17,15 @@ const FRIENDS_URL = '/api/statuses/friends.json' const FOLLOWING_URL = '/api/friendships/create.json' const UNFOLLOWING_URL = '/api/friendships/destroy.json' const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json' +const REGISTRATION_URL = '/api/account/register.json' +const AVATAR_UPDATE_URL = '/api/qvitter/update_avatar.json' const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json' const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json' // const USER_URL = '/api/users/show.json' -const oldfetch = window.fetch +import { each, map } from 'lodash' -import { map } from 'lodash' +const oldfetch = window.fetch let fetch = (url, options) => { const baseUrl = '' @@ -31,6 +33,55 @@ let fetch = (url, options) => { return oldfetch(fullUrl, options) } +// Params +// cropH +// cropW +// cropX +// cropY +// img (base 64 encodend data url) +const updateAvatar = ({credentials, params}) => { + let url = AVATAR_UPDATE_URL + + const form = new FormData() + + each(params, (value, key) => { + if (value) { + form.append(key, value) + } + }) + return fetch(url, { + headers: authHeaders(credentials), + method: 'POST', + body: form + }).then((data) => data.json()) +} + +// Params needed: +// nickname +// email +// fullname +// password +// password_confirm +// +// Optional +// bio +// homepage +// location +const register = (params) => { + const form = new FormData() + + each(params, (value, key) => { + if (value) { + form.append(key, value) + } + }) + + return fetch(REGISTRATION_URL, { + method: 'POST', + body: form + }) +} + const authHeaders = (user) => { if (user && user.username && user.password) { return { 'Authorization': `Basic ${btoa(`${user.username}:${user.password}`)}` } @@ -220,6 +271,8 @@ const apiService = { fetchAllFollowing, setUserMute, fetchMutes, + register, + updateAvatar, externalProfile } diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index f2d01c70..5dbbf4b3 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -36,6 +36,8 @@ const backendInteractorService = (credentials) => { const fetchMutes = () => apiService.fetchMutes({credentials}) + const register = (params) => apiService.register(params) + const updateAvatar = ({params}) => apiService.updateAvatar({credentials, params}) const externalProfile = (profileUrl) => apiService.externalProfile(profileUrl) const backendInteractorServiceInstance = { @@ -49,6 +51,8 @@ const backendInteractorService = (credentials) => { startFetching, setUserMute, fetchMutes, + register, + updateAvatar, externalProfile } diff --git a/static/config.json b/static/config.json index 3b6d56c4..195ee046 100644 --- a/static/config.json +++ b/static/config.json @@ -2,5 +2,6 @@ "name": "Pleroma FE", "theme": "base16-pleroma-dark.css", "background": "/static/bg.jpg", - "logo": "/static/logo.png" + "logo": "/static/logo.png", + "registrationOpen": false } diff --git a/static/terms-of-service.html b/static/terms-of-service.html new file mode 100644 index 00000000..c02cb719 --- /dev/null +++ b/static/terms-of-service.html @@ -0,0 +1,7 @@ +This is a placeholder ToS.
+ +Edit "/static/terms-of-service.html"
to make it fit the needs of your instance.