refactor
This commit is contained in:
parent
f2b24d33e1
commit
6d55f0ff92
2 changed files with 6 additions and 10 deletions
|
@ -17,10 +17,10 @@ fn read_json_file(f: &str) -> Option<Value> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn new() -> Config {
|
pub fn new() -> Self {
|
||||||
let v = read_json_file("./config/config.json").expect("could not read config file");
|
let v = read_json_file("./config/config.json").expect("could not read config file");
|
||||||
let c = read_json_file("./config/colors.json");
|
let c = read_json_file("./config/colors.json");
|
||||||
Config { root: v, color: c }
|
Self { root: v, color: c }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> Option<String> {
|
pub fn name(&self) -> Option<String> {
|
||||||
|
|
|
@ -132,7 +132,7 @@ fn build_information_block(conf: &web::Data<config::Config>) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_contact_block(conf: &web::Data<config::Config>) -> String {
|
fn build_contact_block(conf: &web::Data<config::Config>) -> String {
|
||||||
if let Some(email) = conf.email() {
|
conf.email().map_or_else(String::new, |email| {
|
||||||
let pgp_key_message = if std::path::Path::new("./config/pub.key").exists() {
|
let pgp_key_message = if std::path::Path::new("./config/pub.key").exists() {
|
||||||
html! {
|
html! {
|
||||||
a href="/public_key" { "My PGP Key" };
|
a href="/public_key" { "My PGP Key" };
|
||||||
|
@ -158,13 +158,11 @@ fn build_contact_block(conf: &web::Data<config::Config>) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.into_string()
|
.into_string()
|
||||||
} else {
|
})
|
||||||
String::new()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_donation_block(conf: &web::Data<config::Config>) -> String {
|
fn build_donation_block(conf: &web::Data<config::Config>) -> String {
|
||||||
if let Some(xmr_addr) = conf.xmr_address() {
|
conf.xmr_address().map_or_else(String::new, |xmr_addr| {
|
||||||
html! {
|
html! {
|
||||||
div class="container" style="margin-top: 20px" {
|
div class="container" style="margin-top: 20px" {
|
||||||
h1 {
|
h1 {
|
||||||
|
@ -179,9 +177,7 @@ fn build_donation_block(conf: &web::Data<config::Config>) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.into_string()
|
.into_string()
|
||||||
} else {
|
})
|
||||||
String::new()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue