add icons
This commit is contained in:
parent
d8ffb7cf75
commit
b2f7640b29
3 changed files with 17 additions and 1 deletions
|
@ -6,5 +6,6 @@ services:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./config.yml:/config.yml
|
- ./config.yml:/config.yml
|
||||||
|
- ./icons:/static/icons
|
||||||
environment:
|
environment:
|
||||||
ROCKET_ADDRESS: 0.0.0.0
|
ROCKET_ADDRESS: 0.0.0.0
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub struct Config {
|
||||||
pub struct Project {
|
pub struct Project {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
pub icon: Option<String>,
|
||||||
pub website: Option<String>,
|
pub website: Option<String>,
|
||||||
pub documentation: Option<String>,
|
pub documentation: Option<String>,
|
||||||
pub since: Option<String>,
|
pub since: Option<String>,
|
||||||
|
@ -47,6 +48,9 @@ impl Project {
|
||||||
|
|
||||||
maud::html!(
|
maud::html!(
|
||||||
div class="card" id=(card_id) {
|
div class="card" id=(card_id) {
|
||||||
|
@if let Some(icon) = &self.icon {
|
||||||
|
img src=(format!("/static/icons/{}", icon)) style="float: left; width: 200px; height: 200px;";
|
||||||
|
}
|
||||||
h3 { (self.name) };
|
h3 { (self.name) };
|
||||||
p { (self.description) };
|
p { (self.description) };
|
||||||
@if let Some(website) = &self.website {
|
@if let Some(website) = &self.website {
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -1,10 +1,19 @@
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
use rocket::fs::NamedFile;
|
||||||
use rocket::response::content::RawHtml;
|
use rocket::response::content::RawHtml;
|
||||||
use rocket::{get, launch, routes, State};
|
use rocket::{get, launch, routes, State};
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod site;
|
mod site;
|
||||||
|
|
||||||
|
#[get("/icon/<file>")]
|
||||||
|
async fn icon_res(file: &str) -> Option<NamedFile> {
|
||||||
|
let path = Path::new("static/icons/").join(file);
|
||||||
|
NamedFile::open(path).await.ok()
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub fn main_page(c: &State<Config>) -> RawHtml<String> {
|
pub fn main_page(c: &State<Config>) -> RawHtml<String> {
|
||||||
RawHtml(site::gen_site(c))
|
RawHtml(site::gen_site(c))
|
||||||
|
@ -18,5 +27,7 @@ async fn rocket() -> _ {
|
||||||
.unwrap_or("./config.yml".to_string());
|
.unwrap_or("./config.yml".to_string());
|
||||||
let conf = config::Config::load(&conf_path);
|
let conf = config::Config::load(&conf_path);
|
||||||
|
|
||||||
rocket::build().mount("/", routes![main_page]).manage(conf)
|
rocket::build()
|
||||||
|
.mount("/", routes![main_page, icon_res])
|
||||||
|
.manage(conf)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue