Skip to content

Commit 4da29f4

Browse files
idk
1 parent e5e9247 commit 4da29f4

File tree

4 files changed

+26
-132
lines changed

4 files changed

+26
-132
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# Bento GitHub Stats
2-
![Bento GitHub Stats](https://firebasestorage.googleapis.com/v0/b/smartkaksha-fe32c.appspot.com/o/opbento2%2Fbento_1730556270333.png?alt=media&token=11391eec-e77d-4077-b116-54bfbe8d8d02)
1+
[![OpBento](https://firebasestorage.googleapis.com/v0/b/smartkaksha-fe32c.appspot.com/o/opbento%2Fbento_1730558369899.png?alt=media&token=7d7aab09-27a6-495b-86de-a33d33a5012a)](https://opbento.vercel.app)

src/app/api/bento/route.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ ${contributionStats.longestStreakStartDate} - ${contributionStats.longestStreakE
220220
<body class="bg-neutral-950 text-white font-['Space_Grotesk']">
221221
<div class="max-w-5xl mx-auto">
222222
<div
223-
class="p-4 grid grid-cols-1 md:grid-cols-4 gap-4 max-w-5xl mt-20 mb-8 w-full mx-auto"
223+
class="p-1 grid grid-cols-1 md:grid-cols-4 gap-4 max-w-5xl my-8 w-full mx-auto"
224224
>
225225
<!-- Name Card -->
226226
<div class="text-white py-6 px-8 rounded-lg bg-gradient-to-br from-cyan-400 via-blue-500 to-violet-600 col-span-1 row-span-1 min-h-32">
@@ -305,16 +305,13 @@ ${contributionStats.longestStreakStartDate} - ${contributionStats.longestStreakE
305305
${htmlofGithubStats}
306306
307307
<div class="bg-gradient-to-br from-green-950/80 p-4 col-span-4 row-span-2 rounded-lg w-full h-full">
308-
<div class="flex items-center flex-col justify-between">
309-
<h1 className="text-2xl font-bold">
310-
${g}'s Contribution Graph
311-
</h1>
312-
<div class="flex justify-center pb-4 items-center w-full h-full" id="graph-container">
313-
${graphSVG}
308+
<div class="flex items-center justify-between"><h1 class="text-2xl font-bold">subhadeeproy3902's Contribution Graph</h1><div class="flex items-center justify-end text-sm"><span>Less</span><div class="flex gap-2 mx-3"><div class="w-4 h-4 rounded-sm" title="Contribution level 0" style="background-color: rgb(25, 25, 25);"></div><div class="w-4 h-4 rounded-sm" title="Contribution level 1" style="background-color: rgb(20, 83, 45);"></div><div class="w-4 h-4 rounded-sm" title="Contribution level 2" style="background-color: rgb(30, 122, 30);"></div><div class="w-4 h-4 rounded-sm" title="Contribution level 3" style="background-color: rgb(40, 167, 69);"></div><div class="w-4 h-4 rounded-sm" title="Contribution level 4" style="background-color: rgb(0, 239, 87);"></div></div><span>More</span></div></div>
309+
310+
<div class="flex justify-center pb-4 items-center w-full h-full">
311+
${graphSVG}
314312
</div>
315313
</div>
316314
</div>
317-
</div>
318315
</div>
319316
<script src="https://unpkg.com/lucide@latest/dist/umd/lucide.js"></script>
320317
<script>

src/components/Bento1.tsx

Lines changed: 20 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const BentoGrid = ({
5757
portfolioUrl: string;
5858
}) => {
5959
const [bentoLink, setBentoLink] = useState<string>("");
60-
const [apiLink, setApiLink] = useState<string>("");
6160

6261
const getColor = (value: number) => {
6362
switch (value) {
@@ -108,131 +107,22 @@ const BentoGrid = ({
108107

109108
await uploadBytes(storageRef, blob);
110109
const downloadUrl = await getDownloadURL(storageRef);
111-
112-
const newApiLink = `https://opbento.vercel.app/api/bento?n=${encodeURIComponent(
113-
name
114-
)}&i=${encodeURIComponent(
115-
imageUrl
116-
)}&g=${githubURL}&x=${encodeURIComponent(
117-
twitterURL
118-
)}&l=${encodeURIComponent(linkedinURL)}&p=${encodeURIComponent(
119-
portfolioUrl
120-
)}`;
121-
const newBentoLink = `[![OpBento](${downloadUrl})](https://opbento.vercel.app)`;
122-
123-
// Update state with new links
124-
setApiLink(newApiLink);
125-
setBentoLink(newBentoLink);
126-
127-
// Debugging output to ensure links are set correctly
128-
console.log("API Link:", newApiLink);
129-
console.log("Bento Link:", newBentoLink);
130-
131-
const scriptContent = `
132-
#!/bin/bash
133-
134-
# Prompt for GitHub details and user-specific links
135-
read -p "Enter your GitHub username: " USERNAME
136-
read -p "Enter your GitHub email: " EMAIL
137-
138-
# Define API and image link based on provided input
139-
API_LINK="${newApiLink}"
140-
BENTO_LINK="${newBentoLink}"
141-
142-
echo "Generated API Link: \$API_LINK"
143-
echo "Generated Bento Link: \$BENTO_LINK"
144-
145-
# Create README.md dynamically with Bento Link
146-
echo "# Bento GitHub Stats for \$USERNAME" > README.md
147-
echo "\$BENTO_LINK" >> README.md
148-
echo "Updated README.md with dynamic Bento GitHub Stats link."
149-
150-
# Create .github/workflows directory and GitHub Actions workflow file
151-
mkdir -p .github/workflows
152-
touch .github/workflows/update_bento_readme.yml
153-
154-
# Generate content for GitHub Actions workflow
155-
cat <<EOF > .github/workflows/update_bento_readme.yml
156-
157-
name: Update README with Bento Stats
158-
159-
on:
160-
schedule:
161-
- cron: "*/10 * * * *" # Runs every 5 minutes
162-
workflow_dispatch: # Allows manual triggering of the workflow
163-
164-
jobs:
165-
update-readme:
166-
runs-on: ubuntu-latest
167-
168-
steps:
169-
- name: Checkout repository
170-
uses: actions/checkout@v3
171-
172-
- name: Fetch Latest Bento Image URL
173-
id: fetch_bento_url
174-
run: |
175-
API_URL="$API_LINK"
176-
RESPONSE=$(curl -s "$API_URL")
177-
echo "API Response: $RESPONSE" # Log the entire response
178-
IMAGE_URL=$(echo $RESPONSE | jq -r '.url')
179-
echo "Fetched Image URL: $IMAGE_URL"
180-
echo "::set-output name=image_url::$IMAGE_URL"
181-
182-
- name: Delete current README.md
183-
if: env.skip != 'true'
184-
run: |
185-
if [ -f README.md ]; then
186-
rm README.md
187-
echo "Deleted old README.md"
188-
fi
189-
190-
- name: Create new README.md
191-
if: env.skip != 'true'
192-
run: |
193-
IMAGE_URL=$(cat last_image_url.txt) # Read the URL from last_image_url.txt
194-
echo "# Bento GitHub Stats" > README.md
195-
echo "![Bento GitHub Stats]($IMAGE_URL)" >> README.md
196-
echo "Created new README.md with the latest image URL."
197-
198-
- name: Commit and Push Changes
199-
if: env.skip != 'true'
200-
run: |
201-
git config --global user.email "\$EMAIL"
202-
git config --global user.name "\$USERNAME"
203-
git add .
204-
git commit -m "Update README with latest Bento stats image"
205-
git push
206-
207-
EOF
208-
209-
git config --global user.email "\$EMAIL"
210-
git config --global user.name "\$USERNAME"
211-
git add .
212-
git commit -m "Setup OpBento GitHub Action"
213-
git push
214-
215-
echo "Setup complete! Your GitHub Actions workflow will run every 5 minutes and update the README with the latest Bento stats link."
216-
`;
217-
218-
// Download the script
219-
const blob2 = new Blob([scriptContent], { type: "text/plain" });
220-
const url = URL.createObjectURL(blob2);
221-
const a = document.createElement("a");
222-
a.href = url;
223-
a.download = "setup_bento_stats.sh";
224-
document.body.appendChild(a);
225-
a.click();
226-
document.body.removeChild(a);
227110
setLoading(false);
228-
URL.revokeObjectURL(url);
111+
setBentoLink(downloadUrl);
229112
} catch (error) {
230113
console.error("Error generating or uploading the image:", error);
231114
} finally {
232115
bentoRef.current.className = previousClass;
233116
}
234117
};
235118

119+
const copyToClipboard = async () => {
120+
await navigator.clipboard.writeText(
121+
`[![OpBento](${bentoLink})](https://opbento.vercel.app)`
122+
);
123+
toast.success("Copied to clipboard");
124+
};
125+
236126
return (
237127
<div className="max-w-5xl mx-auto">
238128
<div
@@ -503,10 +393,19 @@ echo "Setup complete! Your GitHub Actions workflow will run every 5 minutes and
503393
)}
504394
</div>
505395

506-
<Button className="mx-4" onClick={handleGenerateLink}>
507-
Generate Bento{" "}
508-
{loading && <Loader2 className="ml-2 size-4 animate-spin" />}
396+
<Button className="mx-auto" onClick={handleGenerateLink}>
397+
Generate Bento {loading && <Loader2 className="ml-2 w-4 h-4 animate-spin" />}
509398
</Button>
399+
400+
<div className="relative mt-4">
401+
<Input
402+
value={`[![OpBento](${bentoLink})](https://opbento.vercel.app)`}
403+
readOnly
404+
/>
405+
<Button className="absolute top-0 right-0" onClick={copyToClipboard}>
406+
<Clipboard />
407+
</Button>
408+
</div>
510409
</div>
511410
);
512411
};

0 commit comments

Comments
 (0)