Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Willie Zutz 2025-07-18 10:48:09 -06:00
commit a027ccb25a
4 changed files with 44 additions and 5 deletions

View file

@ -36,6 +36,7 @@ export const GET = async (req: Request) => {
{ {
engines: ['bing news'], engines: ['bing news'],
pageno: 1, pageno: 1,
language: 'en',
}, },
) )
).results; ).results;
@ -49,7 +50,11 @@ export const GET = async (req: Request) => {
data = ( data = (
await searchSearxng( await searchSearxng(
`site:${articleWebsites[Math.floor(Math.random() * articleWebsites.length)]} ${topics[Math.floor(Math.random() * topics.length)]}`, `site:${articleWebsites[Math.floor(Math.random() * articleWebsites.length)]} ${topics[Math.floor(Math.random() * topics.length)]}`,
{ engines: ['bing news'], pageno: 1 }, {
engines: ['bing news'],
pageno: 1,
language: 'en',
},
) )
).results; ).results;
} }

View file

@ -1,6 +1,7 @@
export const POST = async (req: Request) => { export const POST = async (req: Request) => {
try { try {
const body: { lat: number; lng: number } = await req.json(); const body: { lat: number; lng: number; temperatureUnit: 'C' | 'F' } =
await req.json();
if (!body.lat || !body.lng) { if (!body.lat || !body.lng) {
return Response.json( return Response.json(
@ -12,7 +13,7 @@ export const POST = async (req: Request) => {
} }
const res = await fetch( const res = await fetch(
`https://api.open-meteo.com/v1/forecast?latitude=${body.lat}&longitude=${body.lng}&current=weather_code,temperature_2m,is_day,relative_humidity_2m,wind_speed_10m&timezone=auto`, `https://api.open-meteo.com/v1/forecast?latitude=${body.lat}&longitude=${body.lng}&current=weather_code,temperature_2m,is_day,relative_humidity_2m,wind_speed_10m&timezone=auto${body.temperatureUnit === 'C' ? '' : '&temperature_unit=fahrenheit'}`,
); );
const data = await res.json(); const data = await res.json();
@ -33,12 +34,14 @@ export const POST = async (req: Request) => {
humidity: number; humidity: number;
windSpeed: number; windSpeed: number;
icon: string; icon: string;
temperatureUnit: 'C' | 'F';
} = { } = {
temperature: data.current.temperature_2m, temperature: data.current.temperature_2m,
condition: '', condition: '',
humidity: data.current.relative_humidity_2m, humidity: data.current.relative_humidity_2m,
windSpeed: data.current.wind_speed_10m, windSpeed: data.current.wind_speed_10m,
icon: '', icon: '',
temperatureUnit: body.temperatureUnit,
}; };
const code = data.current.weather_code; const code = data.current.weather_code;

View file

@ -232,6 +232,7 @@ export default function SettingsPage() {
>(null); >(null);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [automaticSuggestions, setAutomaticSuggestions] = useState(true); const [automaticSuggestions, setAutomaticSuggestions] = useState(true);
const [temperatureUnit, setTemperatureUnit] = useState<'C' | 'F'>('C');
const [savingStates, setSavingStates] = useState<Record<string, boolean>>({}); const [savingStates, setSavingStates] = useState<Record<string, boolean>>({});
const [contextWindowSize, setContextWindowSize] = useState(2048); const [contextWindowSize, setContextWindowSize] = useState(2048);
const [isCustomContextWindow, setIsCustomContextWindow] = useState(false); const [isCustomContextWindow, setIsCustomContextWindow] = useState(false);
@ -333,6 +334,8 @@ export default function SettingsPage() {
!predefinedContextSizes.includes(storedContextWindow), !predefinedContextSizes.includes(storedContextWindow),
); );
setTemperatureUnit(localStorage.getItem('temperatureUnit')! as 'C' | 'F');
setIsLoading(false); setIsLoading(false);
}; };
@ -553,6 +556,8 @@ export default function SettingsPage() {
localStorage.setItem('embeddingModel', value); localStorage.setItem('embeddingModel', value);
} else if (key === 'ollamaContextWindow') { } else if (key === 'ollamaContextWindow') {
localStorage.setItem('ollamaContextWindow', value.toString()); localStorage.setItem('ollamaContextWindow', value.toString());
} else if (key === 'temperatureUnit') {
localStorage.setItem('temperatureUnit', value.toString());
} }
} catch (err) { } catch (err) {
console.error('Failed to save:', err); console.error('Failed to save:', err);
@ -721,13 +726,35 @@ export default function SettingsPage() {
) : ( ) : (
config && ( config && (
<div className="flex flex-col space-y-6 pb-28 lg:pb-8"> <div className="flex flex-col space-y-6 pb-28 lg:pb-8">
<SettingsSection title="Appearance"> <SettingsSection title="Preferences">
<div className="flex flex-col space-y-1"> <div className="flex flex-col space-y-1">
<p className="text-black/70 dark:text-white/70 text-sm"> <p className="text-black/70 dark:text-white/70 text-sm">
Theme Theme
</p> </p>
<ThemeSwitcher /> <ThemeSwitcher />
</div> </div>
<div className="flex flex-col space-y-1">
<p className="text-black/70 dark:text-white/70 text-sm">
Temperature Unit
</p>
<Select
value={temperatureUnit ?? undefined}
onChange={(e) => {
setTemperatureUnit(e.target.value as 'C' | 'F');
saveConfig('temperatureUnit', e.target.value);
}}
options={[
{
label: 'Celsius',
value: 'C',
},
{
label: 'Fahrenheit',
value: 'F',
},
]}
/>
</div>
</SettingsSection> </SettingsSection>
<SettingsSection title="Automatic Search"> <SettingsSection title="Automatic Search">

View file

@ -9,7 +9,9 @@ const WeatherWidget = () => {
humidity: 0, humidity: 0,
windSpeed: 0, windSpeed: 0,
icon: '', icon: '',
temperatureUnit: 'C',
}); });
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
@ -73,6 +75,7 @@ const WeatherWidget = () => {
body: JSON.stringify({ body: JSON.stringify({
lat: location.latitude, lat: location.latitude,
lng: location.longitude, lng: location.longitude,
temperatureUnit: localStorage.getItem('temperatureUnit') ?? 'C',
}), }),
}); });
@ -91,6 +94,7 @@ const WeatherWidget = () => {
humidity: data.humidity, humidity: data.humidity,
windSpeed: data.windSpeed, windSpeed: data.windSpeed,
icon: data.icon, icon: data.icon,
temperatureUnit: data.temperatureUnit,
}); });
setLoading(false); setLoading(false);
}); });
@ -125,7 +129,7 @@ const WeatherWidget = () => {
className="h-10 w-auto" className="h-10 w-auto"
/> />
<span className="text-base font-semibold text-black dark:text-white"> <span className="text-base font-semibold text-black dark:text-white">
{data.temperature}°C {data.temperature}°{data.temperatureUnit}
</span> </span>
</div> </div>
<div className="flex flex-col justify-between flex-1 h-full py-1"> <div className="flex flex-col justify-between flex-1 h-full py-1">