From cab7d62b2ec471241317d5e7f64fbc7c4ca15514 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Tue, 21 Oct 2025 13:06:33 -0500 Subject: [PATCH] Add "Copy Edit with Shakespeare URL" button to repository section - Added Copy icon import from lucide-react - Created handleCopyShakespeareURL function that: - Validates that a repository URL exists - Encodes the URL and formats it as a Shakespeare clone URL - Copies the formatted URL to clipboard - Shows success/error toast notifications - Added button below Git URL input that appears when URL is present - Button copies the properly formatted Shakespeare clone URL (https://shakespeare.diy/clone?url=...) - Works with GitHub, GitLab, NostrGit, and any other git repository URL --- src/components/GitDialog.tsx | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/components/GitDialog.tsx b/src/components/GitDialog.tsx index 8de746bf..63191ed5 100644 --- a/src/components/GitDialog.tsx +++ b/src/components/GitDialog.tsx @@ -46,6 +46,7 @@ import { Settings2, GitPullRequest, ExternalLink, + Copy, } from 'lucide-react'; import { useGitStatus } from '@/hooks/useGitStatus'; import { useGitSettings } from '@/hooks/useGitSettings'; @@ -683,6 +684,34 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog const [isGitManagementOpen, setIsGitManagementOpen] = useState(false); const [gitManagementDefaultTab, setGitManagementDefaultTab] = useState('branches'); + const handleCopyShakespeareURL = () => { + if (!originUrl.trim()) { + toast({ + title: "No repository URL", + description: "Please enter a Git URL first", + variant: "destructive", + }); + return; + } + + // Create the Shakespeare clone URL by encoding the origin URL + const shakespeareURL = `https://shakespeare.diy/clone?url=${encodeURIComponent(originUrl.trim())}`; + + // Copy to clipboard + navigator.clipboard.writeText(shakespeareURL).then(() => { + toast({ + title: "Copied to clipboard", + description: "Edit with Shakespeare URL copied", + }); + }).catch(() => { + toast({ + title: "Failed to copy", + description: "Could not copy to clipboard", + variant: "destructive", + }); + }); + }; + return ( <> @@ -752,6 +781,19 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog + {/* Copy Shakespeare URL Button */} + {originUrl.trim() && ( + + )} + {/* Credentials Warning */} {gitStatus.remotes.length > 0 && ( (() => {