@@ -881,9 +881,7 @@ def fetch_kernel_patches():
881881 parts .append ('</div>' )
882882 return '\n ' .join (parts )
883883
884- def build_downloads_page (root , nav_template , footer_template ):
885- dl_nav = nav_template .replace ('{{FEATURES_HREF}}' , '/#features' ).replace ('{{DOCS_STYLE}}' , '' )
886- releases = []
884+ def fetch_latest_release ():
887885 try :
888886 url = 'https://api.github.com/repos/ravindu644/Droidspaces-OSS/releases?per_page=5'
889887 req = urllib .request .Request (url )
@@ -892,8 +890,55 @@ def build_downloads_page(root, nav_template, footer_template):
892890 req .add_header ('Authorization' , f'Bearer { token } ' )
893891 with urllib .request .urlopen (req , timeout = 10 ) as resp :
894892 releases = json .loads (resp .read ())
895- except :
896- pass
893+ except Exception :
894+ return None
895+
896+ if not releases :
897+ return None
898+
899+ latest = releases [0 ]
900+ version = latest .get ('tag_name' , 'v6.2.0' )
901+ date = latest .get ('published_at' , '2026-05-22' )[:10 ]
902+ apk_url = ''
903+ tar_url = ''
904+ for a in latest .get ('assets' , []):
905+ name = a .get ('name' , '' )
906+ if name .endswith ('.apk' ):
907+ apk_url = a .get ('browser_download_url' , '' )
908+ elif name .endswith ('.tar.gz' ):
909+ tar_url = a .get ('browser_download_url' , '' )
910+ body = latest .get ('body' , '' )
911+ changelog = md_to_html (body ) if body else '<p>No changelog available.</p>'
912+
913+ older_rows = []
914+ for r in releases [1 :]:
915+ tag = r .get ('tag_name' , '' )
916+ rd = r .get ('published_at' , '' )[:10 ]
917+ rn = r .get ('name' , tag )
918+ older_rows .append (
919+ f'<tr><td>{ rn } </td><td>{ rd } </td>'
920+ f'<td><a href="https://github.com/ravindu644/Droidspaces-OSS/releases/tag/{ tag } " class="dl-secondary">Download</a></td></tr>'
921+ )
922+ older_html = (
923+ '<div class="table-wrap"><table><thead><tr><th>Version</th><th>Date</th><th></th></tr></thead><tbody>'
924+ + '\n ' .join (older_rows )
925+ + '</tbody></table></div>'
926+ if older_rows else ''
927+ )
928+
929+ return {
930+ 'version' : version ,
931+ 'date' : date ,
932+ 'apk_url' : apk_url ,
933+ 'tar_url' : tar_url ,
934+ 'changelog' : changelog ,
935+ 'older_html' : older_html ,
936+ }
937+
938+
939+ def build_downloads_page (root , nav_template , footer_template ):
940+ dl_nav = nav_template .replace ('{{FEATURES_HREF}}' , '/#features' ).replace ('{{DOCS_STYLE}}' , '' )
941+ release_info = fetch_latest_release ()
897942 patches_html = '''<div class="patch-group"><h3 class="patch-group-title">GKI</h3>
898943<div class="patch-subgroup"><h4 class="patch-subgroup-title">below-kernel-6.12</h4><ul class="patch-list">
899944<li><a href="https://raw.githubusercontent.com/ravindu644/Droidspaces-OSS/main/Documentation/resources/kernel-patches/GKI/below-kernel-6.12/001.GKI-below-6.12-fix_sysvipc_kabi_1_2_3.patch" download>001.GKI-below-6.12-fix_sysvipc_kabi_1_2_3.patch</a></li>
@@ -909,26 +954,13 @@ def build_downloads_page(root, nav_template, footer_template):
909954<ul class="patch-list"><li><a href="https://raw.githubusercontent.com/ravindu644/Droidspaces-OSS/main/Documentation/resources/kernel-patches/non-GKI/01.fix_kernel_panic_in_xt_qtaguid.patch" download>01.fix_kernel_panic_in_xt_qtaguid.patch</a></li></ul>
910955<ul class="patch-list"><li><a href="https://raw.githubusercontent.com/ravindu644/Droidspaces-OSS/main/Documentation/resources/kernel-patches/non-GKI/02.fix_restore%20cgroup%20file%20prefix%20handling%20.patch" download>02.fix_restore cgroup file prefix handling .patch</a></li></ul>
911956</div>'''
912- if releases :
913- latest = releases [0 ]
914- version = latest .get ('tag_name' , 'v6.2.0' )
915- date = latest .get ('published_at' , '2026-05-22' )[:10 ]
916- apk_url = tar_url = ''
917- for a in latest .get ('assets' , []):
918- n = a ['name' ]
919- if n .endswith ('.apk' ):
920- apk_url = a ['browser_download_url' ]
921- elif n .endswith ('.tar.gz' ):
922- tar_url = a ['browser_download_url' ]
923- body = latest .get ('body' , '' )
924- changelog = md_to_html (body ) if body else '<p>No changelog available.</p>'
925- older_rows = []
926- for r in releases [1 :]:
927- tag = r ['tag_name' ]
928- rd = r .get ('published_at' , '' )[:10 ]
929- rn = r ['name' ]
930- older_rows .append (f'<tr><td>{ rn } </td><td>{ rd } </td><td><a href="https://github.com/ravindu644/Droidspaces-OSS/releases/tag/{ tag } " class="dl-secondary">Download</a></td></tr>' )
931- older_html = '<div class="table-wrap"><table><thead><tr><th>Version</th><th>Date</th><th></th></tr></thead><tbody>' + '\n ' .join (older_rows ) + '</tbody></table></div>' if older_rows else ''
957+ if release_info :
958+ version = release_info ['version' ]
959+ date = release_info ['date' ]
960+ apk_url = release_info ['apk_url' ]
961+ tar_url = release_info ['tar_url' ]
962+ changelog = release_info ['changelog' ]
963+ older_html = release_info ['older_html' ]
932964 else :
933965 version = 'v6.2.0'
934966 date = '2026-05-22'
@@ -1126,6 +1158,19 @@ def generate_sitemap(root):
11261158 index_html ,
11271159 flags = re .DOTALL
11281160 )
1161+ release_info = fetch_latest_release ()
1162+ if release_info :
1163+ version = release_info ['version' ]
1164+ index_html = re .sub (
1165+ r'(<div class="hero-badge"><span></span>)v[^<]+( · Open Source</div>)' ,
1166+ lambda m : f'{ m .group (1 )} { version } { m .group (2 )} ' ,
1167+ index_html ,
1168+ )
1169+ index_html = re .sub (
1170+ r'("softwareVersion"\s*:\s*")v?[^"\n]+(",)' ,
1171+ lambda m : f'{ m .group (1 )} { version .lstrip ("v" )} { m .group (2 )} ' ,
1172+ index_html ,
1173+ )
11291174 index_html = index_html .replace ('{{FOOTER}}' , footer_template )
11301175 with open (index_path , 'w' ) as f :
11311176 f .write (index_html )
0 commit comments