Skip to content

Commit 9a204b9

Browse files
committed
add sourcebot cloud card to public search demo
1 parent ba19f39 commit 9a204b9

File tree

10 files changed

+168
-4
lines changed

10 files changed

+168
-4
lines changed

.github/workflows/ghcr-publish.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ jobs:
8181
build-args: |
8282
SOURCEBOT_VERSION=${{ github.ref_name }}
8383
POSTHOG_PAPIK=${{ secrets.POSTHOG_PAPIK }}
84-
84+
PUBLIC_SEARCH_DEMO=${{ secrets.PUBLIC_SEARCH_DEMO }}
85+
8586
- name: Export digest
8687
run: |
8788
mkdir -p /tmp/digests

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ENV NEXT_TELEMETRY_DISABLED=1
2626
# @see: https://phase.dev/blog/nextjs-public-runtime-variables/
2727
ARG NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED=BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED
2828
ARG NEXT_PUBLIC_SOURCEBOT_VERSION=BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION
29+
ENV NEXT_PUBLIC_SEARCH_DEMO=BAKED_NEXT_PUBLIC_SEARCH_DEMO
2930
ENV NEXT_PUBLIC_POSTHOG_PAPIK=BAKED_NEXT_PUBLIC_POSTHOG_PAPIK
3031
# @note: leading "/" is required for the basePath property. @see: https://nextjs.org/docs/app/api-reference/next-config-js/basePath
3132
ARG NEXT_PUBLIC_DOMAIN_SUB_PATH=/BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH
@@ -54,6 +55,10 @@ ARG SOURCEBOT_VERSION=unknown
5455
ENV SOURCEBOT_VERSION=$SOURCEBOT_VERSION
5556
RUN echo "Sourcebot Version: $SOURCEBOT_VERSION"
5657

58+
ARG PUBLIC_SEARCH_DEMO=false
59+
ENV PUBLIC_SEARCH_DEMO=$PUBLIC_SEARCH_DEMO
60+
RUN echo "Public Search Demo: $PUBLIC_SEARCH_DEMO"
61+
5762
# Valid values are: debug, info, warn, error
5863
ENV SOURCEBOT_LOG_LEVEL=info
5964

demo-site-config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@
9696
"flameshot-org/flameshot",
9797
"envoyproxy/envoy"
9898
]
99+
},
100+
{
101+
"type": "gitlab",
102+
"token": {
103+
"env": "GITLAB_TOKEN"
104+
},
105+
"groups": [
106+
"fdroid"
107+
],
108+
"exclude": {
109+
"projects": [
110+
"fdroid/wiki",
111+
"Matrixcoffee/internal-twif-preview"
112+
]
113+
}
99114
}
100115
]
101116
}

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
9393
export NEXT_PUBLIC_SOURCEBOT_VERSION="$SOURCEBOT_VERSION"
9494
fi
9595

96+
# Infer NEXT_PUBLIC_SEARCH_DEMO if it is not set
97+
if [ -z "$NEXT_PUBLIC_SEARCH_DEMO" ] && [ ! -z "$PUBLIC_SEARCH_DEMO" ]; then
98+
export NEXT_PUBLIC_SEARCH_DEMO="$PUBLIC_SEARCH_DEMO"
99+
fi
100+
96101
# Always infer NEXT_PUBLIC_POSTHOG_PAPIK
97102
export NEXT_PUBLIC_POSTHOG_PAPIK="$POSTHOG_PAPIK"
98103

@@ -103,6 +108,7 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
103108
sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED|${NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED}|g" "$file"
104109
sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION|${NEXT_PUBLIC_SOURCEBOT_VERSION}|g" "$file"
105110
sed -i "s|BAKED_NEXT_PUBLIC_POSTHOG_PAPIK|${NEXT_PUBLIC_POSTHOG_PAPIK}|g" "$file"
111+
sed -i "s|BAKED_NEXT_PUBLIC_SEARCH_DEMO|${NEXT_PUBLIC_SEARCH_DEMO}|g" "$file"
106112
done
107113
}
108114

packages/web/src/app/components/editorContextMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const EditorContextMenu = ({
116116
description: "✅ Copied link to selection",
117117
});
118118

119-
captureEvent('share_link_created', {});
119+
captureEvent('wa_share_link_created', {});
120120

121121
// Reset the selection
122122
view.dispatch(
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use client"
2+
3+
import { useState } from "react"
4+
import Link from "next/link"
5+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
6+
import { Button } from "@/components/ui/button"
7+
import { ArrowRight, Code, Database, Search } from "lucide-react"
8+
import useCaptureEvent from "@/hooks/useCaptureEvent"
9+
10+
export default function RegistrationCard() {
11+
const [isHovered, setIsHovered] = useState(false)
12+
const captureEvent = useCaptureEvent()
13+
14+
return (
15+
<Card
16+
className="w-full max-w-md mx-auto border shadow-lg overflow-hidden"
17+
onMouseEnter={() => setIsHovered(true)}
18+
onMouseLeave={() => setIsHovered(false)}
19+
>
20+
<CardHeader className="pb-2">
21+
<CardTitle className="text-xl font-bold mt-2">Try Sourcebot Cloud</CardTitle>
22+
<CardDescription>Index and search your own code repositories</CardDescription>
23+
</CardHeader>
24+
<CardContent className="space-y-4">
25+
<div className="space-y-3">
26+
<div className="flex items-start">
27+
<Search className="h-5 w-5 mr-3 text-primary" />
28+
<p className="text-sm">Search your private and public repositories</p>
29+
</div>
30+
<div className="flex items-start">
31+
<Database className="h-5 w-5 mr-3 text-primary" />
32+
<p className="text-sm">Index your own codebase in minutes</p>
33+
</div>
34+
</div>
35+
</CardContent>
36+
<CardFooter className="flex flex-col space-y-3 pt-0">
37+
<Link href="https://app.sourcebot.dev" className="w-full" rel="noopener noreferrer" onClick={() => captureEvent("wa_demo_try_card_pressed", {})}>
38+
<Button className={`w-full transition-all duration-300 ${isHovered ? "translate-y-[-2px]" : ""}`}>
39+
Try With Your Code
40+
<ArrowRight className="ml-2 h-4 w-4" />
41+
</Button>
42+
</Link>
43+
<p className="text-xs text-center text-muted-foreground">
44+
14 day free trial. No credit card required.
45+
</p>
46+
</CardFooter>
47+
</Card>
48+
)
49+
}

packages/web/src/app/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { SymbolIcon } from "@radix-ui/react-icons";
1212
import { UpgradeToast } from "./components/upgradeToast";
1313
import Link from "next/link";
1414
import { KeyboardShortcutHint } from "./components/keyboardShortcutHint";
15+
import RegistrationCard from "./components/registrationCard";
16+
import { PUBLIC_SEARCH_DEMO } from "@/lib/environment";
1517

1618
export default async function Home() {
1719
return (
@@ -38,6 +40,11 @@ export default async function Home() {
3840
autoFocus={true}
3941
className="mt-4 w-full max-w-[800px]"
4042
/>
43+
{PUBLIC_SEARCH_DEMO && (
44+
<div className="mt-8">
45+
<RegistrationCard />
46+
</div>
47+
)}
4148
<div className="mt-8">
4249
<Suspense fallback={<div>...</div>}>
4350
<RepositoryList />
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import * as React from "react"
2+
3+
import { cn } from "@/lib/utils"
4+
5+
const Card = React.forwardRef<
6+
HTMLDivElement,
7+
React.HTMLAttributes<HTMLDivElement>
8+
>(({ className, ...props }, ref) => (
9+
<div
10+
ref={ref}
11+
className={cn(
12+
"rounded-lg border bg-card text-card-foreground shadow-sm",
13+
className
14+
)}
15+
{...props}
16+
/>
17+
))
18+
Card.displayName = "Card"
19+
20+
const CardHeader = React.forwardRef<
21+
HTMLDivElement,
22+
React.HTMLAttributes<HTMLDivElement>
23+
>(({ className, ...props }, ref) => (
24+
<div
25+
ref={ref}
26+
className={cn("flex flex-col space-y-1.5 p-6", className)}
27+
{...props}
28+
/>
29+
))
30+
CardHeader.displayName = "CardHeader"
31+
32+
const CardTitle = React.forwardRef<
33+
HTMLDivElement,
34+
React.HTMLAttributes<HTMLDivElement>
35+
>(({ className, ...props }, ref) => (
36+
<div
37+
ref={ref}
38+
className={cn(
39+
"text-2xl font-semibold leading-none tracking-tight",
40+
className
41+
)}
42+
{...props}
43+
/>
44+
))
45+
CardTitle.displayName = "CardTitle"
46+
47+
const CardDescription = React.forwardRef<
48+
HTMLDivElement,
49+
React.HTMLAttributes<HTMLDivElement>
50+
>(({ className, ...props }, ref) => (
51+
<div
52+
ref={ref}
53+
className={cn("text-sm text-muted-foreground", className)}
54+
{...props}
55+
/>
56+
))
57+
CardDescription.displayName = "CardDescription"
58+
59+
const CardContent = React.forwardRef<
60+
HTMLDivElement,
61+
React.HTMLAttributes<HTMLDivElement>
62+
>(({ className, ...props }, ref) => (
63+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
64+
))
65+
CardContent.displayName = "CardContent"
66+
67+
const CardFooter = React.forwardRef<
68+
HTMLDivElement,
69+
React.HTMLAttributes<HTMLDivElement>
70+
>(({ className, ...props }, ref) => (
71+
<div
72+
ref={ref}
73+
className={cn("flex items-center p-6 pt-0", className)}
74+
{...props}
75+
/>
76+
))
77+
CardFooter.displayName = "CardFooter"
78+
79+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import 'server-only';
22

3-
import { getEnv, getEnvNumber } from "./utils";
3+
import { getEnv, getEnvBoolean, getEnvNumber } from "./utils";
44

55
export const ZOEKT_WEBSERVER_URL = getEnv(process.env.ZOEKT_WEBSERVER_URL, "http://localhost:6070")!;
66
export const SHARD_MAX_MATCH_COUNT = getEnvNumber(process.env.SHARD_MAX_MATCH_COUNT, 10000);
77
export const TOTAL_MAX_MATCH_COUNT = getEnvNumber(process.env.TOTAL_MAX_MATCH_COUNT, 100000);
88
export const SOURCEBOT_VERSION = getEnv(process.env.SOURCEBOT_VERSION, 'unknown')!;
99
export const NODE_ENV = process.env.NODE_ENV;
10+
export const PUBLIC_SEARCH_DEMO = getEnvBoolean(process.env.PUBLIC_SEARCH_DEMO, false);

packages/web/src/lib/posthogEvents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export type PosthogEventMap = {
2424
flushReason: number,
2525
fileLanguages: string[]
2626
},
27-
share_link_created: {},
27+
wa_demo_try_card_pressed: {},
28+
wa_share_link_created: {},
2829
}
2930

3031
export type PosthogEvent = keyof PosthogEventMap;

0 commit comments

Comments
 (0)