forge
Explore
Log in

Don't you dare go Hollow

Revert "⚡ 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"

Browse files at this commit

0a411966bff31048a7ff5fcb14f16fab36340eceAhmet Kaan GümüşParent: 37e985d
This reverts commit 37e985d7446f13ea8d71da4ff0e8d2d11d64a25f.
crates/forge-web-pages/src/pages/repo.rsmodified+17 -6
@@ -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- ages_url, entry_rows, latest_bar, load_readme, read_dir, readme_sheet, tree_table,26+ entry_rows, last_commits, 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,7 +383,6 @@ 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();
387 let mut readme = None;386 let mut readme = None;
388 let mut bar = None;387 let mut bar = None;
389 let mut facts = None;388 let mut facts = None;
@@ -392,10 +391,22 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
392 {391 {
393 let names: Vec<String> = entries.iter().map(|e| e.name.clone()).collect();392 let names: Vec<String> = entries.iter().map(|e| e.name.clone()).collect();
394 facts = Some(tree_facts(state, repo, &ctx.path, commit, &names).await?);393 facts = Some(tree_facts(state, repo, &ctx.path, commit, &names).await?);
395- bar = latest_bar(state, repo, &ctx.path, commit, lang, ctx.viewer_tz()).await;394+ let (last, latest) = tokio::join!(
396- ages = ages_url(repo, commit, "");395+ last_commits(state, &ctx.path, commit, "", &names),
396+ latest_bar(state, repo, &ctx.path, commit, lang, ctx.viewer_tz()),
397+ );
398+ bar = latest;
397 readme = load_readme(state, repo, &ctx.path, &branch, commit, "", &entries).await?;399 readme = load_readme(state, repo, &ctx.path, &branch, commit, "", &entries).await?;
398- tree = Some(entry_rows(repo, &branch, "", entries));400+ tree = Some(entry_rows(
401+ lang,
402+ repo,
403+ &branch,
404+ "",
405+ entries,
406+ &last,
407+ now_unix(),
408+ ctx.viewer_tz(),
409+ ));
399 }410 }
400 let follows = follows_branch(&refs, &branch);411 let follows = follows_branch(&refs, &branch);
401 let live = home_live_url(&repo.owner_name, &repo.name, &branch);412 let live = home_live_url(&repo.owner_name, &repo.name, &branch);
@@ -436,7 +447,7 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
436 file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),447 file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),
437 ref_name: branch.clone())448 ref_name: branch.clone())
438 </div>449 </div>
439- tree_table(rows: rows, lang: lang, ages: ages.clone(), current: readme_file)450+ tree_table(rows: rows, lang: lang, current: readme_file)
440 </nav>451 </nav>
441 readme_sheet(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), ref_name: branch.clone(), dir: String::new(), readme: readme,452 readme_sheet(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), ref_name: branch.clone(), dir: String::new(), readme: readme,
442 none: s(lang, "No README yet", "Henüz README yok"))453 none: s(lang, "No README yet", "Henüz README yok"))
crates/forge-web-pages/src/pages/tree.rsmodified+57 -46
@@ -1,5 +1,6 @@
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};
3 use std::time::Duration;4 use std::time::Duration;
4 5
5 use forge_core::Repo as RepoRow;6 use forge_core::Repo as RepoRow;
@@ -9,8 +10,7 @@ use forge_git::history;
9 use topcoat::Result;10 use topcoat::Result;
10 use topcoat::context::{Cx, context};11 use topcoat::context::{Cx, context};
11 use topcoat::router::error::not_found;12 use topcoat::router::error::not_found;
12-use topcoat::router::response::Response;13+use topcoat::router::{page, path_param};
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,6 +67,13 @@ 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+
70 pub async fn last_commits(77 pub async fn last_commits(
71 state: &AppState,78 state: &AppState,
72 path: &Path,79 path: &Path,
@@ -74,9 +81,22 @@ pub async fn last_commits(
74 dir: &str,81 dir: &str,
75 names: &[String],82 names: &[String],
76 ) -> HashMap<String, CommitInfo> {83 ) -> 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+ }
77 let walk = history::last_commits(&state.git, path, commit, dir, names, LAST_COMMIT_WALK);90 let walk = history::last_commits(&state.git, path, commit, dir, names, LAST_COMMIT_WALK);
78 match tokio::time::timeout(LAST_COMMIT_TIMEOUT, walk).await {91 match tokio::time::timeout(LAST_COMMIT_TIMEOUT, walk).await {
79- Ok(Ok(map)) => map,92+ Ok(Ok(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+ }
80 Ok(Err(e)) => {100 Ok(Err(e)) => {
81 tracing::warn!(error = %e, "last-commit walk failed");101 tracing::warn!(error = %e, "last-commit walk failed");
82 HashMap::new()102 HashMap::new()
@@ -152,9 +172,20 @@ pub struct EntryRow {
152 pub name: String,172 pub name: String,
153 pub href: Option<String>,173 pub href: Option<String>,
154 pub short: String,174 pub short: String,
175+ pub last: Option<LastCommit>,
155 }176 }
156 177
157-pub fn entry_rows(repo: &RepoRow, ref_name: &str, dir: &str, entries: Vec<TreeEntry>) -> Vec<EntryRow> {178+#[allow(clippy::too_many_arguments)]
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> {
158 entries189 entries
159 .into_iter()190 .into_iter()
160 .map(|entry| {191 .map(|entry| {
@@ -175,11 +206,15 @@ pub fn entry_rows(repo: &RepoRow, ref_name: &str, dir: &str, entries: Vec<TreeEn
175 EntryKind::Symlink => ("link", blob_href(repo, ref_name, &rel), String::new()),206 EntryKind::Symlink => ("link", blob_href(repo, ref_name, &rel), String::new()),
176 EntryKind::Submodule => ("submodule", None, short_oid(&entry.oid).to_owned()),207 EntryKind::Submodule => ("submodule", None, short_oid(&entry.oid).to_owned()),
177 };208 };
209+ let last = last
210+ .get(&entry.name)
211+ .map(|c| last_commit_view(lang, repo, c, now, tz));
178 EntryRow {212 EntryRow {
179 kind,213 kind,
180 name: entry.name,214 name: entry.name,
181 href,215 href,
182 short,216 short,
217+ last,
183 }218 }
184 })219 })
185 .collect()220 .collect()
@@ -231,41 +266,6 @@ fn blob_href(repo: &RepoRow, ref_name: &str, rel: &str) -> Option<String> {
231 ))266 ))
232 }267 }
233 268
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,16 +338,18 @@ 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,
342 #[default] current: Option<String>,341 #[default] current: Option<String>,
343 ) -> Result<impl View> {342 ) -> Result<impl View> {
344 Ok(view! {343 Ok(view! {
345- <div class="rail-list tree-list" data-ages=(ages)>344+ <div class="rail-list tree-list">
346 for row in rows.into_iter() {345 for row in rows.into_iter() {
347 if let Some(href) = row.href {346 if let Some(href) = row.href {
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"))>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"))>
349 <span class="sr-only">(g::kind_label(lang, row.kind))</span>348 <span class="sr-only">(g::kind_label(lang, row.kind))</span>
350 <span class="nm dir">(row.name)if row.kind == "dir" { "/" }</span>349 <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+ }
351 </a>353 </a>
352 } else {354 } else {
353 <div class="rail-item tree-entry" data-kb-row="">355 <div class="rail-item tree-entry" data-kb-row="">
@@ -453,7 +455,8 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
453 .map(|e| e.name)455 .map(|e| e.name)
454 .collect()456 .collect()
455 };457 };
456- let (bar, strip, runs) = tokio::join!(458+ let (last, bar, strip, runs) = tokio::join!(
459+ last_commits(state, &ctx.path, &commit, &dir, &names),
457 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),460 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),
458 commit_strip(state, repo, &ctx.path, &commit),461 commit_strip(state, repo, &ctx.path, &commit),
459 run_rows(state, lang, repo),462 run_rows(state, lang, repo),
@@ -464,8 +467,16 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
464 let sub = code_sub(lang, bar, Some(facts), None, strip.total);467 let sub = code_sub(lang, bar, Some(facts), None, strip.total);
465 let refs: Vec<RefInfo> = load_refs(ctx.path.clone()).await?;468 let refs: Vec<RefInfo> = load_refs(ctx.path.clone()).await?;
466 let readme = load_readme(state, repo, &ctx.path, &ref_name, &commit, &dir, &entries).await?;469 let readme = load_readme(state, repo, &ctx.path, &ref_name, &commit, &dir, &entries).await?;
467- let rows = entry_rows(repo, &ref_name, &dir, entries);470+ let rows = entry_rows(
468- let ages = ages_url(repo, &commit, &dir);471+ lang,
472+ repo,
473+ &ref_name,
474+ &dir,
475+ entries,
476+ &last,
477+ now_unix(),
478+ ctx.viewer_tz(),
479+ );
469 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);480 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);
470 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");481 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");
471 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");482 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");
@@ -496,7 +507,7 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
496 <a class="act code-search-act" href=(code_search_href)>(g::t(lang, K::SearchCodePlaceholder))</a>507 <a class="act code-search-act" href=(code_search_href)>(g::t(lang, K::SearchCodePlaceholder))</a>
497 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)508 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)
498 </div>509 </div>
499- tree_table(rows: rows, lang: lang, ages: ages, current: readme_file)510+ tree_table(rows: rows, lang: lang, current: readme_file)
500 </nav>511 </nav>
501 readme_sheet(lang: lang, owner: dock_owner, repo: dock_repo, ref_name: ref_name.clone(), dir: dir.clone(), readme: readme,512 readme_sheet(lang: lang, owner: dock_owner, repo: dock_repo, ref_name: ref_name.clone(), dir: dir.clone(), readme: readme,
502 none: s(lang, "No README in this folder", "Bu klasörde README yok"))513 none: s(lang, "No README in this folder", "Bu klasörde README yok"))
crates/forge-web-repo/src/pages/blob.rsmodified+15 -6
@@ -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- ages_url, entry_rows, latest_bar, link_context, read_dir, read_file, resolve, tree_table,22+ entry_rows, last_commits, 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, ref_selector, repo_href, shell};29+use crate::views::{human_size, now_unix, 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,7 +256,8 @@ 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 (bar, strip, runs) = tokio::join!(259+ let (last, bar, strip, runs) = tokio::join!(
260+ last_commits(state, &ctx.path, &commit, &dir, &names),
260 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),261 latest_bar(state, repo, &ctx.path, &commit, lang, ctx.viewer_tz()),
261 commit_strip(state, repo, &ctx.path, &commit),262 commit_strip(state, repo, &ctx.path, &commit),
262 run_rows(state, lang, repo),263 run_rows(state, lang, repo),
@@ -268,8 +269,16 @@ async fn blob_page(cx: &Cx) -> Result<impl View> {
268 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);269 let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);
269 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");270 let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");
270 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");271 let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");
271- let rows = entry_rows(repo, &ref_name, &dir, siblings);272+ let rows = entry_rows(
272- let ages = ages_url(repo, &commit, &dir);273+ lang,
274+ repo,
275+ &ref_name,
276+ &dir,
277+ siblings,
278+ &last,
279+ now_unix(),
280+ ctx.viewer_tz(),
281+ );
273 let mut header = ctx.head(state, "code").await?;282 let mut header = ctx.head(state, "code").await?;
274 header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name);283 header.live = live_url(&repo.owner_name, &repo.name, &refs, &ref_name);
275 let size = human_size(lang, blob.size);284 let size = human_size(lang, blob.size);
@@ -290,7 +299,7 @@ async fn blob_page(cx: &Cx) -> Result<impl View> {
290 branches_href: branches_href, tags_href: tags_href)299 branches_href: branches_href, tags_href: tags_href)
291 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)300 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)
292 </div>301 </div>
293- tree_table(rows: rows, lang: lang, ages: ages, current: Some(file_name.clone()))302+ tree_table(rows: rows, lang: lang, current: Some(file_name.clone()))
294 </nav>303 </nav>
295 <div class="sheet">304 <div class="sheet">
296 <div class="sheet-tools">305 <div class="sheet-tools">
crates/forge-web-repo/src/pages/repo_scrub.rsmodified+12 -3
@@ -1,4 +1,4 @@
1-use std::collections::VecDeque;1+use std::collections::{HashMap, 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::shell;19+use crate::views::{now_unix, shell};
20 20
21 const CACHE_CAP: usize = 64;21 const CACHE_CAP: usize = 64;
22 22
@@ -113,7 +113,16 @@ 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(repo, oid, "", entries)116+ let rows = entry_rows(
117+ ctx.lang,
118+ repo,
119+ oid,
120+ "",
121+ entries,
122+ &HashMap::new(),
123+ now_unix(),
124+ ctx.viewer_tz(),
125+ )
117 .into_iter()126 .into_iter()
118 .map(|row| ScrubRow {127 .map(|row| ScrubRow {
119 kind: row.kind,128 kind: row.kind,
crates/forge-web/assets/nav.jsmodified+0 -43
@@ -6102,46 +6102,3 @@
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+0 -1
@@ -293,7 +293,6 @@ 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])
297 route /{owner}/{repo}/archive/{*rest} Only([GET])296 route /{owner}/{repo}/archive/{*rest} Only([GET])
298 route /{owner}/{repo}/attachments Only([POST])297 route /{owner}/{repo}/attachments Only([POST])
299 route /{owner}/{repo}/badge.svg Only([GET])298 route /{owner}/{repo}/badge.svg Only([GET])