Skip to content

Commit

Permalink
Add timezone selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Cantido committed Jan 21, 2024
1 parent 61ca4f7 commit 90a09c2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ time = { version = "0.3.31", features = ["serde"] }
tokio = { version = "1.35.1", features = ["full"], optional = true }
tower-http = { version = "0.5.1", features = ["fs"], optional = true }
tz-rs = "0.6.14"
tzdb = "0.6.1"
uuid = { version = "1.7.0", features = ["v7"], optional = true }

[build-dependencies]
Expand Down
7 changes: 6 additions & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ pub fn router() -> Result<Router> {
Ok(router)
}

#[derive(Serialize)]
struct IndexHtml<'a> {
timezones: &'a[&'a str],
}

async fn get_index(State(state): State<Arc<AppState<'_>>>) -> Result<Response, Response> {
let data: HashMap<String, String> = HashMap::new();
let data = IndexHtml { timezones: tzdb::TZ_NAMES };
let body = state
.handlebars
.render("index", &data)
Expand Down
8 changes: 8 additions & 0 deletions templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ https://waifu-calendar.fly.dev/ics?username=Owldown
AniList username
<input id="username-field" name="username" autocomplete="username" type="text" minlength="2" maxlength="64" pattern="^[^\s]*$" required />
</label>
<label>
Time zone
<select "tz-select" name="tz">
{{#each timezones}}
<option>{{this}}</option>
{{/each}}
</select>
</label>
<button type="submit" formaction="/cal">View Calendar</button>
<button type="submit" formaction="/ics">Download ICS</button>
</form>
Expand Down

0 comments on commit 90a09c2

Please sign in to comment.