~ntietz/isabella-db

eaf392cda19f872df5c84a0884b80e8a6a5f8307 — Nicholas Tietz-Sokolsky 20 days ago bd608e7
Appease the linter
2 files changed, 5 insertions(+), 7 deletions(-)

M isabella/src/web/templates.rs
M isabella/src/web/views.rs
M isabella/src/web/templates.rs => isabella/src/web/templates.rs +4 -5
@@ 1,25 1,24 @@
use askama::Template;
use shakmaty::{Board, Square, Piece, Color, Role};
use shakmaty::{Board, Color, Piece, Role, Square};

#[derive(Template)]
#[template(path = "home.html")]
pub struct HomeTemplate;

#[derive(Template)]
#[derive(Default, Template)]
#[template(path = "board.html")]
pub struct BoardTemplate {
    pub board: Board,
    pub piece: String,
}

impl BoardTemplate {
    pub fn new() -> BoardTemplate {
        let board = Board::new();
        BoardTemplate { board, piece: "♛".into() }
        BoardTemplate { board }
    }

    pub fn render_piece_on(&self, rank: &u8, file: &u8) -> String {
        let square_idx = (file + rank*8) as u32;
        let square_idx = (file + rank * 8) as u32;
        let piece = self.board.piece_at(Square::new(square_idx));

        html_display_piece(piece)

M isabella/src/web/views.rs => isabella/src/web/views.rs +1 -2
@@ 1,4 1,4 @@
use actix_web::{HttpResponse, Responder, route};
use actix_web::{route, HttpResponse, Responder};
use askama::Template;

use super::templates::{BoardTemplate, HomeTemplate};


@@ 12,7 12,6 @@ pub async fn home() -> impl Responder {
#[route("/position/", method = "GET")]
pub async fn position() -> impl Responder {
    tracing::info!("here");
    println!("{}", "♛");
    let s = BoardTemplate::new()
        .render()
        .expect("BoardTemplate should render");