[READ-ONLY] Mirror of https://github.com/mrgnw/ananas. learn multiple languages at once ananas.xcc.es
0

Configure Feed

Select the types of activity you want to include in your feed.

simpler

+10 -52
+2 -16
src/lib/utils/cloudflare.js
··· 24 24 { name: countryInfo.name, languages: countryInfo.languages?.length || 0 } : 25 25 'Not found'); 26 26 27 - // For development testing only - override with a sample country 28 - let dev_country = null; 29 - if (!ip_country && process.env.NODE_ENV !== 'production') { 30 - try { 31 - const url = new URL(request.url); 32 - dev_country = url.searchParams.get('country') || 'US'; // Default to US for testing 33 - console.log(`[DEV] Using test country: ${dev_country}`); 34 - } catch (error) { 35 - console.error('Error parsing URL:', error); 36 - } 37 - } 38 - 39 27 return { 40 - ip_country: ip_country || dev_country || '', 28 + ip_country, 41 29 country_phone, 42 30 accept_language, 43 - countryInfo, 44 - // Additional info for debugging 45 - source: process.env.NODE_ENV !== 'production' && !ip_country ? 'development override' : 'Cloudflare' 31 + countryInfo 46 32 }; 47 33 }
+8 -36
src/routes/+layout.svelte
··· 14 14 browser && 15 15 page && 16 16 page.data && 17 - (page.data.country || page.data.countryData || page.data.countryInfo) 17 + (page.data.ip_country || page.data.countryInfo) 18 18 ); 19 19 20 20 // Get current page path safely ··· 22 22 browser && page && page.url ? page.url.pathname : 'unknown' 23 23 ); 24 24 25 - // Get Cloudflare data for debugging 26 - const cloudflareData = $derived( 27 - hasCloudflareData ? { 28 - country: page.data.country, 29 - countryData: page.data.countryData, 30 - countryInfo: page.data.countryInfo, 31 - rawData: page.data 32 - } : null 33 - ); 34 - 35 - // Default debug data if Cloudflare data is not available 36 - const defaultDebugData = $derived({ 37 - appInfo: { 38 - page: currentPath, 39 - environment: import.meta.env.MODE, 40 - time: new Date().toISOString() 41 - } 42 - }); 43 - 44 25 // Log Cloudflare data to console on client 45 26 onMount(() => { 46 - if (browser && cloudflareData) { 47 - console.log('[CLIENT] Cloudflare data:', cloudflareData); 27 + if (browser && page && page.data) { 28 + console.log('[CLIENT] Cloudflare data:', page.data); 48 29 } 49 30 }); 50 31 </script> ··· 60 41 <DebugButton 61 42 title="Debug Info" 62 43 data={{ 63 - cloudflare: cloudflareData ? { 64 - countryDetection: { 65 - source: cloudflareData.countryData?.source || 'Unknown', 66 - countryCode: cloudflareData.country || 'Not detected', 67 - countryName: cloudflareData.countryInfo?.name || 'Not found', 68 - countryFlag: cloudflareData.countryInfo?.flag || 'Not found' 69 - }, 70 - countryInfo: cloudflareData.countryInfo ? { 71 - nativeName: cloudflareData.countryInfo.native_name, 72 - isoCode: cloudflareData.countryInfo.iso, 73 - iso3Code: cloudflareData.countryInfo.iso3, 74 - languages: cloudflareData.countryInfo.languages?.map(lang => `${lang.name} (${lang.iso}) ${lang.speakers_m ? '- ' + lang.speakers_m + 'M speakers' : ''}`) || [] 75 - } : null, 76 - rawData: cloudflareData 44 + cloudflare: hasCloudflareData ? { 45 + ip_country: page.data.ip_country || '', 46 + country_phone: page.data.country_phone || '', 47 + accept_language: page.data.accept_language || '', 48 + countryInfo: page.data.countryInfo || null 77 49 } : 'No Cloudflare data available', 78 50 appInfo: { 79 51 page: currentPath,