date
This commit is contained in:
parent
6efbfc0e9c
commit
74d0caa569
@ -1,3 +1,7 @@
|
|||||||
[debug]
|
[debug]
|
||||||
static_route = "http://localhost:8001"
|
static_route = "http://localhost:8001"
|
||||||
|
cv_backend_path = "http://localhost:8002"
|
||||||
|
|
||||||
|
[default]
|
||||||
|
static_route = "http://localhost:8001"
|
||||||
cv_backend_path = "http://localhost:8002"
|
cv_backend_path = "http://localhost:8002"
|
@ -2,7 +2,7 @@
|
|||||||
use rocket::{*, fairing::AdHoc};
|
use rocket::{*, fairing::AdHoc};
|
||||||
use rocket_dyn_templates::Template;
|
use rocket_dyn_templates::Template;
|
||||||
use ::serde::Deserialize;
|
use ::serde::Deserialize;
|
||||||
use tools::tera::{static_filter, translate_filter, calculate_age, insert_space_every, lang_entity, gravatar_link};
|
use tools::tera::{static_filter, translate_filter, calculate_age, insert_space_every, lang_entity, gravatar_link, format_date};
|
||||||
|
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod services;
|
pub mod services;
|
||||||
@ -36,6 +36,7 @@ pub fn rocket_builder() -> Rocket<Build> {
|
|||||||
engines.tera.register_filter("gravatar_link", gravatar_link);
|
engines.tera.register_filter("gravatar_link", gravatar_link);
|
||||||
// filters specific to API
|
// filters specific to API
|
||||||
engines.tera.register_filter("lang_entity", lang_entity);
|
engines.tera.register_filter("lang_entity", lang_entity);
|
||||||
|
engines.tera.register_filter("format_date", format_date);
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
).attach(
|
).attach(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{collections::HashMap, str::FromStr};
|
use std::{collections::HashMap, str::FromStr};
|
||||||
|
|
||||||
use chrono::{Utc, Datelike};
|
use chrono::{Utc, Datelike, NaiveDate};
|
||||||
use log::error;
|
use log::error;
|
||||||
use rocket_dyn_templates::tera::{Value, Error};
|
use rocket_dyn_templates::tera::{Value, Error};
|
||||||
use ovlach_data::cv::chrono::from_string;
|
use ovlach_data::cv::chrono::from_string;
|
||||||
@ -56,7 +56,7 @@ pub fn lang_entity(
|
|||||||
value: &Value,
|
value: &Value,
|
||||||
_: &HashMap<String, rocket_dyn_templates::tera::Value>
|
_: &HashMap<String, rocket_dyn_templates::tera::Value>
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
error!("{:?}", value); // TODO: rewrite me!!!
|
// TODO: rewrite me!
|
||||||
return Ok(rocket_dyn_templates::tera::Value::String(format!("{}", value["en"].as_str().unwrap()))); // TODO: fix-me here!
|
return Ok(rocket_dyn_templates::tera::Value::String(format!("{}", value["en"].as_str().unwrap()))); // TODO: fix-me here!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +68,30 @@ pub fn gravatar_link(
|
|||||||
return Ok(rocket_dyn_templates::tera::Value::String(format!("https://gravatar.com/avatar/{}", val))); // TODO: fix-me here!
|
return Ok(rocket_dyn_templates::tera::Value::String(format!("https://gravatar.com/avatar/{}", val))); // TODO: fix-me here!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn format_date(
|
||||||
|
value: &Value,
|
||||||
|
_: &HashMap<String, rocket_dyn_templates::tera::Value>
|
||||||
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
|
if value.is_null() {
|
||||||
|
return Ok(rocket_dyn_templates::tera::Value::String("".to_string()))
|
||||||
|
}
|
||||||
|
let val = value.as_str().unwrap();
|
||||||
|
|
||||||
|
if val == "" {
|
||||||
|
return Ok(rocket_dyn_templates::tera::Value::String("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
let value = from_string(value.as_str().unwrap().into());
|
||||||
|
match value {
|
||||||
|
Ok(date) => Ok(rocket_dyn_templates::tera::Value::String(date.format("%Y").to_string())),
|
||||||
|
Err(e) => {
|
||||||
|
error!("Can't parse date: {}", e);
|
||||||
|
return Ok(rocket_dyn_templates::tera::Value::String("".to_string())) // TOdo: error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert_space_every(
|
pub fn insert_space_every(
|
||||||
value: &Value,
|
value: &Value,
|
||||||
args: &HashMap<String, rocket_dyn_templates::tera::Value>
|
args: &HashMap<String, rocket_dyn_templates::tera::Value>
|
||||||
@ -90,7 +114,6 @@ pub fn calculate_age(
|
|||||||
value: &Value,
|
value: &Value,
|
||||||
_: &HashMap<String, rocket_dyn_templates::tera::Value>
|
_: &HashMap<String, rocket_dyn_templates::tera::Value>
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
error!("{:?}", value.as_str());
|
|
||||||
//let s = value.to_string().trim_matches('"'); // TODO: unwrap here!
|
//let s = value.to_string().trim_matches('"'); // TODO: unwrap here!
|
||||||
let value = from_string(value.as_str().unwrap().into());
|
let value = from_string(value.as_str().unwrap().into());
|
||||||
match value {
|
match value {
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h2 class="h2 fw-light mb-4">{{ "about-me" | translate(lang=lang) }} </h2>
|
<h2 class="h2 fw-light mb-4">{{ "about-me" | translate(lang=lang) }} </h2>
|
||||||
<p>{{ cv.person.about | lang_entity }}</p>
|
<p>{{ cv.person.about | lang_entity(lang=lang) }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5 offset-lg-1">
|
<div class="col-md-5 offset-lg-1">
|
||||||
<div class="row mt-2">
|
<div class="row mt-2">
|
||||||
@ -147,8 +147,12 @@
|
|||||||
<div class="h5">{{ job.title }} <span class="text-muted h6">at {{ job.company }}</span></div>
|
<div class="h5">{{ job.title }} <span class="text-muted h6">at {{ job.company }}</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="timeline-body px-4 pb-4">
|
<div class="timeline-body px-4 pb-4">
|
||||||
<div class="text-muted text-small mb-3">May, 2015 - Present</div>
|
{% if job.from | format_date(type="job") != job.from | format_date(type="job") %}
|
||||||
<div>{{ job.description | lang_entity }} </div>
|
<div class="text-muted text-small mb-3">{{ job.from | format_date(type="job") }} - {{ job.to | format_date(type="job") }}</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="text-muted text-small mb-3">{{ job.from | format_date(type="job") }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<div>{{ job.description | lang_entity(lang=lang) }} </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -163,7 +167,7 @@
|
|||||||
<div class="timeline-card timeline-card-success" data-aos="fade-in" data-aos-delay="0">
|
<div class="timeline-card timeline-card-success" data-aos="fade-in" data-aos-delay="0">
|
||||||
<div class="timeline-head px-4 pt-3">
|
<div class="timeline-head px-4 pt-3">
|
||||||
{% if education.degree %}
|
{% if education.degree %}
|
||||||
<div class="h5">{{ education.degree | lang_entity }} <span class="text-muted h6">{{ education.school }}</span> </div>
|
<div class="h5">{{ education.degree | lang_entity(lang=lang) }} <span class="text-muted h6">{{ education.school }}</span> </div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="h5">{{ education.school }}</div>
|
<div class="h5">{{ education.school }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -171,8 +175,8 @@
|
|||||||
<div class="timeline-body px-4 pb-4">
|
<div class="timeline-body px-4 pb-4">
|
||||||
|
|
||||||
{% if education.description %}
|
{% if education.description %}
|
||||||
<div class="text-muted text-small mb-3">2011 - 2013</div>
|
<div class="text-muted text-small mb-3">{{ education.from | format_date(type="job") }} - {{ education.to | format_date(type="job") }}</div>
|
||||||
<div>{{ education.description | lang_entity }}</div>
|
<div>{{ education.description | lang_entity(lang=lang) }}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
2011 - 2013
|
2011 - 2013
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user