11import get404Sketch from './404Page' ;
22
3- export function renderIndex ( username , projectName ) {
3+ export function renderIndex ( ) {
44 const assetsManifest = process . env . webpackAssets && JSON . parse ( process . env . webpackAssets ) ;
55 return `
66 <!DOCTYPE html>
@@ -10,7 +10,55 @@ export function renderIndex(username , projectName) {
1010 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1111 <meta name="keywords" content="p5.js, p5.js web editor, web editor, processing, code editor" />
1212 <meta name="description" content="A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners." />
13- <title>${ `${ username ? `${ projectName } by ${ username } -` : "" } ` } p5.js Web Editor</title>
13+ <title>p5.js Web Editor</title>
14+ ${ process . env . NODE_ENV === 'production' ? `<link rel='stylesheet' href='${ assetsManifest [ '/app.css' ] } ' />` : '' }
15+ <link href='https://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
16+ <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
17+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' / >
18+ <script>
19+ if (!window.process) {
20+ window.process = {};
21+ }
22+ if (!window.process.env) {
23+ window.process.env = {};
24+ }
25+ window.process.env.API_URL = '${ process . env . API_URL } ';
26+ window.process.env.NODE_ENV = '${ process . env . NODE_ENV } ';
27+ window.process.env.S3_BUCKET = '${ process . env . S3_BUCKET } ';
28+ window.process.env.S3_BUCKET_URL_BASE = ${ process . env . S3_BUCKET_URL_BASE ? `'${ process . env . S3_BUCKET_URL_BASE } '` : undefined } ;
29+ window.process.env.AWS_REGION = '${ process . env . AWS_REGION } ';
30+ window.process.env.FORCE_TO_HTTPS = ${ process . env . FORCE_TO_HTTPS === 'false' ? false : undefined } ;
31+ window.process.env.CLIENT = true;
32+ window.process.env.LOGIN_ENABLED = ${ process . env . LOGIN_ENABLED === 'false' ? false : true } ;
33+ window.process.env.EXAMPLES_ENABLED = ${ process . env . EXAMPLES_ENABLED === 'false' ? false : true } ;
34+ window.process.env.UI_ACCESS_TOKEN_ENABLED = ${ process . env . UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true } ;
35+ window.process.env.UI_COLLECTIONS_ENABLED = ${ process . env . UI_COLLECTIONS_ENABLED === 'false' ? false : true } ;
36+ window.process.env.UPLOAD_LIMIT = ${ process . env . UPLOAD_LIMIT ? `${ process . env . UPLOAD_LIMIT } ` : undefined } ;
37+ window.process.env.TRANSLATIONS_ENABLED = ${ process . env . TRANSLATIONS_ENABLED === 'true' ? true : false } ;
38+ window.process.env.PREVIEW_URL = '${ process . env . PREVIEW_URL } ';
39+ window.process.env.GA_MEASUREMENT_ID='${ process . env . GA_MEASUREMENT_ID } ';
40+ </script>
41+ </head>
42+ <body>
43+ <div id="root" class="root-app">
44+ </div>
45+ <script src='${ process . env . NODE_ENV === 'production' ? `${ assetsManifest [ '/app.js' ] } ` : '/app.js' } '></script>
46+ </body>
47+ </html>
48+ ` ;
49+ }
50+
51+ export function renderProjectIndex ( username , projectName ) {
52+ const assetsManifest = process . env . webpackAssets && JSON . parse ( process . env . webpackAssets ) ;
53+ return `
54+ <!DOCTYPE html>
55+ <html lang="en">
56+ <head>
57+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
58+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
59+ <meta name="keywords" content="p5.js, p5.js web editor, web editor, processing, code editor" />
60+ <meta name="description" content="A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners." />
61+ <title>${ `${ projectName } by ${ username } -` } p5.js Web Editor</title>
1462 ${ process . env . NODE_ENV === 'production' ? `<link rel='stylesheet' href='${ assetsManifest [ '/app.css' ] } ' />` : '' }
1563 <link href='https://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
1664 <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
@@ -59,6 +107,6 @@ export default function sendHtml(req, res, exists = {success:true}) {
59107 res . status ( 404 ) ;
60108 get404Sketch ( ( html ) => res . send ( html ) ) ;
61109 } else {
62- res . send ( renderIndex ( req . params . username , exists . projectName ) ) ;
110+ res . send ( renderProjectIndex ( req . params . username , exists . projectName ) ) ;
63111 }
64112} ;
0 commit comments