mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add About Shakespeare page
This commit is contained in:
7 files changed
+901
-2
No files matched your search
@@ -10,6 +10,7 @@ import NostrSettings from "./pages/NostrSettings";
|
||||
import AISettings from "./pages/AISettings";
|
||||
import GitSettings from "./pages/GitSettings";
|
||||
import DataSettings from "./pages/DataSettings";
|
||||
import AboutSettings from "./pages/AboutSettings";
|
||||
import GitHubOAuth from "./pages/GitHubOAuth";
|
||||
import { NIP19Page } from "./pages/NIP19Page";
|
||||
import NotFound from "./pages/NotFound";
|
||||
@@ -32,6 +33,7 @@ export function AppRouter() {
|
||||
<Route path="ai" element={<AISettings />} />
|
||||
<Route path="git" element={<GitSettings />} />
|
||||
<Route path="data" element={<DataSettings />} />
|
||||
<Route path="about" element={<AboutSettings />} />
|
||||
</Route>
|
||||
<Route path="/project/:projectId" element={<ProjectView />} />
|
||||
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useNavigate, useLocation, Outlet } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Menu, Bot, GitBranch, Database, Wifi, Settings2 } from 'lucide-react';
|
||||
import { Menu, Bot, GitBranch, Database, Wifi, Settings2, Info } from 'lucide-react';
|
||||
import { ProjectSidebar } from '@/components/ProjectSidebar';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
@@ -56,6 +56,13 @@ const getSettingsItems = (t: (key: string) => string): SettingsItem[] => [
|
||||
icon: Database,
|
||||
href: '/settings/data',
|
||||
},
|
||||
{
|
||||
id: 'about',
|
||||
title: t('aboutShakespeare'),
|
||||
description: t('aboutShakespeareDescription'),
|
||||
icon: Info,
|
||||
href: '/settings/about',
|
||||
},
|
||||
];
|
||||
|
||||
export function SettingsLayout() {
|
||||
|
||||
@@ -78,6 +78,8 @@ const resources = {
|
||||
nostrSettingsDescription: 'Configure relay connections and Nostr preferences',
|
||||
dataSettings: 'Data',
|
||||
dataSettingsDescription: 'Export files and manage local data',
|
||||
aboutShakespeareSettings: 'About Shakespeare',
|
||||
aboutShakespeareSettingsDescription: 'Information about Shakespeare',
|
||||
|
||||
// Project Sidebar
|
||||
newProject: 'New Project',
|
||||
@@ -199,6 +201,16 @@ const resources = {
|
||||
corsProxy: 'CORS Proxy',
|
||||
corsProxyDescription: 'CORS proxy server used for all Git operations with remote repositories. Required for browser-based Git operations.',
|
||||
|
||||
// About Settings
|
||||
aboutShakespeare: 'About Shakespeare',
|
||||
aboutShakespeareDescription: 'Information about Shakespeare',
|
||||
sourceCode: 'Source Code',
|
||||
viewOnGitLab: 'View on GitLab',
|
||||
description: 'Description',
|
||||
license: 'License',
|
||||
loadingLicense: 'Loading license...',
|
||||
failedToLoadLicense: 'Failed to load license',
|
||||
|
||||
// Data Settings
|
||||
dataSettingsDescriptionLong: 'Export files and manage local data.',
|
||||
exportFiles: 'Export Files',
|
||||
@@ -361,6 +373,8 @@ const resources = {
|
||||
nostrSettingsDescription: 'Configure conexões de relay e preferências do Nostr',
|
||||
dataSettings: 'Dados',
|
||||
dataSettingsDescription: 'Exporte arquivos e gerencie dados locais',
|
||||
aboutShakespeareSettings: 'Sobre o Shakespeare',
|
||||
aboutShakespeareSettingsDescription: 'Informações sobre o Shakespeare',
|
||||
|
||||
// Project Sidebar
|
||||
newProject: 'Novo Projeto',
|
||||
@@ -512,6 +526,16 @@ const resources = {
|
||||
dataClearedDescription: 'Todos os dados locais foram removidos. Redirecionando para a página inicial...',
|
||||
failedToClearData: 'Falha ao limpar dados',
|
||||
|
||||
// About Settings
|
||||
aboutShakespeare: 'Sobre o Shakespeare',
|
||||
aboutShakespeareDescription: 'Informações sobre o Shakespeare.',
|
||||
sourceCode: 'Código-fonte',
|
||||
viewOnGitLab: 'Ver no GitLab',
|
||||
description: 'Descrição',
|
||||
license: 'Licença',
|
||||
loadingLicense: 'Carregando licença...',
|
||||
failedToLoadLicense: 'Falha ao carregar licença',
|
||||
|
||||
// 404 Page
|
||||
pageNotFound: 'Ops! Página não encontrada',
|
||||
returnToHome: 'Voltar ao Início',
|
||||
@@ -644,6 +668,8 @@ const resources = {
|
||||
nostrSettingsDescription: '配置中继连接和Nostr偏好',
|
||||
dataSettings: '数据',
|
||||
dataSettingsDescription: '导出文件和管理本地数据',
|
||||
aboutShakespeareSettings: '关于Shakespeare',
|
||||
aboutShakespeareSettingsDescription: '关于Shakespeare的信息',
|
||||
|
||||
// Project Sidebar
|
||||
newProject: '新项目',
|
||||
@@ -795,6 +821,16 @@ const resources = {
|
||||
dataClearedDescription: '所有本地数据已删除。正在重定向到主页...',
|
||||
failedToClearData: '清除数据失败',
|
||||
|
||||
// About Settings
|
||||
aboutShakespeare: '关于Shakespeare',
|
||||
aboutShakespeareDescription: '关于Shakespeare的信息。',
|
||||
sourceCode: '源代码',
|
||||
viewOnGitLab: '在GitLab上查看',
|
||||
description: '描述',
|
||||
license: '许可证',
|
||||
loadingLicense: '加载许可证中...',
|
||||
failedToLoadLicense: '加载许可证失败',
|
||||
|
||||
// 404 Page
|
||||
pageNotFound: '哎呀!页面未找到',
|
||||
returnToHome: '返回首页',
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { TestApp } from '@/test/TestApp';
|
||||
import { AboutSettings } from './AboutSettings';
|
||||
|
||||
// Mock fetch
|
||||
global.fetch = vi.fn();
|
||||
|
||||
describe('AboutSettings', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('renders about settings page with project information', () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<AboutSettings />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
expect(screen.getByText('About Shakespeare')).toBeInTheDocument();
|
||||
expect(screen.getByText(/Information about Shakespeare/)).toBeInTheDocument();
|
||||
expect(screen.getByText('Source Code')).toBeInTheDocument();
|
||||
expect(screen.getByText('View on GitLab')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('fetches and displays license text', async () => {
|
||||
const mockLicense = 'MIT License\n\nCopyright (c) 2024 Shakespeare';
|
||||
const mockFetch = global.fetch as ReturnType<typeof vi.fn>;
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
text: () => Promise.resolve(mockLicense),
|
||||
} as Response);
|
||||
|
||||
render(
|
||||
<TestApp>
|
||||
<AboutSettings />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Initially shows loading
|
||||
expect(screen.getByText('Loading license...')).toBeInTheDocument();
|
||||
|
||||
// Wait for license to load
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/MIT License/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Copyright \(c\) 2024 Shakespeare/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Verify fetch was called with correct URL
|
||||
expect(global.fetch).toHaveBeenCalledWith('/LICENSE.txt');
|
||||
});
|
||||
|
||||
it('shows error when license fetch fails', async () => {
|
||||
const mockFetch = global.fetch as ReturnType<typeof vi.fn>;
|
||||
mockFetch.mockRejectedValueOnce(new Error('Network error'));
|
||||
|
||||
render(
|
||||
<TestApp>
|
||||
<AboutSettings />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Wait for error to appear
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Failed to load license/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,117 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Info, ExternalLink, Loader2, AlertTriangle } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
|
||||
export function AboutSettings() {
|
||||
const { t } = useTranslation();
|
||||
const [license, setLicense] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchLicense = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
|
||||
const response = await fetch('/LICENSE.txt');
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch license: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
const licenseText = await response.text();
|
||||
setLicense(licenseText);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch license:', err);
|
||||
setError(err instanceof Error ? err.message : 'Failed to fetch license');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchLicense();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Info className="h-6 w-6 text-primary" />
|
||||
{t('aboutShakespeare')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aboutShakespeareDescription')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
{/* Project Information */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Info className="h-5 w-5" />
|
||||
{t('sourceCode')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div>
|
||||
<Button
|
||||
variant="outline"
|
||||
asChild
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
<a
|
||||
href="https://gitlab.com/soapbox-pub/act2"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
{t('viewOnGitLab')}
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* License */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Info className="h-5 w-5" />
|
||||
{t('license')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{isLoading ? (
|
||||
<div className="flex items-center gap-2 text-muted-foreground py-4">
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
<span className="text-sm">{t('loadingLicense')}</span>
|
||||
</div>
|
||||
) : error ? (
|
||||
<Alert variant="destructive">
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
<AlertDescription>
|
||||
{t('failedToLoadLicense')}: {error}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
) : license ? (
|
||||
<ScrollArea className="h-96 w-full rounded-md border p-4">
|
||||
<pre className="text-xs font-mono whitespace-pre-wrap break-words">
|
||||
{license}
|
||||
</pre>
|
||||
</ScrollArea>
|
||||
) : null}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AboutSettings;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Bot, GitBranch, Database, Wifi, Settings2 } from 'lucide-react';
|
||||
import { Bot, GitBranch, Database, Wifi, Settings2, Info } from 'lucide-react';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
|
||||
interface SettingsItem {
|
||||
@@ -48,6 +48,13 @@ const getSettingsItems = (t: (key: string) => string): SettingsItem[] => [
|
||||
icon: Database,
|
||||
href: '/settings/data',
|
||||
},
|
||||
{
|
||||
id: 'about',
|
||||
title: t('aboutShakespeare'),
|
||||
description: t('aboutShakespeareDescription'),
|
||||
icon: Info,
|
||||
href: '/settings/about',
|
||||
},
|
||||
];
|
||||
|
||||
export function Settings() {
|
||||
|
||||
Reference in new issue
Block a user