🔥 remove: repo wiki (wiki pages, .wiki.git transport and hooks, wiki switch, wiki in backups, replication and trash)
Browse files at this commitaabd6126e6f9e56fcb92b8a36b9cd7fe7f276b23Parent: dd294d652 changed files +55 -2357
- crates/forge-core/src/audit.rs +0 -4
- crates/forge-core/src/names.rs +0 -31
- crates/forge-core/src/store/mod.rs +0 -1
- crates/forge-core/src/store/wiki.rs +0 -76
- crates/forge-e2e/tests/e2e/ci_e2e.rs +1 -89
- crates/forge-e2e/tests/e2e/main.rs +0 -1
- crates/forge-e2e/tests/e2e/wiki_e2e.rs +0 -297
- crates/forge-git/src/lib.rs +0 -1
- crates/forge-git/src/repo.rs +3 -56
- crates/forge-git/src/seed.rs +13 -2
- crates/forge-git/src/wiki.rs +0 -351
- crates/forge-ssh/src/parse.rs +0 -10
- crates/forge-web-account/src/pages/palette.rs +1 -6
- crates/forge-web-app/src/access.rs +0 -15
- crates/forge-web-app/src/api/gitea.rs +1 -1
- crates/forge-web-app/src/backup/create.rs +2 -25
- crates/forge-web-app/src/backup/fsck.rs +0 -12
- crates/forge-web-app/src/backup/mod.rs +0 -8
- crates/forge-web-app/src/backup/restore.rs +0 -66
- crates/forge-web-app/src/backup/verify.rs +0 -16
- crates/forge-web-app/src/git_http.rs +1 -16
- crates/forge-web-app/src/hook_cmd.rs +0 -2
- crates/forge-web-app/src/internal.rs +3 -79
- crates/forge-web-app/src/live.rs +0 -5
- crates/forge-web-app/src/replication/mod.rs +0 -14
- crates/forge-web-app/src/replication/worker.rs +4 -26
- crates/forge-web-app/src/views/mod.rs +4 -16
- crates/forge-web-base/src/i18n/audit_names.rs +0 -12
- crates/forge-web-base/src/i18n/code.rs +0 -1
- crates/forge-web-base/src/i18n/community.rs +0 -18
- crates/forge-web-base/src/i18n/repo_admin.rs +0 -1
- crates/forge-web-pages/Cargo.toml +1 -1
- crates/forge-web-pages/src/lib.rs +2 -2
- crates/forge-web-pages/src/pages/ci_fail.rs +2 -2
- crates/forge-web-pages/src/pages/code_live.rs +1 -2
- crates/forge-web-pages/src/pages/mod.rs +0 -2
- crates/forge-web-pages/src/pages/repo.rs +1 -2
- crates/forge-web-pages/src/pages/repo_ctx.rs +0 -3
- crates/forge-web-pages/src/pages/repo_settings.rs +2 -39
- crates/forge-web-pages/src/pages/wiki.rs +0 -842
- crates/forge-web-pages/src/pages/wiki_live.rs +0 -76
- crates/forge-web/assets/nav.js +2 -2
- crates/forge-web/src/routes.snap +0 -12
- docs/api.md +1 -1
- docs/architecture.md +1 -2
- docs/backlog.md +0 -1
- docs/ci.md +1 -1
- scripts/audit/mock.py +2 -2
- scripts/audit/seed.py +3 -21
- scripts/audit/shoot.py +3 -3
- style/_wiki.scss +0 -82
- style/main.scss +0 -1
crates/forge-core/src/audit.rsmodified+0 -4
| @@ -80,10 +80,6 @@ audit_actions! { | ||
| 80 | 80 | SnippetCreated => "snippet_created", |
| 81 | 81 | SnippetUpdated => "snippet_updated", |
| 82 | 82 | SnippetDeleted => "snippet_deleted", |
| 83 | - WikiPageSaved => "wiki_page_saved", | |
| 84 | - WikiEnabled => "wiki_enabled", | |
| 85 | - WikiDisabled => "wiki_disabled", | |
| 86 | - WikiPushed => "wiki_pushed", | |
| 87 | 83 | OrgCreated => "org_created", |
| 88 | 84 | OrgDeleted => "org_deleted", |
| 89 | 85 | OrgSettingsUpdated => "org_settings_updated", |
crates/forge-core/src/names.rsmodified+0 -31
| @@ -57,17 +57,9 @@ pub fn validate_name(input: &str) -> Result<String> { | ||
| 57 | 57 | )); |
| 58 | 58 | } |
| 59 | 59 | check_folded(input, &name)?; |
| 60 | - if name.ends_with(".wiki") { | |
| 61 | - return Err(invalid(input, "must not end with .wiki")); | |
| 62 | - } | |
| 63 | 60 | Ok(name) |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | -pub fn wiki_base(path_name: &str) -> Option<&str> { | |
| 67 | - let base = path_name.strip_suffix(".git").unwrap_or(path_name); | |
| 68 | - base.strip_suffix(".wiki").filter(|b| !b.is_empty()) | |
| 69 | -} | |
| 70 | - | |
| 71 | 63 | pub fn validate_username(input: &str) -> Result<(String, String)> { |
| 72 | 64 | let display: String = input.nfkc().collect(); |
| 73 | 65 | if !display |
| @@ -199,26 +191,3 @@ mod tests { | ||
| 199 | 191 | } |
| 200 | 192 | } |
| 201 | 193 | } |
| 202 | - | |
| 203 | -#[cfg(test)] | |
| 204 | -mod wiki_name_tests { | |
| 205 | - use super::*; | |
| 206 | - | |
| 207 | - #[test] | |
| 208 | - fn repo_names_may_not_end_in_wiki() { | |
| 209 | - assert!(matches!( | |
| 210 | - validate_name("proj.wiki"), | |
| 211 | - Err(Error::InvalidName(_)) | |
| 212 | - )); | |
| 213 | - assert!(validate_name("wikiproj").is_ok()); | |
| 214 | - } | |
| 215 | - | |
| 216 | - #[test] | |
| 217 | - fn wiki_transport_names_map_to_the_repo() { | |
| 218 | - assert_eq!(wiki_base("proj.wiki.git"), Some("proj")); | |
| 219 | - assert_eq!(wiki_base("proj.wiki"), Some("proj")); | |
| 220 | - assert_eq!(wiki_base("proj.git"), None); | |
| 221 | - assert_eq!(wiki_base("proj"), None); | |
| 222 | - assert_eq!(wiki_base(".wiki"), None); | |
| 223 | - } | |
| 224 | -} |
crates/forge-core/src/store/mod.rsmodified+0 -1
| @@ -46,7 +46,6 @@ pub mod ui_prefs; | ||
| 46 | 46 | pub mod user_delete; |
| 47 | 47 | pub mod user_prefs; |
| 48 | 48 | pub mod webhooks; |
| 49 | -pub mod wiki; | |
| 50 | 49 | |
| 51 | 50 | use std::path::Path; |
| 52 | 51 | use std::sync::Arc; |
crates/forge-core/src/store/wiki.rsdeleted+0 -76
| @@ -1,76 +0,0 @@ | ||
| 1 | -use super::{Store, col_bool, db_err}; | |
| 2 | -use crate::error::{Error, Result}; | |
| 3 | - | |
| 4 | -impl Store { | |
| 5 | - pub async fn wiki_enabled(&self, repo_id: &str) -> Result<bool> { | |
| 6 | - let conn = self.read_conn().await; | |
| 7 | - let mut rows = conn | |
| 8 | - .query( | |
| 9 | - "SELECT wiki_enabled FROM repos WHERE id = ?1 LIMIT 1", | |
| 10 | - (repo_id.to_string(),), | |
| 11 | - ) | |
| 12 | - .await | |
| 13 | - .map_err(db_err)?; | |
| 14 | - match rows.next().await.map_err(db_err)? { | |
| 15 | - Some(row) => col_bool(&row, 0), | |
| 16 | - None => Err(Error::NotFound), | |
| 17 | - } | |
| 18 | - } | |
| 19 | - | |
| 20 | - pub async fn set_wiki_enabled(&self, repo_id: &str, enabled: bool) -> Result<()> { | |
| 21 | - let conn = self.inner.conn.lock().await; | |
| 22 | - let n = conn | |
| 23 | - .execute( | |
| 24 | - "UPDATE repos SET wiki_enabled = ?2 WHERE id = ?1", | |
| 25 | - (repo_id.to_string(), i64::from(enabled)), | |
| 26 | - ) | |
| 27 | - .await | |
| 28 | - .map_err(db_err)?; | |
| 29 | - if n == 0 { | |
| 30 | - return Err(Error::NotFound); | |
| 31 | - } | |
| 32 | - Ok(()) | |
| 33 | - } | |
| 34 | -} | |
| 35 | - | |
| 36 | -#[cfg(test)] | |
| 37 | -mod tests { | |
| 38 | - use super::*; | |
| 39 | - use crate::model::Visibility; | |
| 40 | - | |
| 41 | - #[tokio::test] | |
| 42 | - async fn wiki_is_on_by_default_can_be_switched_and_unknown_repo_is_not_found() { | |
| 43 | - let dir = tempfile::tempdir().unwrap(); | |
| 44 | - let store = Store::open(&dir.path().join("forge.db")).await.unwrap(); | |
| 45 | - let tahinli = store | |
| 46 | - .create_user("Tahinli", None, "hash", false) | |
| 47 | - .await | |
| 48 | - .unwrap(); | |
| 49 | - let repo = store | |
| 50 | - .create_repo(&tahinli.id, "proj", "", Visibility::Public, "main") | |
| 51 | - .await | |
| 52 | - .unwrap(); | |
| 53 | - assert!(store.wiki_enabled(&repo.id).await.unwrap(), "on by default"); | |
| 54 | - store.set_wiki_enabled(&repo.id, false).await.unwrap(); | |
| 55 | - assert!(!store.wiki_enabled(&repo.id).await.unwrap(), "switched off"); | |
| 56 | - store.set_wiki_enabled(&repo.id, true).await.unwrap(); | |
| 57 | - assert!(store.wiki_enabled(&repo.id).await.unwrap(), "switched on"); | |
| 58 | - | |
| 59 | - assert!( | |
| 60 | - matches!( | |
| 61 | - store.wiki_enabled("01ARZ3NDEKTSV4RRFFQ69G5FAV").await, | |
| 62 | - Err(Error::NotFound) | |
| 63 | - ), | |
| 64 | - "unknown repo read" | |
| 65 | - ); | |
| 66 | - assert!( | |
| 67 | - matches!( | |
| 68 | - store | |
| 69 | - .set_wiki_enabled("01ARZ3NDEKTSV4RRFFQ69G5FAV", false) | |
| 70 | - .await, | |
| 71 | - Err(Error::NotFound) | |
| 72 | - ), | |
| 73 | - "unknown repo write" | |
| 74 | - ); | |
| 75 | - } | |
| 76 | -} |
crates/forge-e2e/tests/e2e/ci_e2e.rsmodified+1 -89
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::common::{ |
| 2 | 2 | BOB_CMD, FAST_CLAIMS, Http, PW, Server, TAHINLI_CMD, boot_forge, clone, commit, create_repo, |
| 3 | - create_token, csrf_for, first_text, git_text, git_text_env, login, temp_dir, | |
| 3 | + create_token, csrf_for, first_text, git_text, login, temp_dir, | |
| 4 | 4 | }; |
| 5 | 5 | use forge_ci::proto::{JobAssignment, Outcome, RegisterRequest}; |
| 6 | 6 | use forge_runner::client::ForgeClient; |
| @@ -10,7 +10,6 @@ use forge_runner::runner::{RunOptions, Runner}; | ||
| 10 | 10 | use std::collections::BTreeMap; |
| 11 | 11 | use std::fs; |
| 12 | 12 | use std::path::{Path, PathBuf}; |
| 13 | -use std::process::Command; | |
| 14 | 13 | use std::sync::Arc; |
| 15 | 14 | use std::time::{Duration, Instant}; |
| 16 | 15 | use tokio_util::sync::CancellationToken; |
| @@ -584,90 +583,3 @@ run = "echo started; i=0; while [ ! -f {} ] && [ $i -lt 100 ]; do sleep 0.1; i=$ | ||
| 584 | 583 | let found = statuses(&b.http, &token, &sha).await; |
| 585 | 584 | assert_eq!(found["ci/slow"].state, "success"); |
| 586 | 585 | } |
| 587 | - | |
| 588 | -#[tokio::test] | |
| 589 | -async fn ci_job_token_clones_the_repos_wiki_read_only() { | |
| 590 | - let b = boot().await; | |
| 591 | - let tahinli = login(&b.http, "tahinli", PW).await; | |
| 592 | - let token = create_token(&b.http, &tahinli, "ci-token").await; | |
| 593 | - create_repo(&b.http, &tahinli, "r", "public").await; | |
| 594 | - let worker = register_runner(&b, &tahinli, "runner-a").await; | |
| 595 | - | |
| 596 | - let csrf = csrf_for(&b.http, &format!("{REPO_PATH}/wiki/-/new"), &tahinli).await; | |
| 597 | - let saved = b | |
| 598 | - .http | |
| 599 | - .post_form( | |
| 600 | - &format!("{REPO_PATH}/wiki/-/new"), | |
| 601 | - &[ | |
| 602 | - ("csrf", &csrf), | |
| 603 | - ("name", "Home"), | |
| 604 | - ("base", ""), | |
| 605 | - ("content", "# Welcome from the wiki\n"), | |
| 606 | - ("message", "first page"), | |
| 607 | - ], | |
| 608 | - Some(&tahinli), | |
| 609 | - ) | |
| 610 | - .await; | |
| 611 | - assert_eq!(saved.status, 303, "create Home: {}", saved.body); | |
| 612 | - | |
| 613 | - let slow = r#"[on] | |
| 614 | -push = ["main"] | |
| 615 | - | |
| 616 | -[jobs.slow] | |
| 617 | -image = "docker.io/library/alpine:3" | |
| 618 | -run = "echo started; sleep 5; echo done" | |
| 619 | -"#; | |
| 620 | - let work = clone( | |
| 621 | - &remote(b.port, "tahinli", &token, "tahinli", "r"), | |
| 622 | - &b.dir.join("tahinli-work"), | |
| 623 | - ); | |
| 624 | - let sha = push_ci_config(&work, slow); | |
| 625 | - let found = wait_statuses(&b.http, &token, &sha, &["ci/slow"]).await; | |
| 626 | - let job = worker.claim().await.expect("the slow job is claimed"); | |
| 627 | - assert_eq!(job.job_id, job_id_of(&found["ci/slow"])); | |
| 628 | - | |
| 629 | - let wiki_url = format!( | |
| 630 | - "http://ci-job:{}:{}@127.0.0.1:{}/tahinli/r.wiki.git", | |
| 631 | - job.job_id, job.job_token, b.port | |
| 632 | - ); | |
| 633 | - let job_wiki = clone(&wiki_url, &b.dir.join("job-wiki")); | |
| 634 | - let home = fs::read_to_string(job_wiki.join("Home.md")).expect("Home.md in the job's clone"); | |
| 635 | - assert!(home.contains("Welcome from the wiki"), "{home}"); | |
| 636 | - | |
| 637 | - fs::write(job_wiki.join("Home.md"), "# changed by a job\n").expect("write"); | |
| 638 | - git_text(&job_wiki, &["add", "Home.md"]); | |
| 639 | - git_text_env( | |
| 640 | - &job_wiki, | |
| 641 | - &[ | |
| 642 | - "-c", | |
| 643 | - "commit.gpgsign=false", | |
| 644 | - "commit", | |
| 645 | - "-q", | |
| 646 | - "-m", | |
| 647 | - "job edit", | |
| 648 | - ], | |
| 649 | - &[ | |
| 650 | - ("GIT_AUTHOR_NAME", "job"), | |
| 651 | - ("GIT_AUTHOR_EMAIL", "job@example.invalid"), | |
| 652 | - ("GIT_COMMITTER_NAME", "job"), | |
| 653 | - ("GIT_COMMITTER_EMAIL", "job@example.invalid"), | |
| 654 | - ], | |
| 655 | - ); | |
| 656 | - let push = Command::new("git") | |
| 657 | - .current_dir(&job_wiki) | |
| 658 | - .args([ | |
| 659 | - "-c", | |
| 660 | - "credential.helper=", | |
| 661 | - "push", | |
| 662 | - "-q", | |
| 663 | - "origin", | |
| 664 | - "HEAD:main", | |
| 665 | - ]) | |
| 666 | - .env("GIT_TERMINAL_PROMPT", "0") | |
| 667 | - .output() | |
| 668 | - .expect("run git"); | |
| 669 | - assert!( | |
| 670 | - !push.status.success(), | |
| 671 | - "a CI job token must not push to the wiki" | |
| 672 | - ); | |
| 673 | -} |
crates/forge-e2e/tests/e2e/main.rsmodified+0 -1
| @@ -25,4 +25,3 @@ mod snippets_e2e; | ||
| 25 | 25 | mod stars_e2e; |
| 26 | 26 | mod ui_prefs_e2e; |
| 27 | 27 | mod user_delete_e2e; |
| 28 | -mod wiki_e2e; |
crates/forge-e2e/tests/e2e/wiki_e2e.rsdeleted+0 -297
| @@ -1,297 +0,0 @@ | ||
| 1 | -use crate::common::{ | |
| 2 | - Http, PW, Resp, commit_file, create_token, csrf_for, git, init_bare, launch, login, | |
| 3 | - next_changed, ok, path_str, provision, | |
| 4 | -}; | |
| 5 | -use std::fs; | |
| 6 | - | |
| 7 | -use forge_core::{Role, Store, Visibility}; | |
| 8 | -use reqwest::header::LOCATION; | |
| 9 | - | |
| 10 | -async fn get_ok(http: &Http, path: &str, session: Option<&str>) -> Resp { | |
| 11 | - let res = http.get(path, session).await; | |
| 12 | - assert_eq!(res.status, 200, "GET {path}: {}", res.body); | |
| 13 | - res | |
| 14 | -} | |
| 15 | - | |
| 16 | -#[tokio::test] | |
| 17 | -async fn wiki_end_to_end() { | |
| 18 | - let root = crate::common::temp_dir("fwk"); | |
| 19 | - let dir = root.path().to_path_buf(); | |
| 20 | - let (_, ports) = provision( | |
| 21 | - &dir, | |
| 22 | - "", | |
| 23 | - &[ | |
| 24 | - &["create-user", "tahinli", "--admin"], | |
| 25 | - &["create-user", "bob"], | |
| 26 | - &["create-user", "carol"], | |
| 27 | - &["create-user", "dave"], | |
| 28 | - ], | |
| 29 | - ); | |
| 30 | - { | |
| 31 | - let store = Store::open(&dir.join("forge.db")) | |
| 32 | - .await | |
| 33 | - .expect("open store"); | |
| 34 | - let bob = store.user_by_username("bob").await.unwrap().expect("bob"); | |
| 35 | - let carol = store | |
| 36 | - .user_by_username("carol") | |
| 37 | - .await | |
| 38 | - .unwrap() | |
| 39 | - .expect("carol"); | |
| 40 | - let repo = store | |
| 41 | - .create_repo(&bob.id, "proj", "", Visibility::Public, "main") | |
| 42 | - .await | |
| 43 | - .expect("repo"); | |
| 44 | - store | |
| 45 | - .set_collaborator(&repo.id, &carol.id, Role::Write) | |
| 46 | - .await | |
| 47 | - .expect("carol write"); | |
| 48 | - init_bare(&dir, &repo.id); | |
| 49 | - } | |
| 50 | - | |
| 51 | - let (server, ports) = launch(&dir, ports).await; | |
| 52 | - let http = Http::new(ports.http); | |
| 53 | - let bob = login(&http, "bob", PW).await; | |
| 54 | - let carol = login(&http, "carol", PW).await; | |
| 55 | - let dave = login(&http, "dave", PW).await; | |
| 56 | - | |
| 57 | - let empty = get_ok(&http, "/bob/proj/wiki", Some(&bob)).await; | |
| 58 | - assert!(empty.body.contains("no pages yet"), "{}", empty.body); | |
| 59 | - | |
| 60 | - let csrf = csrf_for(&http, "/bob/proj/wiki/-/new", &bob).await; | |
| 61 | - let saved = http | |
| 62 | - .post_form( | |
| 63 | - "/bob/proj/wiki/-/new", | |
| 64 | - &[ | |
| 65 | - ("csrf", &csrf), | |
| 66 | - ("name", "Home"), | |
| 67 | - ("base", ""), | |
| 68 | - ("content", "# Welcome\n\nSee [[Getting Started]].\n"), | |
| 69 | - ("message", "first page"), | |
| 70 | - ], | |
| 71 | - Some(&bob), | |
| 72 | - ) | |
| 73 | - .await; | |
| 74 | - assert_eq!(saved.status, 303, "create Home: {}", saved.body); | |
| 75 | - assert_eq!( | |
| 76 | - saved.header(LOCATION).as_deref(), | |
| 77 | - Some("/bob/proj/wiki/Home") | |
| 78 | - ); | |
| 79 | - let home = get_ok(&http, "/bob/proj/wiki/Home", Some(&bob)).await; | |
| 80 | - assert!(home.body.contains("Welcome"), "{}", home.body); | |
| 81 | - assert!( | |
| 82 | - home.body.contains("/bob/proj/wiki/Getting-Started"), | |
| 83 | - "wiki link should resolve: {}", | |
| 84 | - home.body | |
| 85 | - ); | |
| 86 | - | |
| 87 | - get_ok(&http, "/bob/proj/wiki/Home", Some(&dave)).await; | |
| 88 | - let refused = http.get("/bob/proj/wiki/Home/edit", Some(&dave)).await; | |
| 89 | - assert_eq!(refused.status, 403, "read-only user must not edit"); | |
| 90 | - | |
| 91 | - let carol_token = create_token(&http, &carol, "wiki-e2e").await; | |
| 92 | - let work = dir.join("wiki-work"); | |
| 93 | - let url = format!( | |
| 94 | - "http://carol:{carol_token}@127.0.0.1:{}/bob/proj.wiki.git", | |
| 95 | - ports.http | |
| 96 | - ); | |
| 97 | - ok( | |
| 98 | - &git(&dir, &["clone", "-q", &url, path_str(&work)]), | |
| 99 | - "clone wiki over HTTPS", | |
| 100 | - ); | |
| 101 | - let text = fs::read_to_string(work.join("Home.md")).expect("Home.md in clone"); | |
| 102 | - assert!(text.contains("Welcome"), "{text}"); | |
| 103 | - commit_file(&work, "Home.md", "# Welcome again\n", "edit from git"); | |
| 104 | - ok( | |
| 105 | - &git(&work, &["push", "-q", "origin", "HEAD:main"]), | |
| 106 | - "push wiki change over HTTPS", | |
| 107 | - ); | |
| 108 | - let after_push = get_ok(&http, "/bob/proj/wiki/Home", Some(&carol)).await; | |
| 109 | - assert!( | |
| 110 | - after_push.body.contains("Welcome again"), | |
| 111 | - "{}", | |
| 112 | - after_push.body | |
| 113 | - ); | |
| 114 | - let tahinli = login(&http, "tahinli", PW).await; | |
| 115 | - let audit = http | |
| 116 | - .get("/admin/audit?action=wiki_pushed", Some(&tahinli)) | |
| 117 | - .await; | |
| 118 | - assert_eq!(audit.status, 200, "audit page"); | |
| 119 | - assert!( | |
| 120 | - audit.body.contains("data-action=\"wiki_pushed\""), | |
| 121 | - "the wiki push is audited: {}", | |
| 122 | - audit.body | |
| 123 | - ); | |
| 124 | - assert!(audit.body.contains("carol"), "the pusher is named"); | |
| 125 | - assert!(audit.body.contains("bob/proj"), "the repo is named"); | |
| 126 | - | |
| 127 | - let stale_csrf = csrf_for(&http, "/bob/proj/wiki/Home/edit", &carol).await; | |
| 128 | - let stale = http | |
| 129 | - .post_form( | |
| 130 | - "/bob/proj/wiki/Home/edit", | |
| 131 | - &[ | |
| 132 | - ("csrf", &stale_csrf), | |
| 133 | - ("base", "0000000000000000000000000000000000000000"), | |
| 134 | - ("content", "# Lost write\n"), | |
| 135 | - ("message", "stale"), | |
| 136 | - ], | |
| 137 | - Some(&carol), | |
| 138 | - ) | |
| 139 | - .await; | |
| 140 | - assert_eq!(stale.status, 200, "{}", stale.body); | |
| 141 | - assert!( | |
| 142 | - stale.body.contains("while you were editing"), | |
| 143 | - "{}", | |
| 144 | - stale.body | |
| 145 | - ); | |
| 146 | - let still = get_ok(&http, "/bob/proj/wiki/Home", Some(&bob)).await; | |
| 147 | - assert!(still.body.contains("Welcome again"), "{}", still.body); | |
| 148 | - | |
| 149 | - let history = get_ok(&http, "/bob/proj/wiki/Home/history", Some(&bob)).await; | |
| 150 | - assert!(history.body.contains("first page"), "{}", history.body); | |
| 151 | - assert!(history.body.contains("edit from git"), "{}", history.body); | |
| 152 | - | |
| 153 | - let dave_token = create_token(&http, &dave, "wiki-e2e").await; | |
| 154 | - let dave_url = format!( | |
| 155 | - "http://dave:{dave_token}@127.0.0.1:{}/bob/proj.wiki.git", | |
| 156 | - ports.http | |
| 157 | - ); | |
| 158 | - let dave_work = dir.join("wiki-dave"); | |
| 159 | - ok( | |
| 160 | - &git(&dir, &["clone", "-q", &dave_url, path_str(&dave_work)]), | |
| 161 | - "dave clones the public wiki", | |
| 162 | - ); | |
| 163 | - commit_file(&dave_work, "Hack.md", "x\n", "not allowed"); | |
| 164 | - let denied = git(&dave_work, &["push", "-q", "origin", "HEAD:main"]); | |
| 165 | - assert!(!denied.status.success(), "read-only push must fail"); | |
| 166 | - | |
| 167 | - let settings = get_ok(&http, "/bob/proj/settings", Some(&bob)).await; | |
| 168 | - assert!( | |
| 169 | - settings.body.contains("action=\"/bob/proj/settings/wiki\""), | |
| 170 | - "{}", | |
| 171 | - settings.body | |
| 172 | - ); | |
| 173 | - let forbidden_toggle = http.get("/bob/proj/settings", Some(&carol)).await; | |
| 174 | - assert_eq!( | |
| 175 | - forbidden_toggle.status, 403, | |
| 176 | - "only admins see wiki settings" | |
| 177 | - ); | |
| 178 | - let off = http | |
| 179 | - .post_form( | |
| 180 | - "/bob/proj/settings/wiki", | |
| 181 | - &[("csrf", &csrf_for(&http, "/bob/proj/settings", &bob).await)], | |
| 182 | - Some(&bob), | |
| 183 | - ) | |
| 184 | - .await; | |
| 185 | - assert_eq!(off.status, 303, "{}", off.body); | |
| 186 | - let hidden = http.get("/bob/proj/wiki", Some(&bob)).await; | |
| 187 | - assert_eq!(hidden.status, 404, "disabled wiki must be hidden"); | |
| 188 | - commit_file(&work, "Other.md", "x\n", "after disable"); | |
| 189 | - let refused_push = git(&work, &["push", "-q", "origin", "HEAD:main"]); | |
| 190 | - assert!( | |
| 191 | - !refused_push.status.success(), | |
| 192 | - "push to a disabled wiki must fail" | |
| 193 | - ); | |
| 194 | - | |
| 195 | - drop(server); | |
| 196 | -} | |
| 197 | - | |
| 198 | -#[tokio::test] | |
| 199 | -async fn wiki_streams_follow_saves_and_pushes() { | |
| 200 | - let root = crate::common::temp_dir("fwl"); | |
| 201 | - let dir = root.path().to_path_buf(); | |
| 202 | - let (_, ports) = provision( | |
| 203 | - &dir, | |
| 204 | - "", | |
| 205 | - &[ | |
| 206 | - &["create-user", "tahinli", "--admin"], | |
| 207 | - &["create-user", "bob"], | |
| 208 | - &["create-user", "dave"], | |
| 209 | - ], | |
| 210 | - ); | |
| 211 | - { | |
| 212 | - let store = Store::open(&dir.join("forge.db")) | |
| 213 | - .await | |
| 214 | - .expect("open store"); | |
| 215 | - let bob = store.user_by_username("bob").await.unwrap().expect("bob"); | |
| 216 | - let proj = store | |
| 217 | - .create_repo(&bob.id, "proj", "", Visibility::Public, "main") | |
| 218 | - .await | |
| 219 | - .expect("repo"); | |
| 220 | - init_bare(&dir, &proj.id); | |
| 221 | - let vault = store | |
| 222 | - .create_repo(&bob.id, "vault", "", Visibility::Private, "main") | |
| 223 | - .await | |
| 224 | - .expect("private repo"); | |
| 225 | - init_bare(&dir, &vault.id); | |
| 226 | - } | |
| 227 | - | |
| 228 | - let (server, ports) = launch(&dir, ports).await; | |
| 229 | - let http = Http::new(ports.http); | |
| 230 | - let bob = login(&http, "bob", PW).await; | |
| 231 | - let dave = login(&http, "dave", PW).await; | |
| 232 | - | |
| 233 | - let listing = get_ok(&http, "/bob/proj/wiki/-/pages", Some(&bob)).await; | |
| 234 | - assert!( | |
| 235 | - listing | |
| 236 | - .body | |
| 237 | - .contains(r#"data-live="/bob/proj/wiki/-/events""#), | |
| 238 | - "page list follows the wiki stream" | |
| 239 | - ); | |
| 240 | - | |
| 241 | - let mut wiki_events = http.stream("/bob/proj/wiki/-/events", Some(&bob)).await; | |
| 242 | - assert_eq!(wiki_events.status().as_u16(), 200, "stream wiki events"); | |
| 243 | - let csrf = csrf_for(&http, "/bob/proj/wiki/-/new", &bob).await; | |
| 244 | - let created = http | |
| 245 | - .post_form( | |
| 246 | - "/bob/proj/wiki/-/new", | |
| 247 | - &[ | |
| 248 | - ("csrf", &csrf), | |
| 249 | - ("name", "Home"), | |
| 250 | - ("base", ""), | |
| 251 | - ("content", "# Welcome\n"), | |
| 252 | - ("message", "first page"), | |
| 253 | - ], | |
| 254 | - Some(&bob), | |
| 255 | - ) | |
| 256 | - .await; | |
| 257 | - assert_eq!(created.status, 303, "create Home: {}", created.body); | |
| 258 | - next_changed(&mut wiki_events, "a web save").await; | |
| 259 | - | |
| 260 | - let home = get_ok(&http, "/bob/proj/wiki/Home", Some(&bob)).await; | |
| 261 | - assert!( | |
| 262 | - home.body | |
| 263 | - .contains(r#"data-live="/bob/proj/wiki/Home/events""#), | |
| 264 | - "wiki page follows its stream" | |
| 265 | - ); | |
| 266 | - let mut home_events = http.stream("/bob/proj/wiki/Home/events", Some(&bob)).await; | |
| 267 | - assert_eq!( | |
| 268 | - home_events.status().as_u16(), | |
| 269 | - 200, | |
| 270 | - "stream wiki home events" | |
| 271 | - ); | |
| 272 | - let token = create_token(&http, &bob, "wiki-live").await; | |
| 273 | - let work = dir.join("wiki-live-work"); | |
| 274 | - let url = format!( | |
| 275 | - "http://bob:{token}@127.0.0.1:{}/bob/proj.wiki.git", | |
| 276 | - ports.http | |
| 277 | - ); | |
| 278 | - ok( | |
| 279 | - &git(&dir, &["clone", "-q", &url, path_str(&work)]), | |
| 280 | - "clone wiki over HTTPS", | |
| 281 | - ); | |
| 282 | - commit_file(&work, "Home.md", "# Pushed\n", "edit from git"); | |
| 283 | - ok( | |
| 284 | - &git(&work, &["push", "-q", "origin", "HEAD:main"]), | |
| 285 | - "push to wiki", | |
| 286 | - ); | |
| 287 | - next_changed(&mut home_events, "a push to the wiki").await; | |
| 288 | - | |
| 289 | - for path in ["/bob/vault/wiki/-/events", "/bob/vault/wiki/Home/events"] { | |
| 290 | - let res = http.get(path, Some(&dave)).await; | |
| 291 | - assert_eq!(res.status, 404, "{path} for a non-member"); | |
| 292 | - let anon = http.get(path, None).await; | |
| 293 | - assert_eq!(anon.status, 404, "{path} anonymously"); | |
| 294 | - } | |
| 295 | - | |
| 296 | - drop(server); | |
| 297 | -} |
crates/forge-git/src/lib.rsmodified+0 -1
| @@ -20,7 +20,6 @@ pub mod tags; | ||
| 20 | 20 | pub mod trailers; |
| 21 | 21 | pub mod verify; |
| 22 | 22 | pub mod version; |
| 23 | -pub mod wiki; | |
| 24 | 23 | |
| 25 | 24 | pub use command::{GitCommand, GitEnv}; |
| 26 | 25 | pub use error::{Error, Result}; |
crates/forge-git/src/repo.rsmodified+3 -56
| @@ -19,11 +19,6 @@ pub fn repo_path(data_dir: &Path, repo_id: &str) -> Result<PathBuf> { | ||
| 19 | 19 | .join(format!("{id}.git"))) |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -pub fn wiki_path(data_dir: &Path, repo_id: &str) -> Result<PathBuf> { | |
| 23 | - let main = repo_path(data_dir, repo_id)?; | |
| 24 | - Ok(main.with_extension("").with_extension("wiki.git")) | |
| 25 | -} | |
| 26 | - | |
| 27 | 22 | pub const TRASH_DIR: &str = "trash"; |
| 28 | 23 | |
| 29 | 24 | #[derive(Debug, Clone, PartialEq, Eq)] |
| @@ -31,7 +26,6 @@ pub struct TrashEntry { | ||
| 31 | 26 | pub path: PathBuf, |
| 32 | 27 | pub repo_id: String, |
| 33 | 28 | pub deleted_at: u64, |
| 34 | - pub wiki: bool, | |
| 35 | 29 | } |
| 36 | 30 | |
| 37 | 31 | pub async fn move_to_trash(data_dir: &Path, repo_id: &str) -> Result<PathBuf> { |
| @@ -40,15 +34,6 @@ pub async fn move_to_trash(data_dir: &Path, repo_id: &str) -> Result<PathBuf> { | ||
| 40 | 34 | trash_dir(data_dir, &src, &name).await |
| 41 | 35 | } |
| 42 | 36 | |
| 43 | -pub async fn move_wiki_to_trash(data_dir: &Path, repo_id: &str) -> Result<Option<PathBuf>> { | |
| 44 | - let src = wiki_path(data_dir, repo_id)?; | |
| 45 | - if !tokio::fs::try_exists(&src).await? { | |
| 46 | - return Ok(None); | |
| 47 | - } | |
| 48 | - let name = format!("{}.wiki-{}.git", repo_id.to_ascii_lowercase(), now_unix()); | |
| 49 | - trash_dir(data_dir, &src, &name).await.map(Some) | |
| 50 | -} | |
| 51 | - | |
| 52 | 37 | async fn trash_dir(data_dir: &Path, src: &Path, name: &str) -> Result<PathBuf> { |
| 53 | 38 | if !tokio::fs::try_exists(src).await? { |
| 54 | 39 | return Err(Error::Io(std::io::Error::new( |
| @@ -83,11 +68,6 @@ pub async fn restore_from_trash(data_dir: &Path, trashed: &Path, repo_id: &str) | ||
| 83 | 68 | restore_to(&dest, trashed).await |
| 84 | 69 | } |
| 85 | 70 | |
| 86 | -pub async fn restore_wiki_from_trash(data_dir: &Path, trashed: &Path, repo_id: &str) -> Result<()> { | |
| 87 | - let dest = wiki_path(data_dir, repo_id)?; | |
| 88 | - restore_to(&dest, trashed).await | |
| 89 | -} | |
| 90 | - | |
| 91 | 71 | async fn restore_to(dest: &Path, trashed: &Path) -> Result<()> { |
| 92 | 72 | if tokio::fs::try_exists(dest).await? { |
| 93 | 73 | return Err(Error::Failed(format!( |
| @@ -127,15 +107,13 @@ pub fn list_trash(data_dir: &Path) -> Result<Vec<TrashEntry>> { | ||
| 127 | 107 | let Ok(deleted_at) = ts.parse::<u64>() else { |
| 128 | 108 | continue; |
| 129 | 109 | }; |
| 130 | - let (id, wiki) = match id.strip_suffix(".wiki") { | |
| 131 | - Some(base) => (base, true), | |
| 132 | - None => (id, false), | |
| 133 | - }; | |
| 110 | + if id.ends_with(".wiki") { | |
| 111 | + continue; | |
| 112 | + } | |
| 134 | 113 | entries.push(TrashEntry { |
| 135 | 114 | path: path.clone(), |
| 136 | 115 | repo_id: id.to_owned(), |
| 137 | 116 | deleted_at, |
| 138 | - wiki, | |
| 139 | 117 | }); |
| 140 | 118 | } |
| 141 | 119 | entries.sort_by_key(|e| e.deleted_at); |
| @@ -404,34 +382,3 @@ mod tests { | ||
| 404 | 382 | assert!(dst.is_dir(), "existing target must be left alone"); |
| 405 | 383 | } |
| 406 | 384 | } |
| 407 | - | |
| 408 | -#[cfg(test)] | |
| 409 | -mod wiki_trash_tests { | |
| 410 | - use super::*; | |
| 411 | - | |
| 412 | - const ID: &str = "01arz3ndektsv4rrffq69g5fav"; | |
| 413 | - | |
| 414 | - #[tokio::test] | |
| 415 | - async fn wiki_moves_to_trash_and_back() { | |
| 416 | - let dir = tempfile::tempdir().unwrap(); | |
| 417 | - let wiki = wiki_path(dir.path(), ID).unwrap(); | |
| 418 | - assert!(move_wiki_to_trash(dir.path(), ID).await.unwrap().is_none()); | |
| 419 | - | |
| 420 | - std::fs::create_dir_all(&wiki).unwrap(); | |
| 421 | - let trashed = move_wiki_to_trash(dir.path(), ID) | |
| 422 | - .await | |
| 423 | - .unwrap() | |
| 424 | - .expect("wiki moved"); | |
| 425 | - assert!(!wiki.exists()); | |
| 426 | - let listed = list_trash(dir.path()).unwrap(); | |
| 427 | - assert_eq!(listed.len(), 1); | |
| 428 | - assert!(listed[0].wiki); | |
| 429 | - assert_eq!(listed[0].repo_id, ID); | |
| 430 | - | |
| 431 | - restore_wiki_from_trash(dir.path(), &trashed, ID) | |
| 432 | - .await | |
| 433 | - .unwrap(); | |
| 434 | - assert!(wiki.is_dir()); | |
| 435 | - assert!(list_trash(dir.path()).unwrap().is_empty()); | |
| 436 | - } | |
| 437 | -} |
crates/forge-git/src/seed.rsmodified+13 -2
| @@ -1,10 +1,21 @@ | ||
| 1 | -use std::path::Path; | |
| 1 | +use std::path::{Path, PathBuf}; | |
| 2 | +use std::sync::atomic::{AtomicU64, Ordering}; | |
| 2 | 3 | |
| 3 | 4 | use crate::command::{GitCommand, GitEnv}; |
| 4 | 5 | use crate::error::Result; |
| 5 | 6 | use crate::history::zero_oid; |
| 6 | 7 | use crate::repo::check_branch; |
| 7 | -use crate::wiki::temp_index; | |
| 8 | + | |
| 9 | +static INDEX_SEQ: AtomicU64 = AtomicU64::new(0); | |
| 10 | + | |
| 11 | +fn temp_index(repo: &Path) -> PathBuf { | |
| 12 | + let seq = INDEX_SEQ.fetch_add(1, Ordering::Relaxed); | |
| 13 | + let nanos = std::time::SystemTime::now() | |
| 14 | + .duration_since(std::time::UNIX_EPOCH) | |
| 15 | + .map(|d| d.as_nanos()) | |
| 16 | + .unwrap_or(0); | |
| 17 | + repo.join(format!("forge-index-{}-{nanos}-{seq}", std::process::id())) | |
| 18 | +} | |
| 8 | 19 | |
| 9 | 20 | pub async fn initial_commit( |
| 10 | 21 | env: &GitEnv, |
crates/forge-git/src/wiki.rsdeleted+0 -351
| @@ -1,351 +0,0 @@ | ||
| 1 | -use std::path::{Path, PathBuf}; | |
| 2 | -use std::sync::atomic::{AtomicU64, Ordering}; | |
| 3 | - | |
| 4 | -use crate::browse::{EntryKind, default_branch_commit, read_text_blob, read_tree}; | |
| 5 | -use crate::command::{GitCommand, GitEnv}; | |
| 6 | -use crate::error::{Error, Result}; | |
| 7 | -use crate::history::zero_oid; | |
| 8 | -use crate::repo::init_bare; | |
| 9 | - | |
| 10 | -pub const WIKI_BRANCH: &str = "main"; | |
| 11 | -const PAGE_EXT: &str = ".md"; | |
| 12 | -pub const MAX_PAGE_BYTES: usize = 256 * 1024; | |
| 13 | -const MAX_PAGE_NAME: usize = 100; | |
| 14 | - | |
| 15 | -#[derive(Debug, Clone, Copy)] | |
| 16 | -pub struct PageEdit<'a> { | |
| 17 | - pub name: &'a str, | |
| 18 | - pub content: &'a [u8], | |
| 19 | - pub message: &'a str, | |
| 20 | - pub author_name: &'a str, | |
| 21 | - pub author_email: &'a str, | |
| 22 | -} | |
| 23 | - | |
| 24 | -pub fn valid_page_name(name: &str) -> bool { | |
| 25 | - !name.is_empty() | |
| 26 | - && name.len() <= MAX_PAGE_NAME | |
| 27 | - && !name.starts_with('-') | |
| 28 | - && name | |
| 29 | - .bytes() | |
| 30 | - .all(|b| b.is_ascii_alphanumeric() || b == b'-' || b == b'_') | |
| 31 | -} | |
| 32 | - | |
| 33 | -pub fn page_file(name: &str) -> String { | |
| 34 | - format!("{name}{PAGE_EXT}") | |
| 35 | -} | |
| 36 | - | |
| 37 | -pub async fn ensure_wiki(env: &GitEnv, wiki: &Path) -> Result<()> { | |
| 38 | - if wiki.join("HEAD").is_file() { | |
| 39 | - return Ok(()); | |
| 40 | - } | |
| 41 | - init_bare(env, wiki, WIKI_BRANCH).await | |
| 42 | -} | |
| 43 | - | |
| 44 | -pub fn head_commit(wiki: &Path) -> Result<Option<String>> { | |
| 45 | - if !wiki.join("HEAD").is_file() { | |
| 46 | - return Ok(None); | |
| 47 | - } | |
| 48 | - default_branch_commit(wiki, WIKI_BRANCH) | |
| 49 | -} | |
| 50 | - | |
| 51 | -pub fn list_pages(wiki: &Path) -> Result<Vec<String>> { | |
| 52 | - let Some(head) = head_commit(wiki)? else { | |
| 53 | - return Ok(Vec::new()); | |
| 54 | - }; | |
| 55 | - let Some(entries) = read_tree(wiki, &head, "")? else { | |
| 56 | - return Ok(Vec::new()); | |
| 57 | - }; | |
| 58 | - let mut names: Vec<String> = entries | |
| 59 | - .iter() | |
| 60 | - .filter(|e| matches!(e.kind, EntryKind::Blob | EntryKind::Executable)) | |
| 61 | - .filter_map(|e| e.name.strip_suffix(PAGE_EXT)) | |
| 62 | - .filter(|name| valid_page_name(name)) | |
| 63 | - .map(str::to_owned) | |
| 64 | - .collect(); | |
| 65 | - names.sort(); | |
| 66 | - Ok(names) | |
| 67 | -} | |
| 68 | - | |
| 69 | -pub fn read_page(wiki: &Path, name: &str) -> Result<Option<String>> { | |
| 70 | - if !valid_page_name(name) { | |
| 71 | - return Ok(None); | |
| 72 | - } | |
| 73 | - let Some(head) = head_commit(wiki)? else { | |
| 74 | - return Ok(None); | |
| 75 | - }; | |
| 76 | - read_text_blob(wiki, &head, &page_file(name), MAX_PAGE_BYTES) | |
| 77 | -} | |
| 78 | - | |
| 79 | -#[derive(Debug, Clone, PartialEq, Eq)] | |
| 80 | -pub struct PageRevision { | |
| 81 | - pub oid: String, | |
| 82 | - pub author: String, | |
| 83 | - pub at: i64, | |
| 84 | - pub subject: String, | |
| 85 | -} | |
| 86 | - | |
| 87 | -pub const HISTORY_LIMIT: usize = 200; | |
| 88 | - | |
| 89 | -pub async fn page_history(env: &GitEnv, wiki: &Path, name: &str) -> Result<Vec<PageRevision>> { | |
| 90 | - if !valid_page_name(name) || head_commit(wiki)?.is_none() { | |
| 91 | - return Ok(Vec::new()); | |
| 92 | - } | |
| 93 | - let file = page_file(name); | |
| 94 | - let out = GitCommand::new(env, "log") | |
| 95 | - .git_dir(wiki) | |
| 96 | - .arg("--format=%H%x1f%an%x1f%at%x1f%s") | |
| 97 | - .user_opt("--max-count", &HISTORY_LIMIT.to_string())? | |
| 98 | - .user_arg(&format!("refs/heads/{WIKI_BRANCH}"))? | |
| 99 | - .paths(&[file.as_str()]) | |
| 100 | - .output() | |
| 101 | - .await?; | |
| 102 | - let text = String::from_utf8_lossy(&out); | |
| 103 | - Ok(text | |
| 104 | - .lines() | |
| 105 | - .filter_map(|line| { | |
| 106 | - let mut parts = line.splitn(4, '\u{1f}'); | |
| 107 | - Some(PageRevision { | |
| 108 | - oid: parts.next()?.to_owned(), | |
| 109 | - author: parts.next()?.to_owned(), | |
| 110 | - at: parts.next()?.parse().ok()?, | |
| 111 | - subject: parts.next()?.to_owned(), | |
| 112 | - }) | |
| 113 | - }) | |
| 114 | - .collect()) | |
| 115 | -} | |
| 116 | - | |
| 117 | -static INDEX_SEQ: AtomicU64 = AtomicU64::new(0); | |
| 118 | - | |
| 119 | -pub(crate) fn temp_index(wiki: &Path) -> PathBuf { | |
| 120 | - let seq = INDEX_SEQ.fetch_add(1, Ordering::Relaxed); | |
| 121 | - let nanos = std::time::SystemTime::now() | |
| 122 | - .duration_since(std::time::UNIX_EPOCH) | |
| 123 | - .map(|d| d.as_nanos()) | |
| 124 | - .unwrap_or(0); | |
| 125 | - wiki.join(format!("forge-index-{}-{nanos}-{seq}", std::process::id())) | |
| 126 | -} | |
| 127 | - | |
| 128 | -pub async fn commit_page( | |
| 129 | - env: &GitEnv, | |
| 130 | - wiki: &Path, | |
| 131 | - base: Option<&str>, | |
| 132 | - edit: &PageEdit<'_>, | |
| 133 | -) -> Result<String> { | |
| 134 | - if !valid_page_name(edit.name) { | |
| 135 | - return Err(Error::InvalidInput(format!( | |
| 136 | - "not a valid page name: {:?}", | |
| 137 | - edit.name | |
| 138 | - ))); | |
| 139 | - } | |
| 140 | - if edit.content.len() > MAX_PAGE_BYTES { | |
| 141 | - return Err(Error::InvalidInput("page is too large".into())); | |
| 142 | - } | |
| 143 | - ensure_wiki(env, wiki).await?; | |
| 144 | - if head_commit(wiki)?.as_deref() != base { | |
| 145 | - return Err(Error::RefMoved(format!( | |
| 146 | - "wiki {WIKI_BRANCH} moved since the page was opened" | |
| 147 | - ))); | |
| 148 | - } | |
| 149 | - let index = temp_index(wiki); | |
| 150 | - let result = write_commit(env, wiki, &index, base, edit).await; | |
| 151 | - let _ = tokio::fs::remove_file(&index).await; | |
| 152 | - result | |
| 153 | -} | |
| 154 | - | |
| 155 | -async fn write_commit( | |
| 156 | - env: &GitEnv, | |
| 157 | - wiki: &Path, | |
| 158 | - index: &Path, | |
| 159 | - base: Option<&str>, | |
| 160 | - edit: &PageEdit<'_>, | |
| 161 | -) -> Result<String> { | |
| 162 | - let blob = GitCommand::new(env, "hash-object") | |
| 163 | - .git_dir(wiki) | |
| 164 | - .arg("-w") | |
| 165 | - .arg("--stdin") | |
| 166 | - .output_stdin(edit.content) | |
| 167 | - .await?; | |
| 168 | - let blob = String::from_utf8_lossy(&blob).trim().to_owned(); | |
| 169 | - | |
| 170 | - if let Some(base) = base { | |
| 171 | - GitCommand::new(env, "read-tree") | |
| 172 | - .git_dir(wiki) | |
| 173 | - .env("GIT_INDEX_FILE", index) | |
| 174 | - .user_arg(base)? | |
| 175 | - .status() | |
| 176 | - .await?; | |
| 177 | - } | |
| 178 | - let file = page_file(edit.name); | |
| 179 | - GitCommand::new(env, "update-index") | |
| 180 | - .git_dir(wiki) | |
| 181 | - .env("GIT_INDEX_FILE", index) | |
| 182 | - .arg("--add") | |
| 183 | - .arg("--cacheinfo") | |
| 184 | - .user_arg("100644")? | |
| 185 | - .user_arg(&blob)? | |
| 186 | - .user_arg(&file)? | |
| 187 | - .status() | |
| 188 | - .await?; | |
| 189 | - | |
| 190 | - let tree = GitCommand::new(env, "write-tree") | |
| 191 | - .git_dir(wiki) | |
| 192 | - .env("GIT_INDEX_FILE", index) | |
| 193 | - .output() | |
| 194 | - .await?; | |
| 195 | - let tree = String::from_utf8_lossy(&tree).trim().to_owned(); | |
| 196 | - | |
| 197 | - let mut commit = GitCommand::new(env, "commit-tree") | |
| 198 | - .config("commit.gpgsign=false") | |
| 199 | - .git_dir(wiki) | |
| 200 | - .env("GIT_AUTHOR_NAME", edit.author_name) | |
| 201 | - .env("GIT_AUTHOR_EMAIL", edit.author_email) | |
| 202 | - .env("GIT_COMMITTER_NAME", edit.author_name) | |
| 203 | - .env("GIT_COMMITTER_EMAIL", edit.author_email) | |
| 204 | - .user_arg(&tree)?; | |
| 205 | - if let Some(base) = base { | |
| 206 | - commit = commit.arg("-p").user_arg(base)?; | |
| 207 | - } | |
| 208 | - let commit = commit.arg("-F").arg("-"); | |
| 209 | - let oid = commit.output_stdin(edit.message.as_bytes()).await?; | |
| 210 | - let oid = String::from_utf8_lossy(&oid).trim().to_owned(); | |
| 211 | - | |
| 212 | - let old = match base { | |
| 213 | - Some(base) => base.to_owned(), | |
| 214 | - None => zero_oid(&oid), | |
| 215 | - }; | |
| 216 | - let swapped = GitCommand::new(env, "update-ref") | |
| 217 | - .git_dir(wiki) | |
| 218 | - .arg("-m") | |
| 219 | - .arg("forge wiki edit") | |
| 220 | - .user_arg(&format!("refs/heads/{WIKI_BRANCH}"))? | |
| 221 | - .user_arg(&oid)? | |
| 222 | - .user_arg(&old)? | |
| 223 | - .status() | |
| 224 | - .await; | |
| 225 | - match swapped { | |
| 226 | - Ok(()) => Ok(oid), | |
| 227 | - Err(Error::Failed(msg)) | |
| 228 | - if msg.contains("but expected") || msg.contains("unable to resolve reference") => | |
| 229 | - { | |
| 230 | - Err(Error::RefMoved(format!( | |
| 231 | - "wiki {WIKI_BRANCH} moved during the edit" | |
| 232 | - ))) | |
| 233 | - } | |
| 234 | - Err(e) => Err(e), | |
| 235 | - } | |
| 236 | -} | |
| 237 | - | |
| 238 | -#[cfg(test)] | |
| 239 | -mod tests { | |
| 240 | - use super::*; | |
| 241 | - use crate::repo::{repo_path, wiki_path}; | |
| 242 | - | |
| 243 | - fn env(dir: &Path) -> GitEnv { | |
| 244 | - GitEnv { | |
| 245 | - git_bin: "/usr/bin/git".into(), | |
| 246 | - data_dir: dir.to_path_buf(), | |
| 247 | - } | |
| 248 | - } | |
| 249 | - | |
| 250 | - fn edit<'a>(name: &'a str, body: &'a str) -> PageEdit<'a> { | |
| 251 | - PageEdit { | |
| 252 | - name, | |
| 253 | - content: body.as_bytes(), | |
| 254 | - message: "edit", | |
| 255 | - author_name: "Tahinli", | |
| 256 | - author_email: "tahinli@example.test", | |
| 257 | - } | |
| 258 | - } | |
| 259 | - | |
| 260 | - #[test] | |
| 261 | - fn page_names_are_strict() { | |
| 262 | - assert!(valid_page_name("Home")); | |
| 263 | - assert!(valid_page_name("Getting-Started_2")); | |
| 264 | - assert!(!valid_page_name("")); | |
| 265 | - assert!(!valid_page_name("-x")); | |
| 266 | - assert!(!valid_page_name("a b")); | |
| 267 | - assert!(!valid_page_name("../etc")); | |
| 268 | - assert!(!valid_page_name("a/b")); | |
| 269 | - assert!(!valid_page_name(&"a".repeat(MAX_PAGE_NAME + 1))); | |
| 270 | - } | |
| 271 | - | |
| 272 | - #[test] | |
| 273 | - fn wiki_path_sits_next_to_the_repo() { | |
| 274 | - let id = "01arz3ndektsv4rrffq69g5fav"; | |
| 275 | - let main = repo_path(Path::new("/d"), id).unwrap(); | |
| 276 | - let wiki = wiki_path(Path::new("/d"), id).unwrap(); | |
| 277 | - assert_eq!( | |
| 278 | - wiki.to_string_lossy(), | |
| 279 | - format!("{}.wiki.git", main.with_extension("").display()) | |
| 280 | - ); | |
| 281 | - assert!(wiki_path(Path::new("/d"), "../x").is_err()); | |
| 282 | - } | |
| 283 | - | |
| 284 | - #[tokio::test] | |
| 285 | - async fn commit_then_read_list_and_history() { | |
| 286 | - let dir = tempfile::tempdir().unwrap(); | |
| 287 | - let env = env(dir.path()); | |
| 288 | - let wiki = dir.path().join("w.wiki.git"); | |
| 289 | - assert_eq!(head_commit(&wiki).unwrap(), None); | |
| 290 | - assert!(list_pages(&wiki).unwrap().is_empty()); | |
| 291 | - | |
| 292 | - let first = commit_page(&env, &wiki, None, &edit("Home", "# Hi\n")) | |
| 293 | - .await | |
| 294 | - .unwrap(); | |
| 295 | - assert_eq!(head_commit(&wiki).unwrap().as_deref(), Some(first.as_str())); | |
| 296 | - assert_eq!(read_page(&wiki, "Home").unwrap().as_deref(), Some("# Hi\n")); | |
| 297 | - | |
| 298 | - let second = commit_page( | |
| 299 | - &env, | |
| 300 | - &wiki, | |
| 301 | - Some(&first), | |
| 302 | - &edit("Getting-Started", "more\n"), | |
| 303 | - ) | |
| 304 | - .await | |
| 305 | - .unwrap(); | |
| 306 | - assert_eq!( | |
| 307 | - list_pages(&wiki).unwrap(), | |
| 308 | - vec!["Getting-Started".to_owned(), "Home".to_owned()] | |
| 309 | - ); | |
| 310 | - assert_eq!(read_page(&wiki, "Home").unwrap().as_deref(), Some("# Hi\n")); | |
| 311 | - | |
| 312 | - let history = page_history(&env, &wiki, "Home").await.unwrap(); | |
| 313 | - assert_eq!(history.len(), 1); | |
| 314 | - assert_eq!(history[0].oid, first); | |
| 315 | - assert_eq!(history[0].author, "Tahinli"); | |
| 316 | - assert_eq!( | |
| 317 | - page_history(&env, &wiki, "Getting-Started").await.unwrap()[0].oid, | |
| 318 | - second | |
| 319 | - ); | |
| 320 | - } | |
| 321 | - | |
| 322 | - #[tokio::test] | |
| 323 | - async fn stale_base_is_refused_without_writing() { | |
| 324 | - let dir = tempfile::tempdir().unwrap(); | |
| 325 | - let env = env(dir.path()); | |
| 326 | - let wiki = dir.path().join("w.wiki.git"); | |
| 327 | - let first = commit_page(&env, &wiki, None, &edit("Home", "one\n")) | |
| 328 | - .await | |
| 329 | - .unwrap(); | |
| 330 | - commit_page(&env, &wiki, Some(&first), &edit("Home", "two\n")) | |
| 331 | - .await | |
| 332 | - .unwrap(); | |
| 333 | - let err = commit_page(&env, &wiki, Some(&first), &edit("Home", "lost\n")) | |
| 334 | - .await | |
| 335 | - .unwrap_err(); | |
| 336 | - assert!(matches!(err, Error::RefMoved(_)), "{err:?}"); | |
| 337 | - assert_eq!(read_page(&wiki, "Home").unwrap().as_deref(), Some("two\n")); | |
| 338 | - } | |
| 339 | - | |
| 340 | - #[tokio::test] | |
| 341 | - async fn invalid_name_is_refused() { | |
| 342 | - let dir = tempfile::tempdir().unwrap(); | |
| 343 | - let env = env(dir.path()); | |
| 344 | - let wiki = dir.path().join("w.wiki.git"); | |
| 345 | - let err = commit_page(&env, &wiki, None, &edit("a/b", "x")) | |
| 346 | - .await | |
| 347 | - .unwrap_err(); | |
| 348 | - assert!(matches!(err, Error::InvalidInput(_))); | |
| 349 | - assert!(read_page(&wiki, "a/b").unwrap().is_none()); | |
| 350 | - } | |
| 351 | -} |
crates/forge-ssh/src/parse.rsmodified+0 -10
| @@ -155,16 +155,6 @@ mod tests { | ||
| 155 | 155 | GitService::ReceivePack, |
| 156 | 156 | "tahinli/proj", |
| 157 | 157 | ), |
| 158 | - ( | |
| 159 | - "git-receive-pack '/tahinli/proj.wiki.git'", | |
| 160 | - GitService::ReceivePack, | |
| 161 | - "tahinli/proj.wiki", | |
| 162 | - ), | |
| 163 | - ( | |
| 164 | - "git-upload-pack 'tahinli/proj.wiki'", | |
| 165 | - GitService::UploadPack, | |
| 166 | - "tahinli/proj.wiki", | |
| 167 | - ), | |
| 168 | 158 | ( |
| 169 | 159 | "git upload-pack '/tahinli/proj'", |
| 170 | 160 | GitService::UploadPack, |
crates/forge-web-account/src/pages/palette.rsmodified+1 -6
| @@ -282,12 +282,7 @@ fn repo_pages(lang: Lang) -> Vec<Value> { | ||
| 282 | 282 | repo_page(code(CK::BranchesTitle), "branches", false, &[]), |
| 283 | 283 | repo_page(code(CK::TagsTitle), "tags", false, &[]), |
| 284 | 284 | repo_page(code(CK::TabReleases), "releases", false, &[]), |
| 285 | - repo_page( | |
| 286 | - &settings, | |
| 287 | - "settings", | |
| 288 | - true, | |
| 289 | - &["Description", "Açıklama", "Features", "Özellikler", "Wiki"], | |
| 290 | - ), | |
| 285 | + repo_page(&settings, "settings", true, &["Description", "Açıklama"]), | |
| 291 | 286 | repo_page( |
| 292 | 287 | admin(RK::BranchProtection), |
| 293 | 288 | "settings?section=branches", |
crates/forge-web-app/src/access.rsmodified+0 -15
| @@ -50,15 +50,6 @@ pub async fn resolve_repo( | ||
| 50 | 50 | GitService::UploadPack => Action::Read, |
| 51 | 51 | GitService::ReceivePack => Action::Write, |
| 52 | 52 | }; |
| 53 | - if let Some(base) = forge_core::names::wiki_base(name) { | |
| 54 | - let repo = resolve_repo_for(state, actor, owner, base, action).await?; | |
| 55 | - if !state.store.wiki_enabled(&repo.id).await.map_err(internal)? { | |
| 56 | - return Err(hidden_or_missing(actor)); | |
| 57 | - } | |
| 58 | - let path = | |
| 59 | - forge_git::repo::wiki_path(&state.config.data_dir, &repo.id).map_err(internal)?; | |
| 60 | - return Ok((repo, path)); | |
| 61 | - } | |
| 62 | 53 | let repo = resolve_repo_for(state, actor, owner, name, action).await?; |
| 63 | 54 | let path = forge_git::repo::repo_path(&state.config.data_dir, &repo.id).map_err(internal)?; |
| 64 | 55 | Ok((repo, path)) |
| @@ -146,16 +137,10 @@ pub fn git_process( | ||
| 146 | 137 | if service != GitService::ReceivePack { |
| 147 | 138 | return cmd; |
| 148 | 139 | } |
| 149 | - let is_wiki = repo_path | |
| 150 | - .file_name() | |
| 151 | - .and_then(|n| n.to_str()) | |
| 152 | - .is_some_and(|n| n.ends_with(".wiki.git")); | |
| 153 | - | |
| 154 | 140 | let actor_id = actor.map_or("", |user| user.id.as_str()); |
| 155 | 141 | cmd.env("FORGE_INTERNAL_SOCKET", state.internal_socket.as_os_str()) |
| 156 | 142 | .env("FORGE_INTERNAL_TOKEN", &*state.internal_token) |
| 157 | 143 | .env("FORGE_ACTOR_ID", actor_id) |
| 158 | 144 | .env("FORGE_REPO_ID", repo.id.as_str()) |
| 159 | 145 | .env("FORGE_PROTOCOL", transport.as_str()) |
| 160 | - .env("FORGE_WIKI", if is_wiki { "1" } else { "0" }) | |
| 161 | 146 | } |
crates/forge-web-app/src/api/gitea.rsmodified+1 -1
| @@ -251,7 +251,7 @@ pub async fn repo_json( | ||
| 251 | 251 | "avatar_url": "", |
| 252 | 252 | "has_issues": true, |
| 253 | 253 | "has_pull_requests": true, |
| 254 | - "has_wiki": true, | |
| 254 | + "has_wiki": false, | |
| 255 | 255 | "has_releases": true, |
| 256 | 256 | "created_at": repo.created_at, |
| 257 | 257 | "updated_at": repo.created_at, |
crates/forge-web-app/src/backup/create.rsmodified+2 -25
| @@ -6,8 +6,8 @@ use forge_core::{Error, Result}; | ||
| 6 | 6 | use super::{ |
| 7 | 7 | BACKUP_DIR_PREFIX, BackupOptions, BackupSource, BackupSummary, DB_FILE, DbSnapshot, |
| 8 | 8 | FORMAT_VERSION, FileEntry, KEY_FILE, MANIFEST_FILE, Manifest, PARTIAL_PREFIX, RepoEntry, Scope, |
| 9 | - WikiEntry, create_private_dir, empty_sha256, ensure_private_dir_all, fsync_dir, hash_file, | |
| 10 | - io_err, manifest_stamp, name_stamp, set_private, sorted, unique_suffix, write_private_file, | |
| 9 | + create_private_dir, empty_sha256, ensure_private_dir_all, fsync_dir, hash_file, io_err, | |
| 10 | + manifest_stamp, name_stamp, set_private, sorted, unique_suffix, write_private_file, | |
| 11 | 11 | }; |
| 12 | 12 | use forge_git::GitEnv; |
| 13 | 13 | |
| @@ -114,9 +114,6 @@ async fn build( | ||
| 114 | 114 | if let Some(bundle) = &repo.bundle { |
| 115 | 115 | rels.push(bundle.clone()); |
| 116 | 116 | } |
| 117 | - if let Some(bundle) = repo.wiki.as_ref().and_then(|w| w.bundle.as_ref()) { | |
| 118 | - rels.push(bundle.clone()); | |
| 119 | - } | |
| 120 | 117 | } |
| 121 | 118 | let key_included = opts.include_key; |
| 122 | 119 | if key_included { |
| @@ -210,32 +207,12 @@ async fn bundle_repo( | ||
| 210 | 207 | id, |
| 211 | 208 | ) |
| 212 | 209 | .await?; |
| 213 | - let wiki_dir = forge_git::repo::wiki_path(&git.data_dir, id)?; | |
| 214 | - let wiki = if wiki_dir.join("HEAD").is_file() { | |
| 215 | - let (refs_sha256, bundle) = bundle_git_repo( | |
| 216 | - git, | |
| 217 | - &wiki_dir, | |
| 218 | - staging, | |
| 219 | - scratch_root, | |
| 220 | - &format!("{idx}.wiki.git"), | |
| 221 | - &format!("repos/{id}.wiki.bundle"), | |
| 222 | - id, | |
| 223 | - ) | |
| 224 | - .await?; | |
| 225 | - Some(WikiEntry { | |
| 226 | - refs_sha256, | |
| 227 | - bundle, | |
| 228 | - }) | |
| 229 | - } else { | |
| 230 | - None | |
| 231 | - }; | |
| 232 | 210 | Ok(RepoEntry { |
| 233 | 211 | id: id.to_string(), |
| 234 | 212 | owner: owner.to_string(), |
| 235 | 213 | name: name.to_string(), |
| 236 | 214 | refs_sha256, |
| 237 | 215 | bundle, |
| 238 | - wiki, | |
| 239 | 216 | }) |
| 240 | 217 | } |
| 241 | 218 |
crates/forge-web-app/src/backup/fsck.rsmodified+0 -12
| @@ -33,18 +33,6 @@ pub async fn run_fsck(store: &Store, git: &GitEnv, full: bool) -> Result<FsckSum | ||
| 33 | 33 | )), |
| 34 | 34 | Err(e) => problems.push(format!("repo {id}: {e}")), |
| 35 | 35 | } |
| 36 | - if let Ok(wiki) = forge_git::repo::wiki_path(&git.data_dir, id) | |
| 37 | - && wiki.join("HEAD").is_file() | |
| 38 | - { | |
| 39 | - match forge_git::fsck::fsck(git, &wiki, full).await { | |
| 40 | - Ok(report) if report.ok => {} | |
| 41 | - Ok(report) => problems.push(format!( | |
| 42 | - "repo {id} wiki: {}", | |
| 43 | - truncate(&report.output, MAX_OUTPUT_CHARS) | |
| 44 | - )), | |
| 45 | - Err(e) => problems.push(format!("repo {id} wiki: {e}")), | |
| 46 | - } | |
| 47 | - } | |
| 48 | 36 | } |
| 49 | 37 | let db = store.integrity_check().await?; |
| 50 | 38 | if db.as_slice() != ["ok"] { |
crates/forge-web-app/src/backup/mod.rsmodified+0 -8
| @@ -116,14 +116,6 @@ pub struct RepoEntry { | ||
| 116 | 116 | pub name: String, |
| 117 | 117 | pub refs_sha256: String, |
| 118 | 118 | pub bundle: Option<String>, |
| 119 | - #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 120 | - pub wiki: Option<WikiEntry>, | |
| 121 | -} | |
| 122 | - | |
| 123 | -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | |
| 124 | -pub struct WikiEntry { | |
| 125 | - pub refs_sha256: String, | |
| 126 | - pub bundle: Option<String>, | |
| 127 | 119 | } |
| 128 | 120 | |
| 129 | 121 | fn io_err(e: std::io::Error) -> Error { |
crates/forge-web-app/src/backup/restore.rsmodified+0 -66
| @@ -112,21 +112,6 @@ pub async fn restore_backup( | ||
| 112 | 112 | &format!("repo {}", entry.id), |
| 113 | 113 | ) |
| 114 | 114 | .await?; |
| 115 | - | |
| 116 | - if let Some(wiki) = &entry.wiki { | |
| 117 | - let wiki_repo = forge_git::repo::wiki_path(&target, &entry.id)?; | |
| 118 | - init_bare(&git, &wiki_repo, forge_git::wiki::WIKI_BRANCH).await?; | |
| 119 | - dirs_to_lock.push(wiki_repo.clone()); | |
| 120 | - let bundle = wiki.bundle.as_ref().map(|rel| set.join(rel)); | |
| 121 | - restore_git( | |
| 122 | - &git, | |
| 123 | - &wiki_repo, | |
| 124 | - bundle.as_deref(), | |
| 125 | - &wiki.refs_sha256, | |
| 126 | - &format!("repo {} wiki", entry.id), | |
| 127 | - ) | |
| 128 | - .await?; | |
| 129 | - } | |
| 130 | 115 | } |
| 131 | 116 | drop(store); |
| 132 | 117 | |
| @@ -389,57 +374,6 @@ mod tests { | ||
| 389 | 374 | assert_eq!(dir_mode, 0o700); |
| 390 | 375 | } |
| 391 | 376 | |
| 392 | - #[tokio::test] | |
| 393 | - async fn round_trip_restores_the_wiki_from_its_own_bundle() { | |
| 394 | - let src = source().await; | |
| 395 | - let wiki = forge_git::repo::wiki_path(&src.data_dir, &src.demo_id).expect("wiki path"); | |
| 396 | - forge_git::wiki::ensure_wiki(&src.source.git, &wiki) | |
| 397 | - .await | |
| 398 | - .expect("create wiki"); | |
| 399 | - forge_git::wiki::commit_page( | |
| 400 | - &src.source.git, | |
| 401 | - &wiki, | |
| 402 | - None, | |
| 403 | - &forge_git::wiki::PageEdit { | |
| 404 | - name: "Home", | |
| 405 | - content: b"# Home\n", | |
| 406 | - message: "Add home", | |
| 407 | - author_name: "tahinli", | |
| 408 | - author_email: "tahinli@example.invalid", | |
| 409 | - }, | |
| 410 | - ) | |
| 411 | - .await | |
| 412 | - .expect("commit page"); | |
| 413 | - | |
| 414 | - let out = src.dir.path().join("out"); | |
| 415 | - let summary = create_backup(&src.source, &opts(&out, true, Scope::All)) | |
| 416 | - .await | |
| 417 | - .expect("backup"); | |
| 418 | - let manifest = std::fs::read(summary.path.join(MANIFEST_FILE)).expect("manifest"); | |
| 419 | - let manifest: crate::backup::Manifest = | |
| 420 | - serde_json::from_slice(&manifest).expect("parse manifest"); | |
| 421 | - let demo = manifest | |
| 422 | - .repos | |
| 423 | - .iter() | |
| 424 | - .find(|r| r.id == src.demo_id) | |
| 425 | - .expect("demo listed"); | |
| 426 | - assert!(demo.wiki.is_some(), "the set records the wiki"); | |
| 427 | - | |
| 428 | - let target = src.dir.path().join("fresh"); | |
| 429 | - let report = restore_backup(&summary.path, &target, &git_bin()) | |
| 430 | - .await | |
| 431 | - .expect("restore"); | |
| 432 | - assert!(report.warnings.is_empty(), "{:?}", report.warnings); | |
| 433 | - | |
| 434 | - let restored = forge_git::repo::wiki_path(&target, &src.demo_id).expect("restored path"); | |
| 435 | - assert_eq!(for_each_ref(&wiki), for_each_ref(&restored), "wiki refs"); | |
| 436 | - assert_eq!( | |
| 437 | - forge_git::wiki::read_page(&restored, "Home").expect("read page"), | |
| 438 | - Some("# Home\n".to_string()) | |
| 439 | - ); | |
| 440 | - git_in(&restored, &["fsck", "--full"]); | |
| 441 | - } | |
| 442 | - | |
| 443 | 377 | #[tokio::test] |
| 444 | 378 | async fn restore_refuses_a_non_empty_target() { |
| 445 | 379 | let src = source().await; |
crates/forge-web-app/src/backup/verify.rsmodified+0 -16
| @@ -100,17 +100,6 @@ fn check_layout(root: &Path, manifest: &Manifest, problems: &mut Vec<String>) -> | ||
| 100 | 100 | &repo.refs_sha256, |
| 101 | 101 | format!("repos/{}.bundle", repo.id), |
| 102 | 102 | ); |
| 103 | - if let Some(wiki) = &repo.wiki { | |
| 104 | - check_bundle( | |
| 105 | - problems, | |
| 106 | - &listed, | |
| 107 | - &repo.id, | |
| 108 | - "wiki ", | |
| 109 | - wiki.bundle.as_deref(), | |
| 110 | - &wiki.refs_sha256, | |
| 111 | - format!("repos/{}.wiki.bundle", repo.id), | |
| 112 | - ); | |
| 113 | - } | |
| 114 | 103 | } |
| 115 | 104 | Ok(()) |
| 116 | 105 | } |
| @@ -253,11 +242,6 @@ async fn check_bundles( | ||
| 253 | 242 | if let Some(b) = &repo.bundle { |
| 254 | 243 | bundles.push((format!("repo {}", repo.id), b, &repo.refs_sha256)); |
| 255 | 244 | } |
| 256 | - if let Some(wiki) = &repo.wiki | |
| 257 | - && let Some(b) = &wiki.bundle | |
| 258 | - { | |
| 259 | - bundles.push((format!("repo {} wiki", repo.id), b, &wiki.refs_sha256)); | |
| 260 | - } | |
| 261 | 245 | } |
| 262 | 246 | if bundles.is_empty() { |
| 263 | 247 | return Ok(0); |
crates/forge-web-app/src/git_http.rsmodified+1 -16
| @@ -357,26 +357,11 @@ pub async fn job_token_read( | ||
| 357 | 357 | } |
| 358 | 358 | Err(response) => return Some(Err(response)), |
| 359 | 359 | }; |
| 360 | - let (repo_name, wiki) = match forge_core::names::wiki_base(name) { | |
| 361 | - Some(base) => (base, true), | |
| 362 | - None => (name, false), | |
| 363 | - }; | |
| 364 | - let repo = match find_repo(state, owner, repo_name).await { | |
| 360 | + let repo = match find_repo(state, owner, name).await { | |
| 365 | 361 | Ok(Some(repo)) if repo.id == job_repo_id => repo, |
| 366 | 362 | Ok(_) => return Some(Err(job_unauthorized())), |
| 367 | 363 | Err(e) => return Some(Err(Box::new(access_error(e)))), |
| 368 | 364 | }; |
| 369 | - if wiki { | |
| 370 | - match state.store.wiki_enabled(&repo.id).await { | |
| 371 | - Ok(true) => {} | |
| 372 | - Ok(false) => return Some(Err(job_unauthorized())), | |
| 373 | - Err(e) => return Some(Err(Box::new(internal_error_for(&e)))), | |
| 374 | - } | |
| 375 | - return match forge_git::repo::wiki_path(&state.config.data_dir, &repo.id) { | |
| 376 | - Ok(path) => Some(Ok((repo, path))), | |
| 377 | - Err(_) => Some(Err(Box::new(internal_error()))), | |
| 378 | - }; | |
| 379 | - } | |
| 380 | 365 | match forge_git::repo::repo_path(&state.config.data_dir, &repo.id) { |
| 381 | 366 | Ok(path) => Some(Ok((repo, path))), |
| 382 | 367 | Err(_) => Some(Err(Box::new(internal_error()))), |
crates/forge-web-app/src/hook_cmd.rsmodified+0 -2
| @@ -36,12 +36,10 @@ pub async fn run(stage: &str) -> forge_core::Result<()> { | ||
| 36 | 36 | }) |
| 37 | 37 | .collect(); |
| 38 | 38 | |
| 39 | - let wiki = std::env::var("FORGE_WIKI").is_ok_and(|v| v == "1"); | |
| 40 | 39 | let request = HookRequest { |
| 41 | 40 | repo_id, |
| 42 | 41 | actor_id, |
| 43 | 42 | protocol, |
| 44 | - wiki, | |
| 45 | 43 | updates, |
| 46 | 44 | quarantine_env, |
| 47 | 45 | }; |
crates/forge-web-app/src/internal.rsmodified+3 -79
| @@ -47,8 +47,6 @@ pub struct HookRequest { | ||
| 47 | 47 | pub repo_id: String, |
| 48 | 48 | pub actor_id: String, |
| 49 | 49 | pub protocol: String, |
| 50 | - #[serde(default)] | |
| 51 | - pub wiki: bool, | |
| 52 | 50 | pub updates: Vec<HookUpdate>, |
| 53 | 51 | #[serde(default)] |
| 54 | 52 | pub quarantine_env: BTreeMap<String, String>, |
| @@ -148,12 +146,6 @@ async fn hook_endpoint( | ||
| 148 | 146 | HookResponse::deny("internal error while checking the push") |
| 149 | 147 | } |
| 150 | 148 | }, |
| 151 | - Stage::PostReceive if req.wiki => { | |
| 152 | - record_wiki_push(&state.store, &req).await; | |
| 153 | - crate::live::bump_wiki(state, &req.repo_id); | |
| 154 | - crate::replication::enqueue_repo(state, &req.repo_id); | |
| 155 | - HookResponse::allow() | |
| 156 | - } | |
| 157 | 149 | Stage::PostReceive => { |
| 158 | 150 | let verdict = record_events(&state.store, &req).await; |
| 159 | 151 | trigger_maintenance(&state.git, &req.repo_id); |
| @@ -507,46 +499,6 @@ async fn after_push_refs(state: &AppState, req: &HookRequest) { | ||
| 507 | 499 | } |
| 508 | 500 | } |
| 509 | 501 | |
| 510 | -async fn record_wiki_push(store: &Store, req: &HookRequest) { | |
| 511 | - let repo = match store.repo_by_id(&req.repo_id).await { | |
| 512 | - Ok(Some(repo)) => repo, | |
| 513 | - Ok(None) => return, | |
| 514 | - Err(e) => { | |
| 515 | - tracing::error!(error = %e, repo_id = %req.repo_id, "could not load repo for wiki audit"); | |
| 516 | - return; | |
| 517 | - } | |
| 518 | - }; | |
| 519 | - let user = match store.user_by_id(&req.actor_id).await { | |
| 520 | - Ok(user) => user, | |
| 521 | - Err(e) => { | |
| 522 | - tracing::error!(error = %e, actor_id = %req.actor_id, "could not load pusher for wiki audit"); | |
| 523 | - None | |
| 524 | - } | |
| 525 | - }; | |
| 526 | - let actor = match user.as_ref() { | |
| 527 | - Some(user) => Actor::User(user), | |
| 528 | - None => Actor::Anonymous, | |
| 529 | - }; | |
| 530 | - let updates: Vec<serde_json::Value> = req | |
| 531 | - .updates | |
| 532 | - .iter() | |
| 533 | - .map(|u| serde_json::json!({ "ref": u.ref_name, "old": u.old, "new": u.new })) | |
| 534 | - .collect(); | |
| 535 | - audit::record( | |
| 536 | - store, | |
| 537 | - None, | |
| 538 | - actor, | |
| 539 | - AuditAction::WikiPushed, | |
| 540 | - Target { | |
| 541 | - kind: "repo", | |
| 542 | - id: &repo.id, | |
| 543 | - name: &format!("{}/{}", repo.owner_name, repo.name), | |
| 544 | - }, | |
| 545 | - serde_json::json!({ "updates": updates }), | |
| 546 | - ) | |
| 547 | - .await; | |
| 548 | -} | |
| 549 | - | |
| 550 | 502 | async fn evaluate_pre_receive( |
| 551 | 503 | store: &Store, |
| 552 | 504 | git: &GitEnv, |
| @@ -558,23 +510,11 @@ async fn evaluate_pre_receive( | ||
| 558 | 510 | if repo.archived { |
| 559 | 511 | return Ok(HookResponse::deny("repository is archived")); |
| 560 | 512 | } |
| 561 | - if req.wiki { | |
| 562 | - if !store.wiki_enabled(&repo.id).await? { | |
| 563 | - return Ok(HookResponse::deny("the wiki is disabled")); | |
| 564 | - } | |
| 565 | - } else if store.pull_mirror(&repo.id).await?.is_some() { | |
| 513 | + if store.pull_mirror(&repo.id).await?.is_some() { | |
| 566 | 514 | return Ok(HookResponse::deny("this repository is a pull mirror")); |
| 567 | 515 | } |
| 568 | - let repo_dir = if req.wiki { | |
| 569 | - forge_git::repo::wiki_path(&git.data_dir, &repo.id)? | |
| 570 | - } else { | |
| 571 | - forge_git::repo::repo_path(&git.data_dir, &repo.id)? | |
| 572 | - }; | |
| 573 | - let rules = if req.wiki { | |
| 574 | - Vec::new() | |
| 575 | - } else { | |
| 576 | - store.list_branch_rules(&repo.id).await? | |
| 577 | - }; | |
| 516 | + let repo_dir = forge_git::repo::repo_path(&git.data_dir, &repo.id)?; | |
| 517 | + let rules = store.list_branch_rules(&repo.id).await?; | |
| 578 | 518 | |
| 579 | 519 | for update in &req.updates { |
| 580 | 520 | if !is_valid_ref_name(&update.ref_name) { |
| @@ -589,19 +529,6 @@ async fn evaluate_pre_receive( | ||
| 589 | 529 | update.ref_name |
| 590 | 530 | ))); |
| 591 | 531 | } |
| 592 | - if req.wiki { | |
| 593 | - if update.ref_name != "refs/heads/main" { | |
| 594 | - return Ok(HookResponse::deny( | |
| 595 | - "the wiki only accepts changes to its main branch", | |
| 596 | - )); | |
| 597 | - } | |
| 598 | - if is_zero_oid(&update.new) { | |
| 599 | - return Ok(HookResponse::deny( | |
| 600 | - "the wiki's main branch cannot be deleted", | |
| 601 | - )); | |
| 602 | - } | |
| 603 | - continue; | |
| 604 | - } | |
| 605 | 532 | let Some(branch) = update.ref_name.strip_prefix("refs/heads/") else { |
| 606 | 533 | continue; |
| 607 | 534 | }; |
| @@ -930,7 +857,6 @@ mod tests { | ||
| 930 | 857 | repo_id: repo.id.clone(), |
| 931 | 858 | actor_id: actor.into(), |
| 932 | 859 | protocol: "http".into(), |
| 933 | - wiki: false, | |
| 934 | 860 | updates: vec![HookUpdate { |
| 935 | 861 | old: old.into(), |
| 936 | 862 | new: new.into(), |
| @@ -996,7 +922,6 @@ mod tests { | ||
| 996 | 922 | repo_id: repo.id.clone(), |
| 997 | 923 | actor_id: owner.id.clone(), |
| 998 | 924 | protocol: "http".into(), |
| 999 | - wiki: false, | |
| 1000 | 925 | updates: vec![HookUpdate { |
| 1001 | 926 | old: "0".repeat(40), |
| 1002 | 927 | new: "1".repeat(40), |
| @@ -1075,7 +1000,6 @@ mod tests { | ||
| 1075 | 1000 | repo_id: repo.id.clone(), |
| 1076 | 1001 | actor_id: owner.id.clone(), |
| 1077 | 1002 | protocol: "http".into(), |
| 1078 | - wiki: false, | |
| 1079 | 1003 | updates: vec![HookUpdate { |
| 1080 | 1004 | old: old.into(), |
| 1081 | 1005 | new: new.into(), |
crates/forge-web-app/src/live.rsmodified+0 -5
| @@ -27,7 +27,6 @@ pub enum Topic { | ||
| 27 | 27 | ReviewRequests(String), |
| 28 | 28 | Imports(String), |
| 29 | 29 | Explore, |
| 30 | - Wiki(String), | |
| 31 | 30 | Snippets, |
| 32 | 31 | Snippet(String), |
| 33 | 32 | Org(String), |
| @@ -204,10 +203,6 @@ pub fn bump_settings(hub: &LiveHub, repo_id: &str) { | ||
| 204 | 203 | hub.bump(&Topic::RepoSettings(repo_id.to_owned())); |
| 205 | 204 | } |
| 206 | 205 | |
| 207 | -pub fn bump_wiki(state: &AppState, repo_id: &str) { | |
| 208 | - state.live.bump(&Topic::Wiki(repo_id.to_owned())); | |
| 209 | -} | |
| 210 | - | |
| 211 | 206 | pub fn bump_pull(state: &AppState, repo_id: &str, issue_id: &str) { |
| 212 | 207 | state.live.bump(&Topic::Pull(issue_id.to_owned())); |
| 213 | 208 | bump_list(state, repo_id); |
crates/forge-web-app/src/replication/mod.rsmodified+0 -14
| @@ -19,7 +19,6 @@ pub const PUSH_DEBOUNCE: Duration = Duration::from_secs(5); | ||
| 19 | 19 | pub const KEEP_SNAPSHOTS: usize = 24; |
| 20 | 20 | const DB_DIR: &str = "db"; |
| 21 | 21 | const REPOS_DIR: &str = "repos"; |
| 22 | -const WIKI_SUBJECT_SUFFIX: &str = ".wiki"; | |
| 23 | 22 | const SNAPSHOT_PREFIX: &str = "forge-"; |
| 24 | 23 | const SNAPSHOT_SUFFIX: &str = ".db"; |
| 25 | 24 | const STAMP_LEN: usize = 16; |
| @@ -42,14 +41,6 @@ pub fn validate_remote_path(path: &str) -> Result<(), String> { | ||
| 42 | 41 | } |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | -pub fn wiki_subject(repo_id: &str) -> String { | |
| 46 | - format!("{repo_id}{WIKI_SUBJECT_SUFFIX}") | |
| 47 | -} | |
| 48 | - | |
| 49 | -pub fn wiki_subject_repo(subject: &str) -> Option<&str> { | |
| 50 | - subject.strip_suffix(WIKI_SUBJECT_SUFFIX) | |
| 51 | -} | |
| 52 | - | |
| 53 | 44 | pub fn validate_repo_id(id: &str) -> Result<(), String> { |
| 54 | 45 | if id.len() == 26 && id.bytes().all(|b| b.is_ascii_alphanumeric()) { |
| 55 | 46 | Ok(()) |
| @@ -148,11 +139,6 @@ impl Layout { | ||
| 148 | 139 | Ok(format!("{}/{repo_id}.git", self.repos_dir())) |
| 149 | 140 | } |
| 150 | 141 | |
| 151 | - pub fn wiki_dir(&self, repo_id: &str) -> Result<String, String> { | |
| 152 | - validate_repo_id(repo_id)?; | |
| 153 | - Ok(format!("{}/{repo_id}.wiki.git", self.repos_dir())) | |
| 154 | - } | |
| 155 | - | |
| 156 | 142 | pub fn snapshot_file(&self, stamp: &str) -> String { |
| 157 | 143 | format!( |
| 158 | 144 | "{}/{SNAPSHOT_PREFIX}{stamp}{SNAPSHOT_SUFFIX}", |
crates/forge-web-app/src/replication/worker.rsmodified+4 -26
| @@ -10,7 +10,7 @@ use forge_git::maintenance::{clear_standby_prune, standby_prune_due}; | ||
| 10 | 10 | |
| 11 | 11 | use super::{ |
| 12 | 12 | KEEP_SNAPSHOTS, Layout, SshTransport, StandbyTransport, Target, is_snapshot_name, push_repo, |
| 13 | - remote_refs_checksum, sh_quote, snapshot_stamp, wiki_subject, wiki_subject_repo, | |
| 13 | + remote_refs_checksum, sh_quote, snapshot_stamp, | |
| 14 | 14 | }; |
| 15 | 15 | use crate::backup::healthcheck; |
| 16 | 16 | use crate::live::Topic; |
| @@ -162,16 +162,7 @@ pub async fn replicate_repo<T: StandbyTransport>( | ||
| 162 | 162 | repo_id: &str, |
| 163 | 163 | ) -> Result<(), String> { |
| 164 | 164 | let result = replicate_inner(ctx, repo_id).await; |
| 165 | - let repo_outcome = record(&ctx.store, repo_id, result).await; | |
| 166 | - let wiki = forge_git::repo::wiki_path(&ctx.data_dir, repo_id).map_err(|e| e.to_string())?; | |
| 167 | - let wiki_outcome = if wiki.join("HEAD").is_file() { | |
| 168 | - let result = replicate_wiki_inner(ctx, repo_id).await; | |
| 169 | - record(&ctx.store, &wiki_subject(repo_id), result).await | |
| 170 | - } else { | |
| 171 | - Ok(()) | |
| 172 | - }; | |
| 173 | - repo_outcome?; | |
| 174 | - wiki_outcome | |
| 165 | + record(&ctx.store, repo_id, result).await | |
| 175 | 166 | } |
| 176 | 167 | |
| 177 | 168 | async fn replicate_inner<T: StandbyTransport>( |
| @@ -189,15 +180,6 @@ async fn replicate_inner<T: StandbyTransport>( | ||
| 189 | 180 | replicate_dir(ctx, &local, &remote).await |
| 190 | 181 | } |
| 191 | 182 | |
| 192 | -async fn replicate_wiki_inner<T: StandbyTransport>( | |
| 193 | - ctx: &Ctx<T>, | |
| 194 | - repo_id: &str, | |
| 195 | -) -> Result<Option<String>, String> { | |
| 196 | - let local = forge_git::repo::wiki_path(&ctx.data_dir, repo_id).map_err(|e| e.to_string())?; | |
| 197 | - let remote = ctx.layout.wiki_dir(repo_id)?; | |
| 198 | - replicate_dir(ctx, &local, &remote).await | |
| 199 | -} | |
| 200 | - | |
| 201 | 183 | async fn replicate_dir<T: StandbyTransport>( |
| 202 | 184 | ctx: &Ctx<T>, |
| 203 | 185 | local: &Path, |
| @@ -352,8 +334,7 @@ pub async fn reconcile_once<T: StandbyTransport>(ctx: &Ctx<T>) -> ReconcileRepor | ||
| 352 | 334 | } |
| 353 | 335 | }; |
| 354 | 336 | for status in statuses { |
| 355 | - let owner = wiki_subject_repo(&status.subject).unwrap_or(&status.subject); | |
| 356 | - if status.subject == DB_SUBJECT || ids.iter().any(|id| id == owner) { | |
| 337 | + if status.subject == DB_SUBJECT || ids.iter().any(|id| *id == status.subject) { | |
| 357 | 338 | continue; |
| 358 | 339 | } |
| 359 | 340 | match remove_remote_repo(ctx, &status.subject).await { |
| @@ -375,10 +356,7 @@ async fn remove_remote_repo<T: StandbyTransport>( | ||
| 375 | 356 | ctx: &Ctx<T>, |
| 376 | 357 | subject: &str, |
| 377 | 358 | ) -> Result<(), String> { |
| 378 | - let remote = match wiki_subject_repo(subject) { | |
| 379 | - Some(repo_id) => ctx.layout.wiki_dir(repo_id)?, | |
| 380 | - None => ctx.layout.repo_dir(subject)?, | |
| 381 | - }; | |
| 359 | + let remote = ctx.layout.repo_dir(subject)?; | |
| 382 | 360 | ctx.transport |
| 383 | 361 | .run(&format!("rm -rf -- {}", sh_quote(&remote))) |
| 384 | 362 | .await |
crates/forge-web-app/src/views/mod.rsmodified+4 -16
| @@ -154,8 +154,9 @@ fn step_label(lang: Lang, word: &str) -> String { | ||
| 154 | 154 | |
| 155 | 155 | fn repo_section_label(lang: Lang, kind: &str) -> Option<String> { |
| 156 | 156 | match kind { |
| 157 | - "issues" | "pulls" | "ci" | "commits" | "branches" | "tags" | "releases" | "wiki" | |
| 158 | - | "settings" => Some(tab_title(lang, kind, "")), | |
| 157 | + "issues" | "pulls" | "ci" | "commits" | "branches" | "tags" | "releases" | "settings" => { | |
| 158 | + Some(tab_title(lang, kind, "")) | |
| 159 | + } | |
| 159 | 160 | "milestones" => Some(s(lang, "Milestones", "Kilometre taşları").to_owned()), |
| 160 | 161 | "labels" => Some(s(lang, "Labels", "Etiketler").to_owned()), |
| 161 | 162 | _ => None, |
| @@ -294,12 +295,7 @@ fn path_segments(lang: Lang, path: &str, title: &str) -> Vec<(String, Option<Str | ||
| 294 | 295 | }; |
| 295 | 296 | segments.push((step_label(lang, step), None)); |
| 296 | 297 | } |
| 297 | - ("wiki", [dash, new]) if dash == "-" && new == "new" => { | |
| 298 | - segments.push((s(lang, "New page", "Yeni sayfa").to_owned(), None)); | |
| 299 | - } | |
| 300 | - ("wiki" | "settings", [page, more @ ..]) | |
| 301 | - if !more.is_empty() && page != "-" => | |
| 302 | - { | |
| 298 | + ("settings", [page, more @ ..]) if !more.is_empty() && page != "-" => { | |
| 303 | 299 | let page_label = match page.as_str() { |
| 304 | 300 | "hooks" => { |
| 305 | 301 | i18n::integrations::t(lang, i18n::integrations::K::Webhooks) |
| @@ -1286,7 +1282,6 @@ pub async fn repo_tabs( | ||
| 1286 | 1282 | lang: Lang, |
| 1287 | 1283 | #[default] open_issues: Option<u64>, |
| 1288 | 1284 | #[default] open_pulls: Option<u64>, |
| 1289 | - #[default] wiki: bool, | |
| 1290 | 1285 | ) -> Result<impl View> { |
| 1291 | 1286 | let home = repo_href(&owner, &repo, "", ""); |
| 1292 | 1287 | let issues = repo_href(&owner, &repo, "issues", ""); |
| @@ -1304,7 +1299,6 @@ pub async fn repo_tabs( | ||
| 1304 | 1299 | ); |
| 1305 | 1300 | let code_on = active == "code" || more_on; |
| 1306 | 1301 | let settings = repo_href(&owner, &repo, "settings", ""); |
| 1307 | - let wiki_tab = repo_href(&owner, &repo, "wiki", ""); | |
| 1308 | 1302 | Ok(view! { |
| 1309 | 1303 | <nav class="repo-tabs" aria-label=(g::t(lang, K::RepositoryNav))> |
| 1310 | 1304 | <a class=(tab_class(code_on)) href=(home)> |
| @@ -1336,11 +1330,6 @@ pub async fn repo_tabs( | ||
| 1336 | 1330 | <a class=(tab_class(active == "ci")) href=(ci)> |
| 1337 | 1331 | (g::t(lang, K::TabCi)) |
| 1338 | 1332 | </a> |
| 1339 | - if wiki { | |
| 1340 | - <a class=(tab_class(active == "wiki")) href=(wiki_tab)> | |
| 1341 | - (g::t(lang, K::TabWiki)) | |
| 1342 | - </a> | |
| 1343 | - } | |
| 1344 | 1333 | if can_admin { |
| 1345 | 1334 | <a class=(tab_class(active == "settings")) href=(settings)> |
| 1346 | 1335 | (g::t(lang, K::TabSettings)) |
| @@ -1595,7 +1584,6 @@ pub fn tab_title(lang: Lang, active: &str, repo: &str) -> String { | ||
| 1595 | 1584 | "branches" => g::t(lang, K::BranchesTitle).to_owned(), |
| 1596 | 1585 | "tags" => g::t(lang, K::TagsTitle).to_owned(), |
| 1597 | 1586 | "releases" => g::t(lang, K::TabReleases).to_owned(), |
| 1598 | - "wiki" => g::t(lang, K::TabWiki).to_owned(), | |
| 1599 | 1587 | "settings" => g::t(lang, K::TabSettings).to_owned(), |
| 1600 | 1588 | _ => repo.to_owned(), |
| 1601 | 1589 | } |
crates/forge-web-base/src/i18n/audit_names.rsmodified+0 -12
| @@ -128,14 +128,6 @@ pub fn action_name(lang: Lang, action: &str) -> Option<&'static str> { | ||
| 128 | 128 | ("snippet_updated", Lang::Tr) => Some("Parçacık güncellendi"), |
| 129 | 129 | ("snippet_deleted", Lang::En) => Some("Snippet deleted"), |
| 130 | 130 | ("snippet_deleted", Lang::Tr) => Some("Parçacık silindi"), |
| 131 | - ("wiki_page_saved", Lang::En) => Some("Wiki page saved"), | |
| 132 | - ("wiki_page_saved", Lang::Tr) => Some("Wiki sayfası kaydedildi"), | |
| 133 | - ("wiki_enabled", Lang::En) => Some("Wiki turned on"), | |
| 134 | - ("wiki_enabled", Lang::Tr) => Some("Wiki açıldı"), | |
| 135 | - ("wiki_disabled", Lang::En) => Some("Wiki turned off"), | |
| 136 | - ("wiki_disabled", Lang::Tr) => Some("Wiki kapatıldı"), | |
| 137 | - ("wiki_pushed", Lang::En) => Some("Wiki pushed"), | |
| 138 | - ("wiki_pushed", Lang::Tr) => Some("Wiki gönderildi"), | |
| 139 | 131 | ("org_created", Lang::En) => Some("Organization created"), |
| 140 | 132 | ("org_created", Lang::Tr) => Some("Kuruluş oluşturuldu"), |
| 141 | 133 | ("org_deleted", Lang::En) => Some("Organization deleted"), |
| @@ -437,10 +429,6 @@ mod tests { | ||
| 437 | 429 | "snippet_created", |
| 438 | 430 | "snippet_updated", |
| 439 | 431 | "snippet_deleted", |
| 440 | - "wiki_page_saved", | |
| 441 | - "wiki_enabled", | |
| 442 | - "wiki_disabled", | |
| 443 | - "wiki_pushed", | |
| 444 | 432 | "org_created", |
| 445 | 433 | "org_deleted", |
| 446 | 434 | "org_settings_updated", |
crates/forge-web-base/src/i18n/code.rsmodified+0 -1
| @@ -107,7 +107,6 @@ strings! { | ||
| 107 | 107 | TabCommits => "Commits", "Commitler"; |
| 108 | 108 | TabReleases => "Releases", "Sürümler"; |
| 109 | 109 | TabCi => "CI", "CI"; |
| 110 | - TabWiki => "Wiki", "Wiki"; | |
| 111 | 110 | TabSettings => "Settings", "Ayarlar"; |
| 112 | 111 | } |
| 113 | 112 |
crates/forge-web-base/src/i18n/community.rsmodified+0 -18
| @@ -10,25 +10,7 @@ strings! { | ||
| 10 | 10 | CouldNotSave => "Could not save", "Kaydedilemedi"; |
| 11 | 11 | Reply => "Reply", "Yanıtla"; |
| 12 | 12 | |
| 13 | - Wiki => "Wiki", "Wiki"; | |
| 14 | 13 | Home => "Home", "Ana sayfa"; |
| 15 | - AllPages => "All pages", "Tüm sayfalar"; | |
| 16 | - NewPage => "New page", "Yeni sayfa"; | |
| 17 | - History => "History", "Geçmiş"; | |
| 18 | - PageNav => "Page", "Sayfa"; | |
| 19 | - WikiNoPages => "This wiki has no pages yet.", "Bu wiki'de henüz sayfa yok."; | |
| 20 | - CreateFirstPage => "Create the first page", "İlk sayfayı oluştur"; | |
| 21 | - NoPagesYet => "No pages yet. Create the first page to start the wiki.", "Henüz sayfa yok. İlk sayfayı oluşturarak wiki'yi başlatın."; | |
| 22 | - BackToPage => "Back to page", "Sayfaya dön"; | |
| 23 | - NoChangesYet => "No changes yet.", "Henüz değişiklik yok."; | |
| 24 | - PageName => "Page name", "Sayfa adı"; | |
| 25 | - ContentMarkdown => "Content (Markdown)", "İçerik (Markdown)"; | |
| 26 | - Summary => "Summary", "Özet"; | |
| 27 | - SavePage => "Save page", "Sayfayı kaydet"; | |
| 28 | - PageNameRules => "Page names use letters, digits, - and _, up to 100 characters.", "Sayfa adları harf, rakam, - ve _ içerebilir; en fazla 100 karakter olabilir."; | |
| 29 | - PageExists => "A page with that name already exists. Edit it instead.", "Bu adla bir sayfa zaten var. Bunun yerine onu düzenleyin."; | |
| 30 | - WikiConflict => "Someone else saved this wiki while you were editing. Your text is kept below; copy it, reload the page, and save again.", "Siz düzenlerken başka biri bu wiki'yi kaydetti. Metniniz aşağıda duruyor; kopyalayın, sayfayı yenileyin ve yeniden kaydedin."; | |
| 31 | - WikiPages => "Wiki pages", "Wiki sayfaları"; | |
| 32 | 14 | |
| 33 | 15 | Snippets => "Snippets", "Parçacıklar"; |
| 34 | 16 | NewSnippet => "New snippet", "Yeni parçacık"; |
crates/forge-web-base/src/i18n/repo_admin.rsmodified+0 -1
| @@ -105,7 +105,6 @@ strings! { | ||
| 105 | 105 | VisibilityHeading => "Visibility", "Görünürlük"; |
| 106 | 106 | MakePrivateConfirm => "Make it private?", "Özel yapılsın mı?"; |
| 107 | 107 | Webhooks => "Webhooks", "Web kancaları"; |
| 108 | - Features => "Features", "Özellikler"; | |
| 109 | 108 | RenameHeading => "Rename", "Yeniden adlandır"; |
| 110 | 109 | } |
| 111 | 110 |
crates/forge-web-pages/Cargo.tomlmodified+1 -1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | [package] |
| 2 | 2 | name = "forge-web-pages" |
| 3 | -description = "forge pages that the rest build on: repo, issues, CI runs, wiki, releases and settings" | |
| 3 | +description = "forge pages that the rest build on: repo, issues, CI runs, releases and settings" | |
| 4 | 4 | version.workspace = true |
| 5 | 5 | edition.workspace = true |
| 6 | 6 | license.workspace = true |
crates/forge-web-pages/src/lib.rsmodified+2 -2
| @@ -4,8 +4,8 @@ | ||
| 4 | 4 | pub(crate) use forge_web_app::test_support; |
| 5 | 5 | pub(crate) use forge_web_app::{ |
| 6 | 6 | api, audit, auth, automerge, blobs, ci, client_ip, i18n, internal, layers, live, merge, |
| 7 | - merge_queue, notify, notify_hub, post_update, raw, release_ops, render, replication, | |
| 8 | - repo_stats, state, templates, views, webhooks, | |
| 7 | + merge_queue, notify, notify_hub, post_update, raw, release_ops, render, repo_stats, state, | |
| 8 | + templates, views, webhooks, | |
| 9 | 9 | }; |
| 10 | 10 | |
| 11 | 11 | pub mod pages; |
crates/forge-web-pages/src/pages/ci_fail.rsmodified+2 -2
| @@ -131,9 +131,9 @@ mod tests { | ||
| 131 | 131 | fn the_place_of_an_error_is_its_file_and_line() { |
| 132 | 132 | let lines = [ |
| 133 | 133 | "error: stream closed".to_owned(), |
| 134 | - " --> crates/forge-e2e/tests/e2e/wiki_e2e.rs:212:9".to_owned(), | |
| 134 | + " --> crates/forge-e2e/tests/e2e/ci_e2e.rs:212:9".to_owned(), | |
| 135 | 135 | ]; |
| 136 | - assert_eq!(place_in(&lines).as_deref(), Some("wiki_e2e.rs:212")); | |
| 136 | + assert_eq!(place_in(&lines).as_deref(), Some("ci_e2e.rs:212")); | |
| 137 | 137 | assert_eq!(place_in(&["test a::b::c ... FAILED".to_owned()]), None); |
| 138 | 138 | } |
| 139 | 139 | } |
crates/forge-web-pages/src/pages/code_live.rsmodified+1 -2
| @@ -71,7 +71,6 @@ async fn header_fingerprint( | ||
| 71 | 71 | let forks = fork_count(state, repo_id).await?; |
| 72 | 72 | let (open_issues, _) = state.store.issue_counts(repo_id).await?; |
| 73 | 73 | let (open_pulls, _) = state.store.pull_counts(repo_id).await?; |
| 74 | - let wiki = state.store.wiki_enabled(repo_id).await?; | |
| 75 | 74 | let watch = match viewer_id { |
| 76 | 75 | Some(viewer) => format!("{:?}", state.store.watch_level(viewer, repo_id).await?), |
| 77 | 76 | None => String::new(), |
| @@ -88,7 +87,7 @@ async fn header_fingerprint( | ||
| 88 | 87 | Ok(header_text( |
| 89 | 88 | &repo, |
| 90 | 89 | [stars, watchers, forks, open_issues, open_pulls], |
| 91 | - &format!("{wiki} {watch}\n{mirror}"), | |
| 90 | + &format!("{watch}\n{mirror}"), | |
| 92 | 91 | )) |
| 93 | 92 | } |
| 94 | 93 |
crates/forge-web-pages/src/pages/mod.rsmodified+0 -2
| @@ -33,8 +33,6 @@ pub mod repo_side; | ||
| 33 | 33 | pub mod repo_transfer; |
| 34 | 34 | pub mod star; |
| 35 | 35 | pub mod tree; |
| 36 | -pub mod wiki; | |
| 37 | -pub mod wiki_live; | |
| 38 | 36 | |
| 39 | 37 | pub fn notice_redirect(href: &str, word: &str) -> SeeOther { |
| 40 | 38 | see_other(format!("{href}?notice={word}")) |
crates/forge-web-pages/src/pages/repo.rsmodified+1 -2
| @@ -64,7 +64,6 @@ pub async fn repo_head( | ||
| 64 | 64 | forks, |
| 65 | 65 | live, |
| 66 | 66 | mirror, |
| 67 | - wiki, | |
| 68 | 67 | lang, |
| 69 | 68 | clone, |
| 70 | 69 | .. |
| @@ -161,7 +160,7 @@ pub async fn repo_head( | ||
| 161 | 160 | (child) |
| 162 | 161 | </div> |
| 163 | 162 | head_sub(parts: parts, pips: pips, keep: true) |
| 164 | - repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), wiki: wiki) | |
| 163 | + repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls)) | |
| 165 | 164 | </section> |
| 166 | 165 | if archived { |
| 167 | 166 | <p class="state" role="status">(g::t(lang, K::ArchivedNotice))</p> |
crates/forge-web-pages/src/pages/repo_ctx.rsmodified+0 -3
| @@ -53,7 +53,6 @@ pub struct RepoHead { | ||
| 53 | 53 | pub forks: u64, |
| 54 | 54 | pub live: String, |
| 55 | 55 | pub mirror: Option<MirrorSource>, |
| 56 | - pub wiki: bool, | |
| 57 | 56 | pub clone: CloneLinks, |
| 58 | 57 | } |
| 59 | 58 | |
| @@ -164,7 +163,6 @@ impl RepoCtx { | ||
| 164 | 163 | None => None, |
| 165 | 164 | }; |
| 166 | 165 | let forks = fork_count(state, &self.repo.id).await?; |
| 167 | - let wiki = state.store.wiki_enabled(&self.repo.id).await?; | |
| 168 | 166 | let mirror = state |
| 169 | 167 | .store |
| 170 | 168 | .pull_mirror(&self.repo.id) |
| @@ -213,7 +211,6 @@ impl RepoCtx { | ||
| 213 | 211 | ), |
| 214 | 212 | )), |
| 215 | 213 | }, |
| 216 | - wiki, | |
| 217 | 214 | }) |
| 218 | 215 | } |
| 219 | 216 |
crates/forge-web-pages/src/pages/repo_settings.rsmodified+2 -39
| @@ -8,10 +8,7 @@ use forge_core::store::MAX_DESCRIPTION_CHARS; | ||
| 8 | 8 | use forge_core::{AuditAction, Repo as RepoRow, User, Visibility}; |
| 9 | 9 | use forge_git::browse::RefKind; |
| 10 | 10 | use forge_git::command::{GitCommand, GitEnv}; |
| 11 | -use forge_git::repo::{ | |
| 12 | - move_to_trash, move_wiki_to_trash, repo_dir_missing, restore_from_trash, | |
| 13 | - restore_wiki_from_trash, | |
| 14 | -}; | |
| 11 | +use forge_git::repo::{move_to_trash, repo_dir_missing, restore_from_trash}; | |
| 15 | 12 | use serde::Deserialize; |
| 16 | 13 | use topcoat::Result; |
| 17 | 14 | use topcoat::context::{Cx, context}; |
| @@ -32,7 +29,6 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; | ||
| 32 | 29 | use crate::pages::repo_rename::rename_section; |
| 33 | 30 | use crate::pages::repo_settings_live::settings_head; |
| 34 | 31 | use crate::pages::repo_transfer::{TransferStatus, transfer_section, transfer_status}; |
| 35 | -use crate::pages::wiki::wiki_switch; | |
| 36 | 32 | use crate::state::AppState; |
| 37 | 33 | use crate::views::parts::{RailItem, confirm_act, post_act, rail}; |
| 38 | 34 | use crate::views::{alert, enc, notice_line, shell}; |
| @@ -490,7 +486,6 @@ async fn general_section( | ||
| 490 | 486 | description: String, |
| 491 | 487 | default_branch: String, |
| 492 | 488 | branches: Vec<String>, |
| 493 | - wiki_on: bool, | |
| 494 | 489 | ) -> Result<impl View> { |
| 495 | 490 | let general_action = format!("/{title}/settings/general"); |
| 496 | 491 | let options: Vec<(String, bool)> = branches |
| @@ -523,11 +518,6 @@ async fn general_section( | ||
| 523 | 518 | <button type="submit" class="primary">(g::t(lang, K::SaveGeneral))</button> |
| 524 | 519 | </form> |
| 525 | 520 | </section> |
| 526 | - | |
| 527 | - <section class="sec"> | |
| 528 | - <h2>(g::t(lang, K::Features))</h2> | |
| 529 | - wiki_switch(action: format!("/{title}/settings/wiki"), csrf: csrf.clone(), enabled: wiki_on) | |
| 530 | - </section> | |
| 531 | 521 | }) |
| 532 | 522 | } |
| 533 | 523 | |
| @@ -850,7 +840,6 @@ struct SettingsView { | ||
| 850 | 840 | draft: RuleDraft, |
| 851 | 841 | danger: DangerForms, |
| 852 | 842 | transfer: TransferStatus, |
| 853 | - wiki_on: bool, | |
| 854 | 843 | contexts: Vec<String>, |
| 855 | 844 | } |
| 856 | 845 | |
| @@ -898,7 +887,6 @@ pub async fn render_settings( | ||
| 898 | 887 | draft: draft.unwrap_or_else(|| RuleDraft::for_default_branch(&ctx.repo.default_branch)), |
| 899 | 888 | danger, |
| 900 | 889 | transfer, |
| 901 | - wiki_on: state.store.wiki_enabled(&ctx.repo.id).await?, | |
| 902 | 890 | contexts: state.store.recent_status_contexts(&ctx.repo.id, 20).await?, |
| 903 | 891 | }; |
| 904 | 892 | let frame = SettingsFrame::new(&ctx, state, lang).await?; |
| @@ -937,7 +925,6 @@ async fn settings_body( | ||
| 937 | 925 | draft, |
| 938 | 926 | danger, |
| 939 | 927 | transfer, |
| 940 | - wiki_on, | |
| 941 | 928 | contexts, |
| 942 | 929 | } = page; |
| 943 | 930 | let mut draft = Some(draft); |
| @@ -980,8 +967,7 @@ async fn settings_body( | ||
| 980 | 967 | } |
| 981 | 968 | if section == "general" { |
| 982 | 969 | general_section(lang: lang, title: title.clone(), csrf: csrf.clone(), description: description, |
| 983 | - default_branch: default_branch.clone(), branches: branches, | |
| 984 | - wiki_on: wiki_on) | |
| 970 | + default_branch: default_branch.clone(), branches: branches) | |
| 985 | 971 | } |
| 986 | 972 | if section == "branches" { |
| 987 | 973 | <section class="sec"> |
| @@ -1244,18 +1230,6 @@ async fn settings_delete(cx: &Cx, Form(form): Form<DeleteForm>) -> Result<impl V | ||
| 1244 | 1230 | .map_err(forge_core::Error::from)?, |
| 1245 | 1231 | ) |
| 1246 | 1232 | }; |
| 1247 | - let wiki_trash = match move_wiki_to_trash(data_dir, &repo.id).await { | |
| 1248 | - Ok(path) => path, | |
| 1249 | - Err(e) => { | |
| 1250 | - if let Some(trash_path) = &trash_path | |
| 1251 | - && let Err(restore_err) = | |
| 1252 | - restore_from_trash(data_dir, trash_path, &repo.id).await | |
| 1253 | - { | |
| 1254 | - tracing::error!(error = %restore_err, repo_id = %repo.id, "could not restore the repo after a failed wiki move"); | |
| 1255 | - } | |
| 1256 | - return Err(forge_core::Error::from(e).into()); | |
| 1257 | - } | |
| 1258 | - }; | |
| 1259 | 1233 | let deleted = state.store.delete_repo(&repo.id).await; |
| 1260 | 1234 | state.live.bump_repo(&repo.owner_id, &repo.id); |
| 1261 | 1235 | if let Err(e) = deleted { |
| @@ -1269,17 +1243,6 @@ async fn settings_delete(cx: &Cx, Form(form): Form<DeleteForm>) -> Result<impl V | ||
| 1269 | 1243 | "failed to restore repo directory after a failed delete; move it back by hand" |
| 1270 | 1244 | ); |
| 1271 | 1245 | } |
| 1272 | - if let Some(wiki_path) = &wiki_trash | |
| 1273 | - && let Err(restore_err) = | |
| 1274 | - restore_wiki_from_trash(data_dir, wiki_path, &repo.id).await | |
| 1275 | - { | |
| 1276 | - tracing::error!( | |
| 1277 | - repo_id = %repo.id, | |
| 1278 | - trash_path = %wiki_path.display(), | |
| 1279 | - error = %restore_err, | |
| 1280 | - "failed to restore wiki after a failed delete; move it back by hand" | |
| 1281 | - ); | |
| 1282 | - } | |
| 1283 | 1246 | return Err(e.into()); |
| 1284 | 1247 | } |
| 1285 | 1248 | for asset_id in &release_assets { |
crates/forge-web-pages/src/pages/wiki.rsdeleted+0 -842
| @@ -1,842 +0,0 @@ | ||
| 1 | -use std::path::PathBuf; | |
| 2 | - | |
| 3 | -use forge_core::AuditAction; | |
| 4 | -use forge_core::time::stamp_from_unix; | |
| 5 | -use forge_git::repo::wiki_path; | |
| 6 | -use forge_git::wiki::{self, MAX_PAGE_BYTES, PageEdit, PageRevision, valid_page_name}; | |
| 7 | -use serde::Deserialize; | |
| 8 | -use topcoat::Result; | |
| 9 | -use topcoat::context::{Cx, context}; | |
| 10 | -use topcoat::router::content::Form; | |
| 11 | -use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; | |
| 12 | -use topcoat::router::{page, path_param, route}; | |
| 13 | -use topcoat::view::{Child, Unescaped, View, component, view}; | |
| 14 | - | |
| 15 | -use crate::audit::{self, Actor, Target}; | |
| 16 | -use crate::auth::{require_csrf, require_user}; | |
| 17 | -use crate::i18n::community::{self as g, K}; | |
| 18 | -use crate::i18n::{self, Lang}; | |
| 19 | -use crate::live::Topic; | |
| 20 | -use crate::live::bump_wiki; | |
| 21 | -use crate::pages::repo::repo_head; | |
| 22 | -use crate::pages::repo_ctx::{RepoCtx, load_repo}; | |
| 23 | -use crate::pages::wiki_live::{page_live_url, wiki_live_url}; | |
| 24 | -use crate::render::markdown::render_markdown; | |
| 25 | -use crate::state::AppState; | |
| 26 | -use crate::views::parts::{RailItem, rail}; | |
| 27 | -use crate::views::{alert, empty_state, rel_time, repo_href, shell}; | |
| 28 | - | |
| 29 | -path_param!(owner); | |
| 30 | -path_param!(repo); | |
| 31 | -path_param!(wiki_page); | |
| 32 | - | |
| 33 | -const MAX_SUMMARY_CHARS: usize = 200; | |
| 34 | - | |
| 35 | -#[derive(Deserialize)] | |
| 36 | -struct EditForm { | |
| 37 | - #[serde(default)] | |
| 38 | - csrf: String, | |
| 39 | - #[serde(default)] | |
| 40 | - base: String, | |
| 41 | - #[serde(default)] | |
| 42 | - name: String, | |
| 43 | - #[serde(default)] | |
| 44 | - content: String, | |
| 45 | - #[serde(default)] | |
| 46 | - message: String, | |
| 47 | -} | |
| 48 | - | |
| 49 | -async fn blocking<T, F>(f: F) -> Result<T> | |
| 50 | -where | |
| 51 | - F: FnOnce() -> forge_git::Result<T> + Send + 'static, | |
| 52 | - T: Send + 'static, | |
| 53 | -{ | |
| 54 | - Ok(tokio::task::spawn_blocking(f).await??) | |
| 55 | -} | |
| 56 | - | |
| 57 | -pub fn wiki_dir(state: &AppState, ctx: &RepoCtx) -> Result<PathBuf> { | |
| 58 | - Ok(wiki_path(&state.config.data_dir, &ctx.repo.id).map_err(forge_core::Error::from)?) | |
| 59 | -} | |
| 60 | - | |
| 61 | -pub async fn ensure_enabled(state: &AppState, ctx: &RepoCtx) -> Result<()> { | |
| 62 | - if state.store.wiki_enabled(&ctx.repo.id).await? { | |
| 63 | - Ok(()) | |
| 64 | - } else { | |
| 65 | - Err(not_found().into()) | |
| 66 | - } | |
| 67 | -} | |
| 68 | - | |
| 69 | -pub fn expand_wiki_links(src: &str, owner: &str, repo: &str) -> String { | |
| 70 | - let mut out = String::with_capacity(src.len()); | |
| 71 | - let mut rest = src; | |
| 72 | - while let Some(start) = rest.find("[[") { | |
| 73 | - out.push_str(&rest[..start]); | |
| 74 | - let after = &rest[start + 2..]; | |
| 75 | - let Some(end) = after.find("]]") else { | |
| 76 | - break; | |
| 77 | - }; | |
| 78 | - let inner = &after[..end]; | |
| 79 | - let (label, target) = match inner.split_once('|') { | |
| 80 | - Some((label, target)) => (label.trim(), target.trim()), | |
| 81 | - None => (inner.trim(), inner.trim()), | |
| 82 | - }; | |
| 83 | - let slug = target.replace(' ', "-"); | |
| 84 | - let plain = !label.contains(['[', ']']) && !label.is_empty(); | |
| 85 | - if plain && valid_page_name(&slug) { | |
| 86 | - let href = repo_href(owner, repo, "wiki", &slug); | |
| 87 | - out.push_str(&format!("[{label}]({href})")); | |
| 88 | - } else { | |
| 89 | - out.push_str(&rest[start..start + 2 + end + 2]); | |
| 90 | - } | |
| 91 | - rest = &after[end + 2..]; | |
| 92 | - } | |
| 93 | - out.push_str(rest); | |
| 94 | - out | |
| 95 | -} | |
| 96 | - | |
| 97 | -pub fn render_page(src: &str, owner: &str, repo: &str) -> String { | |
| 98 | - render_markdown(&expand_wiki_links(src, owner, repo), None) | |
| 99 | -} | |
| 100 | - | |
| 101 | -fn summary(raw: &str, page: &str) -> String { | |
| 102 | - let line = raw.lines().next().unwrap_or("").trim(); | |
| 103 | - if line.is_empty() { | |
| 104 | - return format!("Edit {page}"); | |
| 105 | - } | |
| 106 | - line.chars().take(MAX_SUMMARY_CHARS).collect() | |
| 107 | -} | |
| 108 | - | |
| 109 | -fn page_href(ctx: &RepoCtx, page: &str) -> String { | |
| 110 | - repo_href(&ctx.repo.owner_name, &ctx.repo.name, "wiki", page) | |
| 111 | -} | |
| 112 | - | |
| 113 | -pub struct RevisionRow { | |
| 114 | - pub short: String, | |
| 115 | - pub href: String, | |
| 116 | - pub author: String, | |
| 117 | - pub when: String, | |
| 118 | - pub subject: String, | |
| 119 | -} | |
| 120 | - | |
| 121 | -fn revision_rows(ctx: &RepoCtx, revs: &[PageRevision]) -> Vec<RevisionRow> { | |
| 122 | - revs.iter() | |
| 123 | - .map(|rev| RevisionRow { | |
| 124 | - short: rev.oid.chars().take(10).collect(), | |
| 125 | - href: repo_href(&ctx.repo.owner_name, &ctx.repo.name, "commit", &rev.oid), | |
| 126 | - author: rev.author.clone(), | |
| 127 | - when: stamp_from_unix(rev.at).unwrap_or_default(), | |
| 128 | - subject: rev.subject.clone(), | |
| 129 | - }) | |
| 130 | - .collect() | |
| 131 | -} | |
| 132 | - | |
| 133 | -fn wiki_links( | |
| 134 | - lang: Lang, | |
| 135 | - owner: &str, | |
| 136 | - repo: &str, | |
| 137 | - can_write: bool, | |
| 138 | - extra: Vec<(String, String)>, | |
| 139 | -) -> Vec<(String, String)> { | |
| 140 | - let mut links = vec![ | |
| 141 | - ( | |
| 142 | - g::t(lang, K::Home).to_owned(), | |
| 143 | - repo_href(owner, repo, "wiki", ""), | |
| 144 | - ), | |
| 145 | - ( | |
| 146 | - g::t(lang, K::AllPages).to_owned(), | |
| 147 | - repo_href(owner, repo, "wiki", "-/pages"), | |
| 148 | - ), | |
| 149 | - ]; | |
| 150 | - links.extend(extra); | |
| 151 | - if can_write { | |
| 152 | - links.push(( | |
| 153 | - g::t(lang, K::NewPage).to_owned(), | |
| 154 | - repo_href(owner, repo, "wiki", "-/new"), | |
| 155 | - )); | |
| 156 | - } | |
| 157 | - links | |
| 158 | -} | |
| 159 | - | |
| 160 | -#[component] | |
| 161 | -async fn wiki_rail( | |
| 162 | - cx: &Cx, | |
| 163 | - lang: Lang, | |
| 164 | - owner: String, | |
| 165 | - repo: String, | |
| 166 | - names: Vec<String>, | |
| 167 | - current: String, | |
| 168 | -) -> Result<impl View> { | |
| 169 | - let items: Vec<RailItem> = names | |
| 170 | - .into_iter() | |
| 171 | - .map(|name| RailItem { | |
| 172 | - href: repo_href(&owner, &repo, "wiki", &name), | |
| 173 | - current: name == current, | |
| 174 | - name: name.replace('-', " "), | |
| 175 | - val: String::new(), | |
| 176 | - }) | |
| 177 | - .collect(); | |
| 178 | - let has_pages = !items.is_empty(); | |
| 179 | - Ok(view! { | |
| 180 | - if has_pages { | |
| 181 | - rail(label: g::t(lang, K::PageNav), items: items) | |
| 182 | - } | |
| 183 | - }) | |
| 184 | -} | |
| 185 | - | |
| 186 | -#[component] | |
| 187 | -async fn wiki_sheet( | |
| 188 | - cx: &Cx, | |
| 189 | - #[default] title: Option<String>, | |
| 190 | - links: Vec<(String, String)>, | |
| 191 | - #[default] live: Option<String>, | |
| 192 | - #[default] child: Child<'_>, | |
| 193 | -) -> Result<impl View> { | |
| 194 | - Ok(view! { | |
| 195 | - <div class="sheet" data-live=(live.as_deref())> | |
| 196 | - <div class="sheet-tools"> | |
| 197 | - if let Some(title) = title { | |
| 198 | - <strong>(title.as_str())</strong> | |
| 199 | - } | |
| 200 | - for (label, href) in links.into_iter() { | |
| 201 | - <a class="act" href=(href)>(label)</a> | |
| 202 | - } | |
| 203 | - </div> | |
| 204 | - (child) | |
| 205 | - </div> | |
| 206 | - }) | |
| 207 | -} | |
| 208 | - | |
| 209 | -async fn page_names(dir: PathBuf) -> Result<Vec<String>> { | |
| 210 | - blocking(move || wiki::list_pages(&dir)).await | |
| 211 | -} | |
| 212 | - | |
| 213 | -fn page_links( | |
| 214 | - lang: Lang, | |
| 215 | - owner: &str, | |
| 216 | - repo: &str, | |
| 217 | - name: &str, | |
| 218 | - can_write: bool, | |
| 219 | -) -> Vec<(String, String)> { | |
| 220 | - let mut links = Vec::new(); | |
| 221 | - if can_write { | |
| 222 | - links.push(( | |
| 223 | - g::t(lang, K::Edit).to_owned(), | |
| 224 | - repo_href(owner, repo, "wiki", &format!("{name}/edit")), | |
| 225 | - )); | |
| 226 | - } | |
| 227 | - links.push(( | |
| 228 | - g::t(lang, K::History).to_owned(), | |
| 229 | - repo_href(owner, repo, "wiki", &format!("{name}/history")), | |
| 230 | - )); | |
| 231 | - links | |
| 232 | -} | |
| 233 | - | |
| 234 | -#[component] | |
| 235 | -async fn wiki_view_body(cx: &Cx, html: String) -> Result<impl View> { | |
| 236 | - Ok(view! { | |
| 237 | - <section class="sec wiki-page"> | |
| 238 | - <div class="markdown-body">(Unescaped::new_unchecked(html))</div> | |
| 239 | - </section> | |
| 240 | - }) | |
| 241 | -} | |
| 242 | - | |
| 243 | -#[component] | |
| 244 | -async fn wiki_empty_body( | |
| 245 | - cx: &Cx, | |
| 246 | - lang: Lang, | |
| 247 | - owner: String, | |
| 248 | - repo: String, | |
| 249 | - can_write: bool, | |
| 250 | -) -> Result<impl View> { | |
| 251 | - let new = repo_href(&owner, &repo, "wiki", "-/new"); | |
| 252 | - Ok(view! { | |
| 253 | - empty_state(title: g::t(lang, K::WikiNoPages), | |
| 254 | - if can_write { | |
| 255 | - <a class="act" href=(new.as_str())>(g::t(lang, K::CreateFirstPage))</a> | |
| 256 | - } | |
| 257 | - ) | |
| 258 | - }) | |
| 259 | -} | |
| 260 | - | |
| 261 | -#[component] | |
| 262 | -async fn wiki_list_body( | |
| 263 | - cx: &Cx, | |
| 264 | - lang: Lang, | |
| 265 | - owner: String, | |
| 266 | - repo: String, | |
| 267 | - names: Vec<String>, | |
| 268 | -) -> Result<impl View> { | |
| 269 | - let rows: Vec<(String, String)> = names | |
| 270 | - .into_iter() | |
| 271 | - .map(|name| { | |
| 272 | - let href = repo_href(&owner, &repo, "wiki", &name); | |
| 273 | - (name.replace('-', " "), href) | |
| 274 | - }) | |
| 275 | - .collect(); | |
| 276 | - Ok(view! { | |
| 277 | - if rows.is_empty() { | |
| 278 | - empty_state(title: g::t(lang, K::NoPagesYet)) | |
| 279 | - } else { | |
| 280 | - for (title, href) in rows.into_iter() { | |
| 281 | - <a class="line" href=(href) data-kb-row=""> | |
| 282 | - <span class="name">(title.as_str())</span> | |
| 283 | - </a> | |
| 284 | - } | |
| 285 | - } | |
| 286 | - }) | |
| 287 | -} | |
| 288 | - | |
| 289 | -#[component] | |
| 290 | -async fn wiki_history_body(cx: &Cx, lang: Lang, rows: Vec<RevisionRow>) -> Result<impl View> { | |
| 291 | - Ok(view! { | |
| 292 | - if rows.is_empty() { | |
| 293 | - empty_state(title: g::t(lang, K::NoChangesYet)) | |
| 294 | - } else { | |
| 295 | - for row in rows.into_iter() { | |
| 296 | - <a class="line" href=(row.href) data-kb-row=""> | |
| 297 | - <span class="name">(row.subject.as_str())</span> | |
| 298 | - <span class="val"><code>(row.short.as_str())</code> " · " (row.author.as_str()) " · " rel_time(lang: lang, stamp: row.when.as_str())</span> | |
| 299 | - </a> | |
| 300 | - } | |
| 301 | - } | |
| 302 | - }) | |
| 303 | -} | |
| 304 | - | |
| 305 | -#[component] | |
| 306 | -async fn wiki_edit_body( | |
| 307 | - cx: &Cx, | |
| 308 | - lang: Lang, | |
| 309 | - action: String, | |
| 310 | - csrf: String, | |
| 311 | - base: String, | |
| 312 | - name: String, | |
| 313 | - is_new: bool, | |
| 314 | - content: String, | |
| 315 | - error: Option<String>, | |
| 316 | -) -> Result<impl View> { | |
| 317 | - Ok(view! { | |
| 318 | - <section class="sec wiki-page"> | |
| 319 | - <form method="post" action=(action.as_str()) class="fields wiki-form"> | |
| 320 | - if let Some(message) = error { | |
| 321 | - alert(message: message.as_str()) | |
| 322 | - } | |
| 323 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 324 | - <input type="hidden" name="base" value=(base.as_str())> | |
| 325 | - if is_new { | |
| 326 | - <div class="field"> | |
| 327 | - <label for="wiki-name">(g::t(lang, K::PageName))</label> | |
| 328 | - <input id="wiki-name" type="text" name="name" value=(name.as_str()) maxlength="100" required=(true) pattern="[A-Za-z0-9_-]+"> | |
| 329 | - </div> | |
| 330 | - } | |
| 331 | - <div class="field"> | |
| 332 | - <label for="wiki-content">(g::t(lang, K::ContentMarkdown))</label> | |
| 333 | - <textarea id="wiki-content" name="content" rows="24" spellcheck="false">(content.as_str())</textarea> | |
| 334 | - </div> | |
| 335 | - <div class="field"> | |
| 336 | - <label for="wiki-message">(g::t(lang, K::Summary))</label> | |
| 337 | - <input id="wiki-message" type="text" name="message" maxlength="200" autocomplete="off"> | |
| 338 | - </div> | |
| 339 | - <button type="submit" class="primary">(g::t(lang, K::SavePage))</button> | |
| 340 | - </form> | |
| 341 | - </section> | |
| 342 | - }) | |
| 343 | -} | |
| 344 | - | |
| 345 | -#[page("/{owner}/{repo}/wiki")] | |
| 346 | -async fn wiki_home(cx: &Cx) -> Result<impl View> { | |
| 347 | - let owner = owner(cx); | |
| 348 | - let name = repo(cx); | |
| 349 | - let ctx = load_repo(cx, owner, name).await?; | |
| 350 | - let state = context::<AppState>(cx); | |
| 351 | - ensure_enabled(state, &ctx).await?; | |
| 352 | - let dir = wiki_dir(state, &ctx)?; | |
| 353 | - let names = page_names(dir.clone()).await?; | |
| 354 | - let home = blocking(move || wiki::read_page(&dir, "Home")).await?; | |
| 355 | - let can_write = ctx.can_write(); | |
| 356 | - let owner_name = ctx.repo.owner_name.clone(); | |
| 357 | - let repo_name = ctx.repo.name.clone(); | |
| 358 | - let body_html = home.map(|src| render_page(&src, &owner_name, &repo_name)); | |
| 359 | - let lang = i18n::lang(cx, ctx.viewer_user()); | |
| 360 | - let title = format!( | |
| 361 | - "{}/{} \u{b7} {}", | |
| 362 | - ctx.repo.owner_name, | |
| 363 | - ctx.repo.name, | |
| 364 | - g::t(lang, K::Wiki) | |
| 365 | - ); | |
| 366 | - let live = wiki_live_url(&owner_name, &repo_name); | |
| 367 | - let (head_title, sheet_title, extra) = if body_html.is_some() { | |
| 368 | - ( | |
| 369 | - Some(g::t(lang, K::Home).to_owned()), | |
| 370 | - None, | |
| 371 | - page_links(lang, &owner_name, &repo_name, "Home", can_write), | |
| 372 | - ) | |
| 373 | - } else { | |
| 374 | - (None, Some(g::t(lang, K::Wiki).to_owned()), Vec::new()) | |
| 375 | - }; | |
| 376 | - let links = wiki_links(lang, &owner_name, &repo_name, can_write, extra); | |
| 377 | - let header = ctx.head(state, "wiki").await?; | |
| 378 | - Ok(view! { | |
| 379 | - shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | |
| 380 | - repo_head(head: header, title: head_title) | |
| 381 | - <div class="work"> | |
| 382 | - wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: "Home".to_owned()) | |
| 383 | - wiki_sheet(title: sheet_title, links: links, live: Some(live), | |
| 384 | - if let Some(html) = body_html.clone() { | |
| 385 | - wiki_view_body(html: html) | |
| 386 | - } | |
| 387 | - if body_html.is_none() { | |
| 388 | - wiki_empty_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), can_write: can_write) | |
| 389 | - } | |
| 390 | - ) | |
| 391 | - </div> | |
| 392 | - ) | |
| 393 | - }) | |
| 394 | -} | |
| 395 | - | |
| 396 | -#[page("/{owner}/{repo}/wiki/-/pages")] | |
| 397 | -async fn wiki_pages(cx: &Cx) -> Result<impl View> { | |
| 398 | - let owner = owner(cx); | |
| 399 | - let name = repo(cx); | |
| 400 | - let ctx = load_repo(cx, owner, name).await?; | |
| 401 | - let state = context::<AppState>(cx); | |
| 402 | - ensure_enabled(state, &ctx).await?; | |
| 403 | - let lang = i18n::lang(cx, ctx.viewer_user()); | |
| 404 | - let dir = wiki_dir(state, &ctx)?; | |
| 405 | - let names = page_names(dir).await?; | |
| 406 | - let can_write = ctx.can_write(); | |
| 407 | - let owner_name = ctx.repo.owner_name.clone(); | |
| 408 | - let repo_name = ctx.repo.name.clone(); | |
| 409 | - let title = format!( | |
| 410 | - "{}/{} \u{b7} {}", | |
| 411 | - ctx.repo.owner_name, | |
| 412 | - ctx.repo.name, | |
| 413 | - g::t(lang, K::WikiPages) | |
| 414 | - ); | |
| 415 | - let links = wiki_links(lang, &owner_name, &repo_name, can_write, Vec::new()); | |
| 416 | - let header = ctx.head(state, "wiki").await?; | |
| 417 | - Ok(view! { | |
| 418 | - shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | |
| 419 | - repo_head(head: header, title: Some(g::t(lang, K::AllPages).to_owned())) | |
| 420 | - wiki_sheet(links: links, live: Some(wiki_live_url(&owner_name, &repo_name)), | |
| 421 | - wiki_list_body(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names) | |
| 422 | - ) | |
| 423 | - ) | |
| 424 | - }) | |
| 425 | -} | |
| 426 | - | |
| 427 | -#[page("/{owner}/{repo}/wiki/{wiki_page}")] | |
| 428 | -async fn wiki_page_view(cx: &Cx) -> Result<impl View> { | |
| 429 | - let owner = owner(cx); | |
| 430 | - let repo_param = repo(cx); | |
| 431 | - let page_name = wiki_page(cx).to_owned(); | |
| 432 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 433 | - let state = context::<AppState>(cx); | |
| 434 | - ensure_enabled(state, &ctx).await?; | |
| 435 | - if !valid_page_name(&page_name) { | |
| 436 | - return Err(not_found().into()); | |
| 437 | - } | |
| 438 | - let dir = wiki_dir(state, &ctx)?; | |
| 439 | - let names = page_names(dir.clone()).await?; | |
| 440 | - let name = page_name.clone(); | |
| 441 | - let text = blocking(move || wiki::read_page(&dir, &name)).await?; | |
| 442 | - let Some(text) = text else { | |
| 443 | - return Err(not_found().into()); | |
| 444 | - }; | |
| 445 | - let owner_name = ctx.repo.owner_name.clone(); | |
| 446 | - let repo_name = ctx.repo.name.clone(); | |
| 447 | - let html = render_page(&text, &owner_name, &repo_name); | |
| 448 | - let can_write = ctx.can_write(); | |
| 449 | - let lang = i18n::lang(cx, ctx.viewer_user()); | |
| 450 | - let title = format!( | |
| 451 | - "{} \u{b7} {}/{} wiki", | |
| 452 | - page_name.replace('-', " "), | |
| 453 | - ctx.repo.owner_name, | |
| 454 | - ctx.repo.name | |
| 455 | - ); | |
| 456 | - let links = wiki_links( | |
| 457 | - lang, | |
| 458 | - &owner_name, | |
| 459 | - &repo_name, | |
| 460 | - can_write, | |
| 461 | - page_links(lang, &owner_name, &repo_name, &page_name, can_write), | |
| 462 | - ); | |
| 463 | - let header = ctx.head(state, "wiki").await?; | |
| 464 | - Ok(view! { | |
| 465 | - shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | |
| 466 | - repo_head(head: header, title: Some(page_name.replace('-', " "))) | |
| 467 | - <div class="work"> | |
| 468 | - wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: page_name.clone()) | |
| 469 | - wiki_sheet(links: links, live: Some(page_live_url(&owner_name, &repo_name, &page_name)), | |
| 470 | - wiki_view_body(html: html) | |
| 471 | - ) | |
| 472 | - </div> | |
| 473 | - ) | |
| 474 | - }) | |
| 475 | -} | |
| 476 | - | |
| 477 | -#[page("/{owner}/{repo}/wiki/{wiki_page}/history")] | |
| 478 | -async fn wiki_page_history(cx: &Cx) -> Result<impl View> { | |
| 479 | - let owner = owner(cx); | |
| 480 | - let repo_param = repo(cx); | |
| 481 | - let page_name = wiki_page(cx).to_owned(); | |
| 482 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 483 | - let state = context::<AppState>(cx); | |
| 484 | - ensure_enabled(state, &ctx).await?; | |
| 485 | - if !valid_page_name(&page_name) { | |
| 486 | - return Err(not_found().into()); | |
| 487 | - } | |
| 488 | - let dir = wiki_dir(state, &ctx)?; | |
| 489 | - let names = page_names(dir.clone()).await?; | |
| 490 | - let git = state.git.clone(); | |
| 491 | - let revs = wiki::page_history(&git, &dir, &page_name).await?; | |
| 492 | - let rows = revision_rows(&ctx, &revs); | |
| 493 | - let owner_name = ctx.repo.owner_name.clone(); | |
| 494 | - let repo_name = ctx.repo.name.clone(); | |
| 495 | - let lang = i18n::lang(cx, ctx.viewer_user()); | |
| 496 | - let title = format!( | |
| 497 | - "{} \u{b7} {}/{} wiki", | |
| 498 | - g::t(lang, K::History), | |
| 499 | - ctx.repo.owner_name, | |
| 500 | - ctx.repo.name | |
| 501 | - ); | |
| 502 | - let can_write = ctx.can_write(); | |
| 503 | - let links = wiki_links( | |
| 504 | - lang, | |
| 505 | - &owner_name, | |
| 506 | - &repo_name, | |
| 507 | - can_write, | |
| 508 | - vec![( | |
| 509 | - g::t(lang, K::BackToPage).to_owned(), | |
| 510 | - repo_href(&owner_name, &repo_name, "wiki", &page_name), | |
| 511 | - )], | |
| 512 | - ); | |
| 513 | - let header = ctx.head(state, "wiki").await?; | |
| 514 | - Ok(view! { | |
| 515 | - shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | |
| 516 | - repo_head(head: header, title: Some(format!("{} \u{b7} {}", page_name.replace('-', " "), g::t(lang, K::History)))) | |
| 517 | - <div class="work"> | |
| 518 | - wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: page_name.clone()) | |
| 519 | - wiki_sheet(links: links, live: Some(page_live_url(&owner_name, &repo_name, &page_name)), | |
| 520 | - wiki_history_body(lang: lang, rows: rows) | |
| 521 | - ) | |
| 522 | - </div> | |
| 523 | - ) | |
| 524 | - }) | |
| 525 | -} | |
| 526 | - | |
| 527 | -async fn edit_screen( | |
| 528 | - cx: &Cx, | |
| 529 | - ctx: RepoCtx, | |
| 530 | - name: String, | |
| 531 | - is_new: bool, | |
| 532 | - content: String, | |
| 533 | - error: Option<String>, | |
| 534 | -) -> Result<impl View> { | |
| 535 | - let state = context::<AppState>(cx); | |
| 536 | - let (user, session) = require_user(cx).await?; | |
| 537 | - let lang = i18n::lang(cx, Some(&user)); | |
| 538 | - let dir = wiki_dir(state, &ctx)?; | |
| 539 | - let names = page_names(dir.clone()).await?; | |
| 540 | - let head = blocking(move || wiki::head_commit(&dir)).await?; | |
| 541 | - let action = if is_new { | |
| 542 | - repo_href(&ctx.repo.owner_name, &ctx.repo.name, "wiki", "-/new") | |
| 543 | - } else { | |
| 544 | - repo_href( | |
| 545 | - &ctx.repo.owner_name, | |
| 546 | - &ctx.repo.name, | |
| 547 | - "wiki", | |
| 548 | - &format!("{name}/edit"), | |
| 549 | - ) | |
| 550 | - }; | |
| 551 | - let title = format!( | |
| 552 | - "{} \u{b7} {}/{} wiki", | |
| 553 | - g::t(lang, K::Edit), | |
| 554 | - ctx.repo.owner_name, | |
| 555 | - ctx.repo.name | |
| 556 | - ); | |
| 557 | - let header = ctx.head(state, "wiki").await?; | |
| 558 | - let owner_name = ctx.repo.owner_name.clone(); | |
| 559 | - let repo_name = ctx.repo.name.clone(); | |
| 560 | - let csrf = session.csrf_token.clone(); | |
| 561 | - let base = head.unwrap_or_default(); | |
| 562 | - let head_title = if is_new { | |
| 563 | - g::t(lang, K::NewPage).to_owned() | |
| 564 | - } else { | |
| 565 | - name.replace('-', " ") | |
| 566 | - }; | |
| 567 | - let back_links = if is_new { | |
| 568 | - Vec::new() | |
| 569 | - } else { | |
| 570 | - vec![( | |
| 571 | - g::t(lang, K::BackToPage).to_owned(), | |
| 572 | - repo_href(&owner_name, &repo_name, "wiki", &name), | |
| 573 | - )] | |
| 574 | - }; | |
| 575 | - let links = wiki_links(lang, &owner_name, &repo_name, !is_new, back_links); | |
| 576 | - Ok(view! { | |
| 577 | - shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), | |
| 578 | - repo_head(head: header, title: Some(head_title)) | |
| 579 | - <div class="work"> | |
| 580 | - wiki_rail(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), names: names, current: name.clone()) | |
| 581 | - wiki_sheet(links: links, | |
| 582 | - wiki_edit_body(lang: lang, action: action, csrf: csrf, base: base, name: name.clone(), is_new: is_new, content: content, error: error) | |
| 583 | - ) | |
| 584 | - </div> | |
| 585 | - ) | |
| 586 | - }) | |
| 587 | -} | |
| 588 | - | |
| 589 | -#[page("/{owner}/{repo}/wiki/-/new")] | |
| 590 | -async fn wiki_new_page(cx: &Cx) -> Result<impl View> { | |
| 591 | - let owner = owner(cx); | |
| 592 | - let repo_param = repo(cx); | |
| 593 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 594 | - let state = context::<AppState>(cx); | |
| 595 | - ensure_enabled(state, &ctx).await?; | |
| 596 | - if !ctx.can_write() { | |
| 597 | - return Err(forbidden().into()); | |
| 598 | - } | |
| 599 | - edit_screen(cx, ctx, String::new(), true, String::new(), None).await | |
| 600 | -} | |
| 601 | - | |
| 602 | -#[page("/{owner}/{repo}/wiki/{wiki_page}/edit")] | |
| 603 | -async fn wiki_edit_page(cx: &Cx) -> Result<impl View> { | |
| 604 | - let owner = owner(cx); | |
| 605 | - let repo_param = repo(cx); | |
| 606 | - let page_name = wiki_page(cx).to_owned(); | |
| 607 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 608 | - let state = context::<AppState>(cx); | |
| 609 | - ensure_enabled(state, &ctx).await?; | |
| 610 | - if !ctx.can_write() { | |
| 611 | - return Err(forbidden().into()); | |
| 612 | - } | |
| 613 | - if !valid_page_name(&page_name) { | |
| 614 | - return Err(not_found().into()); | |
| 615 | - } | |
| 616 | - let dir = wiki_dir(state, &ctx)?; | |
| 617 | - let name = page_name.clone(); | |
| 618 | - let text = blocking(move || wiki::read_page(&dir, &name)).await?; | |
| 619 | - edit_screen(cx, ctx, page_name, false, text.unwrap_or_default(), None).await | |
| 620 | -} | |
| 621 | - | |
| 622 | -#[page(POST "/{owner}/{repo}/wiki/-/new")] | |
| 623 | -async fn wiki_new_post(cx: &Cx, Form(form): Form<EditForm>) -> Result<impl View> { | |
| 624 | - let owner = owner(cx); | |
| 625 | - let repo_param = repo(cx); | |
| 626 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 627 | - let state = context::<AppState>(cx); | |
| 628 | - ensure_enabled(state, &ctx).await?; | |
| 629 | - if !ctx.can_write() { | |
| 630 | - return Err(forbidden().into()); | |
| 631 | - } | |
| 632 | - let (viewer, _) = require_csrf(cx, &form.csrf).await?; | |
| 633 | - let lang = i18n::lang(cx, Some(&viewer)); | |
| 634 | - let name = form.name.trim().to_owned(); | |
| 635 | - let refused = if !valid_page_name(&name) { | |
| 636 | - Some(g::t(lang, K::PageNameRules).to_owned()) | |
| 637 | - } else { | |
| 638 | - let dir = wiki_dir(state, &ctx)?; | |
| 639 | - let check = name.clone(); | |
| 640 | - let existing = blocking(move || wiki::read_page(&dir, &check)).await?; | |
| 641 | - if existing.is_some() { | |
| 642 | - Some(g::t(lang, K::PageExists).to_owned()) | |
| 643 | - } else { | |
| 644 | - None | |
| 645 | - } | |
| 646 | - }; | |
| 647 | - let refused = match refused { | |
| 648 | - Some(message) => Some(message), | |
| 649 | - None => match save(cx, &ctx, &form, &name).await? { | |
| 650 | - SaveOutcome::Saved(href) => return Err(see_other(href).into()), | |
| 651 | - SaveOutcome::Refused(message) => Some(message), | |
| 652 | - }, | |
| 653 | - }; | |
| 654 | - edit_screen(cx, ctx, name, true, form.content.clone(), refused).await | |
| 655 | -} | |
| 656 | - | |
| 657 | -#[page(POST "/{owner}/{repo}/wiki/{wiki_page}/edit")] | |
| 658 | -async fn wiki_edit_post(cx: &Cx, Form(form): Form<EditForm>) -> Result<impl View> { | |
| 659 | - let owner = owner(cx); | |
| 660 | - let repo_param = repo(cx); | |
| 661 | - let page_name = wiki_page(cx).to_owned(); | |
| 662 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 663 | - let state = context::<AppState>(cx); | |
| 664 | - ensure_enabled(state, &ctx).await?; | |
| 665 | - if !ctx.can_write() { | |
| 666 | - return Err(forbidden().into()); | |
| 667 | - } | |
| 668 | - require_csrf(cx, &form.csrf).await?; | |
| 669 | - if !valid_page_name(&page_name) { | |
| 670 | - return Err(not_found().into()); | |
| 671 | - } | |
| 672 | - let refused = match save(cx, &ctx, &form, &page_name).await? { | |
| 673 | - SaveOutcome::Saved(href) => return Err(see_other(href).into()), | |
| 674 | - SaveOutcome::Refused(message) => Some(message), | |
| 675 | - }; | |
| 676 | - edit_screen(cx, ctx, page_name, false, form.content.clone(), refused).await | |
| 677 | -} | |
| 678 | - | |
| 679 | -enum SaveOutcome { | |
| 680 | - Saved(String), | |
| 681 | - Refused(String), | |
| 682 | -} | |
| 683 | - | |
| 684 | -async fn save(cx: &Cx, ctx: &RepoCtx, form: &EditForm, name: &str) -> Result<SaveOutcome> { | |
| 685 | - let state = context::<AppState>(cx); | |
| 686 | - let (user, _) = require_user(cx).await?; | |
| 687 | - let lang = i18n::lang(cx, Some(&user)); | |
| 688 | - if form.content.len() > MAX_PAGE_BYTES { | |
| 689 | - return Ok(SaveOutcome::Refused(g::page_too_large( | |
| 690 | - lang, | |
| 691 | - MAX_PAGE_BYTES, | |
| 692 | - ))); | |
| 693 | - } | |
| 694 | - let dir = wiki_dir(state, ctx)?; | |
| 695 | - let base = form.base.trim(); | |
| 696 | - let base = (!base.is_empty()).then_some(base.to_owned()); | |
| 697 | - let message = summary(&form.message, name); | |
| 698 | - let author_email = user | |
| 699 | ||
| 700 | - .clone() | |
| 701 | - .unwrap_or_else(|| format!("{}@users.noreply.forge", user.username)); | |
| 702 | - let edit = PageEdit { | |
| 703 | - name, | |
| 704 | - content: form.content.as_bytes(), | |
| 705 | - message: &message, | |
| 706 | - author_name: &user.username, | |
| 707 | - author_email: &author_email, | |
| 708 | - }; | |
| 709 | - let git = state.git.clone(); | |
| 710 | - let commit = match wiki::commit_page(&git, &dir, base.as_deref(), &edit).await { | |
| 711 | - Ok(commit) => commit, | |
| 712 | - Err(forge_git::Error::RefMoved(_)) => { | |
| 713 | - return Ok(SaveOutcome::Refused(g::t(lang, K::WikiConflict).to_owned())); | |
| 714 | - } | |
| 715 | - Err(forge_git::Error::InvalidInput(msg)) => return Ok(SaveOutcome::Refused(msg)), | |
| 716 | - Err(e) => return Err(forge_core::Error::from(e).into()), | |
| 717 | - }; | |
| 718 | - audit::record( | |
| 719 | - &state.store, | |
| 720 | - Some(cx), | |
| 721 | - Actor::User(&user), | |
| 722 | - AuditAction::WikiPageSaved, | |
| 723 | - Target { | |
| 724 | - kind: "repo", | |
| 725 | - id: &ctx.repo.id, | |
| 726 | - name: &ctx.title(), | |
| 727 | - }, | |
| 728 | - serde_json::json!({ "page": name, "commit": commit }), | |
| 729 | - ) | |
| 730 | - .await; | |
| 731 | - bump_wiki(state, &ctx.repo.id); | |
| 732 | - crate::replication::enqueue_repo(state, &ctx.repo.id); | |
| 733 | - tracing::info!(actor_id = %user.id, repo_id = %ctx.repo.id, page = %name, "wiki page saved"); | |
| 734 | - Ok(SaveOutcome::Saved(page_href(ctx, name))) | |
| 735 | -} | |
| 736 | - | |
| 737 | -#[component] | |
| 738 | -pub async fn wiki_switch( | |
| 739 | - cx: &Cx, | |
| 740 | - action: String, | |
| 741 | - csrf: String, | |
| 742 | - enabled: bool, | |
| 743 | -) -> Result<impl View> { | |
| 744 | - Ok(view! { | |
| 745 | - <form method="post" action=(action.as_str()) id="wiki"> | |
| 746 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | |
| 747 | - <label class="switch"> | |
| 748 | - <input type="checkbox" name="enabled" value="1" checked=(enabled) data-autosubmit="true"> | |
| 749 | - <span>"Wiki"</span> | |
| 750 | - </label> | |
| 751 | - </form> | |
| 752 | - }) | |
| 753 | -} | |
| 754 | - | |
| 755 | -#[route(GET "/{owner}/{repo}/settings/wiki")] | |
| 756 | -async fn wiki_settings_page(cx: &Cx) -> Result<SeeOther> { | |
| 757 | - let owner = owner(cx); | |
| 758 | - let repo_param = repo(cx); | |
| 759 | - Ok(see_other(repo_href(owner, repo_param, "settings", ""))) | |
| 760 | -} | |
| 761 | - | |
| 762 | -#[derive(Deserialize)] | |
| 763 | -struct WikiSettingsForm { | |
| 764 | - #[serde(default)] | |
| 765 | - csrf: String, | |
| 766 | - #[serde(default)] | |
| 767 | - enabled: Option<String>, | |
| 768 | -} | |
| 769 | - | |
| 770 | -#[route(POST "/{owner}/{repo}/settings/wiki")] | |
| 771 | -async fn wiki_settings_post(cx: &Cx, Form(form): Form<WikiSettingsForm>) -> Result<SeeOther> { | |
| 772 | - let owner = owner(cx); | |
| 773 | - let repo_param = repo(cx); | |
| 774 | - let ctx = load_repo(cx, owner, repo_param).await?; | |
| 775 | - let (user, _) = require_csrf(cx, &form.csrf).await?; | |
| 776 | - if !ctx.can_admin() { | |
| 777 | - return Err(forbidden().into()); | |
| 778 | - } | |
| 779 | - let state = context::<AppState>(cx); | |
| 780 | - let enable = form.enabled.is_some(); | |
| 781 | - let before = state.store.wiki_enabled(&ctx.repo.id).await?; | |
| 782 | - state.store.set_wiki_enabled(&ctx.repo.id, enable).await?; | |
| 783 | - state.live.bump(&Topic::Repo(ctx.repo.id.clone())); | |
| 784 | - if before != enable { | |
| 785 | - let action = if enable { | |
| 786 | - AuditAction::WikiEnabled | |
| 787 | - } else { | |
| 788 | - AuditAction::WikiDisabled | |
| 789 | - }; | |
| 790 | - audit::record( | |
| 791 | - &state.store, | |
| 792 | - Some(cx), | |
| 793 | - Actor::User(&user), | |
| 794 | - action, | |
| 795 | - Target { | |
| 796 | - kind: "repo", | |
| 797 | - id: &ctx.repo.id, | |
| 798 | - name: &ctx.title(), | |
| 799 | - }, | |
| 800 | - serde_json::json!({ "enabled": enable }), | |
| 801 | - ) | |
| 802 | - .await; | |
| 803 | - } | |
| 804 | - Ok(see_other(repo_href( | |
| 805 | - &ctx.repo.owner_name, | |
| 806 | - &ctx.repo.name, | |
| 807 | - "settings", | |
| 808 | - "", | |
| 809 | - ))) | |
| 810 | -} | |
| 811 | - | |
| 812 | -#[cfg(test)] | |
| 813 | -mod tests { | |
| 814 | - use super::*; | |
| 815 | - | |
| 816 | - #[test] | |
| 817 | - fn wiki_links_resolve_and_invalid_targets_stay_text() { | |
| 818 | - let out = expand_wiki_links( | |
| 819 | - "See [[Home]] and [[Getting Started|Start]].", | |
| 820 | - "tahinli", | |
| 821 | - "proj", | |
| 822 | - ); | |
| 823 | - assert!(out.contains("[Home](/tahinli/proj/wiki/Home)"), "{out}"); | |
| 824 | - assert!( | |
| 825 | - out.contains("[Getting Started](/tahinli/proj/wiki/Start)"), | |
| 826 | - "{out}" | |
| 827 | - ); | |
| 828 | - let spaced = expand_wiki_links("[[Getting Started]]", "tahinli", "proj"); | |
| 829 | - assert_eq!( | |
| 830 | - spaced, | |
| 831 | - "[Getting Started](/tahinli/proj/wiki/Getting-Started)" | |
| 832 | - ); | |
| 833 | - let bad = expand_wiki_links("[[../etc]] and [[]]", "tahinli", "proj"); | |
| 834 | - assert_eq!(bad, "[[../etc]] and [[]]"); | |
| 835 | - } | |
| 836 | - | |
| 837 | - #[test] | |
| 838 | - fn summary_defaults_and_is_one_line() { | |
| 839 | - assert_eq!(summary(" ", "Home"), "Edit Home"); | |
| 840 | - assert_eq!(summary("first\nsecond", "Home"), "first"); | |
| 841 | - } | |
| 842 | -} |
crates/forge-web-pages/src/pages/wiki_live.rsdeleted+0 -76
| @@ -1,76 +0,0 @@ | ||
| 1 | -use std::path::{Path, PathBuf}; | |
| 2 | - | |
| 3 | -use forge_git::GitEnv; | |
| 4 | -use forge_git::wiki::{self, valid_page_name}; | |
| 5 | -use topcoat::Result; | |
| 6 | -use topcoat::context::{Cx, context}; | |
| 7 | -use topcoat::router::error::not_found; | |
| 8 | -use topcoat::router::response::Response; | |
| 9 | -use topcoat::router::{path_param, route}; | |
| 10 | - | |
| 11 | -use crate::live::{Topic, stream_changes}; | |
| 12 | -use crate::pages::repo_ctx::load_repo; | |
| 13 | -use crate::pages::wiki::{ensure_enabled, wiki_dir}; | |
| 14 | -use crate::state::AppState; | |
| 15 | - | |
| 16 | -path_param!(owner); | |
| 17 | -path_param!(repo); | |
| 18 | -path_param!(wiki_page); | |
| 19 | - | |
| 20 | -pub fn wiki_live_url(owner: &str, repo: &str) -> String { | |
| 21 | - format!("/{owner}/{repo}/wiki/-/events") | |
| 22 | -} | |
| 23 | - | |
| 24 | -pub fn page_live_url(owner: &str, repo: &str, page: &str) -> String { | |
| 25 | - format!("/{owner}/{repo}/wiki/{page}/events") | |
| 26 | -} | |
| 27 | - | |
| 28 | -async fn head_fingerprint(dir: PathBuf) -> Result<String> { | |
| 29 | - let head = tokio::task::spawn_blocking(move || wiki::head_commit(&dir)).await??; | |
| 30 | - Ok(head.unwrap_or_default()) | |
| 31 | -} | |
| 32 | - | |
| 33 | -async fn page_fingerprint(git: &GitEnv, dir: &Path, name: &str) -> Result<String> { | |
| 34 | - let revs = wiki::page_history(git, dir, name).await?; | |
| 35 | - let (dir, name) = (dir.to_path_buf(), name.to_owned()); | |
| 36 | - let text = tokio::task::spawn_blocking(move || wiki::read_page(&dir, &name)).await??; | |
| 37 | - let commits: Vec<&str> = revs.iter().map(|rev| rev.oid.as_str()).collect(); | |
| 38 | - Ok(match text { | |
| 39 | - Some(text) => format!("{text}\n{}", commits.join(" ")), | |
| 40 | - None => "gone".to_owned(), | |
| 41 | - }) | |
| 42 | -} | |
| 43 | - | |
| 44 | -#[route(GET "/{owner}/{repo}/wiki/-/events")] | |
| 45 | -async fn wiki_events(cx: &Cx) -> Result<Response> { | |
| 46 | - let ctx = load_repo(cx, owner(cx), repo(cx)).await?; | |
| 47 | - let state = context::<AppState>(cx); | |
| 48 | - ensure_enabled(state, &ctx).await?; | |
| 49 | - let dir = wiki_dir(state, &ctx)?; | |
| 50 | - let topic = Topic::Wiki(ctx.repo.id.clone()); | |
| 51 | - stream_changes(cx, &state.live, &[topic], move || { | |
| 52 | - head_fingerprint(dir.clone()) | |
| 53 | - }) | |
| 54 | - .await | |
| 55 | -} | |
| 56 | - | |
| 57 | -#[route(GET "/{owner}/{repo}/wiki/{wiki_page}/events")] | |
| 58 | -async fn wiki_page_events(cx: &Cx) -> Result<Response> { | |
| 59 | - let page_name = wiki_page(cx).to_owned(); | |
| 60 | - let ctx = load_repo(cx, owner(cx), repo(cx)).await?; | |
| 61 | - let state = context::<AppState>(cx); | |
| 62 | - ensure_enabled(state, &ctx).await?; | |
| 63 | - if !valid_page_name(&page_name) { | |
| 64 | - return Err(not_found().into()); | |
| 65 | - } | |
| 66 | - let dir = wiki_dir(state, &ctx)?; | |
| 67 | - let git = state.git.clone(); | |
| 68 | - let topic = Topic::Wiki(ctx.repo.id.clone()); | |
| 69 | - stream_changes(cx, &state.live, &[topic], move || { | |
| 70 | - let git = git.clone(); | |
| 71 | - let dir = dir.clone(); | |
| 72 | - let page_name = page_name.clone(); | |
| 73 | - async move { page_fingerprint(&git, &dir, &page_name).await } | |
| 74 | - }) | |
| 75 | - .await | |
| 76 | -} |
crates/forge-web/assets/nav.jsmodified+2 -2
| @@ -3295,7 +3295,7 @@ | ||
| 3295 | 3295 | if (target && word) { showTick(target, word); } |
| 3296 | 3296 | } |
| 3297 | 3297 | |
| 3298 | - // Comment drafts. Free text in a POST form (comments, bodies, wiki pages, the profile about) is kept | |
| 3298 | + // Comment drafts. Free text in a POST form (comments, bodies, the profile about) is kept | |
| 3299 | 3299 | // in localStorage as the reader types, so a closed tab, a crash or a navigation keeps it. An empty |
| 3300 | 3300 | // field with a draft gets the text back, with a note to discard it. A successful post clears them. |
| 3301 | 3301 | function draftConfig() { |
| @@ -5273,7 +5273,7 @@ | ||
| 5273 | 5273 | : { attach: 'Attach', title: 'Attach an image or file (you can also paste or drop it)', up: 'Uploading', fail: 'Upload failed', taskFail: 'Could not save the task' }; |
| 5274 | 5274 | |
| 5275 | 5275 | // Repo pages whose textareas take markdown. `/owner/repo/section/...` |
| 5276 | - var REPO_PATH = /^\/([^\/]+)\/([^\/]+)\/(issues|pulls|wiki|compare|releases)(\/|$)/; | |
| 5276 | + var REPO_PATH = /^\/([^\/]+)\/([^\/]+)\/(issues|pulls|compare|releases)(\/|$)/; | |
| 5277 | 5277 | var NAMES = { body: 1, content: 1, message: 1 }; |
| 5278 | 5278 | |
| 5279 | 5279 | function repoBase() { |
crates/forge-web/src/routes.snapmodified+0 -12
| @@ -165,14 +165,6 @@ page /{owner}/{repo}/settings/secrets Only([POST]) | ||
| 165 | 165 | page /{owner}/{repo}/settings/transfer Only([POST]) |
| 166 | 166 | page /{owner}/{repo}/tags Only([GET]) |
| 167 | 167 | page /{owner}/{repo}/tree/{*rest} Only([GET]) |
| 168 | -page /{owner}/{repo}/wiki Only([GET]) | |
| 169 | -page /{owner}/{repo}/wiki/-/new Only([GET]) | |
| 170 | -page /{owner}/{repo}/wiki/-/new Only([POST]) | |
| 171 | -page /{owner}/{repo}/wiki/-/pages Only([GET]) | |
| 172 | -page /{owner}/{repo}/wiki/{wiki_page} Only([GET]) | |
| 173 | -page /{owner}/{repo}/wiki/{wiki_page}/edit Only([GET]) | |
| 174 | -page /{owner}/{repo}/wiki/{wiki_page}/edit Only([POST]) | |
| 175 | -page /{owner}/{repo}/wiki/{wiki_page}/history Only([GET]) | |
| 176 | 168 | page /{username} Only([GET]) |
| 177 | 169 | route /-/activity Only([GET]) |
| 178 | 170 | route /-/activity/stream Only([GET]) |
| @@ -423,12 +415,8 @@ route /{owner}/{repo}/settings/mirrors/{mirror_id}/sync Only([POST]) | ||
| 423 | 415 | route /{owner}/{repo}/settings/rename Only([GET]) |
| 424 | 416 | route /{owner}/{repo}/settings/secrets/delete Only([POST]) |
| 425 | 417 | route /{owner}/{repo}/settings/visibility Only([POST]) |
| 426 | -route /{owner}/{repo}/settings/wiki Only([GET]) | |
| 427 | -route /{owner}/{repo}/settings/wiki Only([POST]) | |
| 428 | 418 | route /{owner}/{repo}/star Only([POST]) |
| 429 | 419 | route /{owner}/{repo}/suggest Only([GET]) |
| 430 | 420 | route /{owner}/{repo}/transfer Only([GET]) |
| 431 | 421 | route /{owner}/{repo}/unstar Only([POST]) |
| 432 | 422 | route /{owner}/{repo}/watch Only([POST]) |
| 433 | -route /{owner}/{repo}/wiki/-/events Only([GET]) | |
| 434 | -route /{owner}/{repo}/wiki/{wiki_page}/events Only([GET]) |
docs/api.mdmodified+1 -1
| @@ -432,6 +432,6 @@ What the routes answer (all `GET`, paged with `page` and `limit`, at most 50 per | ||
| 432 | 432 | Git over HTTP accepts the same token as the Basic password, with your user name, `oauth2` or |
| 433 | 433 | `x-access-token` as the name. |
| 434 | 434 | |
| 435 | -Not carried over: topics, wiki and LFS objects (the clone brings the code only), user emails and | |
| 435 | +Not carried over: topics and LFS objects (the clone brings the code only), user emails and | |
| 436 | 436 | avatars (people arrive as plain user names, so the target creates placeholders you can re-map), |
| 437 | 437 | team reviews, snippets, CI runs and secrets. |
docs/architecture.mdmodified+1 -2
| @@ -49,7 +49,7 @@ project_git/ | ||
| 49 | 49 | forge-web/ builds the `forge` binary: boot, admin CLI, and the route tests that span page crates |
| 50 | 50 | forge-web-base/ modules with no routes: i18n, render, theme and accents, templates, blobs |
| 51 | 51 | forge-web-app/ everything below the pages: state, auth, live, views, CI, mail, backup, replication, git smart-HTTP, LFS, the HTTP APIs, test_support; its build.rs compiles the stylesheet |
| 52 | - forge-web-pages/ pages the others build on: repo, tree, issues, pulls core, CI runs, wiki, releases, repo settings | |
| 52 | + forge-web-pages/ pages the others build on: repo, tree, issues, pulls core, CI runs, releases, repo settings | |
| 53 | 53 | forge-web-account/ account, admin, org and profile pages (on forge-web-pages) |
| 54 | 54 | forge-web-repo/ code, commits, pull views, issue view pages (on forge-web-pages) |
| 55 | 55 | forge-e2e/ end-to-end tests. They run `FORGE_BIN` when it is set, so CI tests the binary it ships, and otherwise build `forge` |
| @@ -267,7 +267,6 @@ Pages update without a reload. A write that changes what a page shows calls `Liv | ||
| 267 | 267 | | Issues `/{owner}/{repo}/issues` and an issue | `/{owner}/{repo}/issues/live`, `/{owner}/{repo}/issues/{number}/live` | the repo issues (list, labels, milestones, tabs) and the one issue | |
| 268 | 268 | | Pull requests `/{owner}/{repo}/pulls` and a pull | `/{owner}/{repo}/pulls/events`, `/{owner}/{repo}/pulls/{number}/events` | the repo pull list, and the one pull (conversation, commits, files) | |
| 269 | 269 | | Explore `/explore` | `/explore/events`, with the search, sort and page | the public listing | |
| 270 | -| Wiki `/{owner}/{repo}/wiki`, page list, a page and its history | `/{owner}/{repo}/wiki/-/events` (home and list), `/{owner}/{repo}/wiki/{page}/events` (a page and its history) | the repo's wiki: a web save, or a push to the wiki repo | | |
| 271 | 270 | | Snippets `/snippets`, a snippet and its revisions | `/snippets/events` (list), `/snippets/{id}/events` (one snippet) | the snippet list and the snippet; a private snippet answers 404 to everyone but its owner | |
| 272 | 271 | | Org members `/org/{org}/members` | `/org/{org}/members/events` | the org (members, roles, description) | |
| 273 | 272 | | Org teams `/org/{org}/teams` | `/org/{org}/teams/events` | the org (teams and their coverage) | |
docs/backlog.mdmodified+0 -1
| @@ -86,7 +86,6 @@ Status: `[ ]` todo, `[~]` in progress, `[x]` done. | ||
| 86 | 86 | - [x] M1 mail core (lettre, outbox worker, admin mail settings) |
| 87 | 87 | - [x] M2 mail flows (password reset, email verification, invites; notification emails move to M3) |
| 88 | 88 | - [x] M3 notification emails (per-user opt-out on `/settings/notifications`, threaded by Message-ID) |
| 89 | -- [x] W1 wiki (git-backed, web editing, clone/push, backups/replication) | |
| 90 | 89 | - [x] S1 snippets |
| 91 | 90 | - [x] T1 theme and language preferences (dark mode toggle) |
| 92 | 91 | - [x] I18 i18n infrastructure (En/Tr) and the shell, auth and settings pages |
docs/ci.mdmodified+1 -1
| @@ -417,7 +417,7 @@ Treat job logs as sensitive. Never `echo` a secret, even though it is masked. | ||
| 417 | 417 | |
| 418 | 418 | Each claimed job gets its own token. The token: |
| 419 | 419 | |
| 420 | -- is **read-only**. It can fetch the job's repository, and its wiki (`<repo>.wiki`), through smart | |
| 420 | +- is **read-only**. It can fetch the job's repository through smart | |
| 421 | 421 | HTTP with the user name `ci-job` and the password `<job id>:<token>`. Every write is refused; |
| 422 | 422 | - only works while the job is `running`. Once the job finishes, the token stops working for logs, |
| 423 | 423 | artifacts, heartbeat, finish and git reads; |
scripts/audit/mock.pymodified+2 -2
| @@ -92,7 +92,7 @@ def fill_database(): | ||
| 92 | 92 | running 214 tests |
| 93 | 93 | test store::ci::tests::a_requeued_job_starts_with_no_steps ... ok |
| 94 | 94 | test store::ci::tests::steps_take_the_jobs_result ... ok |
| 95 | - test wiki_e2e::follows_a_push ... {result} | |
| 95 | + test ci_e2e::follows_a_push ... {result} | |
| 96 | 96 | """ |
| 97 | 97 | logs = os.path.join(data, "ci", "logs") |
| 98 | 98 | os.makedirs(logs, exist_ok=True) |
| @@ -134,7 +134,7 @@ def fill_database(): | ||
| 134 | 134 | live = job_state == "running" and k == len(steps) - 1 |
| 135 | 135 | text = "::group::" + step + "\n" + LOG.format(step="$ " + step.lower(), result="FAILED" if bad else "ok") |
| 136 | 136 | if bad: |
| 137 | - text += "error: stream closed before the push event arrived\n --> crates/forge-e2e/tests/e2e/wiki_e2e.rs:212:9\n" | |
| 137 | + text += "error: stream closed before the push event arrived\n --> crates/forge-e2e/tests/e2e/ci_e2e.rs:212:9\n" | |
| 138 | 138 | text += "::endgroup::\n" |
| 139 | 139 | step_rows.append((job_id, k, step, stamp(step_start), None if live or bad else stamp(step_start + length // len(steps)), offset)) |
| 140 | 140 | offset += len(text.encode()) |
scripts/audit/seed.pymodified+3 -21
| @@ -157,7 +157,7 @@ A small Rust project used to exercise every page of the forge. | ||
| 157 | 157 | ## Features |
| 158 | 158 | |
| 159 | 159 | - Fast `git` hosting with **smart HTTP** and SSH |
| 160 | -- Issues, pull requests, releases and a wiki | |
| 160 | +- Issues, pull requests, and releases | |
| 161 | 161 | - A commit heatmap that keeps you motivated |
| 162 | 162 | |
| 163 | 163 | ## Usage |
| @@ -303,7 +303,7 @@ R = f"/{ADMIN}/{REPO}" | ||
| 303 | 303 | def _(): |
| 304 | 304 | ok(admin.post(f"{R}/labels", {"name": "ui", "color": "#7c9a6d", "description": "Visual and layout work"}), "label") |
| 305 | 305 | ok(admin.post(f"{R}/labels", {"name": "needs-triage", "color": "#d4a72c", "description": ""}), "label2") |
| 306 | - ok(admin.post(f"{R}/milestones", {"title": "v0.3.0", "description": "Heatmap and wiki polish", | |
| 306 | + ok(admin.post(f"{R}/milestones", {"title": "v0.3.0", "description": "Heatmap polish", | |
| 307 | 307 | "due_on": "2026-12-01", "state": "open"}), "milestone") |
| 308 | 308 | admin.post(f"{R}/milestones", {"title": "v0.2.0", "description": "Shipped", "due_on": "", "state": "closed"}) |
| 309 | 309 | r = admin.get(f"{R}/milestones") |
| @@ -317,7 +317,7 @@ def _(): | ||
| 317 | 317 | ("Heatmap cells overflow on narrow screens", "On a 390px wide phone the heatmap scrolls sideways.\n\n- [ ] fix grid\n- [x] reproduce"), |
| 318 | 318 | ("Add dark theme screenshots to the docs", "We should show both themes in `docs/`."), |
| 319 | 319 | ("Release assets are missing checksums", "Each release should ship a `SHA256SUMS` file."), |
| 320 | - ("Wiki sidebar collapses unexpectedly", "Steps:\n1. open wiki\n2. resize\n\n```rust\nfn main() {}\n```"), | |
| 320 | + ("Sidebar collapses unexpectedly", "Steps:\n1. open the page\n2. resize\n\n```rust\nfn main() {}\n```"), | |
| 321 | 321 | ] |
| 322 | 322 | for title, body in issues: |
| 323 | 323 | ok(admin.post(f"{R}/issues/new", {"title": title, "body": body}), "issue") |
| @@ -389,24 +389,6 @@ def _(): | ||
| 389 | 389 | "body": "Draft notes.", "draft": True, "prerelease": True}).encode(), h) |
| 390 | 390 | |
| 391 | 391 | |
| 392 | -@step("wiki") | |
| 393 | -def _(): | |
| 394 | - r = admin.get(f"{R}/wiki/-/new") | |
| 395 | - base = field(r.text, "base") or "" | |
| 396 | - ok(admin.post(f"{R}/wiki/-/new", {"base": base, "name": "Home", | |
| 397 | - "content": "# Welcome\n\nThis is the **forge-demo** wiki.\n\n- [[Install]]\n- [[Architecture]]\n", | |
| 398 | - "message": "Create Home"}), "wiki home") | |
| 399 | - for name, content in [("Install", "# Install\n\n```sh\ncargo install --path .\n```\n"), | |
| 400 | - ("Architecture", "# Architecture\n\n| Crate | Role |\n| --- | --- |\n| core | store |\n| web | UI |\n")]: | |
| 401 | - r = admin.get(f"{R}/wiki/-/new") | |
| 402 | - admin.post(f"{R}/wiki/-/new", {"base": field(r.text, "base") or "", "name": name, "content": content, | |
| 403 | - "message": f"Add {name}"}) | |
| 404 | - r = admin.get(f"{R}/wiki/Home/edit") | |
| 405 | - admin.post(f"{R}/wiki/Home/edit", {"base": field(r.text, "base") or "", "name": "Home", | |
| 406 | - "content": "# Welcome\n\nThis is the **forge-demo** wiki. Start with [[Install]].\n", | |
| 407 | - "message": "Tweak Home"}) | |
| 408 | - | |
| 409 | - | |
| 410 | 392 | @step("snippets") |
| 411 | 393 | def _(): |
| 412 | 394 | r = ok(admin.post("/snippets/new", {"title": "Backup cron", "description": "Nightly backup with restic", |
scripts/audit/shoot.pymodified+3 -3
| @@ -406,7 +406,7 @@ def concrete(pat): | ||
| 406 | 406 | "{id}": s.get("snippet_id"), "{release_id}": s.get("release_id"), |
| 407 | 407 | "{milestone_id}": s.get("milestone_id"), "{run_number}": s.get("run_number"), |
| 408 | 408 | "{job_id}": s.get("job_id"), "{oid}": s.get("head_oid"), "{tag}": "v0.2.0", |
| 409 | - "{wiki_page}": "Install", "{hook_id}": s.get("hook_id"), "{mirror_id}": None, | |
| 409 | + "{hook_id}": s.get("hook_id"), "{mirror_id}": None, | |
| 410 | 410 | "{spec}": "main...feature/heatmap"} |
| 411 | 411 | if "/pulls/{number}" in pat: |
| 412 | 412 | fill["{number}"] = s.get("pull_number") |
| @@ -488,8 +488,8 @@ def area_of(pat): | ||
| 488 | 488 | return "admin" |
| 489 | 489 | if p.startswith(("/settings", "/notifications")): |
| 490 | 490 | return "settings" |
| 491 | - if p.startswith(("/snippets", "/gists")) or "/wiki" in p: | |
| 492 | - return "wiki-snippets" | |
| 491 | + if p.startswith(("/snippets", "/gists")): | |
| 492 | + return "snippets" | |
| 493 | 493 | if p.startswith(("/orgs", "/{org}")) or p in ("/{username}", "/explore", "/search") or p.startswith("/{username}"): |
| 494 | 494 | return "profile-orgs" |
| 495 | 495 | if "/actions" in p or "/ci" in p or "/runs" in p or "/runners" in p or "/artifacts" in p: |
style/_wiki.scssdeleted+0 -82
| @@ -1,82 +0,0 @@ | ||
| 1 | - | |
| 2 | - | |
| 3 | -.wiki-page .markdown-body > :first-child { | |
| 4 | - margin-top: 0; | |
| 5 | -} | |
| 6 | - | |
| 7 | -.wiki-pages .item a { | |
| 8 | - font-weight: 500; | |
| 9 | -} | |
| 10 | - | |
| 11 | -.wiki-form textarea { | |
| 12 | - font-family: var(--mono); | |
| 13 | - min-height: 24rem; | |
| 14 | -} | |
| 15 | - | |
| 16 | -// A list that fills a card: the card's own padding frames it, so the first and last rows add none. | |
| 17 | -.card > .item-list > .item:first-child { | |
| 18 | - padding-top: 0; | |
| 19 | -} | |
| 20 | - | |
| 21 | -.card > .item-list > .item:last-child { | |
| 22 | - padding-bottom: 0; | |
| 23 | -} | |
| 24 | - | |
| 25 | -// Phones: a history row is too wide for one line, so it stacks (subject first, then hash, author | |
| 26 | -// and time) instead of scrolling sideways. | |
| 27 | -@media (max-width: 639px) { | |
| 28 | - .wiki-history tr { | |
| 29 | - display: flex; | |
| 30 | - flex-wrap: wrap; | |
| 31 | - align-items: baseline; | |
| 32 | - gap: 2px 12px; | |
| 33 | - padding: 12px 0; | |
| 34 | - border-bottom: 1px solid var(--border); | |
| 35 | - } | |
| 36 | - | |
| 37 | - .wiki-history tr:first-child { | |
| 38 | - padding-top: 0; | |
| 39 | - } | |
| 40 | - | |
| 41 | - .wiki-history tr:last-child { | |
| 42 | - padding-bottom: 0; | |
| 43 | - border-bottom: 0; | |
| 44 | - } | |
| 45 | - | |
| 46 | - .wiki-history td { | |
| 47 | - padding: 0; | |
| 48 | - border: 0; | |
| 49 | - } | |
| 50 | - | |
| 51 | - .wiki-history td:nth-child(2) { | |
| 52 | - order: -1; | |
| 53 | - flex: 1 1 100%; | |
| 54 | - } | |
| 55 | -} | |
| 56 | - | |
| 57 | -// The 404 page: a centred message inside the regular shell. | |
| 58 | -.not-found { | |
| 59 | - display: flex; | |
| 60 | - flex-direction: column; | |
| 61 | - align-items: center; | |
| 62 | - gap: 8px; | |
| 63 | - padding: 64px 0; | |
| 64 | - text-align: center; | |
| 65 | - | |
| 66 | - h1, | |
| 67 | - p { | |
| 68 | - margin: 0; | |
| 69 | - } | |
| 70 | - | |
| 71 | - .not-found-code { | |
| 72 | - font-size: 3rem; | |
| 73 | - font-weight: 700; | |
| 74 | - line-height: 1; | |
| 75 | - color: var(--muted); | |
| 76 | - } | |
| 77 | - | |
| 78 | - .button { | |
| 79 | - align-self: center; | |
| 80 | - margin-top: 12px; | |
| 81 | - } | |
| 82 | -} |
style/main.scssmodified+0 -1
| @@ -5665,7 +5665,6 @@ button.ci-job-last { | ||
| 5665 | 5665 | @import "repo"; |
| 5666 | 5666 | @import "pull"; |
| 5667 | 5667 | @import "dashboard"; |
| 5668 | -@import "wiki"; | |
| 5669 | 5668 | @import "browse"; |
| 5670 | 5669 | @import "import"; |
| 5671 | 5670 | @import "authoring"; |