Fixed generating issue templates

This commit is contained in:
famfo 2022-04-10 13:03:52 +02:00
parent 6d2410bf4f
commit 6ecb5dd41f
6 changed files with 74 additions and 11 deletions

View file

@ -29,6 +29,7 @@ use tracing::{debug, error, info, Level};
mod config; mod config;
mod database; mod database;
mod task;
mod web; mod web;
#[cfg(unix)] #[cfg(unix)]

54
src/task.rs Normal file
View file

@ -0,0 +1,54 @@
/*
* tmtd - Suckless To Do list
* Copyright (C) 2022 C4TG1RL5
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
use serde::Serialize;
#[derive(Serialize)]
pub enum Status {
Ideas(),
Assigned(String),
InProgress(),
Done(),
}
#[derive(Debug, Serialize)]
pub struct Task {
title: String,
date: String,
status: String,
assignee: String,
description: String,
}
impl Task {
pub fn new(title: String, date: String, status: Status, assignee: String, description: String) -> Task {
let status = match status {
Status::Ideas() => "Ideas".to_string(),
Status::Assigned(u) => format!("Assiged to {}", u),
Status::InProgress() => "In prograss".to_string(),
Status::Done() => "Done".to_string(),
};
Task {
title,
date,
status,
assignee,
description,
}
}
}

View file

@ -133,12 +133,17 @@ impl App {
let tera = self.tera.clone(); let tera = self.tera.clone();
move |_| { move |_| {
let mut ctx = Context::new(); let mut ctx = Context::new();
ctx.insert("tasks", &vec!["test1", "test2"]); let mut tasks = Vec::new();
ctx.insert("task_title", "TODO"); for _ in 0..3 {
ctx.insert("description", "TODO"); let task_ctx = crate::task::Task::new("TODO".to_string(),
ctx.insert("task_date", "TODO"); "TODO".to_string(),
ctx.insert("status", "TODO"); crate::task::Status::Ideas(),
ctx.insert("assignee", "TODO"); "TODO".to_string(),
"TODO".to_string());
tasks.push(task_ctx);
}
ctx.insert("tasks", &tasks);
tracing::debug!("{:?}", tasks);
warp::reply::html(tera.render("task_page.html", &ctx).unwrap()) warp::reply::html(tera.render("task_page.html", &ctx).unwrap())
} }
})); }));

1
templates/hallo/aa.html Normal file
View file

@ -0,0 +1 @@
Hallo

View file

@ -1,13 +1,13 @@
<h3>{{task_title}}</h3> <h3>{{task.title}}</h3>
<hr> <hr>
<ul> <ul>
<li>Date: {{task_date}}</li> <li>Date: {{task.date}}</li>
<li>Status: {{status}}</li> <li>Status: {{task.status}}</li>
<li>Assignee: {{assignee}}</li> <li>Assignee: {{task.assignee}}</li>
</ul> </ul>
<hr> <hr>
{{description}} {{task.description}}
<hr> <hr>
<label for="move">Move to:</label> <label for="move">Move to:</label>

View file

@ -21,8 +21,10 @@ navbar<br>
<!-- Some only selecting specific task code here, for smarter people then me --> <!-- Some only selecting specific task code here, for smarter people then me -->
<ul>
{% for task in tasks %} {% for task in tasks %}
{% include "task.html" %} {% include "task.html" %}
{% endfor %} {% endfor %}
</ul>
{% endblock content %} {% endblock content %}