Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This module defines the HTTP handlers for the job board home page.
//! This module defines the HTTP handlers for the jobs page.

use anyhow::Result;
use axum::{
Expand All @@ -12,17 +12,21 @@ use crate::{
auth::AuthSession,
db::DynDB,
handlers::{error::HandlerError, extractors::JobBoardId},
templates::{PageId, jobboard::home::Page},
templates::{
PageId,
jobboard::jobs::{ExploreSection, Page, ResultsSection},
},
};

/// Handler that returns the home page.
// Pages and sections handlers.

/// Handler that returns the jobs page.
#[instrument(skip_all, err)]
pub(crate) async fn page(
auth_session: AuthSession,
State(_db): State<DynDB>,
JobBoardId(_job_board_id): JobBoardId,
) -> Result<impl IntoResponse, HandlerError> {
// Prepare template
let template = Page {
logged_in: auth_session.user.is_some(),
page_id: PageId::JobBoard,
Expand All @@ -32,3 +36,19 @@ pub(crate) async fn page(

Ok(Html(template.render()?))
}

/// Handler that returns the explore section.
#[instrument(skip_all, err)]
pub(crate) async fn explore_section() -> Result<impl IntoResponse, HandlerError> {
let template = ExploreSection {};

Ok(Html(template.render()?))
}

/// Handler that returns the results section.
#[instrument(skip_all, err)]
pub(crate) async fn results_section() -> Result<impl IntoResponse, HandlerError> {
let template = ResultsSection {};

Ok(Html(template.render()?))
}
2 changes: 1 addition & 1 deletion gitjobs-server/src/handlers/jobboard/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This module defines the HTTP handlers for the job board site.

pub(crate) mod about;
pub(crate) mod home;
pub(crate) mod jobs;
6 changes: 4 additions & 2 deletions gitjobs-server/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ pub(crate) fn setup(
login_url = LOG_IN_URL,
redirect_field = "next_url"
))
.route("/", get(jobboard::home::page))
.route("/", get(jobboard::jobs::page))
.route("/about", get(jobboard::about::page))
.route("/health-check", get(health_check))
.route("/jobs", get(jobboard::home::page))
.route("/jobs", get(jobboard::jobs::page))
.route("/jobs/explore-section", get(jobboard::jobs::explore_section))
.route("/jobs/results-section", get(jobboard::jobs::results_section))
.route("/log-in", get(auth::log_in_page).post(auth::log_in))
.route("/log-in/oauth2/{provider}", get(auth::oauth2_redirect))
.route("/log-in/oauth2/{provider}/callback", get(auth::oauth2_callback))
Expand Down
18 changes: 0 additions & 18 deletions gitjobs-server/src/templates/jobboard/home.rs

This file was deleted.

30 changes: 30 additions & 0 deletions gitjobs-server/src/templates/jobboard/jobs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! This module defines some templates and types used in the jobs page.

use rinja::Template;
use serde::{Deserialize, Serialize};

use crate::templates::{PageId, filters};

/// Jobs page template.
#[derive(Debug, Clone, Template, Serialize, Deserialize)]
#[template(path = "jobboard/jobs/page.html")]
#[allow(clippy::struct_field_names)]
pub(crate) struct Page {
pub logged_in: bool,
pub page_id: PageId,

pub name: Option<String>,
pub username: Option<String>,
}

/// Explore section template.
#[derive(Debug, Clone, Template, Serialize, Deserialize)]
#[template(path = "jobboard/jobs/explore.html")]
#[allow(clippy::struct_field_names)]
pub(crate) struct ExploreSection {}

/// Results section template.
#[derive(Debug, Clone, Template, Serialize, Deserialize)]
#[template(path = "jobboard/jobs/results.html")]
#[allow(clippy::struct_field_names)]
pub(crate) struct ResultsSection {}
2 changes: 1 addition & 1 deletion gitjobs-server/src/templates/jobboard/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This module defines the templates for the job board pages.

pub(crate) mod about;
pub(crate) mod home;
pub(crate) mod jobs;
1 change: 1 addition & 0 deletions gitjobs-server/templates/jobboard/jobs/explore.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Jobs explore section</h1>
1 change: 1 addition & 0 deletions gitjobs-server/templates/jobboard/jobs/results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Jobs results section</h1>