diff --git a/Rocket.toml b/Rocket.toml index 749c66e..5f84b00 100644 --- a/Rocket.toml +++ b/Rocket.toml @@ -1,8 +1,11 @@ [debug] static_route = "http://localhost:8001" cv_backend_path = "http://localhost:8002" +contact_path = "http://localhost:8004" [default] static_route = "http://localhost:8001" cv_backend_path = "http://localhost:8002" +contact_service = "http://localhost:8004" +pdf_service = "http://localhost:8003" default_person_name = "ovlach" diff --git a/src/lib.rs b/src/lib.rs index 27bbbea..60fa4da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ use nanobyte_tera::{hosts::static_filter, l18n::translate_filter, date::{calcula use ovlach_tera::entity::lang_entity; use rocket::{*, fairing::AdHoc}; use rocket_dyn_templates::Template; -use ::serde::Deserialize; +use ::serde::{Deserialize, Serialize}; use tools::tera::advanced_filter; pub mod routes; @@ -22,6 +22,13 @@ pub struct CVBackendConfig { cv_backend_path: String, } +#[derive(Serialize, Deserialize, Debug)] +#[serde(crate = "rocket::serde")] +pub struct FrontendSVCConfig { + pub contact_service: String, + pub pdf_service: String, +} + #[derive(Deserialize)] #[serde(crate = "rocket::serde")] pub struct DefaultPerson { @@ -55,6 +62,8 @@ pub fn rocket_builder() -> Rocket { AdHoc::config::() ).attach( AdHoc::config::() + ).attach( + AdHoc::config::() ).attach( nanobyte_opentelemetry::rocket::TracingFairing::ignite() ).mount("/", routes![ diff --git a/src/routes/root.rs b/src/routes/root.rs index c3dbb08..83ad1dc 100644 --- a/src/routes/root.rs +++ b/src/routes/root.rs @@ -8,27 +8,29 @@ use rocket::{get, State, response::Redirect, http::Status, futures::executor::en use rocket_dyn_templates::Template; use serde::Serialize; -use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig, tools::rocket::RequestLanguage, DefaultPerson}; +use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig, tools::rocket::RequestLanguage, DefaultPerson, FrontendSVCConfig}; #[derive(Serialize, Debug)] struct RootPage { static_host: String, cv: CV, - download_cv_url: String, lang: LanguageDescription, + contact_svc: String, + pdf_download_url: String } #[get("/")] pub async fn index(presentation_config: &State, cv_config: &State, language: RequestLanguage, client: OtelReqwestClient, -default_person: &State, span: TracingSpan) -> Result { +default_person: &State, frontend_svc: &State, span: TracingSpan) -> Result { let span = span.0.enter(); let context = match fetch_cv_data_from_backend(&cv_config.cv_backend_path, &default_person.default_person_name, &client.0).await { Ok(cv) => RootPage { static_host: presentation_config.static_route.clone(), cv, - download_cv_url: "FIXME!".to_string(), lang: LanguageDescription::new(&language.language.as_str(), "ovlach_frontend"), + contact_svc: frontend_svc.inner().contact_service.clone(), + pdf_download_url: format!("{}/cv/{}/output.pdf", frontend_svc.inner().pdf_service.clone(), default_person.default_person_name) }, Err(e) => { error!("Can't fetch CV data from backend {:?}", e); diff --git a/templates/default.html.tera b/templates/default.html.tera index 04a5054..8524316 100644 --- a/templates/default.html.tera +++ b/templates/default.html.tera @@ -50,7 +50,7 @@ @@ -132,6 +132,9 @@ {% endfor %} + {% for skill in cv.skills | filter(attribute="techtype",value="Language") | advanced_filter(attribute="skill", include_null="only") %} + {{ skill.name }}{% if not loop.last %},{% endif %} + {% endfor %}
{% for skill in cv.skills | filter(attribute="techtype",value="Technology") | advanced_filter(attribute="skill", include_null="none") %} @@ -145,6 +148,14 @@
{% endfor %} + {% for skill in cv.skills | filter(attribute="techtype",value="Technology") | advanced_filter(attribute="skill", include_null="only") %} + {{ skill.name }}{% if not loop.last %},{% endif %} + {% endfor %} + + +

{{ "frameworks-and-databases" | translate(lang=lang) }}

+
+
{% for skill in cv.skills | filter(attribute="techtype",value="Framework") | advanced_filter(attribute="skill", include_null="none") %}
{{ skill.name }}
@@ -156,11 +167,40 @@
{% endfor %} - {% for skill in cv.skills | filter(attribute="techtype",value="Technology") | advanced_filter(attribute="skill", include_null="only") %} - {{ skill.name }}, + {% for skill in cv.skills | filter(attribute="techtype",value="Framework") | advanced_filter(attribute="skill", include_null="only") %} + {{ skill.name }}{% if not loop.last %},{% endif %} + {% endfor %} +
+
+ {% for skill in cv.skills | filter(attribute="techtype",value="Database") | advanced_filter(attribute="skill", include_null="none") %} +
{{ skill.name }} +
+
+ {{ skill.skill}} +
+
+
+ {% endfor %} + {% for skill in cv.skills | filter(attribute="techtype",value="Database") | advanced_filter(attribute="skill", include_null="only") %} + {{ skill.name }}{% if not loop.last %},{% endif %} {% endfor %}
+
+ {{"tools" | translate(lang=lang)}}: {% for skill in cv.skills | filter(attribute="techtype",value="Tool") | advanced_filter(attribute="skill", include_null="all") %} + {{ skill.name }}{% if skill.skill %} - {{skill.skill}}{% endif %}, + {% endfor %} + {{"operating-systems" | translate(lang=lang)}}: {% for skill in cv.skills | filter(attribute="techtype",value="OperatingSystem") | advanced_filter(attribute="skill", include_null="all") %} + {{ skill.name }}{% if skill.skill %} - {{skill.skill}}{% endif %}{% if not loop.last %},{% endif %} + {% endfor %} +
+ {{"languages" | translate(lang=lang)}}: + {% for language in cv.languages %} + {{language.lang}} - {{language.level|translate(lang=lang)}} + {% if not loop.last %},{% endif %} + {% endfor %} @@ -168,13 +208,45 @@

{{ "work-experience" | translate(lang=lang) }}

- {% for job in cv.jobs %} + {% for job in cv.jobs | filter(attribute="jobtype", value="Contract") %} +
+
+
{{ job.title }} at {{ job.company }}
+
+
+ {% if job.languages and job.technologies %} + {{ job.languages | concat(with=job.technologies) }} + {% elif job.languages %} + {{job.languages}} + {% elif job.technologies %} + {{job.technologies}} + {% endif %} + {% if job.from | format_date(type="job") != job.to | format_date(type="job") %} +
{{ job.from | format_date(type="job") }} - {{ job.to | format_date(type="job") }}
+ {% else %} +
{{ job.from | format_date(type="job") }}
+ {% endif %} +
{{ job.description | lang_entity(lang=lang) }}
+
+
+ {% endfor %} +
+

{{ "work-freelance" | translate(lang=lang) }}

+
+ {% for job in cv.jobs | filter(attribute="jobtype", value="Freelance") %}
{{ job.title }} at {{ job.company }}
- {% if job.from | format_date(type="job") != job.from | format_date(type="job") %} + {% if job.languages and job.technologies %} + {{ job.languages | concat(with=job.technologies) }} + {% elif job.languages %} + {{job.languages}} + {% elif job.technologies %} + {{job.technologies}} + {% endif %} + {% if job.from | format_date(type="job") != job.to | format_date(type="job") %}
{{ job.from | format_date(type="job") }} - {{ job.to | format_date(type="job") }}
{% else %}
{{ job.from | format_date(type="job") }}
@@ -219,7 +291,7 @@
-
+