File size: 2,716 Bytes
dcca2d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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"""
    <style>
        .release-notes {{
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
        }}
        .release-note {{
            background: rgba(255, 255, 255, 0.05);
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 20px;
        }}
        .note-date {{
            font-size: 0.9em;
            color: #888;
            margin-bottom: 8px;
        }}
        .note-content {{
            white-space: pre-wrap;
            line-height: 1.6;
        }}
        .last-updated {{
            font-size: 0.8em;
            color: #666;
            text-align: right;
            margin-top: 20px;
            font-style: italic;
        }}
    </style>
    <div class="release-notes">
    """
    
    # Add notes in reverse chronological order
    for note in sorted(notes_data["notes"], key=lambda x: x["date"], reverse=True):
        html += f"""
        <div class="release-note">
            <div class="note-date">πŸ“… {note["date"]}</div>
            <div class="note-content">{note["content"]}</div>
        </div>
        """
    
    html += f"""
        <div class="last-updated">
            Last updated: {notes_data["last_updated"].split("T")[0]}
        </div>
    </div>
    """
    
    return html