Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions functions/_middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ const STATIC_META = {
title: 'Themes - MistWarp',
description: 'Browse community-made editor themes for MistWarp.'
},
'/groups': {
title: 'Groups - MistWarp',
description: 'Organisations that share projects, spaces, members, and funding on MistWarp.'
},
'/posts': {
title: 'Posts - MistWarp',
description: 'Popular posts from claw, the Rotur social network, on MistWarp.'
Expand Down Expand Up @@ -293,8 +289,27 @@ const vanityPullMeta = async (slug, index) => {
return pullMeta(data.id, index);
};

const orgMeta = async name => {
const data = await apiJson(`/orgs/${encodeURIComponent(name)}`);
const org = data && data.org;
if (!org) return null;
const username = org.username || name;
const title = org.displayName || username;
return {
title: `${title} - MistWarp`,
description: flatten(org.bio) ||
`${title} has shared ${(data.projects || []).length} projects on MistWarp.`,
image: `${AVATARS}/${encodeURIComponent(username.toLowerCase())}`,
card: 'summary'
};
};

const ownedByOrg = data => (data.projects || []).some(project => project && project.ownerType === 'org');

const userMeta = async (name, suffix) => {
const data = await apiJson(`/users/${encodeURIComponent(name)}`);
const org = (!data || data.exists !== true || ownedByOrg(data)) && !suffix ? await orgMeta(name) : null;
if (org) return org;
if (!data || data.exists !== true) {
return {
title: 'Profile - MistWarp',
Expand Down Expand Up @@ -337,25 +352,6 @@ const spaceMeta = async id => {
};
};

const groupMeta = async tag => {
const data = await apiJson(`/groups/${encodeURIComponent(tag)}`);
const group = data && data.group;
if (!group) {
return {
title: 'Group - MistWarp',
description: 'View this MistWarp group.'
};
}
const projects = data.projects || [];
return {
title: `${group.name || tag} - MistWarp`,
description: flatten(group.description) ||
`${group.name || tag} has shared ${projects.length} projects on MistWarp.`,
image: group.icon_url || DEFAULT_IMAGE,
card: 'summary'
};
};

const newsMeta = async id => {
const data = await apiJson(`/news/${encodeURIComponent(id)}`);
const item = data && data.item;
Expand Down Expand Up @@ -452,6 +448,15 @@ const legacyEmbedRedirect = url => {
return permanent(`${url.origin}/embed${url.search}#${/^\d+$/.test(id) ? id : `mw-${id}`}`);
};

const ORG_PAGE = /^\/orgs\/([^/]+)$/;
const GROUP_PAGE = /^\/groups(?:\/[^/]+)?$/;

const renamedPagePath = path => {
const org = path.match(ORG_PAGE);
if (org) return `/users/${org[1]}`;
return GROUP_PAGE.test(path) ? '/explore' : path;
};

const editorHostRoute = url => {
const path = pagePath(url.pathname);
if (path === '/' || path === '/editor') {
Expand All @@ -463,18 +468,18 @@ const editorHostRoute = url => {
return project ? {asset: PROJECT_PAGE_ASSETS[project[1]] || '/player'} : {asset: null};
}
if (isFilePath(url.pathname)) return {asset: null};
return {redirect: `${ACCOUNT_ORIGIN}${path}${url.search}`};
return {redirect: `${ACCOUNT_ORIGIN}${renamedPagePath(path)}${url.search}`};
};

const accountHostRoute = url => {
const path = pagePath(url.pathname);
const path = renamedPagePath(pagePath(url.pathname));
if (path === '/editor') return `${EDITOR_ORIGIN}/${url.search}`;
if (MOVED_APP_PAGES.has(path) || PROJECT_PAGE.test(path)) return `${EDITOR_ORIGIN}${path}${url.search}`;
return path === url.pathname ? null : `${url.origin}${path}${url.search}`;
};

const otherHostRoute = url => {
const path = pagePath(url.pathname);
const path = renamedPagePath(pagePath(url.pathname));
return path === url.pathname ? null : `${url.origin}${path}${url.search}`;
};

Expand Down Expand Up @@ -549,12 +554,6 @@ const metaForPath = pathname => {
return NOT_FOUND_META;
}

match = normalizedPath.match(/^\/groups\/([^/]+)$/);
if (match) {
const tag = decodeSegment(match[1]);
return tag === null ? NOT_FOUND_META : groupMeta(tag);
}

match = normalizedPath.match(/^\/news\/([^/]+)$/);
if (match) {
const id = decodeSegment(match[1]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scratch-gui",
"version": "3.14.0",
"version": "3.15.0",
"private": true,
"description": "MistWarp editor, player, and community site",
"author": "MistWarp contributors",
Expand Down
13 changes: 5 additions & 8 deletions src/community/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const PullRequests = lazy(() => import('./pages/PullRequests.jsx'));
const Commit = lazy(() => import('./pages/Commit.jsx'));
const ProjectCode = lazy(() => import('./pages/ProjectCode.jsx'));
const RemixTree = lazy(() => import('./pages/RemixTree.jsx'));
const Profile = lazy(() => import('./pages/Profile.jsx'));
const Account = lazy(() => import('./pages/Account.jsx'));
const OrgRedirect = lazy(() => import('./pages/Account.jsx').then(module => ({default: module.OrgRedirect})));
const UserLibrary = lazy(() => import('./pages/UserLibrary.jsx'));
const Following = lazy(() => import('./pages/Following.jsx'));
const Settings = lazy(() => import('./pages/Settings.jsx'));
Expand All @@ -58,8 +59,6 @@ const Status = lazy(() => import('./pages/Status.jsx'));
const PaidPerks = lazy(() => import('./pages/PaidPerks.jsx'));
const Themes = lazy(() => import('./pages/Themes.jsx'));
const Theme = lazy(() => import('./pages/Theme.jsx'));
const Groups = lazy(() => import('./pages/Groups.jsx'));
const Group = lazy(() => import('./pages/Group.jsx'));
const Classroom = lazy(() => import('./pages/Classroom.jsx'));
const ClassroomClass = lazy(() => import('./pages/ClassroomClass.jsx'));
const ClassroomStudent = lazy(() => import('./pages/ClassroomStudent.jsx'));
Expand All @@ -78,8 +77,6 @@ const ROUTE_TITLES = [
['/random', 'Random project'],
['/themes/', 'Theme'],
['/themes', 'Themes'],
['/groups/', 'Group'],
['/groups', 'Groups'],
['/classroom/join', 'Student sign-in'],
['/classroom/claim', 'Move to your own account'],
['/classroom/school', 'School'],
Expand Down Expand Up @@ -110,6 +107,7 @@ const ROUTE_TITLES = [
['/status', 'Service status'],
['/admin', 'Admin'],
['/users/', 'Profile'],
['/orgs/', 'Organisation'],
['/p/', 'Project'],
['/project/', 'Project']
];
Expand Down Expand Up @@ -246,8 +244,6 @@ const App = () => {
<Route path="/bounties" element={<Bounties />} />
<Route path="/themes" element={<Themes />} />
<Route path="/themes/:id" element={<Theme />} />
<Route path="/groups" element={<Groups />} />
<Route path="/groups/:tag" element={<Group />} />
<Route path="/classroom" element={<ClassroomRoute />}>
<Route index element={<Classroom />} />
<Route path="join" element={<ClassroomJoin />} />
Expand Down Expand Up @@ -276,7 +272,8 @@ const App = () => {
<Route path="/project/:id/pulls" element={<PullRequests />} />
<Route path="/project/:id/commits/:sha" element={<Commit />} />
<Route path="/project/:id/code/*" element={<ProjectCode />} />
<Route path="/users/:name" element={<Profile />} />
<Route path="/users/:name" element={<Account />} />
<Route path="/orgs/:name" element={<OrgRedirect />} />
<Route path="/users/:name/library" element={<UserLibrary />} />
<Route
path="/users/:name/followers"
Expand Down
2 changes: 0 additions & 2 deletions src/community/UserContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const UserProvider = ({children}) => {
setUser(normalizeUser(baseUser ? {
...baseUser,
isNew: isNewAccount(me),
group_tag: roturProfile?.group_tag || '',
subscription: roturProfile?.subscription || baseUser.subscription || ''
} : null));
}, []);
Expand All @@ -127,7 +126,6 @@ const UserProvider = ({children}) => {
const nextUser = normalizeUser({
...user,
...(me || {}),
group_tag: roturProfile?.group_tag || '',
subscription: roturProfile?.subscription || (me && me.subscription) || user.subscription || ''
});
setUser(nextUser);
Expand Down
3 changes: 2 additions & 1 deletion src/community/api/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
request(`/users/${encodeURIComponent(name)}/projects?offset=${offset}&limit=${limit}`),
searchUsers: (q, {limit = 8} = {}) => request(`/search/users?q=${encodeURIComponent(q)}&limit=${limit}`),
activity: users => request(`/activity?users=${encodeURIComponent(users.join(','))}`),
group: tag => request(`/groups/${encodeURIComponent(tag)}`)
org: name => request(`/orgs/${encodeURIComponent(name)}`),
myOrgs: () => request('/me/orgs', {cache: false})
};
2 changes: 0 additions & 2 deletions src/community/components/CommentThread.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Notice from './ui/Notice.jsx';
import StatusMessage from './ui/StatusMessage.jsx';
import SelectMenu from './ui/SelectMenu.jsx';
import RichText from './RichText.jsx';
import GroupTag from './GroupTag.jsx';
import Dropdown, {DropdownItem} from './ui/Dropdown.jsx';
import {timeAgo, sameUser, formatPlaytime} from '../format';
import {payWithRotur} from '../../lib/rotur/payment-window.js';
Expand Down Expand Up @@ -130,7 +129,6 @@ const CommentRow = ({
to={`/users/${comment.author}`}
className={styles.author}
>{comment.author}</Link>
<GroupTag username={comment.author} compact />
{authorBadge ? (
<span className={styles.authorBadge}>
<Trophy size={11} aria-hidden="true" />
Expand Down
3 changes: 1 addition & 2 deletions src/community/components/ExploreNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const GROUPS = [
],
[
{key: 'creators', label: 'Creators', to: '/leaderboard?board=loves'},
{key: 'posts', label: 'Posts', to: '/posts'},
{key: 'groups', label: 'Groups', to: '/groups'}
{key: 'posts', label: 'Posts', to: '/posts'}
],
[
{key: 'themes', label: 'Themes', to: '/themes'},
Expand Down
2 changes: 0 additions & 2 deletions src/community/components/FeaturedProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import api, {embedUrl, projectUrl} from '../api';
import Avatar from './Avatar.jsx';
import ProjectThumbnail from './ProjectThumbnail.jsx';
import styles from './FeaturedProject.module.css';
import GroupTag from './GroupTag.jsx';

const FeaturedProject = ({project}) => {
const {text: communityText} = useCommunityText();
Expand Down Expand Up @@ -61,7 +60,6 @@ const FeaturedProject = ({project}) => {
<Link to={`/users/${displayProject.owner}`} className={styles.owner}>
{communityText('by {value1}', {value1: displayProject.owner})}
</Link>
<GroupTag username={displayProject.owner} compact />
</div>
<Link to={projectUrl(displayProject)} className={styles.openProject}>
<ExternalLink size={14} />
Expand Down
59 changes: 0 additions & 59 deletions src/community/components/GroupTag.jsx

This file was deleted.

60 changes: 0 additions & 60 deletions src/community/components/GroupTag.module.css

This file was deleted.

2 changes: 0 additions & 2 deletions src/community/components/ListSkeleton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import React from 'react';
import {useCommunityIntl} from '../i18n.jsx';
import styles from './ListSkeleton.module.css';

// Placeholder rows for list pages (people, groups, posts) while the first
// page loads: a picture and a couple of lines, like the rows that replace it.
const ListSkeleton = ({className, count, label, lines, media}) => {
const {text: communityText} = useCommunityIntl();
return (
Expand Down
Loading