« get me outta code hell

scratchrlol - Simple HTML-based Scratch client
summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xindex.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/index.js b/index.js
index 7a2d009..1ad3e1f 100755
--- a/index.js
+++ b/index.js
@@ -366,8 +366,19 @@ const handleRequest = async (request, response) => {
       return
     }
 
+    let parentProjectText = ''
+    if (project.remix.parent) {
+      const parentProject = await getProject(project.remix.parent, cookie.token)
+      if (parentProject.code === 'NotFound') {
+        parentProjectText = ` Based on an unshared project.`
+      } else {
+        parentProjectText = ` Based on ${templates.project(parentProject.title, parentProject.id)} by ${templates.user(parentProject.author.username)}.`
+      }
+    }
+
     await page(request, response, fixWS`
       <h1>${project.title}</h1>
+      <p>Created by ${templates.user(project.author.username)}.${parentProjectText}</p>
       <p><img src="${project.image}" alt="The thumbnail for this project"></p>
       ${project.instructions ? fixWS`
         <h2>Instructions</h2>