from nc_py_api import Nextcloud import json from datetime import datetime import config # Initialize Nextcloud client nc = Nextcloud( nextcloud_url=config.NEXTCLOUD_URL, nc_auth_user=config.NEXTCLOUD_USERNAME, nc_auth_pass=config.NEXTCLOUD_PASSWORD ) NEXTCLOUD_NOTES_PATH = "/gpu_poor_release_notes.json" LOCAL_CACHE_FILE = "release_notes.json" def load_release_notes(): """Load release notes from Nextcloud with local file fallback.""" try: # Try to load from Nextcloud remote_data = nc.files.download(NEXTCLOUD_NOTES_PATH) if remote_data: notes = json.loads(remote_data.decode('utf-8')) # Update local cache with open(LOCAL_CACHE_FILE, 'w') as f: json.dump(notes, f, indent=2) return notes except Exception as e: print(f"Could not load release notes from Nextcloud: {e}") # Try local cache try: with open(LOCAL_CACHE_FILE, 'r') as f: return json.load(f) except Exception as e: print(f"Could not load from local cache: {e}") # Return empty notes if both attempts fail return { "last_updated": datetime.now().isoformat(), "notes": [] } def get_release_notes_html(): """Generate HTML display of release notes.""" notes_data = load_release_notes() html = f"""
""" # Add notes in reverse chronological order for note in sorted(notes_data["notes"], key=lambda x: x["date"], reverse=True): html += f"""
📅 {note["date"]}
{note["content"]}
""" html += f"""
Last updated: {notes_data["last_updated"].split("T")[0]}
""" return html