Skip to content

Commit 7ee178b

Browse files
committed
Refactor project components and update messaging for project creation and embedding
1 parent e17a09e commit 7ee178b

7 files changed

Lines changed: 19 additions & 253 deletions

File tree

‎src/components/menu-bar/author-info.jsx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ const ActualAuthorInfo = ({
2121
styles.authorInfo
2222
)}
2323
>
24-
<UserAvatar
25-
className={styles.avatar}
26-
imageUrl={imageUrl}
27-
/>
2824
<div className={styles.titleAuthor}>
2925
<h1 className={styles.projectTitle}>
3026
{decodeURIComponent(projectTitle)}

‎src/components/tw-invalid-embed/invalid-embed.jsx‎

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,7 @@ const InvalidEmbed = () => (
1212
<div className={styles.container}>
1313
<h1>{`Invalid ${APP_NAME} Embed :(`}</h1>
1414
<p>
15-
{'See '}
16-
<a
17-
href="https://docs.turbowarp.org/embedding"
18-
target="_blank"
19-
rel="noreferrer"
20-
>
21-
{'docs.turbowarp.org/embedding'}
22-
</a>
23-
{/* eslint-disable-next-line max-len */}
24-
{' for more information. You need to replace the iframe src with the embed page:'}
25-
</p>
26-
<p className={styles.code}>
27-
{'https://turbowarp.org/<project ID>/embed'}
28-
</p>
29-
<p>
30-
{'Here\'s an example of a full iframe to embed a project:'}
31-
</p>
32-
<p className={styles.code}>
33-
{`<iframe src="https://turbowarp.org/60917032/embed" width="482" height="412" allowtransparency="true" frameborder="0" scrolling="no" allowfullscreen></iframe>`}
34-
</p>
35-
<p>
36-
{'If you are seeing this page even though you aren\'t embedding anything, let us know on '}
37-
<a
38-
href="https://scratch.mit.edu/users/GarboMuffin/#comments"
39-
target="_blank"
40-
rel="noreferrer"
41-
>
42-
{'scratch.mit.edu/users/GarboMuffin'}
43-
</a>
44-
{'.'}
15+
{`You must run this project within an <iframe></iframe> for it to work properly.`}
4516
</p>
4617
</div>
4718
);

‎src/lib/tw-project-meta-fetcher-hoc.jsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {setAuthor, setDescription} from '../reducers/tw';
1111

1212
export const fetchProjectMeta = async projectId => {
1313
const urls = [
14-
API_HOST+`/projectsMETA?${projectId}`,
15-
API_HOST+`/projectsMETA?${projectId}`
14+
API_HOST+`/projectsMETA?id=${projectId}`,
15+
API_HOST+`/projectsMETA?id=${projectId}`
1616
];
1717
let firstError;
1818
for (const url of urls) {

‎src/playground/render-gui.jsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ const cloudHost = searchParams.get('cloud_host') || 'wss://clouddata.turbowarp.o
66

77
const creatingNewProject = new URLSearchParams(location.search).get('new_project') === '1';
88

9+
const restrictedMode = new URLSearchParams(location.search).get('onlyEditor') === '1';
10+
911
const RenderGUI = props => (
1012
<GUI
1113
cloudHost={cloudHost}
1214
canUseCloud
1315
hasCloudPermission
1416
canSave={true}
1517
canCreateNew={creatingNewProject}
18+
//isShared,canRemix,canEditTitle
19+
isShared={!restrictedMode}
20+
canShare={false} //just do it from project page
1621
basePath={process.env.ROOT}
17-
canEditTitle
18-
enableCommunity
22+
canEditTitle={false} //just do it from project page
23+
enableCommunity={!restrictedMode}
1924
{...props}
2025
/>
2126
);

‎src/playground/render-interface.jsx‎

Lines changed: 4 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ import {APP_NAME} from '../lib/brand.js';
4545

4646
import styles from './interface.css';
4747

48-
const isInvalidEmbed = window.parent !== window;
48+
const isInvalidEmbed = window.parent == window;
4949

5050
const handleClickAddonSettings = addonId => {
5151
// addonId might be a string of the addon to focus on, undefined, or an event (treat like undefined)
52-
const path = process.env.ROUTING_STYLE === 'wildcard' ? 'addons' : 'addons.html';
52+
/*const path = process.env.ROUTING_STYLE === 'wildcard' ? 'addons' : 'addons.html';
5353
const url = `${process.env.ROOT}${path}${typeof addonId === 'string' ? `#${addonId}` : ''}`;
54-
window.open(url);
54+
window.open(url);*/
55+
window.parent.postMessage({ type: "block-compiler-action", action: "addonsPage"}, "*");
5556
};
5657

5758
const messages = defineMessages({
@@ -81,117 +82,6 @@ if (AddonChannels.changeChannel) {
8182

8283
runAddons();
8384

84-
const Footer = () => (
85-
<footer className={styles.footer}>
86-
<div className={styles.footerContent}>
87-
<div className={styles.footerText}>
88-
<FormattedMessage
89-
// eslint-disable-next-line max-len
90-
defaultMessage="{APP_NAME} is not affiliated with Scratch, the Scratch Team, or the Scratch Foundation."
91-
description="Disclaimer that TurboWarp is not connected to Scratch"
92-
id="tw.footer.disclaimer"
93-
values={{
94-
APP_NAME
95-
}}
96-
/>
97-
</div>
98-
99-
<div className={styles.footerText}>
100-
<FormattedMessage
101-
// eslint-disable-next-line max-len
102-
defaultMessage="Scratch is a project of the Scratch Foundation. It is available for free at {scratchDotOrg}."
103-
description="A disclaimer that Scratch requires when referring to Scratch. {scratchDotOrg} is a link with text 'https://scratch.org/'"
104-
id="tw.footer.scratchDisclaimer"
105-
values={{
106-
scratchDotOrg: (
107-
<a
108-
href="https://scratch.org/"
109-
target="_blank"
110-
rel="noreferrer"
111-
>
112-
{'https://scratch.org/'}
113-
</a>
114-
)
115-
}}
116-
/>
117-
</div>
118-
119-
<div className={styles.footerColumns}>
120-
<div className={styles.footerSection}>
121-
<a href="credits.html">
122-
<FormattedMessage
123-
defaultMessage="Credits"
124-
description="Credits link in footer"
125-
id="tw.footer.credits"
126-
/>
127-
</a>
128-
<a href="https://github.com/sponsors/GarboMuffin">
129-
<FormattedMessage
130-
defaultMessage="Donate"
131-
description="Donation link in footer"
132-
id="tw.footer.donate"
133-
/>
134-
</a>
135-
</div>
136-
<div className={styles.footerSection}>
137-
<a href="https://desktop.turbowarp.org/">
138-
{/* Do not translate */}
139-
{'TurboWarp Desktop'}
140-
</a>
141-
<a href="https://packager.turbowarp.org/">
142-
{/* Do not translate */}
143-
{'TurboWarp Packager'}
144-
</a>
145-
<a href="https://docs.turbowarp.org/embedding">
146-
<FormattedMessage
147-
defaultMessage="Embedding"
148-
description="Link in footer to embedding documentation for embedding link"
149-
id="tw.footer.embed"
150-
/>
151-
</a>
152-
<a href="https://docs.turbowarp.org/url-parameters">
153-
<FormattedMessage
154-
defaultMessage="URL Parameters"
155-
description="Link in footer to URL parameters documentation"
156-
id="tw.footer.parameters"
157-
/>
158-
</a>
159-
<a href="https://docs.turbowarp.org/">
160-
<FormattedMessage
161-
defaultMessage="Documentation"
162-
description="Link in footer to additional documentation"
163-
id="tw.footer.documentation"
164-
/>
165-
</a>
166-
</div>
167-
<div className={styles.footerSection}>
168-
<a href="https://scratch.mit.edu/users/GarboMuffin/#comments">
169-
<FormattedMessage
170-
defaultMessage="Feedback & Bugs"
171-
description="Link to feedback/bugs page"
172-
id="tw.feedback"
173-
/>
174-
</a>
175-
<a href="https://github.com/TurboWarp/">
176-
<FormattedMessage
177-
defaultMessage="Source Code"
178-
description="Link to source code"
179-
id="tw.code"
180-
/>
181-
</a>
182-
<a href="privacy.html">
183-
<FormattedMessage
184-
defaultMessage="Privacy Policy"
185-
description="Link to privacy policy"
186-
id="tw.privacy"
187-
/>
188-
</a>
189-
</div>
190-
</div>
191-
</div>
192-
</footer>
193-
);
194-
19585
class Interface extends React.Component {
19686
constructor (props) {
19787
super(props);
@@ -237,17 +127,6 @@ class Interface extends React.Component {
237127
})}
238128
dir={isRtl ? 'rtl' : 'ltr'}
239129
>
240-
{isHomepage ? (
241-
<div className={styles.menu}>
242-
<WrappedMenuBar
243-
canChangeLanguage
244-
canManageFiles
245-
canChangeTheme
246-
enableSeeInside
247-
onClickAddonSettings={handleClickAddonSettings}
248-
/>
249-
</div>
250-
) : null}
251130
<div
252131
className={styles.center}
253132
style={isPlayerOnly ? ({
@@ -262,96 +141,7 @@ class Interface extends React.Component {
262141
backpackHost="_local_"
263142
{...props}
264143
/>
265-
{isHomepage ? (
266-
<React.Fragment>
267-
{isBrowserSupported() ? null : (
268-
<BrowserModal isRtl={isRtl} />
269-
)}
270-
<div className={styles.section}>
271-
<ProjectInput />
272-
</div>
273-
{(
274-
// eslint-disable-next-line max-len
275-
description.instructions === 'unshared' || description.credits === 'unshared'
276-
) && (
277-
<div className={classNames(styles.infobox, styles.unsharedUpdate)}>
278-
<p>
279-
<FormattedMessage
280-
defaultMessage="Unshared projects are no longer visible."
281-
description="Appears on unshared projects"
282-
id="tw.unshared2.1"
283-
/>
284-
</p>
285-
<p>
286-
<FormattedMessage
287-
defaultMessage="For more information, visit: {link}"
288-
description="Appears on unshared projects"
289-
id="tw.unshared.2"
290-
values={{
291-
link: (
292-
<a
293-
href="https://docs.turbowarp.org/unshared-projects"
294-
target="_blank"
295-
rel="noopener noreferrer"
296-
>
297-
{'https://docs.turbowarp.org/unshared-projects'}
298-
</a>
299-
)
300-
}}
301-
/>
302-
</p>
303-
<p>
304-
<FormattedMessage
305-
// eslint-disable-next-line max-len
306-
defaultMessage="If the project was shared recently, this message may appear incorrectly for a few minutes."
307-
description="Appears on unshared projects"
308-
id="tw.unshared.cache"
309-
/>
310-
</p>
311-
<p>
312-
<FormattedMessage
313-
// eslint-disable-next-line max-len
314-
defaultMessage="If this project is actually shared, please report a bug."
315-
description="Appears on unshared projects"
316-
id="tw.unshared.bug"
317-
/>
318-
</p>
319-
</div>
320-
)}
321-
{hasCloudVariables && projectId !== '0' && (
322-
<div className={styles.section}>
323-
<CloudVariableBadge />
324-
</div>
325-
)}
326-
{description.instructions || description.credits ? (
327-
<div className={styles.section}>
328-
<Description
329-
instructions={description.instructions}
330-
credits={description.credits}
331-
projectId={projectId}
332-
/>
333-
</div>
334-
) : null}
335-
<div className={styles.section}>
336-
<p>
337-
<FormattedMessage
338-
// eslint-disable-next-line max-len
339-
defaultMessage="{APP_NAME} is a Scratch mod that compiles projects to JavaScript to make them run really fast. Try it out by inputting a project ID or URL above or choosing a featured project below."
340-
description="Description of TurboWarp on the homepage"
341-
id="tw.home.description"
342-
values={{
343-
APP_NAME
344-
}}
345-
/>
346-
</p>
347-
</div>
348-
<div className={styles.section}>
349-
<FeaturedProjects studio="27205657" />
350-
</div>
351-
</React.Fragment>
352-
) : null}
353144
</div>
354-
{isHomepage && <Footer />}
355145
</div>
356146
);
357147
}

‎src/reducers/mode.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const setFullScreen = function (isFullScreen) {
3333
};
3434
const setPlayer = function (isPlayerOnly) {
3535
//reload page (ASSUMES HASH MODE)
36-
window.location.href = window.location.origin + "/" + window.location.hash;
36+
//window.location.href = window.location.origin + "/" + window.location.hash;
37+
window.parent.postMessage({ type: "block-compiler-action", action: "communityPage", projectID: window.location.hash.replace("#","")}, "*");
38+
return {};
3739
};
3840

3941
export {

‎src/reducers/project-state.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ const createProject = () => ({
374374
});
375375

376376
const doneCreatingProject = (id, loadingState) => {
377+
window.parent.postMessage({ type: "block-compiler-action", action: "doneCreatingProject", projectID: id}, "*");
378+
377379
const searchParams = new URLSearchParams(location.search);
378380
if (searchParams.has('new_project')) searchParams.delete('new_project');
379381
if(searchParams.has('username')) searchParams.delete('username');

0 commit comments

Comments
 (0)