forge
Explore
Log in

Don't you dare go Hollow

Sage on Ink is the default look for light and dark, listed first, and backgrounds and accents of one hue share a column (Ink and Sage, Anvil and Ember, Dusk and Ocean, Heather and Plum, Blush and Rose)

Browse files at this commit

9b600b7da77301410fbc673f6f945d25df7cbbe4Ahmet Kaan GümüşParent: f708a8c
All checks have passed
Show checks
  • style
    • Sage on Ink is the default look for light and dark, listed first, and backgrounds and accents of one hue share a column (Ink and Sage, Anvil and Ember, Dusk and Ocean, Heather and Plum, Blush and Rose)
    • every action beside a page title is the same soft pill, links and reveals included
    • the snippet form's files are a choice switch with a Files label, and the new repository mirror reveal starts on the controls' edge
    • an export archive is one flat line on the sheet's edge ✨ feat: every list that can grow has one live search with Exact and Aa beside it, forgiving typos and case by default (audit logs, admin users, replication, explore, a profile's repositories, server settings, and the CI log's find)
    • placeholders name what each tab searches
    • replication, explore and admin users are paged
    • the audit log folds runs of one action by one person whatever the target, opens each fold in place to show every entry, and counts folded lines per page
    • a numbered pager always keeps Previous, Next and seven page slots in place
    • Explore has Repositories and Organizations tabs
    • an export can be deleted
    • regenerating recovery codes asks for the password and a code
    • new repository, import, import history, new organization and your snippets show your profile tabs with counts, the import source is a choice in its form, and Notifications, Needs you and Review requests share one rail 🐛 fix: Send the verification link again shows only when mail can be sent
    • letter avatars are drawn in the page, so lists of people and organizations no longer wait on image requests
    • the replication filter and search options sit on the field's line
    • a removed accent or background moves to the default ✅ test: measure.ts treats a list search as a tools row
Show full message
💄 style: Sage on Ink is the default look for light and dark, listed first, and backgrounds and accents of one hue share a column (Ink and Sage, Anvil and Ember, Dusk and Ocean, Heather and Plum, Blush and Rose); every action beside a page title is the same soft pill, links and reveals included; the snippet form's files are a choice switch with a Files label, and the new repository mirror reveal starts on the controls' edge; an export archive is one flat line on the sheet's edge ✨ feat: every list that can grow has one live search with Exact and Aa beside it, forgiving typos and case by default (audit logs, admin users, replication, explore, a profile's repositories, server settings, and the CI log's find); placeholders name what each tab searches; replication, explore and admin users are paged; the audit log folds runs of one action by one person whatever the target, opens each fold in place to show every entry, and counts folded lines per page; a numbered pager always keeps Previous, Next and seven page slots in place; Explore has Repositories and Organizations tabs; an export can be deleted; regenerating recovery codes asks for the password and a code; new repository, import, import history, new organization and your snippets show your profile tabs with counts, the import source is a choice in its form, and Notifications, Needs you and Review requests share one rail 🐛 fix: Send the verification link again shows only when mail can be sent; letter avatars are drawn in the page, so lists of people and organizations no longer wait on image requests; the replication filter and search options sit on the field's line; a removed accent or background moves to the default ✅ test: measure.ts treats a list search as a tools row

45 changed files +2109 -701

