,
request: Request,
next: middleware::Next,
) -> response::Response {
- let deadline = unlocker.start + unlocker.interval * day;
- let now = time::Instant::now();
- if now >= deadline {
+ if day == 0 {
+ day = 1;
+ }
+
+ if day == 69 {
+ return (http::StatusCode::FORBIDDEN, "Really?").into_response();
+ }
+
+ if day == 42 {
+ return (
+ http::StatusCode::FORBIDDEN,
+ "Oh, you have all the answers, huh?",
+ )
+ .into_response();
+ }
+
+ if day > 25 || day < 1 {
+ return (
+ http::StatusCode::FORBIDDEN,
+ "This isn't even a day in the advent calendar????",
+ )
+ .into_response();
+ }
+
+ let now = chrono::Utc::now();
+ let current_day = now.day();
+ let month = now.month();
+
+ if month != 12 {
+ return (
+ http::StatusCode::FORBIDDEN,
+ "It's not December yet! NO PEAKING",
+ )
+ .into_response();
+ }
+
+ //Show any day previous to the current day and current day
+ if day as u32 <= current_day {
return next.run(request).await;
}
- let time_remaining = deadline.saturating_duration_since(now);
- let error_response = axum::Json(serde_json::json!({
- "error": "Route Locked",
- "time_remaining_seconds": time_remaining.as_secs(),
- }));
- (http::StatusCode::FORBIDDEN, error_response).into_response()
+ (
+ http::StatusCode::FORBIDDEN,
+ "Now just hold on a minute. It ain't time yet.",
+ )
+ .into_response()
+
+ // Just commenting out for now if we do want a json endpoint and i forgot easiest way to return it
+ // let error_response = axum::Json(serde_json::json!({
+ // "error": "Route Locked",
+ // "time_remaining_seconds": time_remaining.as_secs(),
+ // }));
+
+ // (http::StatusCode::FORBIDDEN, error_response).into_response()
}
diff --git a/web/templates/day.askama.html b/web/templates/day.askama.html
new file mode 100644
index 0000000..32f6203
--- /dev/null
+++ b/web/templates/day.askama.html
@@ -0,0 +1,55 @@
+{% extends "layout.askama.html" %}
+
+{% block content %}
+ Day {{ day }}
+ Part 1:
+ {{ challenge_one_text | safe }}
+
+ {% if let Some(msg) = part_one_submit_message %}
+ {% match msg %}
+ {% when FlashMessage::Success with (success) %}
+ {{success}}
+ {% when FlashMessage::Error with (error) %}
+ {{error}}
+ {% endmatch %}
+ {% endif %}
+
+ {% if !challenge_one_completed %}
+
+ {% else %}
+ Great work, you've completed Part 1
+ {% endif %}
+
+
+ {% if let Some(challenge_two_text) = challenge_two_text %}
+
+ Part 2:
+ {{ challenge_two_text | safe }}
+ {% if let Some(msg) = part_two_submit_message %}
+ {% match msg %}
+ {% when FlashMessage::Success with (success) %}
+ {{success}}
+ {% when FlashMessage::Error with (error) %}
+ {{error}}
+ {% endmatch %}
+ {% endif %}
+ {% if !challenge_two_completed %}
+
+ {% endif %}
+
+ {% endif %}
+
+ {% if challenge_one_completed && challenge_two_completed %}
+
+ Great work, you've completed all the challenges for today! Come back tomorrow for more at 00:00 UTC
+ {% endif %}
+
+{% endblock %}
diff --git a/web/templates/error.askama.html b/web/templates/error.askama.html
new file mode 100644
index 0000000..dca9425
--- /dev/null
+++ b/web/templates/error.askama.html
@@ -0,0 +1,7 @@
+{% extends "layout.askama.html" %}
+
+{% block content %}
+An error occurred
+{{ message }}
+Return
+{% endblock %}
diff --git a/web/templates/index.askama.html b/web/templates/index.askama.html
new file mode 100644
index 0000000..28351ac
--- /dev/null
+++ b/web/templates/index.askama.html
@@ -0,0 +1,19 @@
+{% extends "layout.askama.html" %}
+
+{% block content %}
+
+
+ Unlocked days:
+ {% if unlocked_days.len() == 0 %}
+ No days are unlocked yet. Please check back in December!
+ {% else %}
+
+ {% for d in unlocked_days %}
+
Day {{ d }}
+ {% endfor %}
+
+ {% endif %}
+{% endblock %}
diff --git a/web/templates/layout.askama.html b/web/templates/layout.askama.html
new file mode 100644
index 0000000..fa6c451
--- /dev/null
+++ b/web/templates/layout.askama.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+ {% block content %}{% endblock %}
+
+
+
diff --git a/web/templates/login.askama.html b/web/templates/login.askama.html
new file mode 100644
index 0000000..30c2f47
--- /dev/null
+++ b/web/templates/login.askama.html
@@ -0,0 +1,27 @@
+{% extends "layout.askama.html" %}
+
+{% block content %}
+Login
+Enter your Bluesky handle to continue.
+{% if let Some(err) = error %}
+{{ err }}
+{% endif %}
+
+
+{% endblock %}