♻️ (pagetop): Adapta extensiones a Routes y StaticFiles
This commit is contained in:
parent
4062a57cff
commit
a0416e5670
7 changed files with 18 additions and 18 deletions
|
|
@ -104,9 +104,9 @@ impl Extension for Aliner {
|
||||||
Some(&Self)
|
Some(&Self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_static_files(&self, router: Router) -> Router {
|
fn configure_static_files(&self, files: StaticFiles) -> StaticFiles {
|
||||||
serve_static_files!(router, [aliner] => "/aliner");
|
serve_static_files!(files, [aliner] => "/aliner");
|
||||||
router
|
files
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -391,11 +391,11 @@ impl Extension for Cron {
|
||||||
scheduler::shutdown().await;
|
scheduler::shutdown().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_router(&self, router: Router) -> Router {
|
fn configure_router(&self, routes: Routes) -> Routes {
|
||||||
if config::SETTINGS.mode != config::CronMode::External {
|
if config::SETTINGS.mode != config::CronMode::External {
|
||||||
return router;
|
return routes;
|
||||||
}
|
}
|
||||||
router.route(TRIGGER_PATH, web::post(trigger_post).fallback(not_found))
|
routes.public_route(TRIGGER_PATH, web::post(trigger_post).fallback(not_found))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ use crate::hx;
|
||||||
/// [`SortLink`]: pagetop::base::component::table::SortLink
|
/// [`SortLink`]: pagetop::base::component::table::SortLink
|
||||||
/// [`SortLink::with_prop()`]: pagetop::base::component::table::SortLink::with_prop
|
/// [`SortLink::with_prop()`]: pagetop::base::component::table::SortLink::with_prop
|
||||||
/// [`SortLink::with_dir()`]: pagetop::base::component::table::SortLink::with_dir
|
/// [`SortLink::with_dir()`]: pagetop::base::component::table::SortLink::with_dir
|
||||||
/// [`Context::route()`]: pagetop::core::component::Context::route
|
/// [`Context::route()`]: pagetop::core::component::Contextual::route
|
||||||
pub fn sort_link(
|
pub fn sort_link(
|
||||||
href: impl Into<RoutePath>,
|
href: impl Into<RoutePath>,
|
||||||
target: impl AsRef<str>,
|
target: impl AsRef<str>,
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,9 @@ impl Extension for Htmx {
|
||||||
actions![action::page::BeforeRenderBody::new(add_htmx_script)]
|
actions![action::page::BeforeRenderBody::new(add_htmx_script)]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_static_files(&self, router: Router) -> Router {
|
fn configure_static_files(&self, files: StaticFiles) -> StaticFiles {
|
||||||
serve_static_files!(router, [htmx] => "/htmx");
|
serve_static_files!(files, [htmx] => "/htmx");
|
||||||
router
|
files
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ impl HtmxResponse {
|
||||||
/// objetivo definido por el destino. Para personalizar `target`, `swap`, `select` o `values`,
|
/// objetivo definido por el destino. Para personalizar `target`, `swap`, `select` o `values`,
|
||||||
/// usa [`location_json()`](Self::location_json).
|
/// usa [`location_json()`](Self::location_json).
|
||||||
///
|
///
|
||||||
/// Usa [`Context::route()`](pagetop::core::component::Context::route) en lugar de un literal
|
/// Usa [`Context::route()`](pagetop::core::component::Contextual::route) en lugar de un literal
|
||||||
/// para que la URL preserve el parámetro `lang` cuando corresponda:
|
/// para que la URL preserve el parámetro `lang` cuando corresponda:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
|
@ -213,7 +213,7 @@ impl HtmxResponse {
|
||||||
/// El usuario podrá navegar hacia atrás hasta esa URL. Usar `"false"` para desactivar el empuje
|
/// El usuario podrá navegar hacia atrás hasta esa URL. Usar `"false"` para desactivar el empuje
|
||||||
/// aunque esté habilitado por el atributo `hx-push-url` del elemento.
|
/// aunque esté habilitado por el atributo `hx-push-url` del elemento.
|
||||||
///
|
///
|
||||||
/// Usa [`Context::route()`](pagetop::core::component::Context::route) en lugar de un literal
|
/// Usa [`Context::route()`](pagetop::core::component::Contextual::route) en lugar de un literal
|
||||||
/// para que la URL preserve el parámetro `lang` cuando corresponda:
|
/// para que la URL preserve el parámetro `lang` cuando corresponda:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
|
@ -231,7 +231,7 @@ impl HtmxResponse {
|
||||||
/// Reemplaza la URL actual en el historial sin añadir una nueva entrada.
|
/// Reemplaza la URL actual en el historial sin añadir una nueva entrada.
|
||||||
///
|
///
|
||||||
/// Usar `"false"` para desactivar el reemplazo. Usa
|
/// Usar `"false"` para desactivar el reemplazo. Usa
|
||||||
/// [`Context::route()`](pagetop::core::component::Context::route) en lugar de un literal para
|
/// [`Context::route()`](pagetop::core::component::Contextual::route) en lugar de un literal para
|
||||||
/// que la URL preserve el parámetro `lang` cuando corresponda.
|
/// que la URL preserve el parámetro `lang` cuando corresponda.
|
||||||
pub fn replace_url(self, url: impl Into<RoutePath>) -> Self {
|
pub fn replace_url(self, url: impl Into<RoutePath>) -> Self {
|
||||||
self.set_header(hx::response::REPLACE_URL.as_bytes(), url.into().to_string())
|
self.set_header(hx::response::REPLACE_URL.as_bytes(), url.into().to_string())
|
||||||
|
|
@ -242,7 +242,7 @@ impl HtmxResponse {
|
||||||
/// A diferencia de [`location()`](Self::location), esta redirección recarga la página por
|
/// A diferencia de [`location()`](Self::location), esta redirección recarga la página por
|
||||||
/// completo, como un `window.location.href = url` en JavaScript.
|
/// completo, como un `window.location.href = url` en JavaScript.
|
||||||
///
|
///
|
||||||
/// Usa [`Context::route()`](pagetop::core::component::Context::route) en lugar de un literal
|
/// Usa [`Context::route()`](pagetop::core::component::Contextual::route) en lugar de un literal
|
||||||
/// para que la URL preserve el parámetro `lang` cuando corresponda:
|
/// para que la URL preserve el parámetro `lang` cuando corresponda:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ impl Extension for TestApp {
|
||||||
vec![&Htmx]
|
vec![&Htmx]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_router(&self, router: Router) -> Router {
|
fn configure_router(&self, routes: Routes) -> Routes {
|
||||||
router.route("/page", web::get(render_page))
|
routes.public_route("/page", web::get(render_page))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ struct TestApp;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Extension for TestApp {
|
impl Extension for TestApp {
|
||||||
fn configure_router(&self, router: Router) -> Router {
|
fn configure_router(&self, routes: Routes) -> Routes {
|
||||||
router.route("/echo", web::get(echo_request))
|
routes.public_route("/echo", web::get(echo_request))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue