diff --git a/package.json b/package.json index 60e5ca02..90bf48cf 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,8 @@ "whatwg-fetch": "^2.0.3" }, "devDependencies": { + "@babel/polyfill": "^7.0.0", + "@vue/test-utils": "^1.0.0-beta.26", "autoprefixer": "^6.4.0", "babel-core": "^6.0.0", "babel-eslint": "^7.0.0", diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 24a8d3ac..8cd13df7 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -1,21 +1,8 @@ import Vue from 'vue' import VueRouter from 'vue-router' +import routes from './routes' import App from '../App.vue' -import PublicTimeline from '../components/public_timeline/public_timeline.vue' -import PublicAndExternalTimeline from '../components/public_and_external_timeline/public_and_external_timeline.vue' -import FriendsTimeline from '../components/friends_timeline/friends_timeline.vue' -import TagTimeline from '../components/tag_timeline/tag_timeline.vue' -import ConversationPage from '../components/conversation-page/conversation-page.vue' -import Mentions from '../components/mentions/mentions.vue' -import DMs from '../components/dm_timeline/dm_timeline.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 UserSettings from '../components/user_settings/user_settings.vue' -import FollowRequests from '../components/follow_requests/follow_requests.vue' -import OAuthCallback from '../components/oauth_callback/oauth_callback.vue' -import UserSearch from '../components/user_search/user_search.vue' const afterStoreSetup = ({ store, i18n }) => { window.fetch('/api/statusnet/config.json') @@ -102,35 +89,10 @@ const afterStoreSetup = ({ store, i18n }) => { store.dispatch('disableChat') } - const routes = [ - { name: 'root', - path: '/', - redirect: to => { - return (store.state.users.currentUser - ? store.state.instance.redirectRootLogin - : store.state.instance.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: 'dms', path: '/:username/dms', component: DMs }, - { 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 }, - { name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, - { name: 'user-search', path: '/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) } - ] - const router = new VueRouter({ mode: 'history', - routes, - scrollBehavior: (to, from, savedPosition) => { + routes: routes(store), + scrollBehavior: (to, _from, savedPosition) => { if (to.matched.some(m => m.meta.dontScroll)) { return false } diff --git a/src/boot/routes.js b/src/boot/routes.js new file mode 100644 index 00000000..8ea8cc7f --- /dev/null +++ b/src/boot/routes.js @@ -0,0 +1,67 @@ +import PublicTimeline from 'components/public_timeline/public_timeline.vue' +import PublicAndExternalTimeline from 'components/public_and_external_timeline/public_and_external_timeline.vue' +import FriendsTimeline from 'components/friends_timeline/friends_timeline.vue' +import TagTimeline from 'components/tag_timeline/tag_timeline.vue' +import ConversationPage from 'components/conversation-page/conversation-page.vue' +import Mentions from 'components/mentions/mentions.vue' +import DMs from 'components/dm_timeline/dm_timeline.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 UserSettings from 'components/user_settings/user_settings.vue' +import FollowRequests from 'components/follow_requests/follow_requests.vue' +import OAuthCallback from 'components/oauth_callback/oauth_callback.vue' +import UserSearch from 'components/user_search/user_search.vue' + +export default (store) => { + return [ + { name: 'root', + path: '/', + redirect: _to => { + return (store.state.users.currentUser + ? store.state.instance.redirectRootLogin + : store.state.instance.redirectRootNoLogin) || '/~/main/all' + } + }, + { name: 'public-external-timeline', path: '/~/main/all', component: PublicAndExternalTimeline }, + { name: 'public-timeline', path: '/~/main/public', component: PublicTimeline }, + { name: 'friends', path: '/~/main/friends', component: FriendsTimeline }, + // Beginning of temporary redirects + { path: '/main/:route', + redirect: to => { + const { params } = to + const route = params.route ? params.route : 'all' + + return { path: `/~/main/${route}` } + } + }, + { path: '/tag/:tag', + redirect: to => { + const { params } = to + + return { path: `/~/tag/${params.tag}` } + } + }, + { path: '/notice/:id', + redirect: to => { + const { params } = to + + return { path: `/~/notice/${params.id}` } + } + }, + // End of temporary redirects + { name: 'tag-timeline', path: '/~/tag/:tag', component: TagTimeline }, + { name: 'conversation', path: '/~/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, + { name: 'user-profile', path: '/:name', component: UserProfile }, + { name: 'external-user-profile', path: '/~/users/:id', component: UserProfile }, + { name: 'mentions', path: '/:username/mentions', component: Mentions }, + { name: 'dms', path: '/:username/dms', component: DMs }, + { 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 }, + { name: 'oauth-callback', path: '/~/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, + { name: 'user-search', path: '/~/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) } + ] +} diff --git a/src/components/chat_panel/chat_panel.js b/src/components/chat_panel/chat_panel.js index d8736d17..e175e90c 100644 --- a/src/components/chat_panel/chat_panel.js +++ b/src/components/chat_panel/chat_panel.js @@ -1,3 +1,5 @@ +import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' + const chatPanel = { data () { return { @@ -18,6 +20,9 @@ const chatPanel = { }, togglePanel () { this.collapsed = !this.collapsed + }, + userProfileLink (user) { + return generateProfileLink(user.id, user.screen_name) } } } diff --git a/src/components/chat_panel/chat_panel.vue b/src/components/chat_panel/chat_panel.vue index f174319a..1b9c63ff 100644 --- a/src/components/chat_panel/chat_panel.vue +++ b/src/components/chat_panel/chat_panel.vue @@ -13,8 +13,10 @@
- - {{message.author.username}} + + {{message.author.username}}
@@ -67,9 +69,6 @@ overflow-x: hidden; } -.chat-name { -} - .chat-message { display: flex; padding: 0.2em 0.5em diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index 49868aed..81426b44 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -32,7 +32,7 @@ const LoginForm = { .then((result) => { this.$store.commit('setToken', result.access_token) this.$store.dispatch('loginUser', result.access_token) - this.$router.push('/main/friends') + this.$router.push('/~/main/friends') }) }) } diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index b224c5f3..c52d1e52 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -3,7 +3,7 @@
  • - + {{ $t("nav.timeline") }}
  • @@ -18,17 +18,17 @@
  • - + {{ $t("nav.friend_requests") }}
  • - + {{ $t("nav.public_tl") }}
  • - + {{ $t("nav.twkn") }}
  • diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index 345fe3ee..9ab870b6 100644 --- a/src/components/notification/notification.js +++ b/src/components/notification/notification.js @@ -2,6 +2,7 @@ import Status from '../status/status.vue' import StillImage from '../still-image/still-image.vue' import UserCardContent from '../user_card_content/user_card_content.vue' import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js' +import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' const Notification = { data () { @@ -20,6 +21,9 @@ const Notification = { methods: { toggleUserExpanded () { this.userExpanded = !this.userExpanded + }, + userProfileLink (user) { + return generateProfileLink(user.id, user.screen_name) } }, computed: { diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index e84ce0b6..1c89cbb7 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -28,7 +28,9 @@