Compare commits
2 Commits
8c64c5dbe3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ac59f65f2 | |||
| 4a25c377c4 |
13
assets/css/ip.css
Normal file
13
assets/css/ip.css
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
.ip {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ip h1 {
|
||||||
|
font-family: 'Indie Flower', cursive;
|
||||||
|
font-size: 60px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--clr-primary-a60);
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ use middleware::MimeType;
|
|||||||
use pages::{
|
use pages::{
|
||||||
files::file,
|
files::file,
|
||||||
index,
|
index,
|
||||||
|
ip::ip,
|
||||||
music::music,
|
music::music,
|
||||||
projects::{project, projects},
|
projects::{project, projects},
|
||||||
};
|
};
|
||||||
@@ -111,7 +112,8 @@ async fn main() {
|
|||||||
.service(index)
|
.service(index)
|
||||||
.service(projects)
|
.service(projects)
|
||||||
.service(project)
|
.service(project)
|
||||||
.service(music),
|
.service(music)
|
||||||
|
.service(ip),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind(bind_address)
|
.bind(bind_address)
|
||||||
@@ -119,7 +121,7 @@ async fn main() {
|
|||||||
match server.run().await {
|
match server.run().await {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("An error occurred: {e}");
|
println!("An error occurred: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/pages/ip.rs
Normal file
34
src/pages/ip.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use crate::html::elements::{Heading, Link};
|
||||||
|
use crate::html::layouts::Division;
|
||||||
|
use crate::html::pages::BasePage;
|
||||||
|
use crate::html::{Render, boxed_vec};
|
||||||
|
use actix_web::HttpRequest;
|
||||||
|
use actix_web::{Responder, get};
|
||||||
|
|
||||||
|
#[get("/ip")]
|
||||||
|
async fn ip(request: HttpRequest) -> impl Responder {
|
||||||
|
let info = request.connection_info();
|
||||||
|
let ip = info.realip_remote_addr();
|
||||||
|
|
||||||
|
let text = Heading::builder()
|
||||||
|
.text(format!(
|
||||||
|
"Your IP address is {}<br>Don't ask how I know.",
|
||||||
|
ip.unwrap_or("?")
|
||||||
|
))
|
||||||
|
.build();
|
||||||
|
let div = Division::builder()
|
||||||
|
.classes(vec!["ip"])
|
||||||
|
.elements(boxed_vec![text])
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let css = Link::builder()
|
||||||
|
.rel("stylesheet")
|
||||||
|
.href("/static/css/ip.css")
|
||||||
|
.build();
|
||||||
|
BasePage::builder()
|
||||||
|
.title("Your IP address")
|
||||||
|
.head(boxed_vec![css])
|
||||||
|
.body(boxed_vec![div])
|
||||||
|
.build()
|
||||||
|
.render()
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
pub(crate) mod files;
|
pub(crate) mod files;
|
||||||
|
pub(crate) mod ip;
|
||||||
pub(crate) mod music;
|
pub(crate) mod music;
|
||||||
pub(crate) mod projects;
|
pub(crate) mod projects;
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ use sqlx::query_as;
|
|||||||
async fn music(state: Data<AppState>) -> impl Responder {
|
async fn music(state: Data<AppState>) -> impl Responder {
|
||||||
let featured_title = HeadingBuilder::new()
|
let featured_title = HeadingBuilder::new()
|
||||||
.level(1)
|
.level(1)
|
||||||
.text("The song I've been listening to the most recently is \"Hot\" by Avril Lavigne.")
|
.text("The song I've been listening to the most recently is \"Shiawase - VIP\" by Dion Timmer.")
|
||||||
.build();
|
.build();
|
||||||
let featured_iframe = IframeBuilder::new()
|
let featured_iframe = IframeBuilder::new()
|
||||||
.src("https://www.youtube.com/embed/fzb75m8NuMQ")
|
.src("https://www.youtube.com/embed/suisIF4hwyw")
|
||||||
.build();
|
.build();
|
||||||
let featured = DivisionBuilder::new()
|
let featured = DivisionBuilder::new()
|
||||||
.classes(vec!["featured"])
|
.classes(vec!["featured"])
|
||||||
|
|||||||
Reference in New Issue
Block a user