forge
Explore
Log in

Don't you dare go Hollow

File ages load after the page instead of holding it

Browse files at this commit

37e985d7446f13ea8d71da4ff0e8d2d11d64a25fAhmet Kaan GümüşParent: ed35470
All checks have passed
Show checks
  • perf
    • file ages load after the page instead of holding it
    • the history walk moves to /{owner}/{repo}/ages and the last-commit cache is gone, so the code page renders in 5 ms
Show full message
⚡ perf: file ages load after the page instead of holding it; the history walk moves to /{owner}/{repo}/ages and the last-commit cache is gone, so the code page renders in 5 ms
crates/forge-web-pages/src/pages/repo.rsmodified+6 -17
@@ -23,7 +23,7 @@ use crate::pages::refs::{load_refs, ref_links};
23 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};23 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
24 use crate::pages::repo_side::{StripFacts, code_sub, commit_strip, run_pips, run_rows, tree_facts};24 use crate::pages::repo_side::{StripFacts, code_sub, commit_strip, run_pips, run_rows, tree_facts};
25 use crate::pages::tree::{25 use crate::pages::tree::{
26- entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_sheet, tree_table,26+ ages_url, entry_rows, latest_bar, load_readme, read_dir, readme_sheet, tree_table,
27 };27 };
28 use crate::state::AppState;28 use crate::state::AppState;
29 use crate::views::parts::{SubPart, head_sub};29 use crate::views::parts::{SubPart, head_sub};
@@ -383,6 +383,7 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
383 let title = ctx.title();383 let title = ctx.title();
384 384
385 let mut tree = None;385 let mut tree = None;
386+ let mut ages = String::new();
386 let mut readme = None;387 let mut readme = None;
387 let mut bar = None;388 let mut bar = None;
388 let mut facts = None;389 let mut facts = None;
@@ -391,22 +392,10 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
391 {392 {
392 let names: Vec<String> = entries.iter().map(|e| e.name.clone()).collect();393 let names: Vec<String> = entries.iter().map(|e| e.name.clone()).collect();
393 facts = Some(tree_facts(state, repo, &ctx.path, commit, &names).await?);394 facts = Some(tree_facts(state, repo, &ctx.path, commit, &names).await?);
394- let (last, latest) = tokio::join!(395+ bar = latest_bar(state, repo, &ctx.path, commit, lang, ctx.viewer_tz()).await;
395- last_commits(state, &ctx.path, commit, "", &names),396+ ages = ages_url(repo, commit, "");
396- latest_bar(state, repo, &ctx.path, commit, lang, ctx.viewer_tz()),
397- );
398- bar = latest;
399 readme = load_readme(state, repo, &ctx.path, &branch, commit, "", &entries).await?;397 readme = load_readme(state, repo, &ctx.path, &branch, commit, "", &entries).await?;
400- tree = Some(entry_rows(398+ tree = Some(entry_rows(repo, &branch, "", entries));
401- lang,
402- repo,
403- &branch,
404- "",
405- entries,
406- &last,
407- now_unix(),
408- ctx.viewer_tz(),
409- ));
410 }399 }
411 let follows = follows_branch(&refs, &branch);400 let follows = follows_branch(&refs, &branch);
412 let live = home_live_url(&repo.owner_name, &repo.name, &branch);401 let live = home_live_url(&repo.owner_name, &repo.name, &branch);
@@ -447,7 +436,7 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
447 file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),436 file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),
448 ref_name: branch.clone())437 ref_name: branch.clone())
449 </div>438 </div>
450- tree_table(rows: rows, lang: lang, current: readme_file)439+ tree_table(rows: rows, lang: lang, ages: ages.clone(), current: readme_file)
451 </nav>440 </nav>
452 readme_sheet(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), ref_name: branch.clone(), dir: String::new(), readme: readme,441 readme_sheet(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), ref_name: branch.clone(), dir: String::new(), readme: readme,
453 none: s(lang, "No README yet", "Henüz README yok"))442 none: s(lang, "No README yet", "Henüz README yok"))
crates/forge-web-pages/src/pages/tree.rsmodified+46 -57
@@ -1,6 +1,5 @@
1 use std::collections::HashMap;1 use std::collections::HashMap;
2 use std::path::{Path, PathBuf};2 use std::path::{Path, PathBuf};
3-use std::sync::{Mutex, OnceLock};
4 use std::time::Duration;3 use std::time::Duration;
5 4
6 use forge_core::Repo as RepoRow;5 use forge_core::Repo as RepoRow;
@@ -10,7 +9,8 @@ use forge_git::history;
10 use topcoat::Result;9 use topcoat::Result;
11 use topcoat::context::{Cx, context};10 use topcoat::context::{Cx, context};
12 use topcoat::router::error::not_found;11 use topcoat::router::error::not_found;
13-use topcoat::router::{page, path_param};12+use topcoat::router::response::Response;
13+use topcoat::router::{Body, HeaderValue, page, path_param, route};
14 use topcoat::view::{Unescaped, View, component, view};14 use topcoat::view::{Unescaped, View, component, view};
15 15
16 use crate::i18n::code::{self as g, K};16 use crate::i18n::code::{self as g, K};
@@ -67,13 +67,6 @@ pub async fn read_file(path: PathBuf, commit: String, file: String) -> Result<Op
67 .await??)67 .await??)
68 }68 }
69 69
70-type LastCommitCache = Mutex<HashMap<(PathBuf, String), (String, HashMap<String, CommitInfo>)>>;
71-
72-fn last_commit_cache() -> &'static LastCommitCache {
73- static CACHE: OnceLock<LastCommitCache> = OnceLock::new();
74- CACHE.get_or_init(|| Mutex::new(HashMap::new()))
75-}
76-
77 pub async fn last_commits(70 pub async fn last_commits(
78 state: &AppState,71 state: &AppState,
79 path: &Path,72 path: &Path,
@@ -81,22 +74,9 @@ pub async fn last_commits(
81 dir: &str,74 dir: &str,
82 names: &[String],75 names: &[String],
83 ) -> HashMap<String, CommitInfo> {76 ) -> HashMap<String, CommitInfo> {
84- let key = (path.to_path_buf(), dir.to_owned());
85- if let Some((at, map)) = last_commit_cache().lock().expect("last-commit cache").get(&key)
86- && at == commit
87- {
88- return map.clone();
89- }
90 let walk = history::last_commits(&state.git, path, commit, dir, names, LAST_COMMIT_WALK);77 let walk = history::last_commits(&state.git, path, commit, dir, names, LAST_COMMIT_WALK);
91 match tokio::time::timeout(LAST_COMMIT_TIMEOUT, walk).await {78 match tokio::time::timeout(LAST_COMMIT_TIMEOUT, walk).await {
92- Ok(Ok(map)) => {79+ Ok(Ok(map)) => map,
93- let mut cache = last_commit_cache().lock().expect("last-commit cache");
94- if cache.len() >= 1024 {
95- cache.clear();
96- }
97- cache.insert(key, (commit.to_owned(), map.clone()));
98- map
99- }
100 Ok(Err(e)) => {80 Ok(Err(e)) => {
101 tracing::warn!(error = %e, "last-commit walk failed");81 tracing::warn!(error = %e, "last-commit walk failed");
102 HashMap::new()82 HashMap::new()
@@ -172,20 +152,9 @@ pub struct EntryRow {
172 pub name: String,152 pub name: String,
173 pub href: Option<String>,153 pub href: Option<String>,
174 pub short: String,154 pub short: String,
175- pub last: Option<LastCommit>,
176 }155 }
177 156
178-#[allow(clippy::too_many_arguments)]157+pub fn entry_rows(repo: &RepoRow, ref_name: &str, dir: &str, entries: Vec<TreeEntry>) -> Vec<EntryRow> {
179-pub fn entry_rows(
180- lang: Lang,
181- repo: &RepoRow,
182- ref_name: &str,
183- dir: &str,
184- entries: Vec<TreeEntry>,
185- last: &HashMap<String, CommitInfo>,
186- now: i64,
187- tz: &str,
188-) -> Vec<EntryRow> {
189 entries158 entries
190 .into_iter()159 .into_iter()
191 .map(|entry| {160 .map(|entry| {
@@ -206,15 +175,11 @@ pub fn entry_rows(
206 EntryKind::Symlink => ("link", blob_href(repo, ref_name, &rel), String::new()),175 EntryKind::Symlink => ("link", blob_href(repo, ref_name, &rel), String::new()),
207 EntryKind::Submodule => ("submodule", None, short_oid(&entry.oid).to_owned()),176 EntryKind::Submodule => ("submodule", None, short_oid(&entry.oid).to_owned()),
208 };177 };
209- let last = last
210- .get(&entry.name)
211- .map(|c| last_commit_view(lang, repo, c, now, tz));
212 EntryRow {178 EntryRow {
213 kind,179 kind,
214 name: entry.name,180 name: entry.name,
215 href,181 href,
216 short,182 short,
217- last,
218 }183 }
219 })184 })
220 .collect()185 .collect()
@@ -266,6 +231,41 @@ fn blob_href(repo: &RepoRow, ref_name: &str, rel: &str) -> Option<String> {
266 ))231 ))
267 }232 }
268 233
234+pub fn ages_url(repo: &RepoRow, commit: &str, dir: &str) -> String {
235+ repo_href(&repo.owner_name, &repo.name, "ages", &child_path(commit, dir))
236+}
237+
238+#[route(GET "/{owner}/{repo}/ages/{*rest}")]
239+async fn tree_ages(cx: &Cx) -> Result<Response> {
240+ let ctx = load_repo(cx, owner(cx), repo(cx)).await?;
241+ let state = context::<AppState>(cx);
242+ let parts: Vec<String> = rest(cx).map(|part| part.to_string()).collect();
243+ let Some((commit, dir)) = parts.split_first() else {
244+ return Err(not_found().into());
245+ };
246+ let dir = dir.join("/");
247+ let Some(entries) = read_dir(ctx.path.clone(), commit.clone(), dir.clone()).await? else {
248+ return Err(not_found().into());
249+ };
250+ let names: Vec<String> = entries.into_iter().map(|entry| entry.name).collect();
251+ let last = last_commits(state, &ctx.path, commit, &dir, &names).await;
252+ let now = now_unix();
253+ let ages: serde_json::Map<String, serde_json::Value> = last
254+ .iter()
255+ .map(|(name, commit)| {
256+ let view = last_commit_view(ctx.lang, &ctx.repo, commit, now, ctx.viewer_tz());
257+ let age = serde_json::json!({ "iso": view.iso, "absolute": view.absolute, "age": view.age });
258+ (name.clone(), age)
259+ })
260+ .collect();
261+ let mut response = Response::new(Body::from(serde_json::Value::Object(ages).to_string().into_bytes()));
262+ response.headers_mut().insert(
263+ http::header::CONTENT_TYPE,
264+ HeaderValue::from_static("application/json; charset=utf-8"),
265+ );
266+ Ok(response)
267+}
268+
269 pub fn link_context(state: &AppState, repo: &RepoRow, ref_name: &str, dir: &str) -> LinkContext {269 pub fn link_context(state: &AppState, repo: &RepoRow, ref_name: &str, dir: &str) -> LinkContext {
270 let at = |section: &str| {270 let at = |section: &str| {
271 repo_href(271 repo_href(
@@ -338,18 +338,16 @@ pub async fn tree_table(
338 cx: &Cx,338 cx: &Cx,
339 rows: Vec<EntryRow>,339 rows: Vec<EntryRow>,
340 lang: Lang,340 lang: Lang,
341+ ages: String,
341 #[default] current: Option<String>,342 #[default] current: Option<String>,
342 ) -> Result<impl View> {343 ) -> Result<impl View> {
343 Ok(view! {344 Ok(view! {
344- <div class="rail-list tree-list">345+ <div class="rail-list tree-list" data-ages=(ages)>
345 for row in rows.into_iter() {346 for row in rows.into_iter() {
346 if let Some(href) = row.href {347 if let Some(href) = row.href {
347- <a class="rail-item tree-entry" href=(href) data-kb-row="" aria-current=((current.as_deref() == Some(row.name.as_str())).then_some("page"))>348+ <a class="rail-item tree-entry" href=(href) data-kb-row="" data-name=(row.name.clone()) aria-current=((current.as_deref() == Some(row.name.as_str())).then_some("page"))>
348 <span class="sr-only">(g::kind_label(lang, row.kind))</span>349 <span class="sr-only">(g::kind_label(lang, row.kind))</span>
349 <span class="nm dir">(row.name)if row.kind == "dir" { "/" }</span>350 <span class="nm dir">(row.name)if row.kind == "dir" { "/" }</span>
350- if let Some(last) = row.last {
351- <time class="val" data-rel="true" datetime=(last.iso) title=(last.absolute)>(last.age)</time>
352- }
353 </a>351 </a>
354 } else {352 } else {
355 <div class="rail-item tree-entry" data-kb-row="">353 <div class="rail-item tree-entry" data-kb-row="">
@@ -455,8 +453,7 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
455 .map(|e| e.name)453 .map(|e| e.name)
456 .collect()454 .collect()
457 };455 };
458- let (last, bar, strip, runs) = tokio::join!(456+ let (bar, strip, runs) = tokio::join!(
459- last_commits(state, &ctx.path, &commit, &dir, &names),
460 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),457 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),
461 commit_strip(state, repo, &ctx.path, &commit),458 commit_strip(state, repo, &ctx.path, &commit),
462 run_rows(state, lang, repo),459 run_rows(state, lang, repo),
@@ -467,16 +464,8 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
467 let sub = code_sub(lang, bar, Some(facts), None, strip.total);464 let sub = code_sub(lang, bar, Some(facts), None, strip.total);
468 let refs: Vec<RefInfo> = load_refs(ctx.path.clone()).await?;465 let refs: Vec<RefInfo> = load_refs(ctx.path.clone()).await?;
469 let readme = load_readme(state, repo, &ctx.path, &ref_name, &commit, &dir, &entries).await?;466 let readme = load_readme(state, repo, &ctx.path, &ref_name, &commit, &dir, &entries).await?;
470- let rows = entry_rows(467+ let rows = entry_rows(repo, &ref_name, &dir, entries);
471- lang,468+ let ages = ages_url(repo, &commit, &dir);
472- repo,
473- &ref_name,
474- &dir,
475- entries,
476- &last,
477- now_unix(),
478- ctx.viewer_tz(),
479- );
480 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);469 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);
481 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");470 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");
482 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");471 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");
@@ -507,7 +496,7 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
507 <a class="act code-search-act" href=(code_search_href)>(g::t(lang, K::SearchCodePlaceholder))</a>496 <a class="act code-search-act" href=(code_search_href)>(g::t(lang, K::SearchCodePlaceholder))</a>
508 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)497 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)
509 </div>498 </div>
510- tree_table(rows: rows, lang: lang, current: readme_file)499+ tree_table(rows: rows, lang: lang, ages: ages, current: readme_file)
511 </nav>500 </nav>
512 readme_sheet(lang: lang, owner: dock_owner, repo: dock_repo, ref_name: ref_name.clone(), dir: dir.clone(), readme: readme,501 readme_sheet(lang: lang, owner: dock_owner, repo: dock_repo, ref_name: ref_name.clone(), dir: dir.clone(), readme: readme,
513 none: s(lang, "No README in this folder", "Bu klasörde README yok"))502 none: s(lang, "No README in this folder", "Bu klasörde README yok"))
crates/forge-web-repo/src/pages/blob.rsmodified+6 -15
@@ -19,14 +19,14 @@ use crate::pages::repo::repo_head;
19 use crate::pages::repo_ctx::load_repo;19 use crate::pages::repo_ctx::load_repo;
20 use crate::pages::repo_side::{code_sub, commit_strip, run_pips, run_rows, tree_facts};20 use crate::pages::repo_side::{code_sub, commit_strip, run_pips, run_rows, tree_facts};
21 use crate::pages::tree::{21 use crate::pages::tree::{
22- entry_rows, last_commits, latest_bar, link_context, read_dir, read_file, resolve, tree_table,22+ ages_url, entry_rows, latest_bar, link_context, read_dir, read_file, resolve, tree_table,
23 };23 };
24 use crate::raw::media::media_url;24 use crate::raw::media::media_url;
25 use crate::raw::raw_url;25 use crate::raw::raw_url;
26 use crate::render::highlight::highlight_lines;26 use crate::render::highlight::highlight_lines;
27 use crate::render::markdown::render_markdown;27 use crate::render::markdown::render_markdown;
28 use crate::state::AppState;28 use crate::state::AppState;
29-use crate::views::{human_size, now_unix, ref_selector, repo_href, shell};29+use crate::views::{human_size, ref_selector, repo_href, shell};
30 30
31 const IMAGE_EXTS: [&str; 8] = ["png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico"];31 const IMAGE_EXTS: [&str; 8] = ["png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico"];
32 const MARKDOWN_EXTS: [&str; 2] = ["md", "markdown"];32 const MARKDOWN_EXTS: [&str; 2] = ["md", "markdown"];
@@ -256,8 +256,7 @@ async fn blob_page(cx: &Cx) -> Result<impl View> {
256 .map(|e| e.name)256 .map(|e| e.name)
257 .collect()257 .collect()
258 };258 };
259- let (last, bar, strip, runs) = tokio::join!(259+ let (bar, strip, runs) = tokio::join!(
260- last_commits(state, &ctx.path, &commit, &dir, &names),
261 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),260 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),
262 commit_strip(state, repo, &ctx.path, &commit),261 commit_strip(state, repo, &ctx.path, &commit),
263 run_rows(state, lang, repo),262 run_rows(state, lang, repo),
@@ -269,16 +268,8 @@ async fn blob_page(cx: &Cx) -> Result<impl View> {
269 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);268 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);
270 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");269 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");
271 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");270 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");
272- let rows = entry_rows(271+ let rows = entry_rows(repo, &ref_name, &dir, siblings);
273- lang,272+ let ages = ages_url(repo, &commit, &dir);
274- repo,
275- &ref_name,
276- &dir,
277- siblings,
278- &last,
279- now_unix(),
280- ctx.viewer_tz(),
281- );
282 let mut header = ctx.head(state, "code").await?;273 let mut header = ctx.head(state, "code").await?;
283 header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name);274 header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name);
284 let size = human_size(lang, blob.size);275 let size = human_size(lang, blob.size);
@@ -299,7 +290,7 @@ async fn blob_page(cx: &Cx) -> Result<impl View> {
299 branches_href: branches_href, tags_href: tags_href)290 branches_href: branches_href, tags_href: tags_href)
300 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)291 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)
301 </div>292 </div>
302- tree_table(rows: rows, lang: lang, current: Some(file_name.clone()))293+ tree_table(rows: rows, lang: lang, ages: ages, current: Some(file_name.clone()))
303 </nav>294 </nav>
304 <div class="sheet">295 <div class="sheet">
305 <div class="sheet-tools">296 <div class="sheet-tools">
crates/forge-web-repo/src/pages/repo_scrub.rsmodified+3 -12
@@ -1,4 +1,4 @@
1-use std::collections::{HashMap, VecDeque};1+use std::collections::VecDeque;
2 use std::path::PathBuf;2 use std::path::PathBuf;
3 use std::sync::{Arc, Mutex};3 use std::sync::{Arc, Mutex};
4 4
@@ -16,7 +16,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo};
16 use crate::pages::tree::{entry_rows, load_readme, read_dir, readme_card};16 use crate::pages::tree::{entry_rows, load_readme, read_dir, readme_card};
17 use crate::state::AppState;17 use crate::state::AppState;
18 use crate::views::parts::{SubPart, head};18 use crate::views::parts::{SubPart, head};
19-use crate::views::{now_unix, shell};19+use crate::views::shell;
20 20
21 const CACHE_CAP: usize = 64;21 const CACHE_CAP: usize = 64;
22 22
@@ -113,16 +113,7 @@ async fn scrub_parts(state: &AppState, ctx: &RepoCtx, oid: &str) -> Result<Optio
113 return Ok(None);113 return Ok(None);
114 };114 };
115 let readme = load_readme(state, repo, &ctx.path, oid, oid, "", &entries).await?;115 let readme = load_readme(state, repo, &ctx.path, oid, oid, "", &entries).await?;
116- let rows = entry_rows(116+ let rows = entry_rows(repo, oid, "", entries)
117- ctx.lang,
118- repo,
119- oid,
120- "",
121- entries,
122- &HashMap::new(),
123- now_unix(),
124- ctx.viewer_tz(),
125- )
126 .into_iter()117 .into_iter()
127 .map(|row| ScrubRow {118 .map(|row| ScrubRow {
128 kind: row.kind,119 kind: row.kind,
crates/forge-web/assets/nav.jsmodified+43 -0
@@ -6102,3 +6102,46 @@
6102 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); }6102 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); }
6103 else { init(); }6103 else { init(); }
6104 })();6104 })();
6105+
6106+// File ages. A tree list names where its ages come from in data-ages (the commit and the folder), and
6107+// they are asked for after the page shows, so the walk through history never holds the page. A live
6108+// refresh at the same commit gets the same answer, so the last one is put back at once instead of
6109+// the column going blank until the new answer comes.
6110+(function () {
6111+ var last = null;
6112+
6113+ function fill(list, ages) {
6114+ Array.prototype.forEach.call(list.querySelectorAll('.tree-entry[data-name]'), function (row) {
6115+ var age = ages[row.getAttribute('data-name')];
6116+ if (!age || row.querySelector('time')) { return; }
6117+ var el = document.createElement('time');
6118+ el.className = 'val';
6119+ el.setAttribute('data-rel', 'true');
6120+ el.setAttribute('datetime', age.iso);
6121+ el.title = age.absolute;
6122+ el.textContent = age.age;
6123+ row.appendChild(el);
6124+ });
6125+ }
6126+
6127+ function sync() {
6128+ Array.prototype.forEach.call(document.querySelectorAll('.tree-list[data-ages]:not([data-ages-asked])'), function (list) {
6129+ var url = list.getAttribute('data-ages');
6130+ list.setAttribute('data-ages-asked', '');
6131+ if (last && last.url === url) { fill(list, last.ages); return; }
6132+ fetch(url, { credentials: 'same-origin' }).then(function (res) {
6133+ return res.ok ? res.json() : null;
6134+ }).then(function (ages) {
6135+ if (!ages) { return; }
6136+ last = { url: url, ages: ages };
6137+ Array.prototype.forEach.call(document.querySelectorAll('.tree-list[data-ages]'), function (shown) {
6138+ if (shown.getAttribute('data-ages') === url) { fill(shown, ages); }
6139+ });
6140+ }).catch(function () { });
6141+ });
6142+ }
6143+
6144+ document.addEventListener('forge:swapped', sync);
6145+ if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', sync); }
6146+ else { sync(); }
6147+})();
crates/forge-web/src/routes.snapmodified+1 -0
@@ -293,6 +293,7 @@ route /settings/tokens/delete Only([POST])
293 route /theme/custom.css Only([GET])293 route /theme/custom.css Only([GET])
294 route /users/{username}/events Only([GET])294 route /users/{username}/events Only([GET])
295 route /{owner}/{repo} Any295 route /{owner}/{repo} Any
296+route /{owner}/{repo}/ages/{*rest} Only([GET])
296 route /{owner}/{repo}/archive/{*rest} Only([GET])297 route /{owner}/{repo}/archive/{*rest} Only([GET])
297 route /{owner}/{repo}/attachments Only([POST])298 route /{owner}/{repo}/attachments Only([POST])
298 route /{owner}/{repo}/badge.svg Only([GET])299 route /{owner}/{repo}/badge.svg Only([GET])