Skip to content

Commit 7bbb431

Browse files
committed
Font customization, Tag selection now goes on top, instead of side.
1 parent 4138aa5 commit 7bbb431

File tree

9 files changed

+68
-45
lines changed

9 files changed

+68
-45
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Fri 28, March, 2025
2+
- [x] Font's can be customized
3+
- [x] Removed packaged font
4+
15
## Tue 04, March, 2025
26

37
- [x] BIG UI UPDATE

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ By default the "time of the day" widget is not visible, to display it put
117117
118118
in the `.env` file
119119
120+
### Font customization
121+
122+
Previously the app used `Departure Mono` as default font, which was also included in the repo.
123+
It's now removed.
124+
And the font can be set using env variable.
125+
126+
Add the following to change default font:
127+
128+
`TWK_USE_FONT='Maple Mono'`
129+
120130
121131
# Using the app
122132
@@ -179,6 +189,7 @@ there will be errors, as no checks, and there may not be any error messages in c
179189
180190
181191
## Planned
192+
- [ ] Better configuration
182193
- [ ] Usability improvements on a long task list
183194
- [x] Hiding empty columns
184195
- [ ] Temporary highlight last modified row, if visible

build.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@ use std::process::Command;
22

33
fn main() {
44
println!("cargo:rerun-if-changed=frontend/");
5-
let css_build_success = match Command::new("tailwindcss")
5+
if let Err(_) = Command::new("tailwindcss")
66
.args(["-i", "frontend/css/style.css", "-o", "dist/style.css"])
7-
.status() {
8-
Ok(vv) => {
9-
vv.success()
10-
}
11-
Err(_e) => {
12-
false
13-
}
14-
};
15-
if !css_build_success {
7+
.status()
8+
{
169
if let Err(_e) = Command::new("./tailwindcss")
1710
.args(["-i", "frontend/css/style.css", "-o", "dist/style.css"])
18-
.status() {
11+
.status()
12+
{
1913
panic!("Failed to process css")
2014
}
21-
};
15+
}
2216
if !Command::new("rollup")
2317
.args(["-c", "frontend/rollup.config.js"])
24-
.status().unwrap().success() {
18+
.status()
19+
.unwrap()
20+
.success()
21+
{
2522
panic!("Failed to process css")
2623
}
2724
// adding templates
2825
if !Command::new("cp")
29-
.args(["-r", "frontend/templates", "frontend/assets", "dist"])
30-
.status().unwrap().success() {
26+
.args(["-r", "frontend/templates", "dist"])
27+
.status()
28+
.unwrap()
29+
.success()
30+
{
3131
println!("cargo::warning=Failed to copy files");
3232
panic!("Failed to copy template files")
3333
}

env.example

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
TWK_SERVER_PORT=9080
22
DISPLAY_TIME_OF_THE_DAY=1
3+
TWK_USE_FONT='Maple Mono'
-19.3 KB
Binary file not shown.

frontend/css/style.css

-10
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@
4545
@plugin "@tailwindcss/typography";
4646
@plugin "@tailwindcss/forms";
4747

48-
49-
@font-face {
50-
font-family: 'Departure Mono';
51-
src: url('assets/DepartureMono-Regular.woff') format('woff');
52-
}
53-
54-
body {
55-
font-family: 'Departure Mono', sans-serif;
56-
}
57-
5848
.shortcut_key {
5949
@apply px-1 mx-0.5 space-x-0 opacity-50 text-white bg-base-100 rounded-sm;
6050
}

frontend/templates/base.html

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<html lang="en" data-theme="task-warrior">
33
<head>
44
<link rel="stylesheet" href="/dist/style.css"/>
5+
<style>
6+
{% if USE_FONT %}
7+
body {
8+
font-family: '{{ USE_FONT }}', '{{ FALLBACK_FAMILY }}';
9+
}
10+
{% endif %}
11+
</style>
512
<script src="/dist/bundle.js" type="module"></script>
613
<title>
714
Org.Me

frontend/templates/tasks.html

+6-9
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858

5959
<span hx-get="tasks/active" hx-trigger="load" hx-swap="outerHTML" hx-target="this"></span>
6060

61-
<div class="flex">
62-
<div id="tags_map_drawer" class="shrink pt-4 hidden w-10/12">
63-
<div class="flex flex-wrap gap-2 p-4">
61+
<div class="grid grid-cols-1">
62+
<div id="tags_map_drawer" class="pt-4 hidden bg-green-300 mb-2">
63+
<div class="flex flex-wrap gap-2 p-4 bg-accent-content">
6464
<div class="join">
6565
<button
6666
id="tag-btn-back"
@@ -110,8 +110,7 @@
110110
{% endfor %}
111111
</div>
112112
</div>
113-
114-
<div class="grow">
113+
<div>
115114
<ul class="list bg-base-100 rounded-box shadow-md text-sm">
116115
{% for task in tasks %}
117116
<li class="list-row {% if task.start %} bg-green-700 {% endif %} p-2">
@@ -200,10 +199,8 @@
200199
{% elif task.urgency > 10 %}
201200
<div class="btn btn-xs btn-primary join-item">{{ task.urgency }}</div>
202201
{% else %}
203-
<div class="btn btn-xs btn-neutral join-item">{{ task.urgency }}</div>
204-
{% endif %}
205-
{% if task.due %}
206-
<div class="btn btn-xs btn-neutral join-item">{{ task.due }}</div>
202+
<div class="btn btn-xs btn-neutral join-item">
203+
{{ task.urgency }}</div>
207204
{% endif %}
208205

209206
{% if task.due and task.status != 'completed' %}

src/main.rs

+24-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use indexmap::IndexMap;
66
use rand::distr::{Alphanumeric, SampleString};
77
use std::collections::{HashMap, HashSet};
88
use std::env;
9+
use std::string::ToString;
910
use taskwarrior_web::endpoints::tasks::task_query_builder::TaskQuery;
1011
use taskwarrior_web::endpoints::tasks::{fetch_active_task, get_task_details, list_tasks, mark_task_as_done, run_annotate_command, run_denotate_command, run_modify_command, task_add, task_undo, task_undo_report, toggle_task_active, Task, TaskUUID, TaskViewDataRetType};
1112
use taskwarrior_web::{
@@ -18,6 +19,7 @@ use tracing_subscriber::layer::SubscriberExt;
1819
use tracing_subscriber::util::SubscriberInitExt;
1920
use taskwarrior_web::endpoints::tasks;
2021

22+
2123
#[tokio::main]
2224
async fn main() {
2325
// initialize tracing
@@ -56,6 +58,17 @@ async fn main() {
5658
axum::serve(listener, app).await.unwrap();
5759
}
5860

61+
fn get_default_context() -> Context {
62+
let mut ctx = Context::new();
63+
let ss = match env::var("TWK_USE_FONT") {
64+
Ok(v) => Some(v),
65+
Err(_) => None
66+
};
67+
ctx.insert("USE_FONT", &ss);
68+
ctx.insert("FALLBACK_FAMILY", "monospace");
69+
ctx
70+
}
71+
5972
fn init_tracing() {
6073
tracing_subscriber::registry()
6174
.with(
@@ -71,14 +84,14 @@ async fn display_task_details(Query(param): Query<HashMap<String, String>>) -> H
7184
let task = get_task_details(task_id).unwrap();
7285
let tq = TaskQuery::new(TWGlobalState::default());
7386
let tasks = list_tasks(&tq).unwrap();
74-
let mut ctx = Context::new();
87+
let mut ctx = get_default_context();
7588
ctx.insert("tasks_db", &tasks);
7689
ctx.insert("task", &task);
7790
Html(TEMPLATES.render("task_details.html", &ctx).unwrap())
7891
}
7992

8093
async fn get_active_task() -> Html<String> {
81-
let mut ctx = Context::new();
94+
let mut ctx = get_default_context();
8295
if let Ok(v) = fetch_active_task() {
8396
if let Some(v) = v {
8497
ctx.insert("active_task", &v);
@@ -88,13 +101,13 @@ async fn get_active_task() -> Html<String> {
88101
}
89102

90103
async fn get_task_action_bar() -> Html<String> {
91-
let ctx = Context::new();
104+
let ctx = get_default_context();
92105
Html(TEMPLATES.render("task_action_bar.html", &ctx).unwrap())
93106
}
94107

95108
async fn get_bar(Query(param): Query<HashMap<String, String>>) -> Html<String> {
96109
if let Some(bar) = param.get("bar") {
97-
let ctx = Context::new();
110+
let ctx = get_default_context();
98111
if bar == "left_action_bar" {
99112
Html(TEMPLATES.render("left_action_bar.html", &ctx).unwrap())
100113
} else {
@@ -106,7 +119,7 @@ async fn get_bar(Query(param): Query<HashMap<String, String>>) -> Html<String> {
106119
}
107120

108121
async fn get_tag_bar() -> Html<String> {
109-
let ctx = Context::new();
122+
let ctx = get_default_context();
110123
Html(TEMPLATES.render("tag_bar.html", &ctx).unwrap())
111124
}
112125

@@ -115,7 +128,7 @@ async fn just_empty() -> Html<String> {
115128
}
116129

117130
async fn display_flash_message(Query(msg): Query<FlashMsg>) -> Html<String> {
118-
let mut ctx = Context::new();
131+
let mut ctx = get_default_context();
119132
ctx.insert("msg", &msg.msg());
120133
ctx.insert("timeout", &msg.timeout());
121134
Html(TEMPLATES.render("flash_msg.html", &ctx).unwrap())
@@ -124,7 +137,7 @@ async fn display_flash_message(Query(msg): Query<FlashMsg>) -> Html<String> {
124137
async fn get_undo_report() -> Html<String> {
125138
match task_undo_report() {
126139
Ok(s) => {
127-
let mut ctx = Context::new();
140+
let mut ctx = get_default_context();
128141
let lines = s.lines();
129142
let first_line: String = lines.clone().take(1).collect();
130143
let mut rest_lines: Vec<String> = lines.skip(1).map(|v| v.to_string()).collect();
@@ -134,7 +147,7 @@ async fn get_undo_report() -> Html<String> {
134147
Html(TEMPLATES.render("undo_report.html", &ctx).unwrap())
135148
}
136149
Err(e) => {
137-
let mut ctx = Context::new();
150+
let mut ctx = get_default_context();
138151
ctx.insert("heading", &e.to_string());
139152
Html(TEMPLATES.render("error.html", &ctx).unwrap())
140153
}
@@ -154,7 +167,7 @@ async fn display_task_add_window(Query(params): Query<TWGlobalState>) -> Html<St
154167
})
155168
.or(Some(TaskQuery::default()))
156169
.unwrap();
157-
let mut ctx = Context::new();
170+
let mut ctx = get_default_context();
158171
ctx.insert("tags", &tq.tags().join(" "));
159172
ctx.insert("project", tq.project());
160173
Html(TEMPLATES.render("task_add.html", &ctx).unwrap())
@@ -270,7 +283,7 @@ async fn front_page() -> Html<String> {
270283
task_list,
271284
task_shortcut_map,
272285
} = get_tasks_view_data(tasks, &filters);
273-
let mut ctx = Context::new();
286+
let mut ctx = get_default_context();
274287
ctx.insert("tasks_db", &tasks);
275288
ctx.insert("tasks", &task_list);
276289
ctx.insert("current_filter", &tq.as_filter_text());
@@ -321,7 +334,7 @@ fn get_tasks_view(tq: TaskQuery, flash_msg: Option<FlashMsg>) -> Html<String> {
321334
task_list, task_shortcut_map,
322335
} = get_tasks_view_data(tasks, &filter_ar);
323336
trace!("{:?}", tag_map);
324-
let mut ctx_b = Context::new();
337+
let mut ctx_b = get_default_context();
325338
ctx_b.insert("tasks_db", &tasks);
326339
ctx_b.insert("tasks", &task_list);
327340
ctx_b.insert("current_filter", &filter_ar);

0 commit comments

Comments
 (0)