Compare commits
No commits in common. "5269dd7789d8918910c54d8e5f25a430232b0491" and "69a2d1150103c0ba72d20209dced57c768a54b1d" have entirely different histories.
5269dd7789
...
69a2d11501
@ -3,7 +3,8 @@ mod templates;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::http::{StatusCode, Uri};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
@ -13,10 +14,10 @@ async fn fallback(uri: Uri) -> (StatusCode, String) {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
pub struct GetIndexTemplate;
|
||||
pub struct GetIndexResponse;
|
||||
|
||||
async fn root() -> GetIndexTemplate {
|
||||
GetIndexTemplate {}
|
||||
async fn root() -> impl IntoResponse {
|
||||
GetIndexResponse {}.into_response()
|
||||
}
|
||||
|
||||
pub fn get_router(assets_path: &Path) -> axum::Router {
|
||||
|
@ -1,9 +1,10 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "pages/cps.html")]
|
||||
pub struct CpsTemplate;
|
||||
struct CpsResponse;
|
||||
|
||||
pub async fn cps() -> CpsTemplate {
|
||||
CpsTemplate
|
||||
pub async fn cps() -> impl IntoResponse {
|
||||
CpsResponse.into_response()
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "pages/home.html")]
|
||||
pub struct HomeTemplate;
|
||||
struct HomeResponse;
|
||||
|
||||
pub async fn home() -> HomeTemplate {
|
||||
HomeTemplate
|
||||
pub async fn home() -> impl IntoResponse {
|
||||
HomeResponse.into_response()
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{routing, Router};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "hello.html")]
|
||||
struct HelloTemplate {
|
||||
struct HelloResponse {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
async fn hello() -> HelloTemplate {
|
||||
HelloTemplate {
|
||||
async fn hello() -> impl IntoResponse {
|
||||
HelloResponse {
|
||||
name: "Theo".to_string(),
|
||||
}
|
||||
.into_response()
|
||||
}
|
||||
|
||||
pub fn get_routes() -> Router {
|
||||
|
@ -1,4 +1,5 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{extract::Query, routing, Router};
|
||||
use serde::Deserialize;
|
||||
|
||||
@ -15,12 +16,12 @@ struct MenuParameters {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "layout/nav/nav-menu-items.html")]
|
||||
struct MenuTemplate {
|
||||
struct MenuResponse {
|
||||
mobile: bool,
|
||||
items: Vec<MenuItem>,
|
||||
}
|
||||
|
||||
impl MenuTemplate {
|
||||
impl MenuResponse {
|
||||
fn get_classes(&self, is_current_item: &bool) -> String {
|
||||
let common_classes = match self.mobile {
|
||||
true => "block border-l-4 py-2 pl-3 pr-4 text-base font-medium".to_string(),
|
||||
@ -37,8 +38,8 @@ impl MenuTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
MenuTemplate {
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
|
||||
MenuResponse {
|
||||
mobile: params.mobile,
|
||||
items: vec![
|
||||
MenuItem {
|
||||
@ -53,6 +54,7 @@ async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
},
|
||||
],
|
||||
}
|
||||
.into_response()
|
||||
}
|
||||
|
||||
pub fn get_routes() -> Router {
|
||||
|
@ -1,4 +1,5 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{extract::Query, routing, Router};
|
||||
use serde::Deserialize;
|
||||
|
||||
@ -15,12 +16,12 @@ struct MenuParameters {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "layout/nav/profile-menu-items.html")]
|
||||
struct MenuTemplate {
|
||||
struct MenuResponse {
|
||||
mobile: bool,
|
||||
items: Vec<MenuItem>,
|
||||
}
|
||||
|
||||
impl MenuTemplate {
|
||||
impl MenuResponse {
|
||||
fn get_classes(&self, is_current_item: &bool) -> String {
|
||||
let common_classes = match self.mobile {
|
||||
true => "block px-4 py-2 text-base font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-800".to_string(),
|
||||
@ -35,8 +36,8 @@ impl MenuTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
MenuTemplate {
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
|
||||
MenuResponse {
|
||||
mobile: params.mobile,
|
||||
items: vec![
|
||||
MenuItem {
|
||||
@ -56,6 +57,7 @@ async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
},
|
||||
],
|
||||
}
|
||||
.into_response()
|
||||
}
|
||||
|
||||
pub fn get_routes() -> Router {
|
||||
|
Loading…
Reference in New Issue
Block a user