Compare commits

..

No commits in common. "769a5e0a435e34b93634f03d56f08178fec9745d" and "0dca4e8ddc43b76b267239b21f396ffd494618c7" have entirely different histories.

View File

@ -1,43 +1,53 @@
/** /**
* Version Fetcher - Automatically fetches and displays latest pyserveX version * Version Fetcher - Automatically fetches and displays latest pyserveX version
* from Gitea releases API. * from Gitea releases page
*/ */
(function() { (function() {
'use strict'; 'use strict';
const API_URL = 'https://git.pyserve.org/api/v1/repos/Shifty/pyserveX/releases/latest'; const RELEASES_URL = 'https://git.pyserve.org/Shifty/pyserveX/releases/latest';
const VERSION_ELEMENT_ID = 'current-version'; const VERSION_ELEMENT_ID = 'current-version';
const CACHE_KEY = 'pyserve_version_cache'; const CACHE_KEY = 'pyserve_version_cache';
const CACHE_DURATION = 3600000; const CACHE_DURATION = 3600000; // 1 hour
const FALLBACK_VERSION = '0.9.10'; const FALLBACK_VERSION = 'offline';
async function fetchLatestVersion() { async function fetchLatestVersion() {
try { try {
const response = await fetch(API_URL, { const response = await fetch(RELEASES_URL, {
method: 'GET', method: 'GET',
mode: 'cors',
headers: { headers: {
'Accept': 'application/json' 'Accept': 'text/html'
} }
}); });
if (!response.ok) { if (!response.ok) {
console.warn(`API request failed: ${response.status}`); console.warn(`Failed to fetch: ${response.status}`);
return null; return null;
} }
const data = await response.json(); const html = await response.text();
if (data.tag_name) { const patterns = [
const version = data.tag_name.replace(/^v/, ''); /<title>PyServeX\s+v([\d.]+)/i,
console.log(`✓ Version fetched from Gitea API: ${version}`); /releases\/tag\/v([\d.]+)/,
return version; /aria-label="PyServeX\s+v([\d.]+)/i,
/<h4[^>]*>.*?v([\d.]+).*?<\/h4>/i
];
for (const pattern of patterns) {
const match = html.match(pattern);
if (match && match[1]) {
console.log(`✓ Version found: ${match[1]}`);
return match[1];
}
} }
console.warn('tag_name not found in API response'); console.warn('Version not found in HTML');
return null; return null;
} catch (error) { } catch (error) {
console.warn('API fetch error:', error.message); console.warn('Fetch error:', error.message);
return null; return null;
} }
} }