Apple design (plans/gtm/APPLE-DESIGN-RULES-2026-11-17.md): rewrote theme tokens in globals.css/tailwind.config.js to neutral black/white + one accent (#0071E3), replacing the GitHub-dark blue+green dual-accent theme; mechanically swept every raw inline hex/rgba literal across app/components that bypassed the CSS vars (506 hex + 326 rgb(a) replacements) since most of the app hardcoded colors rather than using tokens; removed all emoji, decorative gradients (Tailwind bg-gradient-to-* and raw linear/radial- gradient() in inline styles), confetti, and glow/blur decorative orbs; converted Navbar/Navigation to icon-only with aria-label+title. Finished two stopped agents' in-progress work: deleted the fake AnimatedStats/ LiveActivity/ProjectShowcase/Testimonials auth-panel components and cleaned up the emoji-laden feature list in (auth)/layout.tsx. Removed remaining fabricated stats (topics/topics/[slug] posts-per-week/ contributors/followers) per the no-fake-numbers rule. Rithub sign-in: added "Continue with Rithub" as an icon-only OAuth2 button (RithubMark component) on login/register, hidden "Continue with GitHub" when GITHUB_CLIENT_ID is unset (confirmed unset in prod). Backend: authenticateWithGitea in oauthService.ts exchanges the Gitea OAuth2 code, resolves identity via the existing ForgeConnection table (no schema migration needed), issues the same JWT/session as GitHub/Google login. OAuth2 app created live on rithub.dev via its REST API as admin user caelum0x; client id/secret stored in railyard-box's compose file (env files don't ship to the runtime image, so the actual wiring lives in docker-compose.yml, not backend/.env) and in ~/products/.env. Critical bug found and fixed while verifying: services/api.ts's global 401 interceptor redirected every anonymous visitor to /login a couple seconds after ANY page load -- including /login and /register themselves -- because the AuthBootstrap's background GET /auth/me (expected to 401 for signed-out visitors) was treated the same as a real session-expiry 401, triggering a refresh attempt, another 401, and a hard window.location.href redirect, which re-ran AuthBootstrap and repeated. Fixed by excluding /auth/me and /auth/refresh from that redirect path. Verified live with a fresh, cookie-less browser: previously looped /register -> /login forever; now stable after 6s. Also fixed: production CORS/API origin mismatch -- the frontend was built with NEXT_PUBLIC_API_URL pointing at ritgram.ereboslab.com while served from ritgram.rithub.dev, so every API call (login, register, etc.) was blocked by CORS; rebuilt with rithub.dev as canonical and CORS_ORIGIN allowing both domains. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
121 lines
2.7 KiB
TypeScript
121 lines
2.7 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import api from '@/services/api';
|
|
import { getErrorMessage } from '@/utils/error';
|
|
import dynamic from 'next/dynamic';
|
|
import { parseRepositoryInput } from '@/utils/repositoryRouting';
|
|
|
|
const GifPicker = dynamic(() => import('./GifPicker'), { ssr: false });
|
|
|
|
export default function CreatePostWithRepo() {
|
|
const [content, setContent] = useState('');
|
|
const [repoUrl, setRepoUrl] = useState('');
|
|
const [gifUrl, setGifUrl] = useState('');
|
|
const [showGifPicker, setShowGifPicker] = useState(false);
|
|
const [loading, setLoading] = useState(false);
|
|
const [error, setError] = useState('');
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
setError('');
|
|
setLoading(true);
|
|
|
|
try {
|
|
const repo = parseRepositoryInput(repoUrl);
|
|
if (!repo) {
|
|
setError('Invalid repository reference');
|
|
setLoading(false);
|
|
return;
|
|
}
|
|
|
|
await api.post('/posts', {
|
|
content,
|
|
repoOwner: repo.owner,
|
|
repoName: repo.name,
|
|
gifUrl: gifUrl || undefined,
|
|
});
|
|
|
|
setContent('');
|
|
setRepoUrl('');
|
|
setGifUrl('');
|
|
window.location.reload(); // Refresh feed
|
|
} catch (err: unknown) {
|
|
setError(getErrorMessage(err));
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const handleGifSelect = (url: string) => {
|
|
setGifUrl(url);
|
|
setShowGifPicker(false);
|
|
};
|
|
|
|
return (
|
|
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-4">
|
|
<form onSubmit={handleSubmit}>
|
|
<textarea
|
|
value={content}
|
|
onChange={(e) => setContent(e.target.value)}
|
|
placeholder="What do you think about this project?"
|
|
className="w-full p-3 border rounded-lg resize-none"
|
|
rows={3}
|
|
required
|
|
/>
|
|
|
|
<input
|
|
type="text"
|
|
value={repoUrl}
|
|
onChange={(e) => setRepoUrl(e.target.value)}
|
|
placeholder="GitHub URL or owner/repo (e.g., https://github.com/microsoft/vscode)"
|
|
className="w-full p-3 border rounded-lg mt-2"
|
|
/>
|
|
|
|
{gifUrl && (
|
|
<div className="mt-2 relative">
|
|
<img src={gifUrl} alt="Selected GIF" className="rounded-lg max-h-48" />
|
|
<button
|
|
type="button"
|
|
onClick={() => setGifUrl('')}
|
|
className="absolute top-2 right-2 bg-black/50 text-white rounded-full p-1 hover:bg-black/70"
|
|
>
|
|
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
{error && (
|
|
<p className="text-red-500 text-sm mt-2">{error}</p>
|
|
)}
|
|
|
|
<div className="flex items-center gap-2 mt-3">
|
|
<button
|
|
type="button"
|
|
onClick={() => setShowGifPicker(true)}
|
|
className="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 flex items-center gap-2"
|
|
>
|
|
<span className="text-lg"></span>
|
|
GIF
|
|
</button>
|
|
|
|
<button
|
|
type="submit"
|
|
disabled={loading || !content}
|
|
className="px-6 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 disabled:opacity-50"
|
|
>
|
|
{loading ? 'Posting...' : 'Post'}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
{showGifPicker && (
|
|
<GifPicker
|
|
onSelect={handleGifSelect}
|
|
onClose={() => setShowGifPicker(false)}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|