crates/forge-core/migrations/0073_sage_ink_default.sqladded+21 -0
@@ -0,0 +1,21 @@
1+-- Sage on Ink becomes the look of a new account. An account that never chose its colours moves
2+-- with the default; one that chose keeps its choice. The Fern and Graphite bases are gone, so an
3+-- account that chose one moves to Ink. SQLite cannot change a column's default in place, so each
4+-- column is replaced.
5+ALTER TABLE users RENAME COLUMN accent TO accent_old;
6+ALTER TABLE users RENAME COLUMN accent_dark TO accent_dark_old;
7+ALTER TABLE users RENAME COLUMN base_light TO base_light_old;
8+ALTER TABLE users RENAME COLUMN base_dark TO base_dark_old;
9+ALTER TABLE users ADD COLUMN accent TEXT NOT NULL DEFAULT 'sage';
10+ALTER TABLE users ADD COLUMN accent_dark TEXT NOT NULL DEFAULT 'sage';
11+ALTER TABLE users ADD COLUMN base_light TEXT NOT NULL DEFAULT 'ink';
12+ALTER TABLE users ADD COLUMN base_dark TEXT NOT NULL DEFAULT 'ink';
13+UPDATE users SET accent = accent_old, accent_dark = accent_dark_old,
14+ base_light = CASE WHEN base_light_old IN ('fern', 'graphite') THEN 'ink' ELSE base_light_old END,
15+ base_dark = CASE WHEN base_dark_old IN ('fern', 'graphite') THEN 'ink' ELSE base_dark_old END
16+WHERE NOT (accent_old = 'ember' AND accent_dark_old = 'ember'
17+ AND base_light_old = 'anvil' AND base_dark_old = 'anvil');
18+ALTER TABLE users DROP COLUMN accent_old;
19+ALTER TABLE users DROP COLUMN accent_dark_old;
20+ALTER TABLE users DROP COLUMN base_light_old;
21+ALTER TABLE users DROP COLUMN base_dark_old;
crates/forge-core/src/model.rsmodified+4 -4
@@ -48,13 +48,13 @@ pub struct User {
4848 /// Language code, e.g. "en"; "auto" uses the instance default.
4949 pub language: String,
5050 /// Accent colour for the light theme: the id of a palette in forge-web's `accent_palette.rs`.
51- /// "ember" is the default.
51+ /// "sage" is the default.
5252 pub accent: String,
53- /// Accent colour for the dark theme, chosen separately from `accent`. "ember" is the default.
53+ /// Accent colour for the dark theme, chosen separately from `accent`. "sage" is the default.
5454 pub accent_dark: String,
55- /// Base (neutral background, surface and text) set for the light theme. "anvil" is the default.
55+ /// Base (neutral background, surface and text) set for the light theme. "ink" is the default.
5656 pub base_light: String,
57- /// Base set for the dark theme. "anvil" is the default.
57+ /// Base set for the dark theme. "ink" is the default.
5858 pub base_dark: String,
5959 /// Which side the main shell sidebar sits on: "left" (the default) or "right".
6060 pub sidebar_side: String,
crates/forge-core/src/store/migrate.rsmodified+1 -0
@@ -118,6 +118,7 @@ pub const MIGRATIONS: &[(u32, &str)] = &[
118118 ),
119119 (71, include_str!("../../migrations/0071_ci_job_steps.sql")),
120120 (72, include_str!("../../migrations/0072_ember_anvil_default.sql")),
121+ (73, include_str!("../../migrations/0073_sage_ink_default.sql")),
121122 ];
122123
123124 /// The highest migration version this binary knows about.
crates/forge-core/src/store/ui_prefs.rsmodified+7 -7
@@ -15,11 +15,11 @@ pub const AUTO: &str = "auto";
1515
1616 /// The accent colour a new user gets. It must match the default palette in forge-web's
1717 /// `accent_palette.rs`, which a test there checks.
18-pub const DEFAULT_ACCENT: &str = "ember";
18+pub const DEFAULT_ACCENT: &str = "sage";
1919
2020 /// The base colour set a new user gets, for both themes. It must match the default base in
2121 /// forge-web's `accent_palette.rs`, which a test there checks.
22-pub const DEFAULT_BASE: &str = "anvil";
22+pub const DEFAULT_BASE: &str = "ink";
2323
2424 /// The sidebar sides, in the order the settings page lists them.
2525 pub const SIDEBAR_SIDES: &[&str] = &["left", "right"];
@@ -263,7 +263,7 @@ mod tests {
263263 assert_eq!(user.base_light, DEFAULT_BASE, "case colours default");
264264 assert_eq!(user.base_dark, DEFAULT_BASE, "case colours default");
265265 store
266- .set_colours(&user.id, "ocean", "rose", "graphite", "ink")
266+ .set_colours(&user.id, "ocean", "rose", "heather", "ink")
267267 .await
268268 .unwrap();
269269 let stored = store.user_by_id(&user.id).await.unwrap().unwrap();
@@ -274,12 +274,12 @@ mod tests {
274274 stored.base_light.as_str(),
275275 stored.base_dark.as_str()
276276 ),
277- ("ocean", "rose", "graphite", "ink"),
277+ ("ocean", "rose", "heather", "ink"),
278278 "case colours persisted"
279279 );
280280 assert!(
281281 store
282- .set_colours(&user.id, "ocean", "Rose", "graphite", "ink")
282+ .set_colours(&user.id, "ocean", "Rose", "heather", "ink")
283283 .await
284284 .is_err(),
285285 "case colours casing"
@@ -293,7 +293,7 @@ mod tests {
293293 );
294294 assert!(
295295 store
296- .set_colours(&user.id, "ocean", "rose", "graphite", "")
296+ .set_colours(&user.id, "ocean", "rose", "heather", "")
297297 .await
298298 .is_err(),
299299 "case colours empty"
@@ -306,7 +306,7 @@ mod tests {
306306 still.base_light.as_str(),
307307 still.base_dark.as_str()
308308 ),
309- ("ocean", "rose", "graphite", "ink"),
309+ ("ocean", "rose", "heather", "ink"),
310310 "case colours unchanged"
311311 );
312312
crates/forge-e2e/tests/e2e/ui_prefs_e2e.rsmodified+11 -11
@@ -230,7 +230,7 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() {
230230 let session = login(&env.http, "tahinli", PW).await;
231231
232232 let page = env.http.get("/settings/appearance", Some(&session)).await;
233- let defaults = ["ember", "ember", "anvil", "anvil"].map(str::to_owned);
233+ let defaults = ["sage", "sage", "ink", "ink"].map(str::to_owned);
234234 assert_eq!(checked_colours(&page.body), defaults.clone().map(Some));
235235 assert_eq!(html_colours(&page.body), defaults.map(Some));
236236 let csrf = input_value(&page.body, "csrf");
@@ -267,14 +267,14 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() {
267267 ("csrf", &csrf),
268268 ("theme", "light"),
269269 ("language", "en"),
270- ("base_dark", "graphite"),
270+ ("base_dark", "heather"),
271271 ],
272272 Some(&session),
273273 )
274274 .await;
275275 assert_eq!(saved.status, 303, "save: {}", saved.body);
276276 let page = env.http.get("/settings/appearance", Some(&session)).await;
277- let chosen = ["ocean", "plum", "ink", "graphite"].map(str::to_owned);
277+ let chosen = ["ocean", "plum", "ink", "heather"].map(str::to_owned);
278278 assert_eq!(checked_colours(&page.body), chosen.clone().map(Some));
279279 assert_eq!(html_colours(&page.body), chosen.map(Some));
280280
@@ -300,7 +300,7 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() {
300300 assert_ne!(res.status, 303, "bad {field} {bad:?} must not save");
301301 }
302302 let page = env.http.get("/settings/appearance", Some(&session)).await;
303- let chosen = ["ocean", "plum", "ink", "graphite"].map(str::to_owned);
303+ let chosen = ["ocean", "plum", "ink", "heather"].map(str::to_owned);
304304 assert_eq!(checked_colours(&page.body), chosen.clone().map(Some));
305305 assert_eq!(html_colours(&page.body), chosen.map(Some));
306306
@@ -315,7 +315,7 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() {
315315 ("language", "tr"),
316316 ("accent_light", "hue-200"),
317317 ("accent_dark", "rose"),
318- ("base_light", "graphite"),
318+ ("base_light", "heather"),
319319 ("base_dark", "dusk"),
320320 ],
321321 Some(&session),
@@ -324,9 +324,9 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() {
324324 assert_eq!(saved.status, 303, "save: {}", saved.body);
325325 let page = env.http.get("/settings/appearance", Some(&session)).await;
326326 // The Custom radio carries the hue at the default vividness; the stored id stays `hue-200`.
327- let checked = ["hue-200-v50", "rose", "graphite", "dusk"].map(str::to_owned);
327+ let checked = ["hue-200-v50", "rose", "heather", "dusk"].map(str::to_owned);
328328 assert_eq!(checked_colours(&page.body), checked.map(Some));
329- let chosen = ["hue-200", "rose", "graphite", "dusk"].map(str::to_owned);
329+ let chosen = ["hue-200", "rose", "heather", "dusk"].map(str::to_owned);
330330 assert_eq!(html_colours(&page.body), chosen.map(Some));
331331
332332 // The newest accents and backgrounds save and show the same way.
@@ -341,14 +341,14 @@ async fn light_and_dark_colours_save_independently_and_render_on_html() {
341341 ("accent_light", "sage"),
342342 ("accent_dark", "ocean"),
343343 ("base_light", "ink"),
344- ("base_dark", "graphite"),
344+ ("base_dark", "heather"),
345345 ],
346346 Some(&session),
347347 )
348348 .await;
349349 assert_eq!(saved.status, 303, "save: {}", saved.body);
350350 let page = env.http.get("/settings/appearance", Some(&session)).await;
351- let chosen = ["sage", "ocean", "ink", "graphite"].map(str::to_owned);
351+ let chosen = ["sage", "ocean", "ink", "heather"].map(str::to_owned);
352352 assert_eq!(checked_colours(&page.body), chosen.clone().map(Some));
353353 assert_eq!(html_colours(&page.body), chosen.map(Some));
354354 }
@@ -370,7 +370,7 @@ async fn a_save_without_colour_fields_keeps_the_stored_colours() {
370370 ("language", "en"),
371371 ("accent_light", "rose"),
372372 ("accent_dark", "ocean"),
373- ("base_light", "fern"),
373+ ("base_light", "blush"),
374374 ("base_dark", "dusk"),
375375 ],
376376 Some(&session),
@@ -378,7 +378,7 @@ async fn a_save_without_colour_fields_keeps_the_stored_colours() {
378378 .await;
379379 assert_eq!(saved.status, 303, "save: {}", saved.body);
380380 let before = env.http.get("/settings/appearance", Some(&session)).await;
381- let stored = ["rose", "ocean", "fern", "dusk"].map(str::to_owned);
381+ let stored = ["rose", "ocean", "blush", "dusk"].map(str::to_owned);
382382 assert_eq!(html_colours(&before.body), stored.clone().map(Some));
383383
384384 let saved = env
crates/forge-web-base/src/accent.rsmodified+13 -12
@@ -310,11 +310,11 @@ mod tests {
310310 fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() {
311311 assert_eq!(
312312 ids().collect::<Vec<_>>(),
313- ["ember", "sage", "ocean", "plum", "rose"]
313+ ["sage", "ember", "ocean", "plum", "rose"]
314314 );
315315 assert_eq!(
316316 base_ids().collect::<Vec<_>>(),
317- ["anvil", "fern", "graphite", "dusk", "ink"]
317+ ["ink", "anvil", "dusk", "heather", "blush"]
318318 );
319319 for id in [
320320 "ochre",
@@ -327,7 +327,7 @@ mod tests {
327327 ] {
328328 assert!(!is_offered(id), "{id}");
329329 }
330- for id in ["stone", "mist", "Fern", "dune", "slate-blue", "spark"] {
330+ for id in ["stone", "mist", "fern", "graphite", "dune", "slate-blue", "spark"] {
331331 assert!(!is_offered_base(id), "{id}");
332332 }
333333 }
@@ -345,7 +345,8 @@ mod tests {
345345 assert_eq!(resolve_base("ink").id, "ink");
346346 assert_eq!(resolve_base("removed-base").id, BASE_DEFAULT);
347347 assert_eq!(base_id("mist"), BASE_DEFAULT);
348- assert_eq!(base_id("graphite"), "graphite");
348+ assert_eq!(base_id("heather"), "heather");
349+ assert_eq!(base_id("graphite"), BASE_DEFAULT);
349350 }
350351
351352 #[test]
@@ -383,7 +384,7 @@ mod tests {
383384 assert_eq!(preset_accent_hue("plum"), Some(300));
384385 assert_eq!(preset_accent_hue("fern"), None);
385386 assert_eq!(preset_accent_hue("hue-5"), None);
386- assert!(preset_base_hue("fern").is_some());
387+ assert!(preset_base_hue("blush").is_some());
387388 assert!(preset_base_hue("dusk").is_some());
388389 assert_eq!(preset_base_hue("sage"), None);
389390 }
@@ -397,10 +398,10 @@ mod tests {
397398 accent_tokens(215, 50, false).accent
398399 );
399400 assert_eq!(swatch("hue-215", true), accent_tokens(215, 50, true).accent);
400- // A removed id falls back to the default, Ember.
401- assert_eq!(swatch("terracotta", false), swatch("ember", false));
402- let (bg, text) = base_swatch("fern", false);
403- assert_eq!((bg.as_str(), text.as_str()), ("#F6F8F5", "#1E2420"));
401+ // A removed id falls back to the default.
402+ assert_eq!(swatch("terracotta", false), swatch(DEFAULT, false));
403+ let (bg, text) = base_swatch("blush", false);
404+ assert_eq!((bg.as_str(), text.as_str()), ("#F5EBEC", "#2B191C"));
404405 let (bg, text) = base_swatch("hue-215", true);
405406 assert_eq!(bg, base_tokens(215, 30, true).bg);
406407 assert_eq!(text, base_tokens(215, 30, true).text);
@@ -408,10 +409,10 @@ mod tests {
408409
409410 #[test]
410411 fn the_custom_stylesheet_is_linked_only_when_a_hue_is_chosen() {
411- assert_eq!(custom_css_href("sage", "plum", "fern", "ink"), None);
412+ assert_eq!(custom_css_href("sage", "plum", "blush", "ink"), None);
412413 assert_eq!(
413- custom_css_href("hue-215", "plum", "fern", "hue-7").as_deref(),
414- Some("/theme/custom.css?al=hue-215&ad=plum&bl=fern&bd=hue-7")
414+ custom_css_href("hue-215", "plum", "blush", "hue-7").as_deref(),
415+ Some("/theme/custom.css?al=hue-215&ad=plum&bl=blush&bd=hue-7")
415416 );
416417 assert_eq!(
417418 custom_css_href("sage", "sage", "ink", "hue-0").as_deref(),
crates/forge-web-base/src/accent_palette.rsmodified+123 -123
@@ -27,7 +27,7 @@ pub struct Palette {
2727 }
2828
2929 /// The palette used when none is stored, and for anonymous visitors. It must be `PALETTES[0]`.
30-pub const DEFAULT: &str = "ember";
30+pub const DEFAULT: &str = "sage";
3131
3232 /// One token: the custom property it becomes and the field of `Tokens` that holds its value.
3333 pub struct TokenVar {
@@ -83,34 +83,6 @@ pub const TOKEN_VARS: &[TokenVar] = &[
8383 /// here: style/_heatmap.scss mixes them from `--accent`/`--accent-ink` and the base's surface,
8484 /// so they follow every accent and base.
8585 pub const PALETTES: &[Palette] = &[
86- // Ember: iron at working heat, a soft red-orange; copper in light.
87- Palette {
88- id: "ember",
89- light: Tokens {
90- accent: "#B44D1A",
91- accent_ink: "#8F3A12",
92- accent_soft: "#F8E9DF",
93- accent_text: "#FFFFFF",
94- focus: "#8F3A12",
95- public_bg: "#F9E4D6",
96- public_text: "#8F3A12",
97- note: "#8F3A12",
98- hunk_bg: "#FBF0E8",
99- hunk_text: "#883611",
100- },
101- dark: Tokens {
102- accent: "#E8894A",
103- accent_ink: "#FFB27A",
104- accent_soft: "#3A2518",
105- accent_text: "#1A0E06",
106- focus: "#FFB27A",
107- public_bg: "#3A2416",
108- public_text: "#FFC69A",
109- note: "#FFB27A",
110- hunk_bg: "#24180F",
111- hunk_text: "#F0A066",
112- },
113- },
11486 // Sage: the original forge colour.
11587 Palette {
11688 id: "sage",
@@ -141,6 +113,34 @@ pub const PALETTES: &[Palette] = &[
141113 hunk_text: "#B3C385",
142114 },
143115 },
116+ // Ember: iron at working heat, a soft red-orange; copper in light.
117+ Palette {
118+ id: "ember",
119+ light: Tokens {
120+ accent: "#B44D1A",
121+ accent_ink: "#8F3A12",
122+ accent_soft: "#F8E9DF",
123+ accent_text: "#FFFFFF",
124+ focus: "#8F3A12",
125+ public_bg: "#F9E4D6",
126+ public_text: "#8F3A12",
127+ note: "#8F3A12",
128+ hunk_bg: "#FBF0E8",
129+ hunk_text: "#883611",
130+ },
131+ dark: Tokens {
132+ accent: "#E8894A",
133+ accent_ink: "#FFB27A",
134+ accent_soft: "#3A2518",
135+ accent_text: "#1A0E06",
136+ focus: "#FFB27A",
137+ public_bg: "#3A2416",
138+ public_text: "#FFC69A",
139+ note: "#FFB27A",
140+ hunk_bg: "#24180F",
141+ hunk_text: "#F0A066",
142+ },
143+ },
144144 // Blue, clear and cool.
145145 Palette {
146146 id: "ocean",
@@ -253,7 +253,7 @@ pub struct Base {
253253 }
254254
255255 /// The base used when none is stored, and for anonymous visitors. It must be `BASES[0]`.
256-pub const BASE_DEFAULT: &str = "anvil";
256+pub const BASE_DEFAULT: &str = "ink";
257257
258258 /// One base token: the custom property it becomes and the field of `BaseTokens` that holds its
259259 /// value.
@@ -314,9 +314,42 @@ pub const BASE_TOKEN_VARS: &[BaseTokenVar] = &[
314314 },
315315 ];
316316
317-/// Every base on offer, in the order the picker lists them. `fern` is the original forge
318-/// neutral set.
317+/// Every base on offer, in the order the picker lists them: the default first, then each in the
318+/// column of the accent of its hue (Anvil under Ember, Dusk under Ocean, Heather under Plum, Blush
319+/// under Rose). Ink's faint olive tint sits with Sage.
319320 pub const BASES: &[Base] = &[
321+ // Ink: crisp white in light, near-black in dark.
322+ Base {
323+ id: "ink",
324+ light: BaseTokens {
325+ bg: "#FCFCFB",
326+ surface: "#FFFFFF",
327+ surface_2: "#F2F2F0",
328+ text: "#111111",
329+ text_2: "#333333",
330+ muted: "#5F5F5C",
331+ border: "#E3E3E0",
332+ border_strong: "#C9C9C5",
333+ code_bg: "#F2F2F0",
334+ private_bg: "#F2F2F0",
335+ private_text: "#333333",
336+ ln_text: "#5F5F5C",
337+ },
338+ dark: BaseTokens {
339+ bg: "#000000",
340+ surface: "#0B0B0B",
341+ surface_2: "#141414",
342+ text: "#F2F2F0",
343+ text_2: "#CFCFCC",
344+ muted: "#9C9C98",
345+ border: "#242424",
346+ border_strong: "#353535",
347+ code_bg: "#141414",
348+ private_bg: "#141414",
349+ private_text: "#CFCFCC",
350+ ln_text: "#9C9C98",
351+ },
352+ },
320353 // Anvil: warm soot and cooled steel in dark, ash in light.
321354 Base {
322355 id: "anvil",
@@ -349,71 +382,6 @@ pub const BASES: &[Base] = &[
349382 ln_text: "#AAA69D",
350383 },
351384 },
352- // Fern: the original forge neutrals, green-tinted in light and slate in dark.
353- Base {
354- id: "fern",
355- light: BaseTokens {
356- bg: "#F6F8F5",
357- surface: "#FFFFFF",
358- surface_2: "#EEF2EC",
359- text: "#1E2420",
360- text_2: "#3A433D",
361- muted: "#667068",
362- border: "#DDE3DB",
363- border_strong: "#C5CFC3",
364- code_bg: "#EEF2EC",
365- private_bg: "#EEF2EC",
366- private_text: "#3A433D",
367- ln_text: "#646D65",
368- },
369- // Dark is cool slate: a green-tinted near-black looked swampy.
370- dark: BaseTokens {
371- bg: "#131618",
372- surface: "#191D20",
373- surface_2: "#20252A",
374- text: "#E3E8EA",
375- text_2: "#C3CACD",
376- muted: "#96A0A5",
377- border: "#283035",
378- border_strong: "#384146",
379- code_bg: "#1C2125",
380- private_bg: "#20252A",
381- private_text: "#C3CACD",
382- ln_text: "#8A959A",
383- },
384- },
385- // Graphite: a cool neutral grey, flatter than the warmer neutrals.
386- Base {
387- id: "graphite",
388- light: BaseTokens {
389- bg: "#E9EAEC",
390- surface: "#F9FAFB",
391- surface_2: "#DCDEE2",
392- text: "#17191C",
393- text_2: "#33373D",
394- muted: "#5C626B",
395- border: "#CFD3D9",
396- border_strong: "#B5BBC3",
397- code_bg: "#DCDEE2",
398- private_bg: "#DCDEE2",
399- private_text: "#33373D",
400- ln_text: "#545A63",
401- },
402- dark: BaseTokens {
403- bg: "#1A1B1E",
404- surface: "#222428",
405- surface_2: "#2B2D32",
406- text: "#E6E8EB",
407- text_2: "#C8CCD2",
408- muted: "#9499A2",
409- border: "#33363C",
410- border_strong: "#44484F",
411- code_bg: "#2B2D32",
412- private_bg: "#2B2D32",
413- private_text: "#C8CCD2",
414- ln_text: "#9499A2",
415- },
416- },
417385 // Dusk: cool blue-grey, a deeper blue-tinted neutral.
418386 Base {
419387 id: "dusk",
@@ -446,36 +414,68 @@ pub const BASES: &[Base] = &[
446414 ln_text: "#8F9BB0",
447415 },
448416 },
449- // Ink: crisp white in light, near-black in dark.
417+ // Heather: violet-grey, Dusk turned to the hue of Plum.
450418 Base {
451- id: "ink",
419+ id: "heather",
452420 light: BaseTokens {
453- bg: "#FCFCFB",
454- surface: "#FFFFFF",
455- surface_2: "#F2F2F0",
456- text: "#111111",
457- text_2: "#333333",
458- muted: "#5F5F5C",
459- border: "#E3E3E0",
460- border_strong: "#C9C9C5",
461- code_bg: "#F2F2F0",
462- private_bg: "#F2F2F0",
463- private_text: "#333333",
464- ln_text: "#5F5F5C",
421+ bg: "#EEECF4",
422+ surface: "#FAF9FD",
423+ surface_2: "#E4E0EC",
424+ text: "#211B2B",
425+ text_2: "#40384F",
426+ muted: "#665E77",
427+ border: "#D6D1E1",
428+ border_strong: "#BDB6CB",
429+ code_bg: "#E4E0EC",
430+ private_bg: "#E4E0EC",
431+ private_text: "#40384F",
432+ ln_text: "#605870",
465433 },
466434 dark: BaseTokens {
467- bg: "#000000",
468- surface: "#0B0B0B",
469- surface_2: "#141414",
470- text: "#F2F2F0",
471- text_2: "#CFCFCC",
472- muted: "#9C9C98",
473- border: "#242424",
474- border_strong: "#353535",
475- code_bg: "#141414",
476- private_bg: "#141414",
477- private_text: "#CFCFCC",
478- ln_text: "#9C9C98",
435+ bg: "#110E18",
436+ surface: "#1B1625",
437+ surface_2: "#251F30",
438+ text: "#E8E4F0",
439+ text_2: "#CAC5D7",
440+ muted: "#9D96AD",
441+ border: "#2F293B",
442+ border_strong: "#3F384E",
443+ code_bg: "#251F30",
444+ private_bg: "#251F30",
445+ private_text: "#CAC5D7",
446+ ln_text: "#9D96AD",
447+ },
448+ },
449+ // Blush: rose-grey, Dusk turned to the hue of Rose.
450+ Base {
451+ id: "blush",
452+ light: BaseTokens {
453+ bg: "#F5EBEC",
454+ surface: "#FDF9F9",
455+ surface_2: "#EDDEE0",
456+ text: "#2B191C",
457+ text_2: "#4F3438",
458+ muted: "#77595E",
459+ border: "#E2CED1",
460+ border_strong: "#CCB2B6",
461+ code_bg: "#EDDEE0",
462+ private_bg: "#EDDEE0",
463+ private_text: "#4F3438",
464+ ln_text: "#715358",
465+ },
466+ dark: BaseTokens {
467+ bg: "#180C0E",
468+ surface: "#251316",
469+ surface_2: "#301C20",
470+ text: "#F0E2E4",
471+ text_2: "#D8C2C5",
472+ muted: "#AE9296",
473+ border: "#3C2529",
474+ border_strong: "#4E3438",
475+ code_bg: "#301C20",
476+ private_bg: "#301C20",
477+ private_text: "#D8C2C5",
478+ ln_text: "#AE9296",
479479 },
480480 },
481481 ];
crates/forge-web-base/src/i18n/accents.rsmodified+4 -0
@@ -39,6 +39,10 @@ pub fn base_name(lang: Lang, id: &str) -> &'static str {
3939 ("dusk", Lang::Tr) => "Alacakaranlık",
4040 ("graphite", Lang::En) => "Graphite",
4141 ("graphite", Lang::Tr) => "Grafit",
42+ ("heather", Lang::En) => "Heather",
43+ ("heather", Lang::Tr) => "Funda",
44+ ("blush", Lang::En) => "Blush",
45+ ("blush", Lang::Tr) => "Allık",
4246 ("anvil", Lang::En) => "Anvil",
4347 ("anvil", Lang::Tr) => "Örs",
4448 _ => "",
crates/forge-web/assets/nav.jsmodified+135 -24
@@ -1230,7 +1230,10 @@
12301230 dest.search = q ? '?' + q : '';
12311231 // Enter in a live field on its own results page runs the search now and leaves the reader typing.
12321232 var typing = document.activeElement;
1233- if (typing && typing.form === form && typing.hasAttribute('data-live-search') && url.pathname === location.pathname) {
1233+ // A filter or option ticked in a form that searches live refreshes in place too.
1234+ var liveForm = !!form.querySelector('[data-live-search]');
1235+ if (typing && typing.form === form && url.pathname === location.pathname &&
1236+ (typing.hasAttribute('data-live-search') || (liveForm && typing.hasAttribute('data-autosubmit')))) {
12341237 clearTimeout(searchTimer);
12351238 searchTimer = null;
12361239 if (dest.pathname + dest.search === shown) { pending.delete(form); return; }
@@ -2292,6 +2295,8 @@
22922295 // through the same feed. All text is set with textContent, never as HTML.
22932296 var logQuery = ''; // the search text survives a live swap of the page
22942297 var LOG_MAX_MARKS = 2000;
2298+ var logExact = false; // the Exact and Aa options survive a live swap too
2299+ var logCase = false;
22952300
22962301 function ansiState() { return { fg: null, bg: null, b: false, d: false, i: false, u: false, v: false }; }
22972302
@@ -2504,36 +2509,126 @@
25042509 if (bar) { bar.classList.toggle('has-hits', !!text && !none); }
25052510 }
25062511
2507- // Highlights every match of `q` (case-insensitive) in the log and selects the one at `keep`.
2512+ // Slips a typed word may have, as views/find.rs counts them: none under four letters, one up to seven, two after.
2513+ function logSlips(len) { return len <= 3 ? 0 : (len <= 7 ? 1 : 2); }
2514+
2515+ // Edits (insert, delete, change, swap two neighbours) between two words given as character arrays.
2516+ function logDistance(a, b) {
2517+ if (Math.abs(a.length - b.length) > 2) { return 99; }
2518+ var n = a.length, m = b.length, d = [], i, j;
2519+ for (i = 0; i <= n; i++) { d.push([i]); }
2520+ for (j = 1; j <= m; j++) { d[0][j] = j; }
2521+ for (i = 1; i <= n; i++) {
2522+ for (j = 1; j <= m; j++) {
2523+ var best = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
2524+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { best = Math.min(best, d[i - 2][j - 2] + 1); }
2525+ d[i][j] = best;
2526+ }
2527+ }
2528+ return d[n][m];
2529+ }
2530+
2531+ // True when a typed word is close to a word of the line, or to the start of it as long as the word.
2532+ function logNear(word, token) {
2533+ var slips = logSlips(word.length);
2534+ if (!slips) { return false; }
2535+ if (logDistance(word, token) <= slips) { return true; }
2536+ return token.length > word.length && logDistance(word, token.slice(0, word.length)) <= slips;
2537+ }
2538+
2539+ // Every place `part` occurs in `hay`, as [start, end) spans.
2540+ function logOccur(hay, part, out) {
2541+ var from = 0, at;
2542+ while (part && (at = hay.indexOf(part, from)) >= 0) {
2543+ out.push([at, at + part.length]);
2544+ from = at + part.length;
2545+ }
2546+ return out;
2547+ }
2548+
2549+ // The spans of one line that match the search, or [] when it does not. Mirrors views/find.rs: the
2550+ // whole search as one piece; unless Exact, every typed word as typed (Aa) or, by default, every word
2551+ // in the line or close to one of its words (the near word is the span).
2552+ function logSpans(text, q, exact, cas) {
2553+ var hay = cas ? text : text.toLowerCase();
2554+ var needle = cas ? q : q.toLowerCase();
2555+ if (hay.indexOf(needle) >= 0) { return logOccur(hay, needle, []); }
2556+ if (exact) { return []; }
2557+ var words = needle.match(/[\p{L}\p{N}]+/gu) || [];
2558+ if (!words.length) { return []; }
2559+ // Word by word, each typed word must start one of the line's words (or, without Aa, be near
2560+ // one), so a short word such as "1" does not match every line with a 1 in it.
2561+ var spans = [], w, tokens, i, m, re, found, typed;
2562+ tokens = [];
2563+ re = /[\p{L}\p{N}]+/gu;
2564+ while ((m = re.exec(hay))) { tokens.push([m.index, m.index + m[0].length, m[0], Array.from(m[0])]); }
2565+ for (w = 0; w < words.length; w++) {
2566+ typed = Array.from(words[w]);
2567+ found = false;
2568+ for (i = 0; i < tokens.length; i++) {
2569+ if (tokens[i][2].indexOf(words[w]) === 0) {
2570+ spans.push([tokens[i][0], tokens[i][0] + words[w].length]); found = true;
2571+ } else if (!cas && logNear(typed, tokens[i][3])) {
2572+ spans.push([tokens[i][0], tokens[i][1]]); found = true;
2573+ }
2574+ }
2575+ if (!found) { return []; }
2576+ }
2577+ return spans;
2578+ }
2579+
2580+ // Sorts spans and joins the ones that overlap, so one place is one mark.
2581+ function logMerge(spans) {
2582+ var sorted = spans.slice().sort(function (x, y) { return x[0] - y[0] || x[1] - y[1]; });
2583+ var out = [];
2584+ for (var i = 0; i < sorted.length; i++) {
2585+ var last = out[out.length - 1];
2586+ if (last && sorted[i][0] < last[1]) { last[1] = Math.max(last[1], sorted[i][1]); }
2587+ else { out.push([sorted[i][0], sorted[i][1]]); }
2588+ }
2589+ return out;
2590+ }
2591+
2592+ // Wraps each span of a line's text in a mark, across the line's text nodes.
2593+ function logMark(el, spans) {
2594+ var walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
2595+ var nodes = [];
2596+ while (walker.nextNode()) { nodes.push(walker.currentNode); }
2597+ var base = 0;
2598+ for (var k = 0; k < nodes.length; k++) {
2599+ var node = nodes[k];
2600+ var end = base + node.data.length;
2601+ var cuts = [];
2602+ for (var s = 0; s < spans.length; s++) {
2603+ var a = Math.max(spans[s][0], base), b = Math.min(spans[s][1], end);
2604+ if (a < b) { cuts.push([a - base, b - base]); }
2605+ }
2606+ for (var c = cuts.length - 1; c >= 0; c--) {
2607+ var mid = node.splitText(cuts[c][0]);
2608+ mid.splitText(cuts[c][1] - cuts[c][0]);
2609+ var mark = document.createElement('mark');
2610+ mark.className = 'lm';
2611+ mid.parentNode.replaceChild(mark, mid);
2612+ mark.appendChild(mid);
2613+ }
2614+ base = end;
2615+ }
2616+ }
2617+
2618+ // Highlights every match of `q` in the log and selects the one at `keep`.
25082619 function logFind(pre, q, keep) {
25092620 logClear(pre);
25102621 logCount('', false);
2622+ q = Array.from(q.trim()).slice(0, 100).join('');
25112623 if (!q) { return; }
2512- var needle = q.toLowerCase();
25132624 var total = 0;
25142625 var texts = pre.querySelectorAll('.lt');
25152626 for (var t = 0; t < texts.length && total < LOG_MAX_MARKS; t++) {
2516- var walker = document.createTreeWalker(texts[t], NodeFilter.SHOW_TEXT);
2517- var nodes = [];
2518- while (walker.nextNode()) { nodes.push(walker.currentNode); }
2519- for (var k = 0; k < nodes.length && total < LOG_MAX_MARKS; k++) {
2520- var node = nodes[k];
2521- var lower = node.data.toLowerCase();
2522- var at = [], from = 0, idx;
2523- while ((idx = lower.indexOf(needle, from)) >= 0 && total + at.length < LOG_MAX_MARKS) {
2524- at.push(idx);
2525- from = idx + needle.length;
2526- }
2527- for (var m = at.length - 1; m >= 0; m--) {
2528- var mid = node.splitText(at[m]);
2529- mid.splitText(needle.length);
2530- var mark = document.createElement('mark');
2531- mark.className = 'lm';
2532- mid.parentNode.replaceChild(mark, mid);
2533- mark.appendChild(mid);
2534- }
2535- total += at.length;
2536- }
2627+ var spans = logSpans(texts[t].textContent, q, logExact, logCase);
2628+ if (!spans.length) { continue; }
2629+ spans = logMerge(spans).slice(0, LOG_MAX_MARKS - total);
2630+ total += spans.length;
2631+ logMark(texts[t], spans);
25372632 }
25382633 var marks = pre.querySelectorAll('mark.lm');
25392634 if (!marks.length) {
@@ -2572,6 +2667,10 @@
25722667 var pre = document.querySelector('[data-live-log]');
25732668 if (!pre || pre.getAttribute('data-ci')) { return; }
25742669 logInit(pre);
2670+ var ex = document.querySelector('[data-log-exact]');
2671+ if (ex) { ex.checked = logExact; }
2672+ var cs = document.querySelector('[data-log-case]');
2673+ if (cs) { cs.checked = logCase; }
25752674 var input = document.querySelector('[data-log-q]');
25762675 if (input && logQuery) { input.value = logQuery; logFind(pre, logQuery, -1); }
25772676 if (location.hash && /^#L\d+$/.test(location.hash)) { logSelect(location.hash.slice(1), true); }
@@ -2586,6 +2685,18 @@
25862685 logFind(pre, logQuery, -1);
25872686 });
25882687
2688+ // Exact and Aa re-run the search at once.
2689+ document.addEventListener('change', function (e) {
2690+ var box = e.target;
2691+ if (!box || !box.hasAttribute) { return; }
2692+ if (box.hasAttribute('data-log-exact')) { logExact = box.checked; }
2693+ else if (box.hasAttribute('data-log-case')) { logCase = box.checked; }
2694+ else { return; }
2695+ var pre = document.querySelector('[data-live-log]');
2696+ if (!pre || !pre._ci) { return; }
2697+ logFind(pre, logQuery, -1);
2698+ });
2699+
25892700 document.addEventListener('keydown', function (e) {
25902701 var input = e.target;
25912702 if (!input || !input.hasAttribute || !input.hasAttribute('data-log-q')) { return; }
crates/forge-web/src/exporter.rsmodified+15 -0
@@ -406,6 +406,21 @@ pub async fn sweep_expired(state: &AppState) {
406406 }
407407 }
408408
409+/// Deletes one export by hand, its archive and its row. A missing archive is not an error.
410+pub async fn delete_one(state: &AppState, export: &DataExport) -> forge_core::Result<()> {
411+ match tokio::fs::remove_file(archive_path(state, &export.id)).await {
412+ Ok(()) => {}
413+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
414+ Err(e) => {
415+ tracing::warn!(error = %e, "export: could not remove an archive");
416+ return Err(e.into());
417+ }
418+ }
419+ state.store.delete_export(&export.id).await?;
420+ bump(&export.user_id);
421+ Ok(())
422+}
423+
409424 /// Fails exports a restart cut short and removes expired ones.
410425 pub async fn on_boot(state: &AppState) {
411426 if let Err(e) = state.store.fail_interrupted_exports().await {
crates/forge-web/src/pages/admin_replication.rsmodified+139 -4
@@ -27,14 +27,30 @@ use crate::i18n::{self, Lang};
2727 use crate::live::{Topic, stream_changes};
2828 use crate::pages::admin_users::admin_only;
2929 use crate::state::AppState;
30+use crate::pages::issues_list::list_href;
31+use crate::pages::passkeys::s;
32+use crate::views::find::{Finder, finder_field};
3033 use crate::views::parts::{SubPart, head, post_act};
34+use crate::views::repo_list::{PageLink, pager, pager_links};
3135 use crate::views::{enc, rel_time_or_never, shell};
3236
3337 #[query_params(error = bad_request)]
3438 pub(crate) struct NoticeQuery {
3539 notice: Option<String>,
40+ q: Option<String>,
41+ exact: Option<String>,
42+ case: Option<String>,
43+ /// The health to list: "ok", "lagging", "error", "never", or anything else for all.
44+ health: Option<String>,
45+ page: Option<String>,
3646 }
3747
48+/// Repos per page of the list.
49+const REPO_ROWS: usize = 10;
50+
51+/// The health filter's values, in the order the menu lists them.
52+const HEALTH_KEYS: [&str; 4] = ["error", "lagging", "never", "ok"];
53+
3854 /// How a subject reads on the page.
3955 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4056 enum Health {
@@ -64,6 +80,21 @@ impl Health {
6480 }
6581 }
6682
83+ fn key(self) -> &'static str {
84+ match self {
85+ Health::Ok => "ok",
86+ Health::Lagging => "lagging",
87+ Health::Error => "error",
88+ Health::Never => "never",
89+ }
90+ }
91+
92+ fn from_key(key: &str) -> Option<Health> {
93+ [Health::Ok, Health::Lagging, Health::Error, Health::Never]
94+ .into_iter()
95+ .find(|h| h.key() == key)
96+ }
97+
6798 fn label(self, lang: Lang) -> &'static str {
6899 match self {
69100 Health::Ok => g::t(lang, K::HealthOk),
@@ -91,6 +122,7 @@ fn health(status: Option<&ReplicationStatus>, cutoff: &str) -> Health {
91122 /// One line of the repos table, already formatted.
92123 struct RepoRow {
93124 name: String,
125+ kind: Health,
94126 dot: &'static str,
95127 tone: &'static str,
96128 health: &'static str,
@@ -99,6 +131,20 @@ struct RepoRow {
99131 error: String,
100132 }
101133
134+impl RepoRow {
135+ fn copy(&self) -> RepoRow {
136+ RepoRow {
137+ name: self.name.clone(),
138+ kind: self.kind,
139+ dot: self.dot,
140+ tone: self.tone,
141+ health: self.health,
142+ last_ok: self.last_ok.clone(),
143+ error: self.error.clone(),
144+ }
145+ }
146+}
147+
102148 /// Everything the page shows, already formatted.
103149 struct PageData {
104150 enabled: bool,
@@ -139,6 +185,7 @@ async fn page_data(state: &AppState, lang: Lang) -> forge_core::Result<PageData>
139185 let h = health(status, &repo_cutoff);
140186 repos.push(RepoRow {
141187 name,
188+ kind: h,
142189 dot: h.dot(),
143190 tone: h.tone(),
144191 health: h.label(lang),
@@ -154,6 +201,7 @@ async fn page_data(state: &AppState, lang: Lang) -> forge_core::Result<PageData>
154201 let h = health(Some(status), &repo_cutoff);
155202 repos.push(RepoRow {
156203 name: g::deleted_repo_name(lang, &status.subject),
204+ kind: h,
157205 dot: h.dot(),
158206 tone: h.tone(),
159207 health: h.label(lang),
@@ -187,7 +235,20 @@ async fn replication_view(
187235 csrf: String,
188236 data: PageData,
189237 notice: Option<String>,
238+ list: RepoList,
190239 ) -> Result<impl View> {
240+ let RepoList {
241+ finder,
242+ health,
243+ rows,
244+ page,
245+ pages,
246+ nav: (links, prev, next),
247+ } = list;
248+ let has_repos = !data.repos.is_empty();
249+ let all_label = s(lang, "All", "Tümü");
250+ let health_label = s(lang, "Health", "Durum");
251+ let placeholder = s(lang, "Search repositories", "Depolarda ara");
191252 let sub = vec![SubPart::text(g::t(lang, K::ReplicationIntro))];
192253 Ok(view! {
193254 head(title: g::t(lang, K::Replication), sub: sub,
@@ -239,12 +300,29 @@ async fn replication_view(
239300 }
240301 <section class="sec">
241302 <h2>(g::t(lang, K::Repos))</h2>
242- if data.repos.is_empty() {
303+ if !has_repos {
243304 <p class="state">(g::t(lang, K::NoReposYet))</p>
244305 <p class="hint">(g::t(lang, K::ReposEmptyHint))</p>
245306 <p class="hint">(g::t(lang, K::ReplicationConfigHint))</p>
246307 } else {
247- for row in data.repos.into_iter() {
308+ <form class="sec-tools" method="get" action="/admin/replication" role="search">
309+ finder_field(lang: lang, finder: finder, placeholder: placeholder, id: Some("replication-q"))
310+ <label class="find-filter">
311+ (health_label) " "
312+ <select name="health" data-autosubmit="true">
313+ <option value="" selected=(health.is_none())>(all_label)</option>
314+ for key in HEALTH_KEYS {
315+ if let Some(h) = Health::from_key(key) {
316+ <option value=(key) selected=(health == Some(h))>(h.label(lang))</option>
317+ }
318+ }
319+ </select>
320+ </label>
321+ </form>
322+ if rows.is_empty() {
323+ <p class="state">(s(lang, "No repository matches.", "Eşleşen depo yok."))</p>
324+ }
325+ for row in rows.into_iter() {
248326 <div class="line" data-kb-row="">
249327 <span class="name">(row.name.as_str())</span>
250328 <span class="val"><span class=(row.dot) aria-hidden="true"></span> <span class=(row.tone)>(row.health)</span> " · " (g::t(lang, K::LastSuccess)) ": " rel_time_or_never(lang: lang, stamp: row.last_ok.as_deref())</span>
@@ -255,6 +333,7 @@ async fn replication_view(
255333 }
256334 }
257335 </section>
336+ pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
258337 </div>
259338 })
260339 }
@@ -297,17 +376,73 @@ async fn replication_events(cx: &Cx) -> Result<Response> {
297376 .await
298377 }
299378
379+/// One page of the repo list, after the search and the health filter.
380+struct RepoList {
381+ finder: Finder,
382+ health: Option<Health>,
383+ rows: Vec<RepoRow>,
384+ page: u64,
385+ pages: u64,
386+ nav: (Vec<PageLink>, Option<String>, Option<String>),
387+}
388+
389+/// Takes the repos that match the query out of `data`, a page of them.
390+fn repo_list(data: &mut PageData, query: &NoticeQuery) -> RepoList {
391+ let finder = Finder::new(
392+ query.q.as_deref(),
393+ query.exact.as_deref(),
394+ query.case.as_deref(),
395+ );
396+ let health = query.health.as_deref().and_then(Health::from_key);
397+ let matching: Vec<RepoRow> = data
398+ .repos
399+ .iter()
400+ .filter(|row| health.is_none_or(|h| row.kind == h))
401+ .filter(|row| finder.matches_any(&[row.name.as_str(), row.error.as_str()]))
402+ .map(RepoRow::copy)
403+ .collect();
404+ let pages = (matching.len() as u64).div_ceil(REPO_ROWS as u64).max(1);
405+ let page = query
406+ .page
407+ .as_deref()
408+ .and_then(|p| p.parse::<u64>().ok())
409+ .unwrap_or(1)
410+ .clamp(1, pages);
411+ let rows = matching
412+ .into_iter()
413+ .skip((page - 1) as usize * REPO_ROWS)
414+ .take(REPO_ROWS)
415+ .collect();
416+ let health_key = health.map_or("", Health::key);
417+ let nav = pager_links(page, pages, |n| {
418+ let number = n.to_string();
419+ let mut params = finder.params();
420+ params.push(("health", health_key));
421+ params.push(("page", number.as_str()));
422+ list_href("/admin/replication", &params)
423+ });
424+ RepoList {
425+ finder,
426+ health,
427+ rows,
428+ page,
429+ pages,
430+ nav,
431+ }
432+}
433+
300434 #[page("/admin/replication")]
301435 async fn replication_page(cx: &Cx) -> Result<impl View> {
302436 let viewer = admin_only(cx).await?;
303437 let query = query_params::<NoticeQuery>(cx)?;
304438 let lang = i18n::lang(cx, Some(&viewer.0));
305439 let state = app_context::<AppState>(cx);
306- let data = page_data(state, lang).await?;
440+ let mut data = page_data(state, lang).await?;
441+ let list = repo_list(&mut data, query);
307442 let csrf = viewer.1.csrf_token.clone();
308443 let title = g::t(lang, K::Replication);
309444 Ok(view! {
310- shell(title: title, viewer: Some(&viewer), replication_view(lang: lang, csrf: csrf, data: data, notice: query.notice.clone()))
445+ shell(title: title, viewer: Some(&viewer), replication_view(lang: lang, csrf: csrf, data: data, notice: query.notice.clone(), list: list))
311446 })
312447 }
313448
crates/forge-web/src/pages/admin_server.rsmodified+19 -17
@@ -38,6 +38,7 @@ use crate::pages::ci_runs::{changed_event, events_response};
3838 use crate::pages::passkeys::s;
3939 use crate::self_update;
4040 use crate::state::AppState;
41+use crate::views::find::{Finder, finder_field};
4142 use crate::views::parts::{RailItem, SubPart, confirm_act, head, rail};
4243 use crate::views::{enc, shell};
4344
@@ -48,6 +49,10 @@ pub(crate) struct ServerQuery {
4849 cat: Option<String>,
4950 /// The search text: when set, the page lists the matching settings from every category instead.
5051 q: Option<String>,
52+ /// Set when the search asks for the text as typed, as one piece.
53+ exact: Option<String>,
54+ /// Set when the search keeps upper and lower case apart.
55+ case: Option<String>,
5156 /// The older name for `cat`, still read so an old link opens the same category.
5257 tab: Option<String>,
5358 /// The boot id of the server that was asked to restart.
@@ -329,19 +334,15 @@ async fn rows_for(state: &AppState, lang: Lang, page: &SrvPage) -> forge_core::R
329334 .collect())
330335 }
331336
332-/// The settings from every category whose key, label or help holds `needle` (already lowercase).
333-async fn search_hits(state: &AppState, lang: Lang, needle: &str) -> forge_core::Result<Vec<Row>> {
337+/// The settings from every category whose key, label or help matches the search.
338+async fn search_hits(state: &AppState, lang: Lang, finder: &Finder) -> forge_core::Result<Vec<Row>> {
334339 let overrides = state.store.server_overrides().await?;
335340 Ok(state
336341 .settings
337342 .views(&overrides)
338343 .iter()
339344 .map(|view| row(lang, view))
340- .filter(|hit| {
341- hit.key.contains(needle)
342- || hit.label.to_lowercase().contains(needle)
343- || hit.help.to_lowercase().contains(needle)
344- })
345+ .filter(|hit| finder.matches_any(&[hit.key, hit.label, hit.help]))
345346 .collect())
346347 }
347348
@@ -419,7 +420,7 @@ async fn server_view(
419420 csrf: String,
420421 page: &'static SrvPage,
421422 rows: Vec<Row>,
422- q: String,
423+ finder: Finder,
423424 search: Option<Vec<Row>>,
424425 notice: Option<String>,
425426 restart: Restart,
@@ -472,10 +473,8 @@ async fn server_view(
472473 }
473474 <div class="work">
474475 rail(label: g::t(lang, K::ServerSettings), items: items,
475- <form class="plain-search" method="get" action="/admin/server" role="search">
476- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
477- <label class="sr-only" for="server-search">(search_label)</label>
478- <input id="server-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off">
476+ <form method="get" action="/admin/server" role="search">
477+ finder_field(lang: lang, finder: finder, placeholder: search_label, id: Some("server-search"))
479478 </form>
480479 )
481480 <div class="sheet srv-sheet">
@@ -528,17 +527,20 @@ async fn server_page(cx: &Cx) -> Result<impl View> {
528527 .or(query.tab.as_deref())
529528 .and_then(page_by_slug)
530529 .unwrap_or(&PAGES[0]);
531- let q = query.q.clone().unwrap_or_default();
532- let needle = q.trim().to_lowercase();
533- let (rows, search) = if needle.is_empty() {
530+ let finder = Finder::new(
531+ query.q.as_deref(),
532+ query.exact.as_deref(),
533+ query.case.as_deref(),
534+ );
535+ let (rows, search) = if finder.is_empty() {
534536 (rows_for(state, lang, page).await?, None)
535537 } else {
536- (Vec::new(), Some(search_hits(state, lang, &needle).await?))
538+ (Vec::new(), Some(search_hits(state, lang, &finder).await?))
537539 };
538540 let csrf = viewer.1.csrf_token.clone();
539541 let title = g::t(lang, K::ServerSettings);
540542 Ok(view! {
541- shell(title: title, viewer: Some(&viewer), server_view(lang: lang, csrf: csrf, page: page, rows: rows, q: q, search: search, notice: query.notice.clone(), restart: restart_state(query.restarting.as_deref())))
543+ shell(title: title, viewer: Some(&viewer), server_view(lang: lang, csrf: csrf, page: page, rows: rows, finder: finder, search: search, notice: query.notice.clone(), restart: restart_state(query.restarting.as_deref())))
542544 })
543545 }
544546
crates/forge-web/src/pages/admin_users.rsmodified+39 -48
@@ -23,15 +23,15 @@ use crate::live::{Topic, stream_changes};
2323 use crate::pages::passkeys::s;
2424 use crate::state::AppState;
2525 use crate::views::parts::{head, reveal};
26+use crate::pages::issues_list::list_href;
27+use crate::views::find::{Finder, finder_field};
2628 use crate::views::repo_list::{pager, pager_links};
2729 use crate::views::{alert, enc, rel_time, shell, user_facing_message};
2830
2931 const MIN_PASSWORD_CHARS: usize = 12;
3032 const MAX_PASSWORD_BYTES: usize = 1024;
3133 /// Accounts per page of the list.
32-const PER_PAGE: u64 = 50;
33-/// The longest search the list takes.
34-const MAX_QUERY_CHARS: usize = 100;
34+const PER_PAGE: u64 = 12;
3535
3636 #[derive(Deserialize)]
3737 struct CreateUserForm {
@@ -59,6 +59,8 @@ struct DeleteForm {
5959 #[query_params(error = bad_request)]
6060 struct UsersQuery {
6161 q: Option<String>,
62+ exact: Option<String>,
63+ case: Option<String>,
6264 kind: Option<String>,
6365 page: Option<String>,
6466 }
@@ -98,16 +100,13 @@ impl Kind {
98100 }
99101 }
100102
101-/// The search text, kind and page the query asks for, with the defaults filled in.
102-fn listing_args(query: &UsersQuery) -> (String, Kind, u64) {
103- let q: String = query
104- .q
105- .as_deref()
106- .unwrap_or("")
107- .trim()
108- .chars()
109- .take(MAX_QUERY_CHARS)
110- .collect();
103+/// The search, kind and page the query asks for, with the defaults filled in.
104+fn listing_args(query: &UsersQuery) -> (Finder, Kind, u64) {
105+ let finder = Finder::new(
106+ query.q.as_deref(),
107+ query.exact.as_deref(),
108+ query.case.as_deref(),
109+ );
111110 let kind = Kind::parse(query.kind.as_deref());
112111 let page = query
113112 .page
@@ -115,31 +114,21 @@ fn listing_args(query: &UsersQuery) -> (String, Kind, u64) {
115114 .and_then(|p| p.parse::<u64>().ok())
116115 .unwrap_or(1)
117116 .max(1);
118- (q, kind, page)
117+ (finder, kind, page)
119118 }
120119
121120 /// `/admin/users` with the search, the kind and the page. An empty search is left out.
122-fn users_href(q: &str, kind: Kind, page: u64) -> String {
123- let mut href = String::from("/admin/users?");
124- if !q.is_empty() {
125- href.push_str("q=");
126- href.push_str(&enc(q));
127- href.push('&');
128- }
129- href.push_str(&format!("kind={}&page={page}", kind.key()));
130- href
121+fn users_href(finder: &Finder, kind: Kind, page: u64) -> String {
122+ let number = page.to_string();
123+ let mut params = finder.params();
124+ params.push(("kind", kind.key()));
125+ params.push(("page", number.as_str()));
126+ list_href("/admin/users", &params)
131127 }
132128
133-/// Whether the account's name or email holds the lowercase search text. An empty search holds all.
134-fn matches_search(user: &User, needle: &str) -> bool {
135- needle.is_empty()
136- || user.username.to_lowercase().contains(needle)
137- || user
138- .email
139- .as_deref()
140- .unwrap_or("")
141- .to_lowercase()
142- .contains(needle)
129+/// Whether the account's name or email matches the search. An empty search matches all.
130+fn matches_search(user: &User, finder: &Finder) -> bool {
131+ finder.matches_any(&[user.username.as_str(), user.email.as_deref().unwrap_or("")])
143132 }
144133
145134 /// The ghost account is reserved and never shown as a deletable user.
@@ -182,15 +171,14 @@ async fn users_view(
182171 lang: Lang,
183172 csrf: &str,
184173 users: Vec<User>,
185- q: String,
174+ finder: Finder,
186175 kind: Kind,
187176 page: u64,
188177 error: Option<String>,
189178 ) -> Result<impl View> {
190- let needle = q.to_lowercase();
191179 let matching: Vec<User> = users
192180 .into_iter()
193- .filter(|user| matches_search(user, &needle))
181+ .filter(|user| matches_search(user, &finder))
194182 .collect();
195183 let all_count = matching.len();
196184 let org_count = matching.iter().filter(|user| user.is_org()).count();
@@ -205,10 +193,15 @@ async fn users_view(
205193 .take(PER_PAGE as usize)
206194 .map(|user| UserRow::new(lang, user))
207195 .collect();
208- let (links, prev, next) = pager_links(page, pages, |n| users_href(&q, kind, n));
196+ let (links, prev, next) = pager_links(page, pages, |n| users_href(&finder, kind, n));
209197 let empty = rows.is_empty();
210198 let open = error.is_some();
211- let search_label = s(lang, "Search users and organizations", "Kullanıcı ve kuruluşlarda ara");
199+ // The field says what the current tab lists.
200+ let search_label = match kind {
201+ Kind::All => s(lang, "Search users and organizations", "Kullanıcı ve kuruluşlarda ara"),
202+ Kind::People => s(lang, "Search users", "Kullanıcılarda ara"),
203+ Kind::Organizations => s(lang, "Search organizations", "Kuruluşlarda ara"),
204+ };
212205 let filter_label = s(lang, "Filter", "Filtre");
213206 let all_label = format!("{} {}", s(lang, "All", "Tümü"), all_count);
214207 let people_label = format!(
@@ -217,9 +210,9 @@ async fn users_view(
217210 all_count - org_count
218211 );
219212 let orgs_label = format!("{} {}", og::t(lang, OG::Organizations), org_count);
220- let all_href = users_href(&q, Kind::All, 1);
221- let people_href = users_href(&q, Kind::People, 1);
222- let orgs_href = users_href(&q, Kind::Organizations, 1);
213+ let all_href = users_href(&finder, Kind::All, 1);
214+ let people_href = users_href(&finder, Kind::People, 1);
215+ let orgs_href = users_href(&finder, Kind::Organizations, 1);
223216 Ok(view! {
224217 head(title: g::t(lang, K::Users),
225218 reveal(label: g::t(lang, K::CreateUser), id: Some("create-user"), open: open,
@@ -256,10 +249,8 @@ async fn users_view(
256249 </nav>
257250 <div class="sheet" data-live="/admin/users/events">
258251 <div class="sheet-tools">
259- <form class="plain-search" method="get" action="/admin/users" role="search">
260- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
261- <label class="sr-only" for="user-search">(search_label)</label>
262- <input id="user-search" type="search" name="q" value=(q.as_str()) placeholder=(search_label) data-live-search="" autocomplete="off">
252+ <form method="get" action="/admin/users" role="search">
253+ finder_field(lang: lang, finder: finder.clone(), placeholder: search_label, id: Some("user-search"))
263254 <input type="hidden" name="kind" value=(kind.key())>
264255 </form>
265256 </div>
@@ -330,12 +321,12 @@ async fn users_events(cx: &Cx) -> Result<Response> {
330321 async fn users_page(cx: &Cx) -> Result<impl View> {
331322 let viewer = admin_only(cx).await?;
332323 let lang = i18n::lang(cx, Some(&viewer.0));
333- let (q, kind, page) = listing_args(query_params::<UsersQuery>(cx)?);
324+ let (finder, kind, page) = listing_args(query_params::<UsersQuery>(cx)?);
334325 let users = app_context::<AppState>(cx).store.list_users().await?;
335326 let csrf = viewer.1.csrf_token.clone();
336327 let title = g::t(lang, K::Users);
337328 Ok(view! {
338- shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), users: users, q: q, kind: kind, page: page, error: None))
329+ shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), users: users, finder: finder, kind: kind, page: page, error: None))
339330 })
340331 }
341332
@@ -372,7 +363,7 @@ async fn users_create(cx: &Cx, Form(form): Form<CreateUserForm>) -> Result<impl
372363 let csrf = viewer.1.csrf_token.clone();
373364 let title = g::t(lang, K::Users);
374365 Ok(view! {
375- shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), users: users, q: String::new(), kind: Kind::All, page: 1, error: Some(message)))
366+ shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), users: users, finder: Finder::default(), kind: Kind::All, page: 1, error: Some(message)))
376367 })
377368 }
378369 }
crates/forge-web/src/pages/audit_log.rsmodified+326 -131
@@ -1,8 +1,9 @@
11 //! Pages: the admin audit log (`/admin/audit`, instance admins only, 404 otherwise) and a user's
22 //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted
3-//! them). Both list newest first, a page of rows at a time, with numbered pages: 8 rows on the
4-//! admin page (its filter bar takes the room) and 10 in the own log, sized to fit the window.
5-//! Repeats in a row (same action, actor and target) fold into one row with a count.
3+//! them). Both list newest first with a live search over every word of an entry (forgiving typos
4+//! unless Exact or Aa is on) and an action filter. Runs of the same action by the same actor fold
5+//! into one row with a count, which opens to show each entry. Pages count rows as shown, so a page
6+//! is always full.
67
78 use forge_core::{AuditAction, AuditEntry, AuditFilter, Store};
89 use topcoat::Result;
@@ -20,23 +21,29 @@ use crate::pages::issues_list::list_href;
2021 use crate::pages::passkeys::s;
2122 use crate::pages::settings_security::{security_rail_for, security_sub};
2223 use crate::state::AppState;
24+use crate::views::find::{Finder, finder_field};
2325 use crate::views::parts::{RailItem, SubPart, head, rail};
2426 use crate::views::repo_list::{PageLink, pager, pager_links};
2527 use crate::views::{rel_time, shell};
2628
27-/// Entries per page of the admin audit log, under its filter bar.
28-const ADMIN_PAGE_SIZE: usize = 8;
29+/// Rows per page of either log. A folded run is one row.
30+const PAGE_ROWS: usize = 10;
2931
30-/// Entries per page of the own security log.
31-const OWN_PAGE_SIZE: usize = 10;
32+/// The newest entries a search reads. Older ones are past any page a person pages to.
33+const SEARCH_CAP: u32 = 5000;
3234
33-/// Details shorter than this show in the row; longer ones move to the line's hover title.
35+/// Details longer than this are cut in a row, with the whole text in its hover title.
3436 const DETAILS_INLINE_CHARS: usize = 80;
3537
3638 #[query_params(error = bad_request)]
3739 pub(crate) struct AuditQuery {
3840 action: Option<String>,
41+ /// An exact actor username. No form sends it any more (the search covers actors); old links
42+ /// still filter by it.
3943 actor: Option<String>,
44+ q: Option<String>,
45+ exact: Option<String>,
46+ case: Option<String>,
4047 /// Old cursor links. Still accepted so old bookmarks load, and ignored.
4148 #[allow(dead_code)]
4249 before: Option<String>,
@@ -44,23 +51,81 @@ pub(crate) struct AuditQuery {
4451 page: Option<String>,
4552 }
4653
47-/// One table row, already formatted for display. A row can stand for several entries in a row.
54+/// One entry, already formatted for display.
4855 struct RowView {
4956 when: String,
5057 actor: String,
51- /// The action as words: "Ui prefs changed".
58+ /// The action as words: "Display preferences changed".
5259 name: String,
5360 /// The raw action, for the hover title.
5461 action: String,
5562 /// "kind: name", or the name alone, or empty when the entry has no target name.
5663 target: String,
5764 ip: String,
58- /// The details when short enough to show in the row. Empty when they are long.
59- details_inline: String,
60- /// The details when too long for the row, for the line's hover title. Empty otherwise.
61- details_title: String,
62- /// How many entries this row stands for.
63- count: usize,
65+ /// The details as words, whole.
66+ details: String,
67+}
68+
69+impl RowView {
70+ /// Every word a search reads.
71+ fn text(&self) -> String {
72+ [
73+ self.name.as_str(),
74+ self.action.as_str(),
75+ self.actor.as_str(),
76+ self.target.as_str(),
77+ self.ip.as_str(),
78+ self.details.as_str(),
79+ ]
80+ .join(" \u{1f} ")
81+ }
82+
83+ /// The details as shown in a row: cut when long.
84+ fn details_short(&self) -> String {
85+ if self.details.chars().count() <= DETAILS_INLINE_CHARS {
86+ self.details.clone()
87+ } else {
88+ let cut: String = self.details.chars().take(DETAILS_INLINE_CHARS).collect();
89+ format!("{cut}\u{2026}")
90+ }
91+ }
92+}
93+
94+/// A run of entries of one action by one actor, newest first. A run of one is a plain row.
95+struct Group {
96+ /// The key the run folds on.
97+ key: (String, Option<String>, String),
98+ rows: Vec<RowView>,
99+}
100+
101+impl Group {
102+ fn first(&self) -> &RowView {
103+ &self.rows[0]
104+ }
105+
106+ /// The target when every entry has the same one.
107+ fn shared_target(&self) -> Option<&str> {
108+ let first = self.first().target.as_str();
109+ self.rows
110+ .iter()
111+ .all(|row| row.target == first)
112+ .then_some(first)
113+ }
114+
115+ /// The IP when every entry came from the same one.
116+ fn shared_ip(&self) -> Option<&str> {
117+ let first = self.first().ip.as_str();
118+ self.rows.iter().all(|row| row.ip == first).then_some(first)
119+ }
120+
121+ /// The details when every entry has the same.
122+ fn shared_details(&self) -> Option<&str> {
123+ let first = self.first().details.as_str();
124+ self.rows
125+ .iter()
126+ .all(|row| row.details == first)
127+ .then_some(first)
128+ }
64129 }
65130
66131 /// "ci_secret_set" as "CI secret set": words, with the short names in capitals.
@@ -164,11 +229,6 @@ fn row_view(entry: &AuditEntry, lang: Lang) -> RowView {
164229 } else {
165230 details_words(lang, &entry.data)
166231 };
167- let (details_inline, details_title) = if details.chars().count() < DETAILS_INLINE_CHARS {
168- (details.clone(), String::new())
169- } else {
170- (String::new(), details.clone())
171- };
172232 RowView {
173233 when: entry.at.clone(),
174234 actor,
@@ -176,32 +236,33 @@ fn row_view(entry: &AuditEntry, lang: Lang) -> RowView {
176236 action: entry.action.as_str().to_owned(),
177237 target,
178238 ip: entry.ip.clone(),
179- details_inline,
180- details_title,
181- count: 1,
239+ details,
182240 }
183241 }
184242
185-/// Rows for `entries` (newest first), with consecutive entries of the same action, actor and
186-/// target folded into one row. The row keeps the newest entry's time, IP and details.
187-fn fold_rows(entries: &[AuditEntry], lang: Lang) -> Vec<RowView> {
188- let mut rows: Vec<(&AuditEntry, RowView)> = Vec::new();
243+/// Groups for `entries` (newest first) that match the search: consecutive entries of the same
244+/// action by the same actor fold into one group, whatever their targets.
245+fn fold_groups(entries: &[AuditEntry], lang: Lang, finder: &Finder) -> Vec<Group> {
246+ let mut groups: Vec<Group> = Vec::new();
189247 for entry in entries {
190- if let Some((last, row)) = rows.last_mut() {
191- let same = last.action == entry.action
192- && last.actor_id == entry.actor_id
193- && last.actor_name == entry.actor_name
194- && last.target_kind == entry.target_kind
195- && last.target_id == entry.target_id
196- && last.target_name == entry.target_name;
197- if same {
198- row.count += 1;
199- continue;
200- }
248+ let row = row_view(entry, lang);
249+ if !finder.matches(&row.text()) {
250+ continue;
251+ }
252+ let key = (
253+ entry.action.as_str().to_owned(),
254+ entry.actor_id.clone(),
255+ entry.actor_name.clone(),
256+ );
257+ match groups.last_mut() {
258+ Some(group) if group.key == key => group.rows.push(row),
259+ _ => groups.push(Group {
260+ key,
261+ rows: vec![row],
262+ }),
201263 }
202- rows.push((entry, row_view(entry, lang)));
203264 }
204- rows.into_iter().map(|(_, row)| row).collect()
265+ groups
205266 }
206267
207268 /// The page the query asks for, 1-based. Anything unreadable is page 1.
@@ -214,23 +275,21 @@ fn requested_page(query: &AuditQuery) -> u64 {
214275 .max(1)
215276 }
216277
217-/// One page of `size` entries, and the page that was asked for, clamped to the pages there are,
218-/// with the page count.
219-async fn fetch_page(
220- store: &Store,
221- filter: &AuditFilter,
222- page: u64,
223- size: usize,
224-) -> forge_core::Result<(Vec<AuditEntry>, u64, u64)> {
225- let total = store.count_audit(filter).await?;
226- let pages = total.div_ceil(size as u64).max(1);
278+/// The groups of one page, the page clamped to the pages there are, and the page count.
279+fn page_of(mut groups: Vec<Group>, page: u64) -> (Vec<Group>, u64, u64) {
280+ let pages = (groups.len() as u64).div_ceil(PAGE_ROWS as u64).max(1);
227281 let page = page.clamp(1, pages);
228- let offset = ((page - 1) * size as u64) as u32;
229- let entries = store.list_audit_page(filter, offset, size as u32).await?;
230- Ok((entries, page, pages))
282+ let start = (page - 1) as usize * PAGE_ROWS;
283+ let shown: Vec<Group> = groups.drain(..).skip(start).take(PAGE_ROWS).collect();
284+ (shown, page, pages)
285+}
286+
287+/// The newest entries the filter selects, as many as a search reads.
288+async fn fetch_entries(store: &Store, filter: &AuditFilter) -> forge_core::Result<Vec<AuditEntry>> {
289+ store.list_audit_page(filter, 0, SEARCH_CAP).await
231290 }
232291
233-/// The numbered pager's entries and links for `page` of `pages`, under `href`'s params.
292+/// The numbered pager's entries and links for `page` of `pages`, under `base` with `params`.
234293 fn nav_for(
235294 page: u64,
236295 pages: u64,
@@ -245,48 +304,181 @@ fn nav_for(
245304 })
246305 }
247306
307+/// The search and the action filter, in one GET form to `action`.
248308 #[component]
249-async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result<impl View> {
309+async fn log_tools(
310+ lang: Lang,
311+ form_action: &str,
312+ finder: Finder,
313+ action: String,
314+ actor: String,
315+) -> Result<impl View> {
316+ let placeholder = s(lang, "Search the log", "Günlükte ara");
250317 Ok(view! {
251- if rows.is_empty() {
318+ <div class="sheet-tools">
319+ <form method="get" action=(form_action)>
320+ finder_field(lang: lang, finder: finder, placeholder: placeholder, id: Some("log-q"))
321+ <label class="find-filter">
322+ (g::t(lang, K::ActionLabel)) " "
323+ <select name="action" data-autosubmit="true">
324+ <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option>
325+ for known in AuditAction::ALL.iter().copied() {
326+ <option value=(known.as_str()) selected=(known.as_str() == action.as_str())>(action_label(lang, known.as_str()))</option>
327+ }
328+ </select>
329+ </label>
330+ if !actor.is_empty() {
331+ <input type="hidden" name="actor" value=(actor.as_str())>
332+ }
333+ </form>
334+ </div>
335+ })
336+}
337+
338+/// The facts of one entry after its name: time, then whatever `show` asks for.
339+#[component]
340+async fn entry_facts(
341+ lang: Lang,
342+ row: RowView,
343+ show_actor: bool,
344+ show_target: bool,
345+ show_ip: bool,
346+ show_details: bool,
347+) -> Result<impl View> {
348+ let details = row.details_short();
349+ Ok(view! {
350+ rel_time(lang: lang, stamp: row.when.as_str())
351+ if show_actor {
352+ " · " (row.actor.as_str())
353+ }
354+ if show_target && !row.target.is_empty() {
355+ " · " (row.target.as_str())
356+ }
357+ if show_ip && !row.ip.is_empty() {
358+ " · IP " (row.ip.as_str())
359+ }
360+ if show_details && !details.is_empty() {
361+ " · " (details.as_str())
362+ }
363+ })
364+}
365+
366+#[component]
367+async fn audit_table(lang: Lang, groups: Vec<Group>, show_actor: bool) -> Result<impl View> {
368+ Ok(view! {
369+ if groups.is_empty() {
252370 <p class="state">(g::t(lang, K::NoEntries))</p>
253371 } else {
254- for row in rows.into_iter() {
255- let count = row.count.to_string();
256- <div class="line" data-kb-row="" title=(row.details_title.as_str())>
257- <span class="name" title=(row.action.as_str())>(row.name.as_str())</span>
258- if row.count > 1 {
259- <span class="count">"×" (count.as_str())</span>
260- }
261- <span class="val">
262- rel_time(lang: lang, stamp: row.when.as_str())
263- if show_actor {
264- " · " (row.actor.as_str())
265- }
266- if !row.target.is_empty() {
267- " · " (row.target.as_str())
268- }
269- if !row.ip.is_empty() {
270- " · IP " (row.ip.as_str())
271- }
272- if !row.details_inline.is_empty() {
273- " · " (row.details_inline.as_str())
274- }
275- </span>
276- </div>
372+ for group in groups.into_iter() {
373+ if group.rows.len() == 1 {
374+ single_row(lang: lang, group: group, show_actor: show_actor)
375+ } else {
376+ group_row(lang: lang, group: group, show_actor: show_actor)
377+ }
277378 }
278379 }
279380 })
280381 }
281382
383+/// One entry on its own line.
384+#[component]
385+async fn single_row(lang: Lang, mut group: Group, show_actor: bool) -> Result<impl View> {
386+ let row = group.rows.remove(0);
387+ let title = row.details.clone();
388+ let name = row.name.clone();
389+ let action = row.action.clone();
390+ Ok(view! {
391+ <div class="line" data-kb-row="" title=(title.as_str())>
392+ <span class="name" title=(action.as_str())>(name.as_str())</span>
393+ <span class="val">entry_facts(lang: lang, row: row, show_actor: show_actor, show_target: true, show_ip: true, show_details: true)</span>
394+ </div>
395+ })
396+}
397+
398+/// A run of entries: one row with the count and what they share, which opens to list each one
399+/// with what differs.
400+#[component]
401+async fn group_row(lang: Lang, mut group: Group, show_actor: bool) -> Result<impl View> {
402+ let count = group.rows.len().to_string();
403+ let target = group.shared_target().map(str::to_owned);
404+ let ip = group.shared_ip().map(str::to_owned).filter(|ip| !ip.is_empty());
405+ let details = group
406+ .shared_details()
407+ .map(str::to_owned)
408+ .filter(|d| !d.is_empty());
409+ let mut seen: Vec<String> = group.rows.iter().map(|row| row.target.clone()).collect();
410+ seen.sort_unstable();
411+ seen.dedup();
412+ let target_text = match target.as_deref() {
413+ Some(target) => target.to_owned(),
414+ None => format!("{} {}", seen.len(), s(lang, "targets", "hedef")),
415+ };
416+ let show_target = target.is_none();
417+ let show_ip = ip.is_none();
418+ let show_details = details.is_none();
419+ let ip = ip.unwrap_or_default();
420+ let details = details.unwrap_or_default();
421+ let name = group.first().name.clone();
422+ let action = group.first().action.clone();
423+ let when = group.first().when.clone();
424+ let actor = group.first().actor.clone();
425+ let rows = std::mem::take(&mut group.rows);
426+ Ok(view! {
427+ <details class="log-group">
428+ <summary class="line" data-kb-row="">
429+ <span class="name" title=(action.as_str())>(name.as_str())</span>
430+ <span class="count">"×" (count.as_str())</span>
431+ <span class="val">
432+ rel_time(lang: lang, stamp: when.as_str())
433+ if show_actor {
434+ " · " (actor.as_str())
435+ }
436+ if !target_text.is_empty() {
437+ " · " (target_text.as_str())
438+ }
439+ if !ip.is_empty() {
440+ " · IP " (ip.as_str())
441+ }
442+ if !details.is_empty() {
443+ " · " (details.as_str())
444+ }
445+ </span>
446+ </summary>
447+ <div class="log-items">
448+ for row in rows.into_iter() {
449+ item_line(lang: lang, row: row, show_target: show_target, show_ip: show_ip, show_details: show_details)
450+ }
451+ </div>
452+ </details>
453+ })
454+}
455+
456+/// One entry inside an opened run: its time and what the run's row does not already say.
457+#[component]
458+async fn item_line(
459+ lang: Lang,
460+ row: RowView,
461+ show_target: bool,
462+ show_ip: bool,
463+ show_details: bool,
464+) -> Result<impl View> {
465+ let title = row.details.clone();
466+ Ok(view! {
467+ <div class="line" title=(title.as_str())>
468+ <span class="val">entry_facts(lang: lang, row: row, show_actor: false, show_target: show_target, show_ip: show_ip, show_details: show_details)</span>
469+ </div>
470+ })
471+}
472+
282473 #[component]
283474 async fn admin_audit_view(
284475 lang: Lang,
285476 live: String,
477+ finder: Finder,
286478 action: String,
287479 actor: String,
288480 notice: Option<String>,
289- rows: Vec<RowView>,
481+ groups: Vec<Group>,
290482 page: u64,
291483 pages: u64,
292484 nav: (Vec<PageLink>, Option<String>, Option<String>),
@@ -296,28 +488,11 @@ async fn admin_audit_view(
296488 Ok(view! {
297489 head(title: g::t(lang, K::AuditLog), sub: sub)
298490 <div class="sheet" data-live=(live.as_str())>
299- <div class="sheet-tools">
300- <form method="get" action="/admin/audit">
301- <div class="plain-search">
302- <label class="sr-only" for="audit-actor">(g::t(lang, K::ActorUsername))</label>
303- <input id="audit-actor" type="search" name="actor" value=(actor.as_str()) placeholder=(g::t(lang, K::ActorUsername)) data-live-search="" autocomplete="off">
304- <button type="submit" class="sr-only">(g::t(lang, K::Filter))</button>
305- </div>
306- <label>
307- (g::t(lang, K::ActionLabel)) " "
308- <select name="action" data-autosubmit="true">
309- <option value="" selected=(action.is_empty())>(g::t(lang, K::AllActions))</option>
310- for known in AuditAction::ALL.iter().copied() {
311- <option value=(known.as_str()) selected=(known.as_str() == action.as_str())>(action_label(lang, known.as_str()))</option>
312- }
313- </select>
314- </label>
315- </form>
316- </div>
491+ log_tools(lang: lang, form_action: "/admin/audit", finder: finder, action: action, actor: actor)
317492 if let Some(message) = notice {
318493 <p class="state" role="status">(message.as_str())</p>
319494 }
320- audit_table(lang: lang, rows: rows, show_actor: true)
495+ audit_table(lang: lang, groups: groups, show_actor: true)
321496 pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
322497 </div>
323498 })
@@ -327,7 +502,9 @@ async fn admin_audit_view(
327502 async fn own_log_view(
328503 lang: Lang,
329504 items: Vec<RailItem>,
330- rows: Vec<RowView>,
505+ finder: Finder,
506+ action: String,
507+ groups: Vec<Group>,
331508 page: u64,
332509 pages: u64,
333510 nav: (Vec<PageLink>, Option<String>, Option<String>),
@@ -339,25 +516,41 @@ async fn own_log_view(
339516 <div class="work">
340517 rail(label: i18n::t(lang, i18n::Key::Security), items: items)
341518 <div class="sheet">
342- <section class="sec">
343- <h2>(g::t(lang, K::SecurityLogTitle))</h2>
344- <p class="hint">(g::t(lang, K::OwnLogIntro))</p>
345- audit_table(lang: lang, rows: rows, show_actor: false)
346- </section>
519+ log_tools(lang: lang, form_action: "/settings/security/log", finder: finder, action: action, actor: String::new())
520+ audit_table(lang: lang, groups: groups, show_actor: false)
347521 pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
348522 </div>
349523 </div>
350524 })
351525 }
352526
527+/// The search, action and actor a query asks for, trimmed.
528+fn query_parts(query: &AuditQuery) -> (Finder, String, String) {
529+ let finder = Finder::new(
530+ query.q.as_deref(),
531+ query.exact.as_deref(),
532+ query.case.as_deref(),
533+ );
534+ let action = query.action.clone().unwrap_or_default().trim().to_owned();
535+ let actor = query.actor.clone().unwrap_or_default().trim().to_owned();
536+ (finder, action, actor)
537+}
538+
539+/// The link params that keep the search and filters.
540+fn keep_params<'a>(finder: &'a Finder, action: &'a str, actor: &'a str) -> Vec<(&'a str, &'a str)> {
541+ let mut params = finder.params();
542+ params.push(("action", action));
543+ params.push(("actor", actor));
544+ params
545+}
546+
353547 #[page("/admin/audit")]
354548 async fn admin_audit_page(cx: &Cx) -> Result<impl View> {
355549 let viewer = admin_only(cx).await?;
356550 let lang = i18n::lang(cx, Some(&viewer.0));
357551 let query = query_params::<AuditQuery>(cx)?;
358552 let store = &app_context::<AppState>(cx).store;
359- let action = query.action.clone().unwrap_or_default().trim().to_owned();
360- let actor = query.actor.clone().unwrap_or_default().trim().to_owned();
553+ let (finder, action, actor) = query_parts(query);
361554
362555 let mut filter = AuditFilter::default();
363556 let mut notice: Option<String> = None;
@@ -374,30 +567,26 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> {
374567 }
375568 }
376569 // An unknown action or actor matches nothing, so the notice explains the empty table.
377- let (entries, page, pages) = if notice.is_some() {
378- (Vec::new(), 1, 1)
570+ let entries = if notice.is_some() {
571+ Vec::new()
379572 } else {
380- fetch_page(store, &filter, requested_page(&query), ADMIN_PAGE_SIZE).await?
573+ fetch_entries(store, &filter).await?
381574 };
382-
383- let rows = fold_rows(&entries, lang);
384- let nav = nav_for(
385- page,
386- pages,
387- "/admin/audit",
388- &[("action", action.as_str()), ("actor", actor.as_str())],
389- );
575+ let groups = fold_groups(&entries, lang, &finder);
576+ let (groups, page, pages) = page_of(groups, requested_page(query));
577+ let params = keep_params(&finder, &action, &actor);
578+ let nav = nav_for(page, pages, "/admin/audit", &params);
390579 let live = list_href(
391580 "/admin/audit/events",
392581 &[("action", action.as_str()), ("actor", actor.as_str())],
393582 );
394583 let title = g::t(lang, K::AuditLog);
395584 Ok(view! {
396- shell(title: title, viewer: Some(&viewer), admin_audit_view(lang: lang, live: live, action: action, actor: actor, notice: notice, rows: rows, page: page, pages: pages, nav: nav))
585+ shell(title: title, viewer: Some(&viewer), admin_audit_view(lang: lang, live: live, finder: finder.clone(), action: action.clone(), actor: actor.clone(), notice: notice, groups: groups, page: page, pages: pages, nav: nav))
397586 })
398587 }
399588
400-/// The first page of entries the filter selects, as one string: the stream sends when it changes.
589+/// The newest entries the filter selects, as one string: the stream sends when it changes.
401590 /// An unknown action or actor selects nothing, as on the page.
402591 async fn first_page_fingerprint(store: &Store, action: &str, actor: &str) -> Result<String> {
403592 let mut filter = AuditFilter::default();
@@ -413,7 +602,7 @@ async fn first_page_fingerprint(store: &Store, action: &str, actor: &str) -> Res
413602 None => return Ok(String::new()),
414603 }
415604 }
416- let (entries, _, _) = fetch_page(store, &filter, 1, ADMIN_PAGE_SIZE).await?;
605+ let entries = store.list_audit_page(&filter, 0, PAGE_ROWS as u32).await?;
417606 Ok(entries
418607 .iter()
419608 .map(|entry| entry.id.as_str())
@@ -444,19 +633,24 @@ async fn own_log_page(cx: &Cx) -> Result<impl View> {
444633 let lang = i18n::lang(cx, Some(&viewer.0));
445634 let query = query_params::<AuditQuery>(cx)?;
446635 let store = &app_context::<AppState>(cx).store;
447- let filter = AuditFilter {
636+ let (finder, action, _) = query_parts(query);
637+ let mut filter = AuditFilter {
448638 involving_user: Some(viewer.0.id.clone()),
449639 ..Default::default()
450640 };
451- let (entries, page, pages) =
452- fetch_page(store, &filter, requested_page(&query), OWN_PAGE_SIZE).await?;
453-
454- let rows = fold_rows(&entries, lang);
455- let nav = nav_for(page, pages, "/settings/security/log", &[]);
641+ // An unknown action is ignored here: the menu only offers known ones.
642+ if let Some(known) = AuditAction::parse(&action) {
643+ filter.action = Some(known);
644+ }
645+ let entries = fetch_entries(store, &filter).await?;
646+ let groups = fold_groups(&entries, lang, &finder);
647+ let (groups, page, pages) = page_of(groups, requested_page(query));
648+ let params = keep_params(&finder, &action, "");
649+ let nav = nav_for(page, pages, "/settings/security/log", &params);
456650 let items = security_rail_for(app_context::<AppState>(cx), lang, &viewer, "log").await?;
457651 let title = g::t(lang, K::SecurityLogTitle);
458652 Ok(view! {
459- shell(title: title, viewer: Some(&viewer), own_log_view(lang: lang, items: items, rows: rows, page: page, pages: pages, nav: nav))
653+ shell(title: title, viewer: Some(&viewer), own_log_view(lang: lang, items: items, finder: finder.clone(), action: action.clone(), groups: groups, page: page, pages: pages, nav: nav))
460654 })
461655 }
462656
@@ -604,7 +798,8 @@ mod tests {
604798 )
605799 .await;
606800 assert_eq!(status, 200);
607- assert_eq!(body.matches("login_success").count(), 1);
801+ // One row of the viewer's own sign-in (the action filter lists it once more).
802+ assert_eq!(body.matches("title=\"login_success\"").count(), 1);
608803 assert!(body.contains("password_reset_by_admin"));
609804
610805 // The own log needs a session.
@@ -618,6 +813,6 @@ mod tests {
618813 let row = row_view(&entry, Lang::En);
619814 assert_eq!(row.actor, "anonymous");
620815 assert_eq!(row.target, "mallory");
621- assert_eq!(row.details_inline, "");
816+ assert_eq!(row.details, "");
622817 }
623818 }
crates/forge-web/src/pages/avatars.rsmodified+30 -7
@@ -24,6 +24,9 @@ const PALETTE: [&str; 8] = [
2424 const CACHE_IMMUTABLE: &str = "public, max-age=31536000, immutable";
2525 /// Without a matching `?v=`, the browser revalidates: the ETag gives a cheap 304.
2626 const CACHE_REVALIDATE: &str = "no-cache";
27+/// The generated letter avatar is the same for a username until a photo is set, which changes the
28+/// link: a page shows it from cache at once and checks it in the background.
29+const CACHE_DEFAULT: &str = "public, max-age=3600, stale-while-revalidate=604800";
2730 const CSP: &str = "default-src 'none'";
2831
2932 #[query_params(error = bad_request)]
@@ -31,9 +34,10 @@ struct AvatarQuery {
3134 v: Option<String>,
3235 }
3336
34-/// The generated default avatar: the first letter of the username on a palette color.
35-pub fn default_svg(username: &str, user_id: &str) -> String {
36- let digest = Sha256::digest(user_id.as_bytes());
37+/// The generated default avatar: the first letter of the username on a palette color picked by
38+/// the username, so a page can draw it inline without asking the server.
39+pub fn default_svg(username: &str) -> String {
40+ let digest = Sha256::digest(username.as_bytes());
3741 let color = PALETTE[usize::from(digest[0]) % PALETTE.len()];
3842 let letter = username
3943 .chars()
@@ -45,6 +49,22 @@ pub fn default_svg(username: &str, user_id: &str) -> String {
4549 )
4650 }
4751
52+/// The generated default avatar as a `data:` URL, for an `<img>` of an account known to have no
53+/// photo: the page shows it at once, with no request.
54+pub fn default_data_url(username: &str) -> String {
55+ let svg = default_svg(username);
56+ let mut out = String::with_capacity(svg.len() + 40);
57+ out.push_str("data:image/svg+xml,");
58+ for byte in svg.bytes() {
59+ if byte.is_ascii_alphanumeric() || b" -_.~/=:;,'()".contains(&byte) {
60+ out.push(char::from(byte));
61+ } else {
62+ out.push_str(&format!("%{byte:02X}"));
63+ }
64+ }
65+ out
66+}
67+
4868 fn xml_escape(text: &str) -> String {
4969 let mut out = String::with_capacity(text.len());
5070 for c in text.chars() {
@@ -97,10 +117,10 @@ async fn avatar(cx: &Cx) -> Result<(StatusCode, HeaderMap, Vec<u8>)> {
97117 (png, "image/png", hash, cache)
98118 }
99119 None => {
100- let svg = default_svg(&user.username, &user.id).into_bytes();
120+ let svg = default_svg(&user.username).into_bytes();
101121 let digest = Sha256::digest(&svg);
102122 let tag: String = digest.iter().take(8).map(|b| format!("{b:02x}")).collect();
103- (svg, "image/svg+xml", tag, CACHE_REVALIDATE)
123+ (svg, "image/svg+xml", tag, CACHE_DEFAULT)
104124 }
105125 };
106126
@@ -130,9 +150,12 @@ mod tests {
130150
131151 #[test]
132152 fn default_svg_escapes_the_letter_and_is_stable() {
133- let svg = super::default_svg("<", "user-1");
153+ let svg = super::default_svg("<");
134154 assert!(svg.contains(">&lt;</text>"), "{svg}");
135- assert_eq!(svg, super::default_svg("<", "user-1"));
155+ assert_eq!(svg, super::default_svg("<"));
156+ let url = super::default_data_url("<");
157+ assert!(url.starts_with("data:image/svg+xml,%3Csvg"), "{url}");
158+ assert!(!url.contains('<') && !url.contains('#') && !url.contains('"'), "{url}");
136159 assert!(super::PALETTE.iter().any(|c| svg.contains(c)));
137160 }
138161
crates/forge-web/src/pages/ci_job.rsmodified+2 -0
@@ -479,6 +479,8 @@ async fn job_body(
479479 <strong>(g::t(lang, K::Log))</strong>
480480 <div class="ci-tl-tools">
481481 <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false">
482+ <label class="find-opt" title=(crate::pages::passkeys::s(lang, "Only the text as typed, as one piece", "Yalnızca yazılan metin, tek parça olarak"))><input type="checkbox" data-log-exact="true"><span>(crate::pages::passkeys::s(lang, "Exact", "Tam"))</span></label>
483+ <label class="find-opt" title=(crate::pages::passkeys::s(lang, "Keep upper and lower case apart", "Büyük ve küçük harfi ayırt et"))><input type="checkbox" data-log-case="true"><span>"Aa"</span></label>
482484 <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span>
483485 <button type="button" class="act" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button>
484486 <button type="button" class="act" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button>
crates/forge-web/src/pages/ci_runs.rsmodified+2 -0
@@ -2623,6 +2623,8 @@ async fn run_log(
26232623 if let Some(log) = run.log.as_ref() {
26242624 <div class="ci-tl-tools">
26252625 <input type="search" class="ci-logsearch" data-log-q="true" placeholder=(g::t(lang, K::LogSearch)) aria-label=(g::t(lang, K::LogSearch)) autocomplete="off" spellcheck="false">
2626+ <label class="find-opt" title=(crate::pages::passkeys::s(lang, "Only the text as typed, as one piece", "Yalnızca yazılan metin, tek parça olarak"))><input type="checkbox" data-log-exact="true"><span>(crate::pages::passkeys::s(lang, "Exact", "Tam"))</span></label>
2627+ <label class="find-opt" title=(crate::pages::passkeys::s(lang, "Keep upper and lower case apart", "Büyük ve küçük harfi ayırt et"))><input type="checkbox" data-log-case="true"><span>"Aa"</span></label>
26262628 <span class="ci-logcount" data-log-count="true" data-none=(g::t(lang, K::LogNoMatches)) aria-live="polite"></span>
26272629 <button type="button" class="act" data-log-prev="true" aria-label=(g::t(lang, K::LogPrev)) title=(g::t(lang, K::LogPrev))>"\u{2191}"</button>
26282630 <button type="button" class="act" data-log-next="true" aria-label=(g::t(lang, K::LogNext)) title=(g::t(lang, K::LogNext))>"\u{2193}"</button>
crates/forge-web/src/pages/explore.rsmodified+200 -87
@@ -1,8 +1,10 @@
11 //! Page: public repo listing at `/explore`. Only public repos are listed, even for their owners
2-//! (private repos never appear here). A search box filters by name or description, three sort
3-//! orders are offered, and 30 repos are shown per page. `explore` is a reserved username, so this
2+//! (private repos never appear here). A live search reads names and descriptions, forgiving typos
3+//! unless Exact or Aa is on; three sort orders are offered, and 12 repos are shown per page, so a
4+//! page fits the window. `explore` is a reserved username, so this
45 //! route cannot collide with a profile.
56
7+use forge_core::{Repo, User};
68 use forge_core::store::RepoSort;
79 use topcoat::Result;
810 use topcoat::context::{Cx, app_context};
@@ -19,11 +21,13 @@ use crate::views::parts::{SubPart, head};
1921 use crate::views::repo_list::{
2022 PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips,
2123 };
22-use crate::views::{enc, now_unix, shell};
24+use crate::pages::issues_list::list_href;
25+use crate::views::find::{Finder, finder_field};
26+use crate::views::{now_unix, shell};
2327
24-const PER_PAGE: u64 = 30;
25-/// Longest search text kept, in characters.
26-const MAX_QUERY_CHARS: usize = 100;
28+const PER_PAGE: u64 = 12;
29+/// The most public repos a search reads.
30+const SEARCH_CAP: u64 = 5000;
2731
2832 /// Sort keys in the order their links are shown, with the text key of each link. The first one is
2933 /// the default.
@@ -36,20 +40,61 @@ const SORTS: [(&str, K); 3] = [
3640 #[query_params(error = bad_request)]
3741 struct ExploreQuery {
3842 q: Option<String>,
43+ exact: Option<String>,
44+ case: Option<String>,
3945 sort: Option<String>,
4046 page: Option<String>,
47+ tab: Option<String>,
48+}
49+
50+/// The Organizations tab's key in the query.
51+const ORGS_TAB: &str = "organizations";
52+
53+/// True when the query asks for the Organizations tab.
54+fn orgs_tab(query: &ExploreQuery) -> bool {
55+ query.tab.as_deref() == Some(ORGS_TAB)
56+}
57+
58+/// `/explore?tab=organizations` with the given search and page.
59+fn orgs_href(finder: &Finder, page: u64) -> String {
60+ let number = page.to_string();
61+ let mut params = finder.params();
62+ params.push(("tab", ORGS_TAB));
63+ params.push(("page", number.as_str()));
64+ list_href("/explore", &params)
65+}
66+
67+/// The organizations the search matches, by name, and how many there are: one page.
68+async fn org_listing(state: &AppState, finder: &Finder, page: u64) -> Result<(Vec<User>, u64)> {
69+ let mut all: Vec<User> = state
70+ .store
71+ .list_orgs()
72+ .await?
73+ .into_iter()
74+ .filter(|org| {
75+ finder.matches_any(&[
76+ org.username.as_str(),
77+ org.display_name.as_deref().unwrap_or(""),
78+ ])
79+ })
80+ .collect();
81+ all.sort_by_key(|org| org.username.to_lowercase());
82+ let total = all.len() as u64;
83+ let shown = all
84+ .into_iter()
85+ .skip(((page.max(1) - 1) * PER_PAGE) as usize)
86+ .take(PER_PAGE as usize)
87+ .collect();
88+ Ok((shown, total))
4189 }
4290
4391 /// `/explore` with the given search, sort key and page. An empty search is left out.
44-fn explore_href(q: &str, sort: &str, page: u64) -> String {
45- let mut href = String::from("/explore?");
46- if !q.is_empty() {
47- href.push_str("q=");
48- href.push_str(&enc(q));
49- href.push('&');
50- }
51- href.push_str(&format!("sort={sort}&page={page}"));
52- href
92+fn explore_href(finder: &Finder, sort: &str, page: u64) -> String {
93+ let number = page.to_string();
94+ let mut params = finder.params();
95+ params.push(("sort", sort));
96+ params.push(("page", number.as_str()));
97+ list_href("/explore", &params)
5398 }
5499
55100 /// Maps the `sort` query value to a key from `SORTS`; anything unknown means the default.
@@ -61,16 +106,13 @@ fn sort_key(raw: Option<&str>) -> &'static str {
61106 .unwrap_or(SORTS[0].0)
62107 }
63108
64-/// The search text, sort key and page the query asks for, with the defaults filled in.
65-fn listing_args(query: &ExploreQuery) -> (String, &'static str, u64) {
66- let q: String = query
67- .q
68- .as_deref()
69- .unwrap_or("")
70- .trim()
71- .chars()
72- .take(MAX_QUERY_CHARS)
73- .collect();
109+/// The search, sort key and page the query asks for, with the defaults filled in.
110+fn listing_args(query: &ExploreQuery) -> (Finder, &'static str, u64) {
111+ let finder = Finder::new(
112+ query.q.as_deref(),
113+ query.exact.as_deref(),
114+ query.case.as_deref(),
115+ );
74116 let sort = sort_key(query.sort.as_deref());
75117 let page = query
76118 .page
@@ -78,28 +120,63 @@ fn listing_args(query: &ExploreQuery) -> (String, &'static str, u64) {
78120 .and_then(|p| p.parse::<u64>().ok())
79121 .unwrap_or(1)
80122 .max(1);
81- (q, sort, page)
123+ (finder, sort, page)
124+}
125+
126+/// The public repos the search matches, in the sort's order, and how many there are: one page.
127+async fn listing(
128+ state: &AppState,
129+ finder: &Finder,
130+ sort: &'static str,
131+ page: u64,
132+) -> Result<(Vec<(Repo, u64, String)>, u64)> {
133+ let sort_kind = match sort {
134+ "stars" => RepoSort::MostStars,
135+ "name" => RepoSort::Name,
136+ _ => RepoSort::RecentlyUpdated,
137+ };
138+ let (all, _) = state
139+ .store
140+ .list_public_repos(None, sort_kind, 1, SEARCH_CAP)
141+ .await?;
142+ let matching: Vec<_> = all
143+ .into_iter()
144+ .filter(|(repo, _, _)| {
145+ let full = format!("{}/{}", repo.owner_name, repo.name);
146+ finder.matches_any(&[full.as_str(), repo.description.as_str()])
147+ })
148+ .collect();
149+ let total = matching.len() as u64;
150+ let shown = matching
151+ .into_iter()
152+ .skip(((page.max(1) - 1) * PER_PAGE) as usize)
153+ .take(PER_PAGE as usize)
154+ .collect();
155+ Ok((shown, total))
82156 }
83157
84158 #[page("/explore")]
85159 async fn explore_page(cx: &Cx) -> Result<impl View> {
86160 let query = query_params::<ExploreQuery>(cx)?;
87- let (q, sort, page) = listing_args(query);
88- let live = explore_href(&q, sort, page).replacen("/explore?", "/explore/events?", 1);
161+ let (finder, sort, page) = listing_args(query);
162+ let live = explore_href(&finder, sort, page).replacen("/explore?", "/explore/events?", 1);
89163 let viewer = current_user(cx).await?;
90164 let lang = i18n::lang(cx, viewer.as_ref().map(|(u, _)| u));
91165 let state = app_context::<AppState>(cx);
92-
93- let sort_kind = match sort {
94- "stars" => RepoSort::MostStars,
95- "name" => RepoSort::Name,
96- _ => RepoSort::RecentlyUpdated,
97- };
98- let search = (!q.is_empty()).then_some(q.as_str());
99- let (listed, total) = state
166+ let on_orgs = orgs_tab(query);
167+ let (listed, repo_total) = listing(state, &finder, sort, page).await?;
168+ let (org_page, org_total) = org_listing(state, &finder, page).await?;
169+ let total = if on_orgs { org_total } else { repo_total };
170+ let (_, repos_all) = state
100171 .store
101- .list_public_repos(search, sort_kind, page, PER_PAGE)
172+ .list_public_repos(None, RepoSort::RecentlyUpdated, 1, 1)
102173 .await?;
174+ let orgs_all = state.store.list_orgs().await?.len() as u64;
175+ let live = if on_orgs {
176+ orgs_href(&finder, page).replacen("/explore?", "/explore/events?", 1)
177+ } else {
178+ live
179+ };
103180
104181 let now = now_unix();
105182 let tz = viewer.as_ref().map_or("UTC", |(u, _)| u.timezone.as_str());
@@ -107,30 +184,38 @@ async fn explore_page(cx: &Cx) -> Result<impl View> {
107184 .into_iter()
108185 .map(|listed| RepoRow::new(lang, tz, now, listed))
109186 .collect();
110- let orgs: Vec<String> = state
111- .store
112- .list_orgs()
113- .await?
114- .into_iter()
115- .map(|org| org.username)
116- .collect();
187+ let mut orgs: Vec<(String, String)> = Vec::new();
188+ for org in org_page {
189+ let hash = state.store.avatar_hash(&org.id).await?;
190+ let avatar = crate::views::avatar_url(&org.username, hash.as_deref());
191+ orgs.push((org.username, avatar));
192+ }
117193 let pages = total.div_ceil(PER_PAGE).max(1);
118194 let page = page.min(pages);
119195 let sort_links: Vec<SortLink> = SORTS
120196 .iter()
121197 .map(|(key, label)| SortLink {
122198 label: g::t(lang, *label),
123- href: explore_href(&q, key, 1),
199+ href: explore_href(&finder, key, 1),
124200 current: *key == sort,
125201 })
126202 .collect();
127- let nav = pager_links(page, pages, |n| explore_href(&q, sort, n));
203+ let nav = if on_orgs {
204+ pager_links(page, pages, |n| orgs_href(&finder, n))
205+ } else {
206+ pager_links(page, pages, |n| explore_href(&finder, sort, n))
207+ };
208+ let tabs = vec![
209+ (g::t(lang, K::Repositories), explore_href(&Finder::default(), sort, 1), repos_all, !on_orgs),
210+ (g::t(lang, K::Organizations), orgs_href(&Finder::default(), 1), orgs_all, on_orgs),
211+ ];
128212 let title = g::t(lang, K::Explore);
129213
130214 Ok(view! { cx =>
131215 shell(title: title, viewer: viewer.as_ref(),
132- explore_body(q: q, sort: sort, sort_links: sort_links, rows: rows,
133- total: total, page: page, pages: pages, nav: nav, orgs: orgs, lang: lang, live: live))
216+ explore_body(finder: finder, sort: sort, sort_links: sort_links, rows: rows,
217+ total: total, page: page, pages: pages, nav: nav, orgs: orgs, lang: lang, live: live,
218+ on_orgs: on_orgs, tabs: tabs))
134219 })
135220 }
136221
@@ -140,12 +225,13 @@ async fn explore_page(cx: &Cx) -> Result<impl View> {
140225 #[route(GET "/explore/events")]
141226 async fn explore_events(cx: &Cx) -> Result<Response> {
142227 let query = query_params::<ExploreQuery>(cx)?;
143- let (q, sort, page) = listing_args(query);
228+ let (finder, sort, page) = listing_args(query);
229+ let on_orgs = orgs_tab(query);
144230 let state = app_context::<AppState>(cx).clone();
145231 stream_changes(cx, &state.live.clone(), &[Topic::Explore], move || {
146232 let state = state.clone();
147- let q = q.clone();
148- async move { explore_fingerprint(&state, &q, sort, page).await }
233+ let finder = finder.clone();
234+ async move { explore_fingerprint(&state, &finder, sort, page, on_orgs).await }
149235 })
150236 .await
151237 }
@@ -153,20 +239,18 @@ async fn explore_events(cx: &Cx) -> Result<Response> {
153239 /// The state the explore listing shows: its total, each row with its stars, and the org names.
154240 async fn explore_fingerprint(
155241 state: &AppState,
156- q: &str,
242+ finder: &Finder,
157243 sort: &'static str,
158244 page: u64,
245+ on_orgs: bool,
159246 ) -> Result<String> {
160- let sort_kind = match sort {
161- "stars" => RepoSort::MostStars,
162- "name" => RepoSort::Name,
163- _ => RepoSort::RecentlyUpdated,
164- };
165- let search = (!q.is_empty()).then_some(q);
166- let (listed, total) = state
167- .store
168- .list_public_repos(search, sort_kind, page, PER_PAGE)
169- .await?;
247+ if on_orgs {
248+ let (orgs, total) = org_listing(state, finder, page).await?;
249+ let mut lines = vec![total.to_string()];
250+ lines.extend(orgs.into_iter().map(|org| format!("org {}", org.username)));
251+ return Ok(lines.join("\n"));
252+ }
253+ let (listed, total) = listing(state, finder, sort, page).await?;
170254 let mut lines = vec![total.to_string()];
171255 for (repo, stars, activity) in listed {
172256 lines.push(format!(
@@ -174,15 +258,12 @@ async fn explore_fingerprint(
174258 repo.owner_name, repo.name, repo.description, repo.visibility, repo.default_branch
175259 ));
176260 }
177- for org in state.store.list_orgs().await? {
178- lines.push(format!("org {}", org.username));
179- }
180261 Ok(lines.join("\n"))
181262 }
182263
183264 #[component]
184265 async fn explore_body(
185- q: String,
266+ finder: Finder,
186267 sort: &'static str,
187268 sort_links: Vec<SortLink>,
188269 rows: Vec<RepoRow>,
@@ -190,47 +271,79 @@ async fn explore_body(
190271 page: u64,
191272 pages: u64,
192273 nav: (Vec<PageLink>, Option<String>, Option<String>),
193- orgs: Vec<String>,
274+ orgs: Vec<(String, String)>,
194275 lang: Lang,
195276 live: String,
277+ on_orgs: bool,
278+ tabs: Vec<(&'static str, String, u64, bool)>,
196279 ) -> Result<impl View> {
197- let empty = rows.is_empty();
198- let has_search = !q.is_empty();
199- let has_orgs = !orgs.is_empty();
280+ let empty = if on_orgs { orgs.is_empty() } else { rows.is_empty() };
281+ let has_search = !finder.is_empty();
200282 let (links, prev, next) = nav;
201- let clear_href = explore_href("", sort, 1);
283+ let clear_href = if on_orgs {
284+ orgs_href(&Finder::default(), 1)
285+ } else {
286+ explore_href(&Finder::default(), sort, 1)
287+ };
288+ let placeholder = if on_orgs {
289+ crate::pages::passkeys::s(lang, "Search organizations", "Kuruluşlarda ara")
290+ } else {
291+ g::t(lang, K::SearchPublicRepos)
292+ };
293+ let count_text = match (lang, total) {
294+ (Lang::Tr, n) => format!("{n} kuruluş"),
295+ (_, 1) => "1 organization".to_owned(),
296+ (_, n) => format!("{n} organizations"),
297+ };
298+ let empty_text = if on_orgs {
299+ crate::pages::passkeys::s(lang, "No organization matches.", "Eşleşen kuruluş yok.")
300+ } else {
301+ g::t(lang, K::NoPublicReposMatch)
302+ };
202303 Ok(view! {
203304 head(title: g::t(lang, K::Explore), sub: vec![SubPart::text(g::t(lang, K::PublicReposIntro))])
305+ <nav class="tabs" aria-label=(g::t(lang, K::Explore))>
306+ for (label, href, count, on) in tabs.into_iter() {
307+ <a href=(href) aria-current=(on.then_some("page"))>(label) " " <span class="tab-count">(count.to_string())</span></a>
308+ }
309+ </nav>
204310 <div class="sheet" data-live=(live.as_str())>
205311 <div class="sheet-tools">
206- <strong>(g::repo_count(lang, total))</strong>
207- <form method="get" action="/explore" class="plain-search" role="search">
208- <input type="search" name="q" value=(q.as_str()) data-live-search=""
209- placeholder=(g::t(lang, K::SearchPublicRepos)) aria-label=(g::t(lang, K::SearchPublicRepos))>
210- <input type="hidden" name="sort" value=(sort)>
211- <button type="submit" class="act">(g::t(lang, K::Search))</button>
312+ if on_orgs {
313+ <strong>(count_text.as_str())</strong>
314+ } else {
315+ <strong>(g::repo_count(lang, total))</strong>
316+ }
317+ <form method="get" action="/explore" role="search">
318+ finder_field(lang: lang, finder: finder, placeholder: placeholder, id: Some("explore-q"))
319+ if on_orgs {
320+ <input type="hidden" name="tab" value=(ORGS_TAB)>
321+ } else {
322+ <input type="hidden" name="sort" value=(sort)>
323+ }
212324 </form>
213- sort_chips(links: sort_links, lang: lang)
325+ if !on_orgs {
326+ sort_chips(links: sort_links, lang: lang)
327+ }
214328 </div>
215329 if empty {
216- <p class="state">(g::t(lang, K::NoPublicReposMatch))</p>
330+ <p class="state">(empty_text)</p>
217331 if has_search {
218332 <div class="acts">
219333 <a class="act" href=(clear_href.as_str())>(g::t(lang, K::ClearSearch))</a>
220334 </div>
221335 }
336+ } else if on_orgs {
337+ for (name, avatar) in orgs.into_iter() {
338+ <a class="line" href=(crate::views::user_href(&name)) data-kb-row="">
339+ <img class="avatar avatar-sm" src=(avatar) alt="" width="24" height="24">
340+ <span class="name">(name)</span>
341+ </a>
342+ }
222343 } else {
223344 repo_rows(rows: rows, lang: lang)
224345 }
225346 pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
226- if has_orgs {
227- <section class="sec">
228- <h2>(g::t(lang, K::Organizations))</h2>
229- for org in orgs.iter() {
230- <a class="line" href=(format!("/{}", org.as_str()))><span class="name">(org.as_str())</span></a>
231- }
232- </section>
233- }
234347 </div>
235348 })
236349 }
crates/forge-web/src/pages/import.rsmodified+49 -29
@@ -180,12 +180,15 @@ async fn source_tabs(lang: Lang, base: &str, active: Source) -> Result<impl View
180180 let gitlab = format!("{base}?source=gitlab");
181181 let forgejo = format!("{base}?source=forgejo");
182182 Ok(view! {
183- <nav class="tabs" aria-label=(g::t(lang, K::TabImport))>
184- <a href=(git.as_str()) aria-current=((active == Source::Git).then_some("page"))>(g::t(lang, K::SrcGit))</a>
185- <a href=(github.as_str()) aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</a>
186- <a href=(gitlab.as_str()) aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</a>
187- <a href=(forgejo.as_str()) aria-current=((active == Source::Forgejo).then_some("page"))>(g::t(lang, K::SrcForgejo))</a>
188- </nav>
183+ <div class="field">
184+ <span class="field-label">(crate::pages::passkeys::s(lang, "Source", "Kaynak"))</span>
185+ <nav class="choice" aria-label=(g::t(lang, K::TabImport))>
186+ <a href=(git.as_str()) aria-current=((active == Source::Git).then_some("page"))>(g::t(lang, K::SrcGit))</a>
187+ <a href=(github.as_str()) aria-current=((active == Source::GitHub).then_some("page"))>(g::t(lang, K::SrcGitHub))</a>
188+ <a href=(gitlab.as_str()) aria-current=((active == Source::GitLab).then_some("page"))>(g::t(lang, K::SrcGitLab))</a>
189+ <a href=(forgejo.as_str()) aria-current=((active == Source::Forgejo).then_some("page"))>(g::t(lang, K::SrcForgejo))</a>
190+ </nav>
191+ </div>
189192 })
190193 }
191194
@@ -278,6 +281,7 @@ impl Draft {
278281 #[component]
279282 async fn import_form(
280283 lang: Lang,
284+ username: String,
281285 csrf: &str,
282286 draft: Draft,
283287 error: Option<String>,
@@ -317,24 +321,16 @@ async fn import_form(
317321 let opts = draft.opts;
318322 Ok(view! {
319323 head(title: g::t(lang, K::ImportTitle), sub: vec![SubPart::text(g::t(lang, K::ImportIntro))])
324+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
320325 newrepo_tabs(lang: lang, active: "import")
321- source_tabs(lang: lang, base: "/new/import", active: source)
322326 <div class="sheet fit">
323- if !is_git {
324- <section class="sec">
325- <h2>(g::t(lang, K::BulkLink))</h2>
326- <p class="hint">(g::t(lang, K::BulkIntro))</p>
327- <div class="acts">
328- <a class="act" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a>
329- </div>
330- </section>
331- }
332327 <form method="post" action="/new/import" class="fields">
333328 if let Some(message) = error {
334329 alert(message: message.as_str())
335330 }
336331 csrf_field(token: csrf)
337332 <input type="hidden" name="source" value=(source_value)>
333+ source_tabs(lang: lang, base: "/new/import", active: source)
338334 if has_instance {
339335 <div class="field">
340336 <label for="import-instance">(instance_label)</label>
@@ -379,6 +375,15 @@ async fn import_form(
379375 visibility_pick(lang: lang, private: private)
380376 <button type="submit" class="primary">(g::t(lang, K::StartImport))</button>
381377 </form>
378+ if !is_git {
379+ <section class="sec">
380+ <h2>(g::t(lang, K::BulkLink))</h2>
381+ <p class="hint">(g::t(lang, K::BulkIntro))</p>
382+ <div class="acts">
383+ <a class="act" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a>
384+ </div>
385+ </section>
386+ }
382387 </div>
383388 })
384389 }
@@ -390,6 +395,7 @@ const RECENT_IMPORTS: usize = 5;
390395 #[component]
391396 async fn import_home(
392397 lang: Lang,
398+ username: String,
393399 csrf: String,
394400 draft: Draft,
395401 owners: Vec<String>,
@@ -397,7 +403,7 @@ async fn import_home(
397403 more: bool,
398404 ) -> Result<impl View> {
399405 Ok(view! {
400- import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners)
406+ import_form(lang: lang, username: username, csrf: csrf.as_str(), draft: draft, error: None, owners: owners)
401407 recent_imports(lang: lang, jobs: jobs, more: more)
402408 })
403409 }
@@ -406,13 +412,14 @@ async fn import_home(
406412 #[component]
407413 async fn import_error_body(
408414 lang: Lang,
415+ username: String,
409416 csrf: String,
410417 draft: Draft,
411418 error: String,
412419 owners: Vec<String>,
413420 ) -> Result<impl View> {
414421 Ok(view! {
415- import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners)
422+ import_form(lang: lang, username: username, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners)
416423 })
417424 }
418425
@@ -431,7 +438,7 @@ async fn import_page(cx: &Cx) -> Result<impl View> {
431438 jobs.truncate(RECENT_IMPORTS);
432439 Ok(view! { cx =>
433440 shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer),
434- import_home(lang: lang, csrf: csrf, draft: Draft::fresh(source), owners: owners, jobs: jobs, more: more))
441+ import_home(lang: lang, username: viewer.0.username.clone(), csrf: csrf, draft: Draft::fresh(source), owners: owners, jobs: jobs, more: more))
435442 })
436443 }
437444
@@ -448,7 +455,7 @@ async fn import_submit(cx: &Cx, Form(form): Form<ImportForm>) -> Result<impl Vie
448455 let draft = Draft::from_form(&form, source);
449456 Ok(view! { cx =>
450457 shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer),
451- import_error_body(lang: lang, csrf: csrf, draft: draft, error: message, owners: owners))
458+ import_error_body(lang: lang, username: viewer.0.username.clone(), csrf: csrf, draft: draft, error: message, owners: owners))
452459 })
453460 }
454461 }
@@ -593,6 +600,7 @@ async fn begin(
593600 #[component]
594601 async fn bulk_form(
595602 lang: Lang,
603+ username: String,
596604 csrf: &str,
597605 source: Source,
598606 instance: &str,
@@ -611,8 +619,8 @@ async fn bulk_form(
611619 let owner_required = source != Source::Forgejo;
612620 Ok(view! {
613621 head(title: g::t(lang, K::BulkTitle), sub: vec![SubPart::text(g::t(lang, K::BulkIntro))])
622+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
614623 newrepo_tabs(lang: lang, active: "import")
615- source_tabs(lang: lang, base: "/new/import/bulk", active: source)
616624 <div class="sheet fit">
617625 <form method="post" action="/new/import/bulk" class="fields">
618626 if let Some(message) = error {
@@ -620,6 +628,7 @@ async fn bulk_form(
620628 }
621629 csrf_field(token: csrf)
622630 <input type="hidden" name="source" value=(source_value)>
631+ source_tabs(lang: lang, base: "/new/import/bulk", active: source)
623632 <input type="hidden" name="stage" value="list">
624633 if has_instance {
625634 <div class="field">
@@ -655,6 +664,7 @@ struct Listed {
655664 #[component]
656665 async fn bulk_select(
657666 lang: Lang,
667+ username: String,
658668 csrf: &str,
659669 form: BulkFormEcho,
660670 repos: Vec<Listed>,
@@ -671,6 +681,7 @@ async fn bulk_select(
671681 };
672682 Ok(view! {
673683 head(title: g::t(lang, K::BulkSelectHeading))
684+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
674685 newrepo_tabs(lang: lang, active: "import")
675686 <div class="sheet">
676687 <form method="post" action="/new/import/bulk" class="fields">
@@ -753,7 +764,7 @@ async fn bulk_page(cx: &Cx) -> Result<impl View> {
753764 let csrf = viewer.1.csrf_token.clone();
754765 Ok(view! { cx =>
755766 shell(title: g::t(lang, K::BulkTitle), viewer: Some(&viewer),
756- bulk_form(lang: lang, csrf: csrf.as_str(), source: source, instance: default_instance(source), owners: owners, error: query.error.clone().filter(|e| e.len() < 300)))
767+ bulk_form(lang: lang, username: viewer.0.username.clone(), csrf: csrf.as_str(), source: source, instance: default_instance(source), owners: owners, error: query.error.clone().filter(|e| e.len() < 300)))
757768 })
758769 }
759770
@@ -852,7 +863,7 @@ async fn bulk_submit(cx: &Cx, Form(form): Form<BulkForm>) -> Result<impl View> {
852863 };
853864 Ok(view! { cx =>
854865 shell(title: g::t(lang, K::BulkTitle), viewer: Some(&viewer),
855- bulk_stage(lang: lang, csrf: csrf.as_str(), source: source, instance: instance.as_str(), owners: owners, error: error, picker: picker))
866+ bulk_stage(lang: lang, username: viewer.0.username.clone(), csrf: csrf.as_str(), source: source, instance: instance.as_str(), owners: owners, error: error, picker: picker))
856867 })
857868 }
858869
@@ -860,6 +871,7 @@ async fn bulk_submit(cx: &Cx, Form(form): Form<BulkForm>) -> Result<impl View> {
860871 #[component]
861872 async fn bulk_stage(
862873 lang: Lang,
874+ username: String,
863875 csrf: &str,
864876 source: Source,
865877 instance: &str,
@@ -869,9 +881,9 @@ async fn bulk_stage(
869881 ) -> Result<impl View> {
870882 Ok(view! {
871883 if let Some((echo, repos)) = picker {
872- bulk_select(lang: lang, csrf: csrf, form: echo, repos: repos, owners: owners)
884+ bulk_select(lang: lang, username: username, csrf: csrf, form: echo, repos: repos, owners: owners)
873885 } else {
874- bulk_form(lang: lang, csrf: csrf, source: source, instance: instance, owners: owners, error: error)
886+ bulk_form(lang: lang, username: username, csrf: csrf, source: source, instance: instance, owners: owners, error: error)
875887 }
876888 })
877889 }
@@ -1075,6 +1087,7 @@ async fn recent_imports(
10751087 #[component]
10761088 async fn jobs_list(
10771089 lang: Lang,
1090+ username: String,
10781091 jobs: Vec<(ImportJob, Option<Repo>)>,
10791092 skipped: Option<String>,
10801093 ) -> Result<impl View> {
@@ -1082,6 +1095,8 @@ async fn jobs_list(
10821095 let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed);
10831096 Ok(view! {
10841097 head(title: g::t(lang, K::JobsTitle), live: Some("/import/events"))
1098+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
1099+ newrepo_tabs(lang: lang, active: "import")
10851100 <div class="sheet">
10861101 if retry {
10871102 <div class="sheet-tools">
@@ -1155,13 +1170,14 @@ async fn jobs_page(cx: &Cx) -> Result<impl View> {
11551170 .filter(|s| !s.is_empty() && s.len() < 2000)
11561171 .map(|s| g::bulk_skipped(lang, &s));
11571172 Ok(view! { cx =>
1158- shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, jobs: rows, skipped: skipped))
1173+ shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, username: viewer.0.username.clone(), jobs: rows, skipped: skipped))
11591174 })
11601175 }
11611176
11621177 #[component]
11631178 async fn job_view(
11641179 lang: Lang,
1180+ username: String,
11651181 csrf: &str,
11661182 job: ImportJob,
11671183 repo: Option<Repo>,
@@ -1194,6 +1210,8 @@ async fn job_view(
11941210 }];
11951211 Ok(view! {
11961212 head(title: job.source_ref.as_str(), sub: sub, live: live.as_deref())
1213+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
1214+ newrepo_tabs(lang: lang, active: "import")
11971215 <div class="sheet import-job" data-live-state=(state_word)>
11981216 <section class="sec">
11991217 if !stage.is_empty() {
@@ -1271,7 +1289,7 @@ async fn job_page(cx: &Cx) -> Result<impl View> {
12711289 let title = job.source_ref.clone();
12721290 Ok(view! { cx =>
12731291 shell(title: title.as_str(), viewer: Some(&viewer),
1274- job_view(lang: lang, csrf: csrf.as_str(), job: job, repo: repo, log: log))
1292+ job_view(lang: lang, username: viewer.0.username.clone(), csrf: csrf.as_str(), job: job, repo: repo, log: log))
12751293 })
12761294 }
12771295
@@ -1409,11 +1427,13 @@ fn source_label(raw: &str) -> &'static str {
14091427 }
14101428
14111429 #[component]
1412-async fn retry_list(lang: Lang, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Result<impl View> {
1430+async fn retry_list(lang: Lang, username: String, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Result<impl View> {
14131431 let count = rows.len();
14141432 let empty = rows.is_empty();
14151433 Ok(view! {
14161434 head(title: g::t(lang, K::RetryFailedTitle))
1435+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
1436+ newrepo_tabs(lang: lang, active: "import")
14171437 <div class="sheet">
14181438 <form method="post" action="/import/retry" class="fields">
14191439 csrf_field(token: csrf)
@@ -1461,7 +1481,7 @@ async fn retry_page(cx: &Cx) -> Result<impl View> {
14611481 let csrf = viewer.1.csrf_token.clone();
14621482 Ok(view! { cx =>
14631483 shell(title: g::t(lang, K::RetryFailedTitle), viewer: Some(&viewer),
1464- retry_list(lang: lang, csrf: csrf.as_str(), rows: rows))
1484+ retry_list(lang: lang, username: viewer.0.username.clone(), csrf: csrf.as_str(), rows: rows))
14651485 })
14661486 }
14671487
crates/forge-web/src/pages/issue_parts.rsmodified+2 -2
@@ -28,7 +28,7 @@ use crate::state::AppState;
2828 use crate::views::review_thread::{ThreadCtx, review_thread_in};
2929 use crate::views::user_facing_message;
3030 use crate::views::{
31- alert, avatar_url, display_name, iso_time, now_unix, relative_time, repo_href, short_oid,
31+ alert, avatar_url, avatar_url_unknown, display_name, iso_time, now_unix, relative_time, repo_href, short_oid,
3232 user_href, user_link,
3333 };
3434 use crate::views::parts::{confirm_act, reveal};
@@ -990,7 +990,7 @@ async fn review_entries(
990990 anchor: format!("review-{}", review.id),
991991 author: display_name(lang, &review.author_name),
992992 login: review.author_name.clone(),
993- avatar: avatar_url(&review.author_name, None),
993+ avatar: avatar_url_unknown(&review.author_name),
994994 when: When::new(lang, &stamp, tz, now),
995995 verb,
996996 dismissed,
crates/forge-web/src/pages/issues_list.rsmodified+2 -2
@@ -28,7 +28,7 @@ use crate::state::AppState;
2828 use crate::templates::{self, Template};
2929 use crate::views::parts::{RailItem, SubPart, rail};
3030 use crate::views::{
31- alert, avatar_url, csrf_field, enc, iso_time, now_unix, relative_time, repo_href,
31+ alert, avatar_url_unknown, csrf_field, enc, iso_time, now_unix, relative_time, repo_href,
3232 shell, user_facing_message, user_link,
3333 };
3434 use crate::webhooks::emit::{Sender, emit_issue};
@@ -349,7 +349,7 @@ fn row_view(row: RowCtx<'_>, item: &IssueListItem) -> RowView {
349349 .iter()
350350 .map(|name| AssigneeView {
351351 name: name.clone(),
352- avatar: avatar_url(name, None),
352+ avatar: avatar_url_unknown(name),
353353 })
354354 .collect(),
355355 has_comments: comments > 0,
crates/forge-web/src/pages/needs_you.rsmodified+14 -10
@@ -410,6 +410,7 @@ async fn needs_you(cx: &Cx) -> Result<impl View> {
410410 let empty = full.is_none() && sections.is_empty();
411411 let back = full.as_ref().map(|_| ni::t(lang, K::BackToNeedsYou));
412412 let heading = ni::t(lang, K::NeedsYou);
413+ let unread = state.store.unread_count(&user.id).await?;
413414 let sub = vec![SubPart::text(s(lang, "Waiting on you", "Senden beklenenler"))];
414415 Ok(view! {
415416 shell(title: heading, viewer: Some(&viewer),
@@ -418,16 +419,19 @@ async fn needs_you(cx: &Cx) -> Result<impl View> {
418419 <a class="act" href="/needs-you">(back)</a>
419420 }
420421 )
421- <div class="sheet">
422- if empty {
423- <p class="state">(ni::t(lang, K::AllClear))</p>
424- }
425- for section in sections.into_iter() {
426- need_section(lang: lang, section: section)
427- }
428- if let Some(section) = full {
429- need_section(lang: lang, section: section)
430- }
422+ <div class="work">
423+ crate::pages::notifications::inbox_rail(lang: lang, current: "needs", unread_count: unread)
424+ <div class="sheet">
425+ if empty {
426+ <p class="state">(ni::t(lang, K::AllClear))</p>
427+ }
428+ for section in sections.into_iter() {
429+ need_section(lang: lang, section: section)
430+ }
431+ if let Some(section) = full {
432+ need_section(lang: lang, section: section)
433+ }
434+ </div>
431435 </div>
432436 )
433437 })
crates/forge-web/src/pages/new_repo.rsmodified+4 -2
@@ -209,6 +209,7 @@ impl Draft {
209209 #[component]
210210 async fn new_repo_form(
211211 lang: Lang,
212+ username: String,
212213 csrf: &str,
213214 draft: Draft,
214215 error: Option<String>,
@@ -235,6 +236,7 @@ async fn new_repo_form(
235236 let draft_mirror_interval = draft.mirror_interval;
236237 Ok(view! {
237238 head(title: i18n::t(lang, Key::NewRepository))
239+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "repositories".to_owned())
238240 crate::pages::import::newrepo_tabs(lang: lang, active: "create")
239241 <div class="sheet fit">
240242 <form method="post" action="/new" class="fields">
@@ -339,7 +341,7 @@ async fn new_repo_page(cx: &Cx) -> Result<impl View> {
339341 }
340342 let csrf = viewer.1.csrf_token.clone();
341343 Ok(view! { cx =>
342- shell(title: i18n::t(lang, Key::NewRepository), viewer: Some(&viewer), new_repo_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners))
344+ shell(title: i18n::t(lang, Key::NewRepository), viewer: Some(&viewer), new_repo_form(lang: lang, username: viewer.0.username.clone(), csrf: csrf.as_str(), draft: draft, error: None, owners: owners))
343345 })
344346 }
345347
@@ -355,7 +357,7 @@ async fn new_repo_submit(cx: &Cx, Form(form): Form<NewRepoForm>) -> Result<impl
355357 let csrf = viewer.1.csrf_token.clone();
356358 let draft = Draft::from_form(&form);
357359 Ok(view! { cx =>
358- shell(title: i18n::t(lang, Key::NewRepository), viewer: Some(&viewer), new_repo_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(message), owners: owners))
360+ shell(title: i18n::t(lang, Key::NewRepository), viewer: Some(&viewer), new_repo_form(lang: lang, username: viewer.0.username.clone(), csrf: csrf.as_str(), draft: draft, error: Some(message), owners: owners))
359361 })
360362 }
361363 }
crates/forge-web/src/pages/notifications.rsmodified+39 -21
@@ -1099,6 +1099,43 @@ fn back(cx: &Cx) -> String {
10991099 return_path(cx).unwrap_or_else(|| "/notifications".to_owned())
11001100 }
11011101
1102+/// The inbox rail's places, the same on Notifications, Needs you and Review requests, so each
1103+/// reaches the others: Unread with its count, All, Needs you, Review requests. `current` is the
1104+/// key of the page showing it.
1105+pub(crate) fn inbox_items(lang: Lang, current: &str, unread_count: u64) -> Vec<RailItem> {
1106+ let item = |key: &str, name: &str, val: String, href: &str| RailItem {
1107+ name: name.to_owned(),
1108+ val,
1109+ href: href.to_owned(),
1110+ current: key == current,
1111+ };
1112+ vec![
1113+ item("unread", g::t(lang, K::Unread), unread_count.to_string(), "/notifications"),
1114+ item("all", g::t(lang, K::AllTab), String::new(), "/notifications?all=1"),
1115+ item(
1116+ "needs",
1117+ crate::i18n::needs::t(lang, crate::i18n::needs::K::NeedsYou),
1118+ String::new(),
1119+ "/needs-you",
1120+ ),
1121+ item(
1122+ "reviews",
1123+ crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab),
1124+ String::new(),
1125+ "/review-requests",
1126+ ),
1127+ ]
1128+}
1129+
1130+/// The inbox rail as Needs you and Review requests show it, beside their sheet.
1131+#[component]
1132+pub(crate) async fn inbox_rail(lang: Lang, current: &str, unread_count: u64) -> Result<impl View> {
1133+ let items = inbox_items(lang, current, unread_count);
1134+ Ok(view! {
1135+ rail(label: g::t(lang, K::NotificationFilter), items: items)
1136+ })
1137+}
1138+
11021139 /// The inbox page: the head with Mark all read, the filter rail (Unread, All, Reviews), then one
11031140 /// sheet holding the transfers, the repo groups and the older-rows link.
11041141 #[component]
@@ -1118,29 +1155,10 @@ async fn inbox_list(
11181155 } else {
11191156 g::t(lang, K::NoUnreadNotifications)
11201157 };
1121- let filters = vec![
1122- RailItem {
1123- name: g::t(lang, K::Unread).to_owned(),
1124- val: unread_count.to_string(),
1125- href: "/notifications".to_owned(),
1126- current: !all,
1127- },
1128- RailItem {
1129- name: g::t(lang, K::AllTab).to_owned(),
1130- val: String::new(),
1131- href: "/notifications?all=1".to_owned(),
1132- current: all,
1133- },
1134- RailItem {
1135- name: crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab)
1136- .to_owned(),
1137- val: String::new(),
1138- href: "/review-requests".to_owned(),
1139- current: false,
1140- },
1141- ];
1158+ let filters = inbox_items(lang, if all { "all" } else { "unread" }, unread_count);
11421159 Ok(view! {
11431160 head(title: i18n::t(lang, Key::Notifications),
1161+ sub: vec![crate::views::parts::SubPart::text(crate::pages::passkeys::s(lang, "What happened where you take part", "Katıldığın yerlerde olanlar"))],
11441162 if !empty {
11451163 <form method="post" action="/notifications/mark_all_read" class="act-form">
11461164 <input type="hidden" name="csrf" value=(csrf.as_str())>
crates/forge-web/src/pages/org_new.rsmodified+4 -2
@@ -48,9 +48,11 @@ async fn new_org_form(
4848 description: String,
4949 error: Option<String>,
5050 lang: Lang,
51+ username: String,
5152 ) -> Result<impl View> {
5253 Ok(view! {
5354 head(title: g::t(lang, K::NewOrganization), sub: vec![SubPart::text(g::t(lang, K::NewOrgIntro))])
55+ crate::pages::profile::own_profile_tabs(lang: lang, username: username, current: "organizations".to_owned())
5456 <div class="sheet fit">
5557 if let Some(message) = error {
5658 alert(message: message.as_str())
@@ -82,7 +84,7 @@ async fn new_org_page(cx: &Cx) -> Result<impl View> {
8284 let csrf = viewer.1.csrf_token.clone();
8385 Ok(view! { cx =>
8486 shell(title: title, viewer: Some(&viewer),
85- new_org_form(csrf: csrf, name: String::new(), description: String::new(), error: None, lang: lang))
87+ new_org_form(csrf: csrf, name: String::new(), description: String::new(), error: None, lang: lang, username: viewer.0.username.clone()))
8688 })
8789 }
8890
@@ -103,7 +105,7 @@ async fn new_org_submit(cx: &Cx, Form(form): Form<NewOrgForm>) -> Result<impl Vi
103105 let description = form.description.clone();
104106 Ok(view! { cx =>
105107 shell(title: title, viewer: Some(&viewer),
106- new_org_form(csrf: csrf, name: name, description: description, error: Some(message), lang: lang))
108+ new_org_form(csrf: csrf, name: name, description: description, error: Some(message), lang: lang, username: viewer.0.username.clone()))
107109 })
108110 }
109111 }
crates/forge-web/src/pages/profile.rsmodified+89 -28
@@ -35,6 +35,7 @@ use crate::pages::repo_settings::{notice_banner_for, take_notice};
3535 use crate::pages::snippets::{ListRow, list_row, snippet_rows};
3636 use crate::render::markdown::render_markdown;
3737 use crate::state::AppState;
38+use crate::views::find::{Finder, finder_field};
3839 use crate::views::heatmap::{Calendar, DayDetail, contribution_calendar};
3940 use crate::views::parts::{SubPart, head};
4041 use crate::views::repo_list::{
@@ -59,13 +60,17 @@ struct PinsMenu {
5960 const POPULAR_COUNT: usize = 6;
6061 /// Members an organization's overview lists; a longer list links to the members page.
6162 const ORG_MEMBERS_SHOWN: usize = 12;
62-/// Longest name filter kept, in characters.
63-const MAX_QUERY_CHARS: usize = 100;
63+/// Repos the name filter reads at once. The filter runs in Rust, so it covers every repo in scope.
64+const SEARCH_CAP: u64 = 5000;
6465
6566 #[query_params(error = bad_request)]
6667 struct ProfileQuery {
6768 tab: Option<String>,
6869 q: Option<String>,
70+ /// Set when the filter asks for the text as typed, as one piece.
71+ exact: Option<String>,
72+ /// Set when the filter keeps upper and lower case apart.
73+ case: Option<String>,
6974 sort: Option<String>,
7075 page: Option<String>,
7176 /// A calendar day whose contributions to list under the calendar on the overview.
@@ -124,14 +129,11 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
124129 } else {
125130 tab
126131 };
127- let q: String = query
128- .q
129- .as_deref()
130- .unwrap_or("")
131- .trim()
132- .chars()
133- .take(MAX_QUERY_CHARS)
134- .collect();
132+ let finder = Finder::new(
133+ query.q.as_deref(),
134+ query.exact.as_deref(),
135+ query.case.as_deref(),
136+ );
135137 let page = page_number(query.page.as_deref());
136138 let sort = sort_key(query.sort.as_deref());
137139
@@ -263,14 +265,35 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
263265 "name" => RepoSort::Name,
264266 _ => RepoSort::RecentlyUpdated,
265267 };
266- let search = (!q.is_empty()).then_some(q.as_str());
267- let (listed, total) = state
268- .store
269- .list_visible_repos(scope, actor, search, sort_kind, page, PER_PAGE)
270- .await?;
268+ let (listed, total) = if finder.is_empty() {
269+ state
270+ .store
271+ .list_visible_repos(scope, actor, None, sort_kind, page, PER_PAGE)
272+ .await?
273+ } else {
274+ // The search reads each repo's name and description, so it runs here over every
275+ // repo in scope, then takes the one page asked for.
276+ let (all, _) = state
277+ .store
278+ .list_visible_repos(scope, actor, None, sort_kind, 1, SEARCH_CAP)
279+ .await?;
280+ let matching: Vec<_> = all
281+ .into_iter()
282+ .filter(|(repo, _, _)| {
283+ finder.matches_any(&[repo.name.as_str(), repo.description.as_str()])
284+ })
285+ .collect();
286+ let total = matching.len() as u64;
287+ let shown = matching
288+ .into_iter()
289+ .skip(((page - 1) * PER_PAGE) as usize)
290+ .take(PER_PAGE as usize)
291+ .collect();
292+ (shown, total)
293+ };
271294 let tz = actor.map_or("UTC", |u| u.timezone.as_str());
272295 let now = now_unix();
273- let empty = match (tab, q.is_empty()) {
296+ let empty = match (tab, finder.is_empty()) {
274297 (_, false) => g::t(lang, K::NoReposMatch),
275298 ("stars", true) => g::t(lang, K::NoVisibleStarred),
276299 _ => g::t(lang, K::NoVisibleRepos),
@@ -290,13 +313,13 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
290313 page,
291314 pages,
292315 pager: pager_links(page, pages, |n| {
293- profile_href(&user.username, tab, &q, sort, n)
316+ profile_href(&user.username, tab, &finder, sort, n)
294317 }),
295318 sort_links: SORTS
296319 .iter()
297320 .map(|(key, label)| SortLink {
298321 label: g::t(lang, *label),
299- href: profile_href(&user.username, tab, &q, key, 1),
322+ href: profile_href(&user.username, tab, &finder, key, 1),
300323 current: *key == sort,
301324 })
302325 .collect(),
@@ -339,7 +362,7 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
339362 shell(title: title.as_str(), viewer: viewer.as_ref(),
340363 notice_banner_for(lang: lang, title: notice)
341364 profile_card(user: user, avatar: avatar, about_html: about_html, local_time: local_time,
342- org: org, lang: lang, tab: tab.to_owned(), q: q, sort: sort, repo_total: repo_total,
365+ org: org, lang: lang, tab: tab.to_owned(), finder: finder, sort: sort, repo_total: repo_total,
343366 star_total: star_total, cards: cards, from_pins: from_pins,
344367 pins_menu_data: pins_menu_data, pins_error: pins_error, edit_profile: own, listing: listing,
345368 packages_on: packages_on, package_rows: package_rows,
@@ -505,11 +528,15 @@ fn page_number(raw: Option<&str>) -> u64 {
505528
506529 /// The profile URL for a tab, with the name filter, a sort other than the default and the page
507530 /// when they are set.
508-fn profile_href(name: &str, tab: &str, q: &str, sort: &str, page: u64) -> String {
531+fn profile_href(name: &str, tab: &str, finder: &Finder, sort: &str, page: u64) -> String {
509532 let mut href = format!("/{}?tab={tab}", enc(name));
510- if !q.is_empty() {
511- href.push_str("&q=");
512- href.push_str(&enc(q));
533+ if !finder.is_empty() {
534+ for (key, value) in finder.params() {
535+ href.push('&');
536+ href.push_str(key);
537+ href.push('=');
538+ href.push_str(&enc(value));
539+ }
513540 }
514541 if sort != SORTS[0].0 {
515542 href.push_str("&sort=");
@@ -568,7 +595,7 @@ async fn profile_card(
568595 org: Option<OrgSummary>,
569596 lang: Lang,
570597 tab: String,
571- q: String,
598+ finder: Finder,
572599 sort: &'static str,
573600 repo_total: u64,
574601 star_total: u64,
@@ -745,12 +772,10 @@ async fn profile_card(
745772 <section class="sec">
746773 <div class="sheet-tools">
747774 <strong>(count_text.as_str())</strong>
748- <form method="get" action=(base.as_str()) class="plain-search" role="search">
775+ <form method="get" action=(base.as_str()) role="search">
749776 <input type="hidden" name="tab" value=(tab.as_str())>
750777 <input type="hidden" name="sort" value=(sort)>
751- <input type="search" name="q" value=(q.as_str()) data-live-search=""
752- placeholder=(filter_label) aria-label=(filter_label)>
753- <button type="submit" class="act">(g::t(lang, K::Search))</button>
778+ finder_field(lang: lang, finder: finder, placeholder: filter_label, id: Some("profile-q"))
754779 </form>
755780 sort_chips(links: sort_links, lang: lang)
756781 </div>
@@ -836,6 +861,42 @@ async fn profile_card(
836861 })
837862 }
838863
864+/// The viewer's own profile tabs on a page that makes something of theirs (a repository, a
865+/// snippet, an organization): the same tabs and counts as their profile, with `current` marked.
866+#[component]
867+pub async fn own_profile_tabs(lang: Lang, username: String, current: String) -> Result<impl View> {
868+ let items = crate::views::profile_items(lang, &username, false, true, false);
869+ let mut counts = Vec::new();
870+ if let Some(state) = topcoat::context::try_app_context::<AppState>(__cx)
871+ && let Some(user) = state.store.user_by_username(&username).await?
872+ {
873+ let actor = Some(&user);
874+ let repos = state
875+ .store
876+ .count_visible_repos(RepoScope::OwnedBy(&user.id), actor)
877+ .await?;
878+ let stars = state
879+ .store
880+ .count_visible_repos(RepoScope::StarredBy(&user.id), actor)
881+ .await?;
882+ let snippets = state
883+ .store
884+ .list_owner_snippets(&user.id, Some(user.id.as_str()))
885+ .await?
886+ .len();
887+ let packages = packages::package_rows(state, actor, &user).await?.len();
888+ counts = vec![
889+ ("repositories", repos.to_string()),
890+ ("snippets", snippets.to_string()),
891+ ("stars", stars.to_string()),
892+ ("packages", packages.to_string()),
893+ ];
894+ }
895+ Ok(view! {
896+ profile_tabs(username: username, items: items, current: current, counts: counts)
897+ })
898+}
899+
839900 /// The profile tab bar: one link per item, the current tab marked, and a count after the label of
840901 /// each tab that has one in `counts`, by the item's key. A person's, an organization's and an
841902 /// organization's member pages all render it.
crates/forge-web/src/pages/pulls_list.rsmodified+2 -2
@@ -25,7 +25,7 @@ use crate::state::AppState;
2525 use crate::pages::passkeys::s;
2626 use crate::views::parts::{RailItem, SubPart, rail};
2727 use crate::views::{
28- avatar_url, iso_time, now_unix, relative_time, repo_href, shell, user_link,
28+ avatar_url_unknown, iso_time, now_unix, relative_time, repo_href, shell, user_link,
2929 };
3030
3131 path_param!(owner);
@@ -136,7 +136,7 @@ fn row_view(
136136 .iter()
137137 .map(|name| AssigneeView {
138138 name: name.clone(),
139- avatar: avatar_url(name, None),
139+ avatar: avatar_url_unknown(name),
140140 })
141141 .collect(),
142142 has_comments: comments > 0,
crates/forge-web/src/pages/register.rsmodified+4 -0
@@ -23,6 +23,7 @@ use crate::auth::{
2323 use crate::client_ip::client_ip;
2424 use crate::i18n::{self, Key, Lang, password_too_long, password_too_short, t};
2525 use crate::mail::account;
26+use crate::pages::settings_security::mail_can_send;
2627 use crate::state::AppState;
2728 use crate::throttle;
2829 use crate::views::parts::{SubPart, head};
@@ -425,6 +426,9 @@ async fn verify_submit(cx: &Cx, Form(form): Form<VerifyForm>) -> Result<impl Vie
425426 async fn verify_resend(cx: &Cx, Form(form): Form<ResendForm>) -> Result<SeeOther> {
426427 let viewer = require_csrf(cx, &form.csrf).await?;
427428 let state = app_context::<AppState>(cx);
429+ if !mail_can_send(state).await {
430+ return Ok(see_other("/settings/security?saved=verify_wait"));
431+ }
428432 if let Some(address) = viewer.0.email.clone()
429433 && !state.store.email_is_verified(&viewer.0.id).await?
430434 && !account::send_verify(state, &viewer.0, &address).await?
crates/forge-web/src/pages/review_requests.rsmodified+17 -13
@@ -286,6 +286,7 @@ async fn review_requests(cx: &Cx) -> Result<impl View> {
286286 }
287287 let heading = ga::t(lang, AK::ReviewRequests);
288288 let empty = rows.is_empty();
289+ let unread = state.store.unread_count(&user.id).await?;
289290 let sub = vec![SubPart::text(s(
290291 lang,
291292 "Pull requests waiting for your review",
@@ -294,19 +295,22 @@ async fn review_requests(cx: &Cx) -> Result<impl View> {
294295 Ok(view! {
295296 shell(title: heading, viewer: Some(&viewer),
296297 head(title: heading, sub: sub, live: Some("/review-requests/events"))
297- <div class="sheet">
298- <div class="sec">
299- if empty {
300- <p class="state">(ga::t(lang, AK::NoReviewRequests))</p>
301- }
302- for row in rows.iter() {
303- <a class="line" href=(row.1.as_str()) data-kb-row="">
304- <span class="name">(row.2.as_str())</span>
305- <span class="val">(row.0.as_str())</span>
306- <span class="val">(row.3.as_str())</span>
307- <span class="val">rel_time(lang: lang, stamp: row.4.as_str())</span>
308- </a>
309- }
298+ <div class="work">
299+ crate::pages::notifications::inbox_rail(lang: lang, current: "reviews", unread_count: unread)
300+ <div class="sheet">
301+ <div class="sec">
302+ if empty {
303+ <p class="state">(ga::t(lang, AK::NoReviewRequests))</p>
304+ }
305+ for row in rows.iter() {
306+ <a class="line" href=(row.1.as_str()) data-kb-row="">
307+ <span class="name">(row.2.as_str())</span>
308+ <span class="val">(row.0.as_str())</span>
309+ <span class="val">(row.3.as_str())</span>
310+ <span class="val">rel_time(lang: lang, stamp: row.4.as_str())</span>
311+ </a>
312+ }
313+ </div>
310314 </div>
311315 </div>
312316 )
crates/forge-web/src/pages/settings_appearance.rsmodified+10 -9
@@ -723,15 +723,15 @@ mod tests {
723723 "accent: empty"
724724 );
725725 assert!(
726- base_choice(Lang::En, Some("ink"), "fern").is_ok(),
726+ base_choice(Lang::En, Some("ink"), "blush").is_ok(),
727727 "base: offered"
728728 );
729729 assert!(
730- base_choice(Lang::En, Some("neon"), "fern").is_err(),
730+ base_choice(Lang::En, Some("neon"), "blush").is_err(),
731731 "base: unknown"
732732 );
733733 assert!(
734- base_choice(Lang::En, Some(""), "fern").is_err(),
734+ base_choice(Lang::En, Some(""), "blush").is_err(),
735735 "base: empty"
736736 );
737737
@@ -746,14 +746,14 @@ mod tests {
746746 "accent upper case {id}"
747747 );
748748 }
749- for id in ["fern", "graphite", "dusk", "ink", "anvil", "hue-120"] {
749+ for id in ["blush", "heather", "dusk", "ink", "anvil", "hue-120"] {
750750 assert_eq!(
751- base_choice(Lang::Tr, Some(id), "fern").unwrap(),
751+ base_choice(Lang::Tr, Some(id), "blush").unwrap(),
752752 id,
753753 "base {id}"
754754 );
755755 assert!(
756- base_choice(Lang::Tr, Some(&id.to_uppercase()), "fern").is_err(),
756+ base_choice(Lang::Tr, Some(&id.to_uppercase()), "blush").is_err(),
757757 "base upper case {id}"
758758 );
759759 }
@@ -777,7 +777,8 @@ mod tests {
777777 for id in [
778778 "dune",
779779 "lilac",
780- "blush",
780+ "fern",
781+ "graphite",
781782 "pine",
782783 "slate-blue",
783784 "spark",
@@ -785,7 +786,7 @@ mod tests {
785786 "hue-07",
786787 ] {
787788 assert!(
788- base_choice(Lang::En, Some(id), "fern").is_err(),
789+ base_choice(Lang::En, Some(id), "blush").is_err(),
789790 "base refused {id}"
790791 );
791792 }
@@ -810,7 +811,7 @@ mod tests {
810811 accent_err.to_string().contains("accent colour"),
811812 "{accent_err}"
812813 );
813- let base_err = base_choice(Lang::En, Some("neon"), "fern").unwrap_err();
814+ let base_err = base_choice(Lang::En, Some("neon"), "blush").unwrap_err();
814815 assert!(base_err.to_string().contains("background"), "{base_err}");
815816 }
816817
crates/forge-web/src/pages/settings_export.rsmodified+28 -12
@@ -26,7 +26,7 @@ use crate::i18n::migrate::{self as g, K};
2626 use crate::i18n::{self, Lang};
2727 use crate::pages::ci_runs::{changed_event, events_response};
2828 use crate::state::AppState;
29-use crate::views::parts::{SubPart, head};
29+use crate::views::parts::{SubPart, confirm_act, head};
3030 use crate::views::{alert, csrf_field, human_size, rel_time, shell};
3131
3232 path_param!(export_id);
@@ -61,6 +61,10 @@ async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result
6161 )
6262 });
6363 let empty = exports.is_empty();
64+ let deletes: Vec<String> = exports
65+ .iter()
66+ .map(|e| format!("/settings/export/{}/delete", e.id))
67+ .collect();
6468 let ttl_note = g::export_ttl_note(lang, exporter::EXPORT_TTL_DAYS);
6569 Ok(view! {
6670 head(title: g::t(lang, K::ExportTitle), sub: vec![SubPart::text(g::t(lang, K::ExportIntro))],
@@ -80,13 +84,14 @@ async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result
8084 if empty {
8185 <p class="state">(g::t(lang, K::ExportNone))</p>
8286 }
83- for export in exports.iter() {
87+ for (export, delete) in exports.iter().zip(deletes.iter()) {
8488 <div class="export-row">
8589 <div class="line">
8690 <span class="name">(g::t(lang, K::ExportRequested)) " " rel_time(lang: lang, stamp: export.created_at.as_str())</span>
8791 <span class="val">
8892 if export.state == ExportState::Ready {
89- (g::t(lang, K::ExportReady))
93+ (g::t(lang, K::ExportReady)) " · " (g::t(lang, K::ExportSize)) ": " (human_size(lang, u64::try_from(export.size).unwrap_or(0)))
94+ " · " (g::expires_label(lang)) " " rel_time(lang: lang, stamp: export.expires_at.as_str())
9095 }
9196 if export.state == ExportState::Building {
9297 (g::t(lang, K::ExportBuilding))
@@ -95,16 +100,13 @@ async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result
95100 (g::t(lang, K::ExportFailed))
96101 }
97102 </span>
98- </div>
99- if export.state == ExportState::Ready {
100- <p class="hint">
101- (g::t(lang, K::ExportSize)) ": " (human_size(lang, u64::try_from(export.size).unwrap_or(0)))
102- " · " (g::expires_label(lang)) " " rel_time(lang: lang, stamp: export.expires_at.as_str())
103- </p>
104- <div class="acts">
103+ if export.state == ExportState::Ready {
105104 <a class="act" href=(format!("/settings/export/{}/download", export.id))>(g::t(lang, K::ExportDownload))</a>
106- </div>
107- }
105+ }
106+ if export.state != ExportState::Building {
107+ confirm_act(lang: lang, label: crate::pages::passkeys::s(lang, "Delete", "Sil"), action: delete.as_str(), csrf: csrf, note: Some(crate::pages::passkeys::s(lang, "The archive is deleted from the server.", "Arşiv sunucudan silinir.").to_owned()))
108+ }
109+ </div>
108110 if export.state == ExportState::Building {
109111 <progress class="import-progress export-progress"></progress>
110112 }
@@ -140,6 +142,20 @@ async fn export_request(cx: &Cx, Form(form): Form<CsrfForm>) -> Result<SeeOther>
140142 Err(see_other("/settings/export").into())
141143 }
142144
145+/// Deletes one archive by hand. Only its owner, and not while it is still building.
146+#[route(POST "/settings/export/{export_id}/delete")]
147+async fn export_delete(cx: &Cx, Form(form): Form<CsrfForm>) -> Result<SeeOther> {
148+ let viewer = require_csrf(cx, &form.csrf).await?;
149+ let id = path_param::<ExportId>(cx).to_owned();
150+ let state = app_context::<AppState>(cx);
151+ let export = match state.store.data_export(&id).await? {
152+ Some(e) if e.user_id == viewer.0.id && e.state != ExportState::Building => e,
153+ _ => return Err(not_found().into()),
154+ };
155+ exporter::delete_one(state, &export).await?;
156+ Err(see_other("/settings/export").into())
157+}
158+
143159 /// The `changed` stream of the export page. It sends when the exports differ from what the page
144160 /// shows, then on each change, and ends once nothing is building.
145161 #[route(GET "/settings/export/events")]
crates/forge-web/src/pages/settings_profile.rsmodified+1 -1
@@ -994,7 +994,7 @@ pub(crate) mod tests {
994994 );
995995 let (_, _, body) = send(&fx.router, "GET", "/explore", true, None).await;
996996 assert!(
997- body.contains(r#"src="/avatars/tahinli?v=default""#),
997+ body.contains(r#"src="data:image/svg+xml,"#),
998998 "remove: nav default {body}"
999999 );
10001000 // With no photo there is nothing to remove, so the menu leaves that item out.
crates/forge-web/src/pages/settings_security.rsmodified+67 -29
@@ -29,7 +29,7 @@ use crate::pages::passkeys::{PasskeyPanel, build_panel, passkeys_panel, s};
2929 use crate::pages::settings_sessions::session_label;
3030 use crate::state::AppState;
3131 use crate::throttle::{self, LOGIN_USER_LIMIT, TWO_FACTOR_USER_LIMIT};
32-use crate::views::parts::{RailItem, SubPart, confirm_act, head, post_act, rail, reveal};
32+use crate::views::parts::{RailItem, SubPart, confirm_act, head, post_act, rail};
3333 use crate::views::{added_status, alert, rel_time, shell, user_facing_message};
3434
3535 /// Shortest and longest new passwords, in characters.
@@ -82,6 +82,8 @@ struct CodeForm {
8282 #[serde(default)]
8383 csrf: String,
8484 #[serde(default)]
85+ current_password: String,
86+ #[serde(default)]
8587 code: String,
8688 }
8789
@@ -171,6 +173,8 @@ struct SecurityPage {
171173 email_status: String,
172174 /// When the latest verification mail went out, shown after the state as a live time.
173175 email_sent: Option<String>,
176+ /// Whether this server can send mail at all. The resend link shows only when it can.
177+ mail_ready: bool,
174178 notice: Option<&'static str>,
175179 password_error: Option<String>,
176180 email_error: Option<String>,
@@ -296,6 +300,7 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> {
296300 stored_email,
297301 email_status,
298302 email_sent,
303+ mail_ready,
299304 notice,
300305 password_error,
301306 email_error,
@@ -323,7 +328,7 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> {
323328 let password_open = password_error.is_some();
324329 let email_open = email_error.is_some();
325330 let email_set = !email.is_empty();
326- let show_resend = email_set && !email_verified;
331+ let show_resend = email_set && !email_verified && mail_ready;
327332 let regenerate_error = two_factor_error
328333 .clone()
329334 .filter(|_| two_factor_panel == TwoFactorPanel::Regenerate);
@@ -444,46 +449,54 @@ async fn security_body(page: SecurityPage, csrf: &str) -> Result<impl View> {
444449 if let Some(device) = two_factor {
445450 <p class="state">(t(lang, Key::PillOn)) " · " (device.name.as_str())</p>
446451 <p class="hint">added_status(lang: lang, added: device.added.as_deref(), used: device.used.as_deref())</p>
447- <p class="hint">(device.codes_line.as_str())</p>
452+ <div class="line">
453+ <span class="name">(t(lang, Key::RecoveryCodes))</span>
454+ <span class="val">(device.codes_line.as_str())</span>
455+ </div>
448456 if device.codes_low {
449457 <p class="hint topic-warn">(t(lang, Key::CodesRunningLow))</p>
450458 }
451- <div class="acts">
452- reveal(label: t(lang, Key::RegenerateCodes), open: regenerate_open,
459+ <details class="reveal" open=(regenerate_open)>
460+ <summary class="act">(s(lang, "Regenerate…", "Yeniden oluştur…"))</summary>
461+ <div class="opened">
453462 if let Some(message) = regenerate_error {
454463 alert(message: message.as_str())
455464 }
456465 <form data-hard="true" method="post" action="/settings/security/2fa/recovery" class="fields">
457466 <input type="hidden" name="csrf" value=(csrf)>
458467 <p class="hint">(t(lang, Key::RegenerateCodesHint))</p>
468+ <div class="field">
469+ <label for="regenerate-password">(t(lang, Key::CurrentPassword))</label>
470+ <input id="regenerate-password" type="password" name="current_password" autocomplete="current-password" required=(true)>
471+ </div>
459472 <div class="field">
460473 <label for="regenerate-code">(t(lang, Key::Code))</label>
461474 <input id="regenerate-code" type="text" name="code" autocomplete="one-time-code" required=(true)>
462475 </div>
463476 <button type="submit" class="primary">(t(lang, Key::RegenerateCodes))</button>
464477 </form>
465- )
466- <details class="reveal" open=(disable_open)>
467- <summary class="act danger">(t(lang, Key::TurnOffTwoFactorButton))</summary>
468- <div class="opened">
469- if let Some(message) = disable_error {
470- alert(message: message.as_str())
471- }
472- <form data-hard="true" method="post" action="/settings/security/2fa/disable" class="fields">
473- <input type="hidden" name="csrf" value=(csrf)>
474- <div class="field">
475- <label for="disable-password">(t(lang, Key::CurrentPassword))</label>
476- <input id="disable-password" type="password" name="current_password" autocomplete="current-password" required=(true)>
477- </div>
478- <div class="field">
479- <label for="disable-code">(t(lang, Key::Code))</label>
480- <input id="disable-code" type="text" name="code" autocomplete="one-time-code" required=(true)>
481- </div>
482- <button type="submit" class="act danger">(t(lang, Key::TurnOffTwoFactorButton))</button>
483- </form>
484- </div>
485- </details>
486- </div>
478+ </div>
479+ </details>
480+ <details class="reveal" open=(disable_open)>
481+ <summary class="act danger">(t(lang, Key::TurnOffTwoFactorButton))</summary>
482+ <div class="opened">
483+ if let Some(message) = disable_error {
484+ alert(message: message.as_str())
485+ }
486+ <form data-hard="true" method="post" action="/settings/security/2fa/disable" class="fields">
487+ <input type="hidden" name="csrf" value=(csrf)>
488+ <div class="field">
489+ <label for="disable-password">(t(lang, Key::CurrentPassword))</label>
490+ <input id="disable-password" type="password" name="current_password" autocomplete="current-password" required=(true)>
491+ </div>
492+ <div class="field">
493+ <label for="disable-code">(t(lang, Key::Code))</label>
494+ <input id="disable-code" type="text" name="code" autocomplete="one-time-code" required=(true)>
495+ </div>
496+ <button type="submit" class="danger">(t(lang, Key::TurnOffTwoFactorButton))</button>
497+ </form>
498+ </div>
499+ </details>
487500 } else if pending_set {
488501 <p class="state">(t(lang, Key::SetupInProgress))</p>
489502 } else {
@@ -617,6 +630,22 @@ fn notice_for(lang: Lang, saved: Option<&str>) -> Option<&'static str> {
617630 }
618631 }
619632
633+/// Whether this server can send mail now. The log transport always can. SMTP can only when the
634+/// stored settings are enabled and name a host and a sender.
635+pub(crate) async fn mail_can_send(state: &AppState) -> bool {
636+ if state.config.mail.transport == forge_core::config::MailTransport::Log {
637+ return true;
638+ }
639+ match state.store.mail_settings().await {
640+ Ok(settings) => {
641+ settings.enabled
642+ && !settings.host.trim().is_empty()
643+ && !settings.from_addr.trim().is_empty()
644+ }
645+ Err(_) => false,
646+ }
647+}
648+
620649 /// Builds the page data from the stored state and the message set for this render.
621650 async fn build_page(
622651 state: &AppState,
@@ -692,6 +721,7 @@ async fn build_page(
692721 stored_email,
693722 email_status,
694723 email_sent,
724+ mail_ready: mail_can_send(state).await,
695725 email: shown
696726 .email_draft
697727 .unwrap_or_else(|| viewer.0.email.clone().unwrap_or_default()),
@@ -1103,6 +1133,11 @@ async fn two_factor_recovery(cx: &Cx, Form(form): Form<CodeForm>) -> Result<impl
11031133 two_factor_panel: TwoFactorPanel::Regenerate,
11041134 ..Shown::default()
11051135 };
1136+ if let Err(refused) = require_password(lang, state, &viewer.0, &form.current_password).await? {
1137+ shown.two_factor_error = Some(refused.message.into());
1138+ shown.throttled = refused.retry;
1139+ return respond(cx, viewer, shown).await;
1140+ }
11061141 if let Some(retry) = second_factor_blocked(state, &user_id) {
11071142 shown.two_factor_error = Some(t(lang, Key::ErrThrottled).into());
11081143 shown.throttled = Some(retry);
@@ -1823,7 +1858,7 @@ mod tests {
18231858 "only the turn-off panel should be open"
18241859 );
18251860
1826- let bad_code = format!("csrf={CSRF}&code=123456x");
1861+ let bad_code = format!("csrf={CSRF}&current_password={PASSWORD}&code=123456x");
18271862 let reply = send(
18281863 &fx.router,
18291864 "POST",
@@ -1843,7 +1878,10 @@ mod tests {
18431878 "a refused code leaves the old codes"
18441879 );
18451880
1846- let good = format!("csrf={CSRF}&code={}", now_code(&shared));
1881+ let good = format!(
1882+ "csrf={CSRF}&current_password={PASSWORD}&code={}",
1883+ now_code(&shared)
1884+ );
18471885 let reply = send(
18481886 &fx.router,
18491887 "POST",
crates/forge-web/src/pages/snippets.rsmodified+12 -1
@@ -344,6 +344,7 @@ async fn snippet_files(
344344 .collect();
345345 Ok(view! {
346346 <div class="snippet-files">
347+ <span class="snippet-files-label" aria-hidden="true">(g::t(lang, K::Files))</span>
347348 <div class="snippet-tabbar">
348349 <div class="snippet-tabs" role="group" aria-label=(g::t(lang, K::Files))>
349350 for (number, label, checked) in tabs.into_iter() {
@@ -474,6 +475,9 @@ async fn snippet_body(
474475 confirm_act(lang: lang, label: g::t(lang, K::Delete), action: delete_action.as_str(), csrf: token.as_str())
475476 }
476477 )
478+ if is_owner {
479+ crate::pages::profile::own_profile_tabs(lang: lang, username: owner.to_owned(), current: "snippets".to_owned())
480+ }
477481 <div class="sheet" data-live=(live.as_deref())>
478482 <section class="sec">
479483 if !description.is_empty() {
@@ -510,6 +514,7 @@ async fn revisions_body(
510514 title: &str,
511515 revisions: Vec<RevisionView>,
512516 live: Option<String>,
517+ owner_tabs: Option<String>,
513518 ) -> Result<impl View> {
514519 let back = format!("/snippets/{snippet_id}");
515520 let heading = g::revisions_of(lang, title);
@@ -517,6 +522,9 @@ async fn revisions_body(
517522 head(title: heading.as_str(),
518523 <a class="button" href=(back)>(g::t(lang, K::BackToSnippet))</a>
519524 )
525+ if let Some(owner) = owner_tabs {
526+ crate::pages::profile::own_profile_tabs(lang: lang, username: owner, current: "snippets".to_owned())
527+ }
520528 <div class="sheet" data-live=(live.as_deref())>
521529 if revisions.is_empty() {
522530 <p class="state">(g::t(lang, K::NoRevisions))</p>
@@ -547,9 +555,11 @@ async fn snippet_form_page(
547555 let title = draft.title.clone();
548556 let description = draft.description.clone();
549557 let visibility = draft.visibility.clone();
558+ let tab_user = viewer.0.username.clone();
550559 Ok(view! {
551560 shell(title: heading, viewer: Some(viewer),
552561 head(title: heading)
562+ crate::pages::profile::own_profile_tabs(lang: lang, username: tab_user, current: "snippets".to_owned())
553563 <div class="sheet">
554564 snippet_form(lang: lang, csrf: csrf.as_str(), action: action,
555565 title: title.as_str(), description: description.as_str(),
@@ -779,7 +789,8 @@ async fn snippet_revisions(cx: &Cx) -> Result<impl View> {
779789 Ok(view! {
780790 shell(title: snippet.title.as_str(), viewer: viewer.as_ref(),
781791 revisions_body(lang: lang, snippet_id: snippet.id.as_str(), title: snippet.title.as_str(),
782- revisions: rows, live: Some(item_live_url(snippet.id.as_str())))
792+ revisions: rows, live: Some(item_live_url(snippet.id.as_str())),
793+ owner_tabs: viewer.as_ref().filter(|(user, _)| user.id == snippet.owner_id).map(|(user, _)| user.username.clone()))
783794 )
784795 })
785796 }
crates/forge-web/src/views/find.rsadded+212 -0
@@ -0,0 +1,212 @@
1+//! Search in a list: one field, live as you type, with two options beside it. By default a search
2+//! forgives typos and case: every word typed must be in the text, or close to one of its words
3+//! (one slip in words of four to seven letters, two in longer ones), or the start of one. "Exact" asks for the typed
4+//! text as it is, as one piece; "Match case" keeps upper and lower case apart and looks for each
5+//! word as typed.
6+
7+use topcoat::Result;
8+use topcoat::view::{View, component, view};
9+
10+use crate::i18n::Lang;
11+use crate::pages::passkeys::s;
12+
13+/// The longest search kept, in characters.
14+pub const MAX_QUERY_CHARS: usize = 100;
15+
16+/// A search as typed, with its options.
17+#[derive(Clone, Debug, Default)]
18+pub struct Finder {
19+ /// The search as typed, trimmed.
20+ pub q: String,
21+ pub exact: bool,
22+ pub case: bool,
23+ /// The search folded for matching: lower case unless Match case is on.
24+ needle: String,
25+ words: Vec<Vec<char>>,
26+}
27+
28+impl Finder {
29+ /// A search from the query's `q`, `exact` and `case` values. An option is on when its value is
30+ /// present and not empty.
31+ pub fn new(q: Option<&str>, exact: Option<&str>, case: Option<&str>) -> Finder {
32+ let q: String = q
33+ .unwrap_or("")
34+ .trim()
35+ .chars()
36+ .take(MAX_QUERY_CHARS)
37+ .collect();
38+ let exact = exact.is_some_and(|v| !v.is_empty());
39+ let case = case.is_some_and(|v| !v.is_empty());
40+ let needle = if case { q.clone() } else { q.to_lowercase() };
41+ let words = needle
42+ .split(|c: char| !c.is_alphanumeric())
43+ .filter(|w| !w.is_empty())
44+ .map(|w| w.chars().collect())
45+ .collect();
46+ Finder {
47+ q,
48+ exact,
49+ case,
50+ needle,
51+ words,
52+ }
53+ }
54+
55+ /// True when nothing was typed: everything matches.
56+ pub fn is_empty(&self) -> bool {
57+ self.needle.is_empty()
58+ }
59+
60+ /// True when `text` matches the search.
61+ pub fn matches(&self, text: &str) -> bool {
62+ if self.is_empty() {
63+ return true;
64+ }
65+ let hay = if self.case {
66+ text.to_owned()
67+ } else {
68+ text.to_lowercase()
69+ };
70+ if hay.contains(&self.needle) {
71+ return true;
72+ }
73+ if self.exact {
74+ return false;
75+ }
76+ // Word by word, each typed word must start one of the text's words, so a short word such
77+ // as "1" does not match every text with a 1 somewhere in it. Match case asks for the words
78+ // as typed, so a slip of case is not forgiven as a typo.
79+ let tokens: Vec<Vec<char>> = hay
80+ .split(|c: char| !c.is_alphanumeric())
81+ .filter(|t| !t.is_empty())
82+ .map(|t| t.chars().collect())
83+ .collect();
84+ !self.words.is_empty()
85+ && self.words.iter().all(|word| {
86+ tokens
87+ .iter()
88+ .any(|token| token.starts_with(word) || (!self.case && near(word, token)))
89+ })
90+ }
91+
92+ /// True when any of `fields` matches, read as one text.
93+ pub fn matches_any(&self, fields: &[&str]) -> bool {
94+ self.is_empty() || self.matches(&fields.join(" \u{1f} "))
95+ }
96+
97+ /// The query pairs that keep this search in a link: `q`, and each option that is on.
98+ pub fn params(&self) -> Vec<(&'static str, &str)> {
99+ let mut out = vec![("q", self.q.as_str())];
100+ if self.exact {
101+ out.push(("exact", "1"));
102+ }
103+ if self.case {
104+ out.push(("case", "1"));
105+ }
106+ out
107+ }
108+}
109+
110+/// How many slips a typed word of `len` letters may have.
111+fn slips_for(len: usize) -> usize {
112+ match len {
113+ 0..=3 => 0,
114+ 4..=7 => 1,
115+ _ => 2,
116+ }
117+}
118+
119+/// True when the typed `word` is close to `token`, or to the start of it as long as the word.
120+fn near(word: &[char], token: &[char]) -> bool {
121+ let slips = slips_for(word.len());
122+ if slips == 0 {
123+ return false;
124+ }
125+ if distance(word, token) <= slips {
126+ return true;
127+ }
128+ token.len() > word.len() && distance(word, &token[..word.len()]) <= slips
129+}
130+
131+/// Edits (insert, delete, change, swap two neighbours) between two words.
132+fn distance(a: &[char], b: &[char]) -> usize {
133+ if a.len().abs_diff(b.len()) > 2 {
134+ return usize::MAX;
135+ }
136+ let (n, m) = (a.len(), b.len());
137+ let mut d = vec![vec![0usize; m + 1]; n + 1];
138+ for (i, row) in d.iter_mut().enumerate() {
139+ row[0] = i;
140+ }
141+ for j in 0..=m {
142+ d[0][j] = j;
143+ }
144+ for i in 1..=n {
145+ for j in 1..=m {
146+ let cost = usize::from(a[i - 1] != b[j - 1]);
147+ let mut best = (d[i - 1][j] + 1)
148+ .min(d[i][j - 1] + 1)
149+ .min(d[i - 1][j - 1] + cost);
150+ if i > 1 && j > 1 && a[i - 1] == b[j - 2] && a[i - 2] == b[j - 1] {
151+ best = best.min(d[i - 2][j - 2] + 1);
152+ }
153+ d[i][j] = best;
154+ }
155+ }
156+ d[n][m]
157+}
158+
159+/// The search field of a list, with its two options beside it, for inside a GET form. The field
160+/// searches as you type; an option applies the moment it is ticked.
161+#[component]
162+pub async fn finder_field(
163+ lang: Lang,
164+ finder: Finder,
165+ placeholder: &str,
166+ #[default] id: Option<&str>,
167+) -> Result<impl View> {
168+ let id = id.unwrap_or("find-q");
169+ Ok(view! {
170+ <div class="list-find">
171+ <div class="plain-search">
172+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
173+ <label class="sr-only" for=(id)>(placeholder)</label>
174+ <input id=(id) type="search" name="q" value=(finder.q.as_str()) placeholder=(placeholder) data-live-search="" autocomplete="off">
175+ </div>
176+ <label class="find-opt" title=(s(lang, "Only the text as typed, as one piece", "Yalnızca yazılan metin, tek parça olarak"))>
177+ <input type="checkbox" name="exact" value="1" checked=(finder.exact) data-autosubmit="true">
178+ <span>(s(lang, "Exact", "Tam"))</span>
179+ </label>
180+ <label class="find-opt" title=(s(lang, "Keep upper and lower case apart", "Büyük ve küçük harfi ayırt et"))>
181+ <input type="checkbox" name="case" value="1" checked=(finder.case) data-autosubmit="true">
182+ <span>"Aa"</span>
183+ </label>
184+ <button type="submit" class="sr-only">(s(lang, "Search", "Ara"))</button>
185+ </div>
186+ })
187+}
188+
189+#[cfg(test)]
190+mod tests {
191+ use super::Finder;
192+
193+ fn find(q: &str, exact: bool, case: bool) -> Finder {
194+ Finder::new(Some(q), exact.then_some("1"), case.then_some("1"))
195+ }
196+
197+ #[test]
198+ fn forgives_typos_and_case_unless_asked() {
199+ let text = "Repository created · Hezarfen/hezarfen_landing";
200+ assert!(find("", false, false).matches(text));
201+ assert!(find("reposotory", false, false).matches(text));
202+ assert!(find("landnig hezarfen", false, false).matches(text));
203+ assert!(find("crea", false, false).matches(text));
204+ assert!(!find("deleted", false, false).matches(text));
205+ assert!(!find("reposotory", true, false).matches(text));
206+ assert!(find("repository CREATED", true, false).matches(text));
207+ assert!(!find("repository", false, true).matches(text));
208+ assert!(find("Repository", false, true).matches(text));
209+ assert!(!find("bulk 1", false, false).matches("tahinli/bulk-21"));
210+ assert!(find("bulk 1", false, false).matches("tahinli/bulk-12"));
211+ }
212+}
crates/forge-web/src/views/mod.rsmodified+25 -14
@@ -4,6 +4,7 @@
44 pub mod commit_line;
55 pub mod commit_status;
66 pub mod diff;
7+pub mod find;
78 pub mod heatmap;
89 pub mod parts;
910 pub mod repo_list;
@@ -1218,9 +1219,19 @@ pub fn display_name(lang: Lang, username: &str) -> String {
12181219 }
12191220
12201221 /// URL of a user's avatar. `hash` is the avatar's content hash (`?v=` makes the response
1221-/// immutable); `None` gives the generated default, which is cached for a short time only.
1222+/// immutable); `None` means the account has no photo, and gives its letter avatar inline, so the
1223+/// page shows it with no request.
12221224 pub fn avatar_url(username: &str, hash: Option<&str>) -> String {
1223- format!("/avatars/{}?v={}", enc(username), hash.unwrap_or("default"))
1225+ match hash {
1226+ Some(hash) => format!("/avatars/{}?v={hash}", enc(username)),
1227+ None => crate::pages::avatars::default_data_url(username),
1228+ }
1229+}
1230+
1231+/// URL of a user's avatar when the page does not know whether the account has a photo: the server
1232+/// answers with the photo or the letter avatar.
1233+pub fn avatar_url_unknown(username: &str) -> String {
1234+ format!("/avatars/{}?v=default", enc(username))
12241235 }
12251236
12261237 /// Public profile URL of a user: `/{username}`.
@@ -2026,10 +2037,10 @@ mod shell_tests {
20262037
20272038 // An anonymous page renders the default colours.
20282039 let tag = html_tag(&html);
2029- assert!(tag.contains("data-accent-light=\"ember\""), "{tag}");
2030- assert!(tag.contains("data-accent-dark=\"ember\""), "{tag}");
2031- assert!(tag.contains("data-base-light=\"anvil\""), "{tag}");
2032- assert!(tag.contains("data-base-dark=\"anvil\""), "{tag}");
2040+ assert!(tag.contains("data-accent-light=\"sage\""), "{tag}");
2041+ assert!(tag.contains("data-accent-dark=\"sage\""), "{tag}");
2042+ assert!(tag.contains("data-base-light=\"ink\""), "{tag}");
2043+ assert!(tag.contains("data-base-dark=\"ink\""), "{tag}");
20332044 }
20342045
20352046 /// The `<html …>` start tag of a page.
@@ -2101,10 +2112,10 @@ mod shell_tests {
21012112 ["removed-palette", "removed-palette", "x", "x"],
21022113 )
21032114 .await;
2104- assert!(removed.contains("data-accent-light=\"ember\""), "{removed}");
2105- assert!(removed.contains("data-accent-dark=\"ember\""), "{removed}");
2106- assert!(removed.contains("data-base-light=\"anvil\""), "{removed}");
2107- assert!(removed.contains("data-base-dark=\"anvil\""), "{removed}");
2115+ assert!(removed.contains("data-accent-light=\"sage\""), "{removed}");
2116+ assert!(removed.contains("data-accent-dark=\"sage\""), "{removed}");
2117+ assert!(removed.contains("data-base-light=\"ink\""), "{removed}");
2118+ assert!(removed.contains("data-base-dark=\"ink\""), "{removed}");
21082119 // A removed preset (`ochre`, `mist`) falls back too, and a hue passes through as itself.
21092120 let retired = html_tag_for_colours(
21102121 &router,
@@ -2114,10 +2125,10 @@ mod shell_tests {
21142125 ["ochre", "terracotta", "mist", "stone"],
21152126 )
21162127 .await;
2117- assert!(retired.contains("data-accent-light=\"ember\""), "{retired}");
2118- assert!(retired.contains("data-accent-dark=\"ember\""), "{retired}");
2119- assert!(retired.contains("data-base-light=\"anvil\""), "{retired}");
2120- assert!(retired.contains("data-base-dark=\"anvil\""), "{retired}");
2128+ assert!(retired.contains("data-accent-light=\"sage\""), "{retired}");
2129+ assert!(retired.contains("data-accent-dark=\"sage\""), "{retired}");
2130+ assert!(retired.contains("data-base-light=\"ink\""), "{retired}");
2131+ assert!(retired.contains("data-base-dark=\"ink\""), "{retired}");
21212132 let hued = html_tag_for_colours(
21222133 &router,
21232134 &store,
crates/forge-web/src/views/repo_list.rsmodified+38 -17
@@ -101,23 +101,36 @@ pub struct PageLink {
101101 current: bool,
102102 }
103103
104-/// The pages to show for `page` of `pages`: the first, the last and the neighbours of the
105-/// current page, with `None` for a gap. A gap of a single page shows that page instead.
104+/// How many page slots the numbered pager shows once there are more pages than that.
105+const PAGE_SLOTS: u64 = 7;
106+
107+/// The pages to show for `page` of `pages`, with `None` for a gap. Past seven pages there are
108+/// always seven slots (the first, the last, the current one's neighbours and the gaps), so moving
109+/// between pages never moves Next or the numbers.
106110 fn page_numbers(page: u64, pages: u64) -> Vec<Option<u64>> {
107- let mut out = Vec::new();
108- let mut last = 0;
109- for n in 1..=pages {
110- let near = n == 1 || n == pages || n.abs_diff(page) <= 1;
111- let fills_gap = (n == 2 && page == 4) || (n + 1 == pages && page + 3 == pages);
112- if near || fills_gap {
113- if n > last + 1 {
114- out.push(None);
115- }
116- out.push(Some(n));
117- last = n;
118- }
111+ if pages <= PAGE_SLOTS {
112+ return (1..=pages).map(Some).collect();
113+ }
114+ let page = page.clamp(1, pages);
115+ if page <= 4 {
116+ let mut out: Vec<Option<u64>> = (1..=5).map(Some).collect();
117+ out.extend([None, Some(pages)]);
118+ out
119+ } else if page + 3 >= pages {
120+ let mut out = vec![Some(1), None];
121+ out.extend((pages - 4..=pages).map(Some));
122+ out
123+ } else {
124+ vec![
125+ Some(1),
126+ None,
127+ Some(page - 1),
128+ Some(page),
129+ Some(page + 1),
130+ None,
131+ Some(pages),
132+ ]
119133 }
120- out
121134 }
122135
123136 /// The numbered pager with Previous and Next, from `pager_links`. Nothing is shown for a single
@@ -138,6 +151,8 @@ pub async fn pager(
138151 <nav class="pager pager-numbered" aria-label=(g::t(lang, K::Pages))>
139152 if let Some(href) = prev {
140153 <a class="pager-step" href=(href.as_str()) rel="prev">(g::t(lang, K::Previous))</a>
154+ } else {
155+ <span class="pager-step off" aria-disabled="true">(g::t(lang, K::Previous))</span>
141156 }
142157 for link in links.into_iter() {
143158 if link.current {
@@ -152,6 +167,8 @@ pub async fn pager(
152167 }
153168 if let Some(href) = next {
154169 <a class="pager-step" href=(href.as_str()) rel="next">(g::t(lang, K::Next))</a>
170+ } else {
171+ <span class="pager-step off" aria-disabled="true">(g::t(lang, K::Next))</span>
155172 }
156173 </nav>
157174 }
@@ -200,10 +217,14 @@ mod tests {
200217 fn pages_are_compact_with_gaps() {
201218 assert_eq!(shown(1, 1), "1");
202219 assert_eq!(shown(1, 3), "1 2 3");
220+ assert_eq!(shown(1, 7), "1 2 3 4 5 6 7");
203221 assert_eq!(shown(5, 12), "1 ... 4 5 6 ... 12");
204- assert_eq!(shown(1, 12), "1 2 ... 12");
205- assert_eq!(shown(12, 12), "1 ... 11 12");
222+ assert_eq!(shown(1, 12), "1 2 3 4 5 ... 12");
223+ assert_eq!(shown(12, 12), "1 ... 8 9 10 11 12");
206224 assert_eq!(shown(4, 12), "1 2 3 4 5 ... 12");
207225 assert_eq!(shown(9, 12), "1 ... 8 9 10 11 12");
226+ for page in 1..=54 {
227+ assert_eq!(page_numbers(page, 54).len(), 7, "page {page}");
228+ }
208229 }
209230 }
crates/forge-web/src/views/review_thread.rsmodified+2 -2
@@ -16,7 +16,7 @@ use crate::i18n::pulls_review::{self as g, K};
1616 use crate::pages::issue_parts::When;
1717 use crate::render::markdown::{LinkContext, render_markdown};
1818 use crate::views::parts::{confirm_act, post_act, reveal};
19-use crate::views::{avatar_url, display_name, now_unix, user_href, user_link};
19+use crate::views::{avatar_url_unknown, display_name, now_unix, user_href, user_link};
2020
2121 /// What the Apply control of a suggestion shows. A root without a state shows the diff only.
2222 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -149,7 +149,7 @@ fn comment_row(
149149 let edited = ctx.edits.get(&comment.id).is_some_and(|count| *count > 0);
150150 let parts = body_parts(&comment, ctx, state);
151151 CommentRow {
152- avatar: avatar_url(&comment.author_name, None),
152+ avatar: avatar_url_unknown(&comment.author_name),
153153 author: display_name(lang, &comment.author_name),
154154 login: comment.author_name.clone(),
155155 when: When::new(lang, &comment.created_at, &ctx.tz, now),
docs/ui-language.mdmodified+29 -9
@@ -67,10 +67,15 @@ no `margin-left:auto`, no `justify-content:space-between`, no second column at t
6767
6868 - **Button**: `<button>` (soft), `<button class="primary">` (filled), `.small`. A head holds the page's
6969 main action as `.primary` and its others as soft. A form's submit is `.primary`, once, under its fields.
70- `a.button` for a link that acts like one.
70+ `a.button` for a link that acts like one. Every action beside a title is that soft pill (or the filled
71+ one), whatever it is made of: an `a.act`, a form's `button.act` or a reveal's `summary.act` in the head
72+ takes the pill's look, so no head shows a bare word beside a button.
7173 - **Tool**: `.act`, a quiet word (14px, dim, radius 12). `.act.danger` for destructive. This is what goes in
7274 tools rows, in rows and in `.acts`.
7375 - `reveal(label, id, open)`: a tool that opens its form in place. `open` when a form came back with an error.
76+ In a `.fields` form its word starts on the controls' edge. What should not be one click away
77+ (regenerating recovery codes, turning off two-factor) is a reveal whose form asks for the password
78+ and the code again, never a prominent button.
7479 - `confirm_act(lang, label, action, csrf, fields, note)`: every destructive action. It always asks first, in
7580 place, with a small filled danger button and "Keep it". There are no one-click deletes.
7681 - `post_act(label, action, csrf, fields)`: a tool that posts at once, for what loses nothing.
@@ -99,13 +104,21 @@ label. Errors are `alert` at the top of the form they belong to, which stays ope
99104
100105 ## Lists and search
101106
102-Every search bar is live: `data-live-search` on a real GET form's input in `.plain-search`. It sits in the
103-tools row or above the rail's list. Filters are the rail, or `.tabs` when there are only a few. Pagers
104-appear only when another page exists, as one `nav.pager` row (Newer, the page, Older) under the list, on
105-the sheet's inset with a hairline above. A long log (the audit log) numbers its pages in the same row
106-(`nav.pager.pager-numbered`), the current page held like a pressed tool. An empty list is `.state` with
107-one line and its action as `.act`. A log reads as text: action words, then facts joined with " · ", never
108-raw JSON; repeats in a row fold into one line with "×N".
107+Every list that can grow has a search, and every search is `finder_field` (`views/find.rs`): a live
108+`.plain-search` (results follow typing, no Enter) with two options beside it, Exact and Aa (match case),
109+which apply the moment they are ticked. By default a search forgives typos and case. Its placeholder
110+names what is searched ("Search users", "Search organizations", not one text for every tab). A category
111+filter is a `.find-filter`: its word, then the small soft select, on the same line. Inside a topic the
112+row is `form.sec-tools`.
113+
114+A list that can grow is paged, never endless: about one screen of rows. Pagers appear only when another
115+page exists, as one `nav.pager` row under the list on the sheet's inset. A numbered pager always has
116+Previous and Next and always seven page slots once there are more than seven pages, so nothing in the
117+row moves when you change page; a step you cannot take stays in place, dimmed. An empty list is
118+`.state` with one line and its action as `.act`. A log reads as text: action words, then facts joined
119+with " · ", never raw JSON. Runs of the same action by the same person fold into one `details.log-group`
120+line with "×N" and what they share; the line opens in place to list every entry with what differs, and
121+a page counts folded lines, so a page of folds is as full as any other.
109122
110123 ## Menus
111124
@@ -123,7 +136,8 @@ with a green hue, so results sit with whichever accent is chosen. Cancelled is g
123136 is blue and deleted is rose.
124137
125138 A colour choice offers five presets and a Custom chip (its swatch and the word), on the same columns
126-in every row.
139+in every row. Backgrounds and accents of one hue share a column: Ink and Sage (the default for light
140+and dark), Anvil and Ember, Dusk and Ocean, Heather and Plum, Blush and Rose.
127141
128142 ## Type
129143
@@ -158,3 +172,9 @@ Turkish page shows no English, an English page no Turkish.
158172 - Every control has one focus ring: 2px in `--focus`, inside its own edge (`outline-offset: -2px`), so
159173 no sheet, row or scrolling list cuts it.
160174 - A tab's own pages sit in its rail: the Security log is a Security rail item, not a page of its own.
175+- No page is an orphan. A page that makes or shows something of yours (a new repository, an import, a
176+ snippet, a new organization) shows your profile tabs with the area it belongs to marked, and the inbox
177+ pages (Notifications, Needs you, Review requests) share one rail, so a mouse reaches every neighbour.
178+- An action a server cannot carry out shows as unavailable: no "send again" when mail is not set up.
179+- Avatars without an uploaded image are drawn in the page (a letter on a colour from the name), so a
180+ list of people or organizations never waits on image requests.
scripts/audit/measure.tsmodified+2 -2
@@ -147,8 +147,8 @@ const DESIGN = `(() => {
147147 if (!CONTROLS.some(([h, r, fs]) => p.h === h && p.r === r && p.fs === fs)) bad.push('control shape ' + p.h + '/' + p.r + '/' + p.fs + ': ' + label);
148148 }
149149 if (isText || tag === 'SELECT') {
150- // One height a place: 32 in a tools row, 36 in the top bar, 38 everywhere else.
151- const want = e.closest('.sheet-tools') ? 32 : e.closest('.topbar, .pathbar, .top-search') ? 36 : 38;
150+ // One height a place: 32 in a tools row or a list's search, 36 in the top bar, 38 everywhere else.
151+ const want = e.closest('.sheet-tools, .sec-tools, .list-find, .find-filter') ? 32 : e.closest('.topbar, .pathbar, .top-search') ? 36 : 38;
152152 if (p.h !== want) bad.push('field height ' + p.h + ' (want ' + want + '): ' + label);
153153 if (p.b) bad.push('field border: ' + label);
154154 if (none(p.bg) && !e.closest('.plain-search, .top-search')) bad.push('field without fill: ' + label);
style/_import.scssmodified+0 -8
@@ -72,14 +72,6 @@
7272 max-width: 960px;
7373 }
7474
75-.export-row {
76- display: flex;
77- flex-wrap: wrap;
78- align-items: center;
79- gap: 8px 14px;
80-
81-}
82-
8375 .export-progress {
8476 width: 120px;
8577 }
style/_min.scssmodified+2 -2
@@ -507,8 +507,8 @@ div.line {
507507 }
508508
509509 // A tick or a radio always sits right before its own text, wherever the label is.
510-main label:not(.colour-choice, .choice > label):has(> input[type="checkbox"]),
511-main label:not(.colour-choice, .choice > label):has(> input[type="radio"]) {
510+main label:not(.colour-choice, .find-opt, .choice > label):has(> input[type="checkbox"]),
511+main label:not(.colour-choice, .find-opt, .choice > label):has(> input[type="radio"]) {
512512 display: flex;
513513 flex-direction: row;
514514 align-items: flex-start;
style/_min_settings.scssmodified+9 -8
@@ -53,12 +53,11 @@
5353 }
5454 }
5555
56-// Data export: one archive, its state beside its name, its link under it.
56+// Data export: each archive is one flat line (when, state, Download, Delete); a building one adds its
57+// progress and an error under the line.
5758 .export-row {
58- display: flex;
59- flex-direction: column;
60- gap: 6px;
61- padding: 10px 0;
59+ display: block;
60+ margin: 0 -18px;
6261 border-bottom: 1px solid var(--border);
6362
6463 &:last-child {
@@ -66,12 +65,14 @@
6665 }
6766
6867 > .line {
69- min-height: 0;
68+ padding-left: 18px;
69+ padding-right: 18px;
7070 border-bottom: 0;
7171 }
7272
73- > .hint {
74- margin: 0;
73+ > progress,
74+ > .alert {
75+ margin: 0 18px 10px;
7576 }
7677 }
7778
style/_one.scssmodified+301 -1
@@ -3230,9 +3230,34 @@ nav.pager.pager-numbered {
32303230 font-size: 14px;
32313231
32323232 .pager-page,
3233- .pager-step {
3233+ .pager-step,
3234+ .pager-gap {
3235+ display: inline-flex;
3236+ align-items: center;
3237+ justify-content: center;
3238+ box-sizing: border-box;
3239+ height: 30px;
3240+ margin: 0;
32343241 color: var(--muted);
32353242 font-weight: 500;
3243+ font-variant-numeric: tabular-nums;
3244+ }
3245+
3246+ // Every number and gap is one width, and Previous and Next always hold their place (dimmed when
3247+ // there is nowhere to go), so moving between pages never moves a thing in the row.
3248+ .pager-page,
3249+ .pager-gap {
3250+ min-width: 40px;
3251+ padding: 0 4px;
3252+ }
3253+
3254+ .pager-step {
3255+ padding: 0 10px;
3256+ }
3257+
3258+ .pager-step.off {
3259+ opacity: 0.4;
3260+ cursor: default;
32363261 }
32373262
32383263 > :first-child {
@@ -3273,3 +3298,278 @@ nav.pager.pager-numbered {
32733298 outline-offset: -2px;
32743299 box-shadow: none;
32753300 }
3301+
3302+// A list's search: one 32px soft field with its icon inside, then Exact and Aa as quiet options that
3303+// hold like a pressed tool when on. The ring is the field's own, drawn inside its edge, so focusing or
3304+// typing never moves or grows a thing in the row.
3305+.list-find {
3306+ display: inline-flex;
3307+ flex-wrap: wrap;
3308+ align-items: center;
3309+ gap: 4px;
3310+
3311+ &#{&} .plain-search {
3312+ display: inline-flex;
3313+ flex: none;
3314+ align-items: center;
3315+ gap: 8px;
3316+ box-sizing: border-box;
3317+ width: 280px;
3318+ height: 32px;
3319+ margin: 0;
3320+ padding: 0 12px;
3321+ border-radius: 16px;
3322+ background: var(--surface-2);
3323+
3324+ &:focus-within {
3325+ outline: 2px solid var(--focus);
3326+ outline-offset: -2px;
3327+ }
3328+
3329+ .ico {
3330+ flex: none;
3331+ width: 16px;
3332+ height: 16px;
3333+ fill: none;
3334+ stroke: var(--muted);
3335+ stroke-width: 2;
3336+ }
3337+
3338+ input[type="search"] {
3339+ flex: 1;
3340+ width: auto;
3341+ min-width: 0;
3342+ height: 100%;
3343+ margin: 0;
3344+ padding: 0;
3345+ border: 0;
3346+ border-radius: 0;
3347+ outline: 0;
3348+ background: none;
3349+ box-shadow: none;
3350+ font-size: 14px;
3351+ }
3352+
3353+ > button[type="submit"] {
3354+ display: none;
3355+ }
3356+ }
3357+}
3358+
3359+.find-opt.find-opt {
3360+ position: relative;
3361+ display: inline-flex;
3362+ flex-direction: row;
3363+ align-items: center;
3364+ box-sizing: border-box;
3365+ height: 32px;
3366+ padding: 0 12px;
3367+ border-radius: 16px;
3368+ color: var(--muted);
3369+ cursor: pointer;
3370+ font-size: 14px;
3371+ font-weight: 500;
3372+ user-select: none;
3373+
3374+ > input {
3375+ position: absolute;
3376+ width: 1px;
3377+ height: 1px;
3378+ margin: 0;
3379+ opacity: 0;
3380+ pointer-events: none;
3381+ }
3382+
3383+ &:hover {
3384+ color: var(--text);
3385+ }
3386+
3387+ &:has(> input:checked) {
3388+ background: var(--surface-2);
3389+ color: var(--text);
3390+ }
3391+
3392+ &:has(> input:focus-visible) {
3393+ outline: 2px solid var(--focus);
3394+ outline-offset: -2px;
3395+ }
3396+}
3397+
3398+@media (max-width: 640px) {
3399+ .list-find {
3400+ width: 100%;
3401+ }
3402+
3403+ .list-find.list-find .plain-search {
3404+ flex: 1 1 auto;
3405+ width: auto;
3406+ }
3407+}
3408+
3409+// A filter beside a list's search: its word, then the small soft select every tools row uses.
3410+.find-filter.find-filter {
3411+ display: inline-flex;
3412+ flex-direction: row;
3413+ align-items: center;
3414+ gap: 8px;
3415+ margin-left: 8px;
3416+ color: var(--muted);
3417+ font-size: 14px;
3418+ font-weight: 500;
3419+
3420+ select {
3421+ width: auto;
3422+ max-width: 220px;
3423+ height: 32px;
3424+ min-height: 0;
3425+ padding: 0 30px 0 14px;
3426+ border-radius: 16px;
3427+ font-size: 14px;
3428+ }
3429+}
3430+
3431+// A list's search inside a topic: the same row as a sheet's tools, on the topic's edge.
3432+.sec-tools {
3433+ display: flex;
3434+ flex-wrap: wrap;
3435+ align-items: center;
3436+ gap: 4px;
3437+ margin: 2px 0 6px;
3438+}
3439+
3440+// A run of log entries folded into one row opens in place to list each entry, a step in from the
3441+// row's edge, so a fold never hides what happened.
3442+details.log-group {
3443+ border-bottom: 1px solid var(--border);
3444+
3445+ &:last-child {
3446+ border-bottom: 0;
3447+ }
3448+
3449+ > summary.line {
3450+ border-bottom: 0;
3451+ cursor: pointer;
3452+ list-style: none;
3453+
3454+ &::-webkit-details-marker {
3455+ display: none;
3456+ }
3457+
3458+ > .count::after {
3459+ content: "";
3460+ display: inline-block;
3461+ width: 5px;
3462+ height: 5px;
3463+ margin-left: 6px;
3464+ border-right: 1.5px solid currentColor;
3465+ border-bottom: 1.5px solid currentColor;
3466+ transform: translateY(-2px) rotate(45deg);
3467+ }
3468+ }
3469+
3470+ &[open] > summary.line > .count {
3471+ background: var(--text);
3472+ color: var(--bg);
3473+
3474+ &::after {
3475+ transform: translateY(1px) rotate(-135deg);
3476+ }
3477+ }
3478+
3479+ > .log-items {
3480+ margin: 0 18px 8px 30px;
3481+ border-left: 2px solid var(--border);
3482+
3483+ > .line {
3484+ min-height: 34px;
3485+ padding: 4px 12px;
3486+ border-bottom: 0;
3487+ }
3488+ }
3489+}
3490+
3491+// A reveal in a form of fields opens from the control column, its word on the controls' edge
3492+// like the switches and the submit beside it.
3493+.fields > details.reveal > summary.act {
3494+ margin-left: calc(var(--label-w, 130px) + 6px);
3495+}
3496+
3497+@media (max-width: 700px) {
3498+ .fields > details.reveal > summary.act {
3499+ margin-left: -10px;
3500+ }
3501+}
3502+
3503+// A page's own actions beside its title are all the same soft pill as Edit profile or Run
3504+// workflow, whether the action is a link, a form's button or a reveal's word; a dangerous one
3505+// keeps its red word on the pill. What opens from a reveal keeps its own kit.
3506+.head-title > :is(a.act, button.act),
3507+.head-title > form.act-form > button.act,
3508+.head-title > details.reveal > summary.act {
3509+ display: inline-flex;
3510+ align-items: center;
3511+ box-sizing: border-box;
3512+ height: var(--control-h);
3513+ padding: 0 18px;
3514+ border: 0;
3515+ border-radius: 19px;
3516+ background: var(--surface-2);
3517+ color: var(--text);
3518+ font-size: 15px;
3519+ font-weight: 600;
3520+ line-height: 1;
3521+ text-decoration: none;
3522+
3523+ &:hover {
3524+ background: color-mix(in oklab, var(--surface-2) 88%, var(--text));
3525+ color: var(--text);
3526+ text-decoration: none;
3527+ }
3528+
3529+ &.danger,
3530+ &.danger:hover {
3531+ color: var(--bad);
3532+ }
3533+}
3534+
3535+// A choice whose options are places (an import's source) reads exactly like one of radios.
3536+.choice.choice > a {
3537+ display: inline-flex;
3538+ align-items: center;
3539+ height: 32px;
3540+ padding: 0 16px;
3541+ border-radius: 16px;
3542+ color: var(--muted);
3543+ font-size: 14px;
3544+ font-weight: 500;
3545+ line-height: 1;
3546+ text-decoration: none;
3547+ white-space: nowrap;
3548+
3549+ &:hover {
3550+ color: var(--text);
3551+ text-decoration: none;
3552+ }
3553+
3554+ &[aria-current="page"] {
3555+ background: var(--surface);
3556+ box-shadow: 0 0 0 1px var(--border);
3557+ color: var(--text);
3558+ }
3559+
3560+ &:focus-visible {
3561+ outline: 2px solid var(--focus);
3562+ outline-offset: -2px;
3563+ }
3564+}
3565+
3566+// In a rail the search takes the rail's width, its options on the line under it.
3567+.rail .list-find {
3568+ display: flex;
3569+ width: 100%;
3570+
3571+ &.list-find .plain-search {
3572+ flex: 1 1 100%;
3573+ width: auto;
3574+ }
3575+}
style/_one_people.scssmodified+54 -0
@@ -351,3 +351,57 @@
351351 }
352352 }
353353 }
354+
355+// The files row reads like every field: its word in the label column, then the files as one
356+// choice switch in the kit's own look, Add file and the count beside it.
357+.snippet-form > .snippet-files {
358+ padding-left: 0;
359+
360+ > .snippet-files-label {
361+ order: 0;
362+ flex: 0 0 var(--label-w, 130px);
363+ margin-right: 8px;
364+ color: var(--text);
365+ font-size: 15px;
366+ font-weight: 500;
367+ }
368+
369+ .snippet-tabs {
370+ gap: 0;
371+ padding: 3px;
372+ border-radius: 19px;
373+ background: var(--surface-2);
374+ }
375+
376+ .snippet-tab {
377+ height: 32px;
378+ padding: 0 16px;
379+ border-radius: 16px;
380+ line-height: 1;
381+ font-family: inherit;
382+ font-size: 14px;
383+ font-weight: 500;
384+ }
385+
386+ .snippet-tab-radio:checked + .snippet-tab {
387+ background: var(--surface);
388+ box-shadow: 0 0 0 1px var(--border);
389+ color: var(--text);
390+ font-weight: 500;
391+ }
392+
393+ .snippet-tab-radio:focus-visible + .snippet-tab {
394+ outline: 2px solid var(--focus);
395+ outline-offset: 1px;
396+ }
397+}
398+
399+@media (max-width: 700px) {
400+ .snippet-form > .snippet-files > .snippet-files-label {
401+ flex-basis: 100%;
402+ }
403+}
404+
405+.snippet-form > .snippet-files > fieldset {
406+ margin-left: 0;
407+}