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