mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Make showcase configurable in System Settings
This commit is contained in:
10 files changed
+85
-5
No files matched your search
@@ -47,6 +47,8 @@ const defaultConfig: AppConfig = {
|
||||
esmUrl: "https://esm.shakespeare.diy",
|
||||
corsProxy: "https://proxy.shakespeare.diy/?url={href}",
|
||||
previewDomain: "local-shakespeare.dev",
|
||||
showcaseEnabled: true,
|
||||
showcaseModerator: "npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc",
|
||||
};
|
||||
|
||||
const presetRelays = [
|
||||
|
||||
@@ -24,6 +24,8 @@ const AppConfigSchema = z.object({
|
||||
corsProxy: z.string().url(),
|
||||
previewDomain: z.string().min(1),
|
||||
language: z.string(),
|
||||
showcaseEnabled: z.boolean(),
|
||||
showcaseModerator: z.string(),
|
||||
}) satisfies z.ZodType<AppConfig>;
|
||||
|
||||
export function AppProvider(props: AppProviderProps) {
|
||||
|
||||
@@ -13,21 +13,23 @@ import { shuffleArray } from "@/lib/utils";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { RelaySelector } from "@/components/RelaySelector";
|
||||
import { useAppContext } from "@/hooks/useAppContext";
|
||||
|
||||
export function AppShowcase() {
|
||||
const { user } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
const { data: submissions = [], isLoading } = useAppSubmissions();
|
||||
const [showAllApps, setShowAllApps] = useState(false);
|
||||
|
||||
const MODERATOR_NPUB = 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc';
|
||||
const MODERATOR_HEX = (() => {
|
||||
// Get moderator hex from config
|
||||
const MODERATOR_HEX = useMemo(() => {
|
||||
try {
|
||||
const decoded = nip19.decode(MODERATOR_NPUB);
|
||||
const decoded = nip19.decode(config.showcaseModerator);
|
||||
return decoded.type === 'npub' ? decoded.data : '';
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
})();
|
||||
}, [config.showcaseModerator]);
|
||||
const isModerator = user?.pubkey === MODERATOR_HEX;
|
||||
|
||||
// Filter submissions
|
||||
@@ -63,6 +65,11 @@ export function AppShowcase() {
|
||||
[nonHalloweenSubmissions]
|
||||
);
|
||||
|
||||
// Don't show showcase if disabled in settings
|
||||
if (!config.showcaseEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Don't show showcase if no apps exist
|
||||
if (isLoading) {
|
||||
return (
|
||||
|
||||
@@ -567,7 +567,7 @@ export function AppShowcaseCard({ app, onEdit, showModerationControls, hideAppro
|
||||
className="flex-1"
|
||||
>
|
||||
<img
|
||||
src="https://shakespeare.diy/badge.svg"
|
||||
src="/badge.svg"
|
||||
alt="Edit with Shakespeare"
|
||||
className="h-6 hover:opacity-80 transition-opacity"
|
||||
/>
|
||||
|
||||
@@ -19,6 +19,10 @@ export interface AppConfig {
|
||||
previewDomain: string;
|
||||
/** Selected language */
|
||||
language?: string;
|
||||
/** Whether to show the showcase section */
|
||||
showcaseEnabled: boolean;
|
||||
/** Npub of the showcase moderator */
|
||||
showcaseModerator: string;
|
||||
}
|
||||
|
||||
export interface AppContextType {
|
||||
|
||||
@@ -47,6 +47,8 @@ describe('useAIProjectId', () => {
|
||||
esmUrl: 'https://esm.sh',
|
||||
corsProxy: 'https://proxy.example.com/{href}',
|
||||
previewDomain: 'local-shakespeare.dev',
|
||||
showcaseEnabled: true,
|
||||
showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc',
|
||||
},
|
||||
updateConfig: vi.fn(),
|
||||
});
|
||||
|
||||
@@ -39,6 +39,8 @@ function createWrapper(corsProxy: string) {
|
||||
esmUrl: 'https://esm.test',
|
||||
corsProxy,
|
||||
previewDomain: 'local-test.dev',
|
||||
showcaseEnabled: true,
|
||||
showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc',
|
||||
};
|
||||
|
||||
return createElement(
|
||||
|
||||
@@ -20,6 +20,8 @@ function Wrapper({ children }: { children: React.ReactNode }) {
|
||||
esmUrl: 'https://esm.test',
|
||||
corsProxy: 'https://proxy.shakespeare.diy/?url={href}',
|
||||
previewDomain: 'local-test.dev',
|
||||
showcaseEnabled: true,
|
||||
showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc',
|
||||
};
|
||||
|
||||
return createElement(
|
||||
|
||||
@@ -3,6 +3,8 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { useIsMobile } from "@/hooks/useIsMobile";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
@@ -18,6 +20,7 @@ export function SystemSettings() {
|
||||
const [corsProxyInput, setCorsProxyInput] = useState(config.corsProxy);
|
||||
const [previewDomainInput, setPreviewDomainInput] = useState(config.previewDomain);
|
||||
const [deployServerInput, setDeployServerInput] = useState(config.deployServer);
|
||||
const [showcaseModeratorInput, setShowcaseModeratorInput] = useState(config.showcaseModerator);
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
@@ -207,6 +210,60 @@ export function SystemSettings() {
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
|
||||
{/* Showcase Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="showcase" className="border rounded-lg">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<h4 className="text-sm font-medium">Showcase</h4>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent className="px-4 pb-4">
|
||||
<div className="py-1 space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="showcase-enabled" className="text-sm font-medium">
|
||||
Showcase Enabled
|
||||
</Label>
|
||||
<Switch
|
||||
id="showcase-enabled"
|
||||
checked={config.showcaseEnabled}
|
||||
onCheckedChange={(checked) => {
|
||||
updateConfig((current) => ({
|
||||
...current,
|
||||
showcaseEnabled: checked,
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Display the app showcase section on the home page
|
||||
</p>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="showcase-moderator" className="text-sm font-medium">
|
||||
Showcase Moderator
|
||||
</Label>
|
||||
<Input
|
||||
id="showcase-moderator"
|
||||
type="text"
|
||||
placeholder="npub1..."
|
||||
value={showcaseModeratorInput}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
setShowcaseModeratorInput(value);
|
||||
updateConfig((current) => ({
|
||||
...current,
|
||||
showcaseModerator: value,
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Nostr public key (npub) of the user who can moderate showcase submissions
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -36,6 +36,8 @@ export function TestApp({ children }: TestAppProps) {
|
||||
corsProxy: 'https://proxy.shakespeare.diy/?url={href}',
|
||||
previewDomain: 'local-shakespeare.dev',
|
||||
language: 'en',
|
||||
showcaseEnabled: true,
|
||||
showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc',
|
||||
};
|
||||
|
||||
// Initialize LightningFS for testing
|
||||
|
||||
Reference in new issue
Block a user