enzostvs HF Staff commited on
Commit
2d01256
Β·
1 Parent(s): 3684768

api fixes

Browse files
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 { COLORS, injectDeepSiteBadge, isIndexPage } from "@/lib/utils";
 
 
 
 
 
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(`/deepsite/api/projects/${repoId}/medias`, {
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
- `/deepsite/api/projects/${projectName.split("/")[1]}`,
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(`/deepsite/api/projects/${repoId}`, {
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
- `/deepsite/api/projects/${repoId}/${commitId}`,
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.6"
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(`/deepsite/api/projects/${repoId}/rename`, {
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
- <Image
98
- src="/deepsite/deepsite/logo.svg"
99
- alt="DeepSite"
100
- width={100}
101
- height={100}
102
- className="size-8"
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
- `/deepsite/api/projects/${deleteProjectId?.split("/")[1]}`,
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-[30deg] dark:invert dark:brightness-0" />
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>