mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Add shakespeare favicon service, configure it as the default, move provider-specific hacks into it
This commit is contained in:
4 files changed
+50
-24
No files matched your search
+1
-1
@@ -49,7 +49,7 @@ const defaultConfig: AppConfig = {
|
||||
projectTemplate: "https://gitlab.com/soapbox-pub/mkstack.git",
|
||||
esmUrl: "https://esm.shakespeare.diy",
|
||||
corsProxy: "https://proxy.shakespeare.diy/?url={href}",
|
||||
faviconUrl: "https://external-content.duckduckgo.com/ip3/{hostname}.ico",
|
||||
faviconUrl: "https://favicon.shakespeare.diy/?url={href}",
|
||||
previewDomain: "local-shakespeare.dev",
|
||||
showcaseEnabled: true,
|
||||
showcaseModerator: "npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc",
|
||||
|
||||
@@ -37,26 +37,6 @@ import type { AIProvider } from '@/contexts/AISettingsContext';
|
||||
import { AI_PROVIDER_PRESETS, type PresetProvider } from '@/lib/aiProviderPresets';
|
||||
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||
|
||||
/** A few provider-specific icon hacks */
|
||||
function getProviderIconUrl(provider: { id: string; baseURL: string }): string {
|
||||
if (provider.id === 'ollama' && provider.baseURL === 'http://localhost:11434/v1') {
|
||||
return 'https://ollama.com/';
|
||||
} else if (provider.baseURL === 'https://generativelanguage.googleapis.com/v1beta/openai') {
|
||||
return 'https://gemini.google.com/';
|
||||
} else if (provider.baseURL === 'https://api.z.ai/api/paas/v4') {
|
||||
return 'https://docs.z.ai/';
|
||||
}
|
||||
try {
|
||||
// Strip .ai and .api subdomains for a better chance at finding a favicon
|
||||
const urlObj = new URL(provider.baseURL);
|
||||
urlObj.hostname = urlObj.hostname.replace(/^(ai\.|api\.)/, '');
|
||||
return urlObj.toString();
|
||||
} catch {
|
||||
// Fallback to baseURL
|
||||
return provider.baseURL;
|
||||
}
|
||||
}
|
||||
|
||||
interface SortableProviderItemProps {
|
||||
provider: AIProvider;
|
||||
preset?: PresetProvider;
|
||||
@@ -103,7 +83,7 @@ function SortableProviderItem({ provider, preset, onRemove, onSetProvider, onOpe
|
||||
)}
|
||||
{provider.baseURL ? (
|
||||
<ExternalFavicon
|
||||
url={getProviderIconUrl(provider)}
|
||||
url={provider.baseURL}
|
||||
size={16}
|
||||
fallback={<Bot size={16} />}
|
||||
/>
|
||||
@@ -390,7 +370,7 @@ export function AISettings() {
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ExternalFavicon
|
||||
url={getProviderIconUrl(preset)}
|
||||
url={preset.baseURL}
|
||||
size={16}
|
||||
fallback={<Bot size={16} />}
|
||||
/>
|
||||
|
||||
@@ -330,7 +330,7 @@ export function SystemSettings() {
|
||||
<Input
|
||||
id="favicon-url"
|
||||
type="url"
|
||||
placeholder="https://external-content.duckduckgo.com/ip3/{hostname}.ico"
|
||||
placeholder="https://favicon.shakespeare.diy/?url={href}"
|
||||
value={faviconUrlInput}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
|
||||
Reference in new issue
Block a user