✨ Serve the PageTop guides with pagetop-mdbook
Rebuild the website on the current PageTop API, with Bootsier as its
theme and edition 2024. Add the first Spanish guide (doc/v0.6/es) as an
mdBook book, built in build.rs and served with pagetop-mdbook, and the
/doc/latest/{lang} redirect.
Add `tools/doccheck.sh` to check the links of the guides and to compile,
run and test their examples against PageTop.
Move the configuration to config/common.toml and translate the README
to English.
This commit is contained in:
parent
e41e71cc78
commit
1a41a456d4
80 changed files with 14112 additions and 1218 deletions
41
tools/doccheck/tests/localization.rs
Normal file
41
tools/doccheck/tests/localization.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Runtime check of the localization chapter: translations, arguments and plurals in both languages.
|
||||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOCALES_APP);
|
||||
|
||||
struct App;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for App {
|
||||
fn configure_router(&self, router: Router) -> Router {
|
||||
router.route("/", web::get(home))
|
||||
}
|
||||
}
|
||||
|
||||
async fn home(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_child(Html::with(|cx| {
|
||||
let welcome = Lc::t("welcome", &LOCALES_APP).with_arg("name", "Ana");
|
||||
let many = Lc::t("notices", &LOCALES_APP).with_number("total", 3);
|
||||
let one = Lc::t("notices", &LOCALES_APP).with_number("total", 1);
|
||||
html! { p { (welcome.using(cx)) } p { (many.using(cx)) } p { (one.using(cx)) } }
|
||||
}))
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn translates_with_arguments_and_plurals() {
|
||||
let app = web::test::init_router(Application::prepare(&App).await.test());
|
||||
for (lang, expected) in [
|
||||
("es", ["Te damos la bienvenida, Ana.", "Tienes 3 avisos", "Tienes un aviso"]),
|
||||
("en", ["Welcome, Ana.", "You have 3 notices", "You have one notice"]),
|
||||
] {
|
||||
let request = web::test::TestRequest::get().uri(format!("/?lang={lang}")).to_request();
|
||||
let response = web::test::send_request(&app, request).await;
|
||||
let body = web::test::read_body_text(response).await;
|
||||
for text in expected {
|
||||
assert!(body.contains(text), "{lang}: {text:?} not found in the page");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue