Spaces:
Running
Running
api fixes
Browse files- app/api/projects/[repoId]/rename/route.ts +0 -2
- app/api/projects/route.ts +9 -1
- components/ask-ai/uploader.tsx +1 -1
- components/ask-ai/useGeneration.ts +1 -2
- components/code/index.tsx +1 -1
- components/code/monaco-editor.tsx +0 -2
- components/editor/history-view.tsx +3 -6
- components/editor/index.tsx +1 -4
- components/editor/project-settings.tsx +12 -8
- components/projects/user-projects.tsx +1 -1
- lib/utils.ts +23 -1
app/api/projects/[repoId]/rename/route.ts
CHANGED
|
@@ -57,8 +57,6 @@ export async function PUT(
|
|
| 57 |
`title: ${newTitle}`
|
| 58 |
);
|
| 59 |
|
| 60 |
-
console.log(readmeFile, updatedReadmeFile);
|
| 61 |
-
|
| 62 |
await uploadFile({
|
| 63 |
repo,
|
| 64 |
accessToken: token,
|
|
|
|
| 57 |
`title: ${newTitle}`
|
| 58 |
);
|
| 59 |
|
|
|
|
|
|
|
| 60 |
await uploadFile({
|
| 61 |
repo,
|
| 62 |
accessToken: token,
|
app/api/projects/route.ts
CHANGED
|
@@ -2,7 +2,12 @@ import { NextResponse } from "next/server";
|
|
| 2 |
import { RepoDesignation, createRepo, uploadFiles } from "@huggingface/hub";
|
| 3 |
|
| 4 |
import { auth } from "@/lib/auth";
|
| 5 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
export async function POST(request: Request) {
|
| 8 |
const session = await auth();
|
|
@@ -39,11 +44,14 @@ export async function POST(request: Request) {
|
|
| 39 |
|
| 40 |
const colorFrom = COLORS[Math.floor(Math.random() * COLORS.length)];
|
| 41 |
const colorTo = COLORS[Math.floor(Math.random() * COLORS.length)];
|
|
|
|
|
|
|
| 42 |
const README = `---
|
| 43 |
title: ${projectTitle}
|
| 44 |
colorFrom: ${colorFrom}
|
| 45 |
colorTo: ${colorTo}
|
| 46 |
sdk: static
|
|
|
|
| 47 |
tags:
|
| 48 |
- deepsite-v4
|
| 49 |
---
|
|
|
|
| 2 |
import { RepoDesignation, createRepo, uploadFiles } from "@huggingface/hub";
|
| 3 |
|
| 4 |
import { auth } from "@/lib/auth";
|
| 5 |
+
import {
|
| 6 |
+
COLORS,
|
| 7 |
+
EMOJIS_FOR_SPACE,
|
| 8 |
+
injectDeepSiteBadge,
|
| 9 |
+
isIndexPage,
|
| 10 |
+
} from "@/lib/utils";
|
| 11 |
|
| 12 |
export async function POST(request: Request) {
|
| 13 |
const session = await auth();
|
|
|
|
| 44 |
|
| 45 |
const colorFrom = COLORS[Math.floor(Math.random() * COLORS.length)];
|
| 46 |
const colorTo = COLORS[Math.floor(Math.random() * COLORS.length)];
|
| 47 |
+
const emoji =
|
| 48 |
+
EMOJIS_FOR_SPACE[Math.floor(Math.random() * EMOJIS_FOR_SPACE.length)];
|
| 49 |
const README = `---
|
| 50 |
title: ${projectTitle}
|
| 51 |
colorFrom: ${colorFrom}
|
| 52 |
colorTo: ${colorTo}
|
| 53 |
sdk: static
|
| 54 |
+
emoji: ${emoji}
|
| 55 |
tags:
|
| 56 |
- deepsite-v4
|
| 57 |
---
|
components/ask-ai/uploader.tsx
CHANGED
|
@@ -63,7 +63,7 @@ export const Uploader = ({
|
|
| 63 |
data.append("images", file);
|
| 64 |
});
|
| 65 |
|
| 66 |
-
const response = await fetch(`/
|
| 67 |
method: "POST",
|
| 68 |
body: data,
|
| 69 |
})
|
|
|
|
| 63 |
data.append("images", file);
|
| 64 |
});
|
| 65 |
|
| 66 |
+
const response = await fetch(`/api/projects/${repoId}/medias`, {
|
| 67 |
method: "POST",
|
| 68 |
body: data,
|
| 69 |
})
|
components/ask-ai/useGeneration.ts
CHANGED
|
@@ -298,7 +298,7 @@ export const useGeneration = (projectName: string) => {
|
|
| 298 |
});
|
| 299 |
} else {
|
| 300 |
const response = await fetch(
|
| 301 |
-
`/
|
| 302 |
{
|
| 303 |
method: "PUT",
|
| 304 |
body: JSON.stringify({
|
|
@@ -334,7 +334,6 @@ export const useGeneration = (projectName: string) => {
|
|
| 334 |
if (errorMatch) {
|
| 335 |
try {
|
| 336 |
const errorData = JSON.parse(errorMatch[1]);
|
| 337 |
-
console.log("Parsed error data:", errorData);
|
| 338 |
if (errorData.isError) {
|
| 339 |
const lastMessageId =
|
| 340 |
currentMessages[currentMessages.length - 1].id;
|
|
|
|
| 298 |
});
|
| 299 |
} else {
|
| 300 |
const response = await fetch(
|
| 301 |
+
`/api/projects/${projectName.split("/")[1]}`,
|
| 302 |
{
|
| 303 |
method: "PUT",
|
| 304 |
body: JSON.stringify({
|
|
|
|
| 334 |
if (errorMatch) {
|
| 335 |
try {
|
| 336 |
const errorData = JSON.parse(errorMatch[1]);
|
|
|
|
| 337 |
if (errorData.isError) {
|
| 338 |
const lastMessageId =
|
| 339 |
currentMessages[currentMessages.length - 1].id;
|
components/code/index.tsx
CHANGED
|
@@ -31,7 +31,7 @@ export function AppEditorCode() {
|
|
| 31 |
setIsSavingChanges(true);
|
| 32 |
const manuallyUpdatedFiles =
|
| 33 |
queryClient.getQueryData<File[]>(["manuallyUpdatedFiles"]) ?? [];
|
| 34 |
-
const response = await fetch(`/
|
| 35 |
method: "PUT",
|
| 36 |
body: JSON.stringify({
|
| 37 |
files: manuallyUpdatedFiles,
|
|
|
|
| 31 |
setIsSavingChanges(true);
|
| 32 |
const manuallyUpdatedFiles =
|
| 33 |
queryClient.getQueryData<File[]>(["manuallyUpdatedFiles"]) ?? [];
|
| 34 |
+
const response = await fetch(`/api/projects/${repoId}`, {
|
| 35 |
method: "PUT",
|
| 36 |
body: JSON.stringify({
|
| 37 |
files: manuallyUpdatedFiles,
|
components/code/monaco-editor.tsx
CHANGED
|
@@ -116,8 +116,6 @@ export function AppEditorMonacoEditor({
|
|
| 116 |
return effectiveTheme === "dark" ? "Night" : "NightLight";
|
| 117 |
}, [theme]);
|
| 118 |
|
| 119 |
-
console.log("++ THEME ++", theme);
|
| 120 |
-
|
| 121 |
return (
|
| 122 |
<SandpackStack className="h-full!">
|
| 123 |
<FileTabs />
|
|
|
|
| 116 |
return effectiveTheme === "dark" ? "Night" : "NightLight";
|
| 117 |
}, [theme]);
|
| 118 |
|
|
|
|
|
|
|
| 119 |
return (
|
| 120 |
<SandpackStack className="h-full!">
|
| 121 |
<FileTabs />
|
components/editor/history-view.tsx
CHANGED
|
@@ -13,12 +13,9 @@ export const HistoryView = function () {
|
|
| 13 |
"This action will set this historical version as the default version of the project. Are you sure you want to proceed?"
|
| 14 |
);
|
| 15 |
if (!confirmation) return;
|
| 16 |
-
const response = await fetch(
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
method: "POST",
|
| 20 |
-
}
|
| 21 |
-
).then(async (response) => {
|
| 22 |
if (response.ok) {
|
| 23 |
const data = await response.json();
|
| 24 |
return data;
|
|
|
|
| 13 |
"This action will set this historical version as the default version of the project. Are you sure you want to proceed?"
|
| 14 |
);
|
| 15 |
if (!confirmation) return;
|
| 16 |
+
const response = await fetch(`/api/projects/${repoId}/${commitId}`, {
|
| 17 |
+
method: "POST",
|
| 18 |
+
}).then(async (response) => {
|
|
|
|
|
|
|
|
|
|
| 19 |
if (response.ok) {
|
| 20 |
const data = await response.json();
|
| 21 |
return data;
|
components/editor/index.tsx
CHANGED
|
@@ -22,9 +22,6 @@ import { HistoryView } from "./history-view";
|
|
| 22 |
import { TourCustomCard } from "@/components/tour/card";
|
| 23 |
import { steps } from "@/lib/onboarding";
|
| 24 |
|
| 25 |
-
// todo: free credit limit reached modal!! + upgrade to pro
|
| 26 |
-
// also do the pro limit credit reached too, maybe show a modal suggesting to add a payment method
|
| 27 |
-
|
| 28 |
const SandpackProvider = dynamic(
|
| 29 |
() =>
|
| 30 |
import("@codesandbox/sandpack-react").then((mod) => mod.SandpackProvider),
|
|
@@ -87,7 +84,7 @@ export function AppEditor({
|
|
| 87 |
cardComponent={TourCustomCard}
|
| 88 |
clickThroughOverlay={false}
|
| 89 |
shadowRgb="0, 0, 0"
|
| 90 |
-
shadowOpacity="0.
|
| 91 |
steps={steps}
|
| 92 |
onComplete={() => {
|
| 93 |
setTourHasBeenShown(true);
|
|
|
|
| 22 |
import { TourCustomCard } from "@/components/tour/card";
|
| 23 |
import { steps } from "@/lib/onboarding";
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
const SandpackProvider = dynamic(
|
| 26 |
() =>
|
| 27 |
import("@codesandbox/sandpack-react").then((mod) => mod.SandpackProvider),
|
|
|
|
| 84 |
cardComponent={TourCustomCard}
|
| 85 |
clickThroughOverlay={false}
|
| 86 |
shadowRgb="0, 0, 0"
|
| 87 |
+
shadowOpacity="0.8"
|
| 88 |
steps={steps}
|
| 89 |
onComplete={() => {
|
| 90 |
setTourHasBeenShown(true);
|
components/editor/project-settings.tsx
CHANGED
|
@@ -56,7 +56,7 @@ export const ProjectSettings = ({
|
|
| 56 |
setIsLoading(true);
|
| 57 |
setError(null);
|
| 58 |
try {
|
| 59 |
-
const response = await fetch(`/
|
| 60 |
method: "PUT",
|
| 61 |
headers: {
|
| 62 |
"Content-Type": "application/json",
|
|
@@ -94,13 +94,17 @@ export const ProjectSettings = ({
|
|
| 94 |
<DropdownMenu>
|
| 95 |
<DropdownMenuTrigger asChild>
|
| 96 |
<Button variant="ghost" className="pl-2.5! pr-3! py-1.5! h-auto!">
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
<div className="flex flex-col -space-y-1 items-start">
|
| 105 |
<p className="text-sm font-bold text-primary">
|
| 106 |
{project?.cardData?.title ?? "New DeepSite website"}{" "}
|
|
|
|
| 56 |
setIsLoading(true);
|
| 57 |
setError(null);
|
| 58 |
try {
|
| 59 |
+
const response = await fetch(`/api/projects/${repoId}/rename`, {
|
| 60 |
method: "PUT",
|
| 61 |
headers: {
|
| 62 |
"Content-Type": "application/json",
|
|
|
|
| 94 |
<DropdownMenu>
|
| 95 |
<DropdownMenuTrigger asChild>
|
| 96 |
<Button variant="ghost" className="pl-2.5! pr-3! py-1.5! h-auto!">
|
| 97 |
+
{project?.cardData?.emoji ? (
|
| 98 |
+
<span className="text-3xl">{project?.cardData?.emoji}</span>
|
| 99 |
+
) : (
|
| 100 |
+
<Image
|
| 101 |
+
src="/logo.svg"
|
| 102 |
+
alt="DeepSite"
|
| 103 |
+
width={100}
|
| 104 |
+
height={100}
|
| 105 |
+
className="size-8"
|
| 106 |
+
/>
|
| 107 |
+
)}
|
| 108 |
<div className="flex flex-col -space-y-1 items-start">
|
| 109 |
<p className="text-sm font-bold text-primary">
|
| 110 |
{project?.cardData?.title ?? "New DeepSite website"}{" "}
|
components/projects/user-projects.tsx
CHANGED
|
@@ -30,7 +30,7 @@ export function UserProjects() {
|
|
| 30 |
|
| 31 |
const handleDeleteProject = async () => {
|
| 32 |
const response = await fetch(
|
| 33 |
-
`/
|
| 34 |
{
|
| 35 |
method: "DELETE",
|
| 36 |
headers: {
|
|
|
|
| 30 |
|
| 31 |
const handleDeleteProject = async () => {
|
| 32 |
const response = await fetch(
|
| 33 |
+
`/api/projects/${deleteProjectId?.split("/")[1]}`,
|
| 34 |
{
|
| 35 |
method: "DELETE",
|
| 36 |
headers: {
|
lib/utils.ts
CHANGED
|
@@ -15,6 +15,28 @@ export const COLORS = [
|
|
| 15 |
"pink",
|
| 16 |
"gray",
|
| 17 |
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
export const getMentionsFromPrompt = async (prompt: string) => {
|
| 20 |
const mentions = prompt.match(/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+/g);
|
|
@@ -89,7 +111,7 @@ export const defaultHTML = `<!DOCTYPE html>
|
|
| 89 |
Ask me anything.
|
| 90 |
</h1>
|
| 91 |
</div>
|
| 92 |
-
<img src="https://huggingface.co/deepsite/arrow.svg" class="absolute bottom-8 left-0 w-[100px] transform rotate-
|
| 93 |
<script></script>
|
| 94 |
</body>
|
| 95 |
</html>
|
|
|
|
| 15 |
"pink",
|
| 16 |
"gray",
|
| 17 |
];
|
| 18 |
+
export const EMOJIS_FOR_SPACE = [
|
| 19 |
+
"π",
|
| 20 |
+
"π₯",
|
| 21 |
+
"β¨",
|
| 22 |
+
"π‘",
|
| 23 |
+
"π€",
|
| 24 |
+
"π",
|
| 25 |
+
"π",
|
| 26 |
+
"π",
|
| 27 |
+
"β‘",
|
| 28 |
+
"π¨",
|
| 29 |
+
"π§ ",
|
| 30 |
+
"π¦",
|
| 31 |
+
"π οΈ",
|
| 32 |
+
"π§",
|
| 33 |
+
"π",
|
| 34 |
+
"π",
|
| 35 |
+
"π§©",
|
| 36 |
+
"π§",
|
| 37 |
+
"π₯οΈ",
|
| 38 |
+
"π±",
|
| 39 |
+
];
|
| 40 |
|
| 41 |
export const getMentionsFromPrompt = async (prompt: string) => {
|
| 42 |
const mentions = prompt.match(/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+/g);
|
|
|
|
| 111 |
Ask me anything.
|
| 112 |
</h1>
|
| 113 |
</div>
|
| 114 |
+
<img src="https://huggingface.co/deepsite/arrow.svg" class="absolute bottom-8 left-0 w-[100px] transform rotate-30 dark:invert dark:brightness-0" />
|
| 115 |
<script></script>
|
| 116 |
</body>
|
| 117 |
</html>
|