mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-05-30 12:55:14 +00:00
Init Rust project
This commit is contained in:
parent
977bbb4ec0
commit
704c5f00d0
15 changed files with 1458 additions and 127 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,10 +1,19 @@
|
||||||
*
|
*
|
||||||
|
|
||||||
|
!assets/
|
||||||
|
|
||||||
|
!src/
|
||||||
|
!src/pages/
|
||||||
|
|
||||||
!.gitignore
|
!.gitignore
|
||||||
|
|
||||||
|
!Cargo.lock
|
||||||
|
|
||||||
!*.css
|
!*.css
|
||||||
!*.gif
|
!*.gif
|
||||||
!*.html
|
!*.html
|
||||||
!*.js
|
!*.js
|
||||||
!*.md
|
!*.md
|
||||||
|
!*.rs
|
||||||
|
!*.toml
|
||||||
!*.woff2
|
!*.woff2
|
||||||
|
|
20
.rustfmt.toml
Normal file
20
.rustfmt.toml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
condense_wildcard_suffixes = true
|
||||||
|
control_brace_style = "ClosingNextLine"
|
||||||
|
enum_discrim_align_threshold = 25
|
||||||
|
force_explicit_abi = false
|
||||||
|
force_multiline_blocks = true
|
||||||
|
format_code_in_doc_comments = true
|
||||||
|
format_macro_matchers = true
|
||||||
|
format_strings = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
hex_literal_case = "Upper"
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
imports_layout = "Vertical"
|
||||||
|
match_block_trailing_comma = true
|
||||||
|
newline_style = "Unix"
|
||||||
|
normalize_comments = true
|
||||||
|
normalize_doc_attributes = true
|
||||||
|
reorder_impl_items = true
|
||||||
|
unstable_features = true
|
||||||
|
use_try_shorthand = true
|
||||||
|
wrap_comments = true
|
1164
Cargo.lock
generated
Normal file
1164
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
21
Cargo.toml
Normal file
21
Cargo.toml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[package]
|
||||||
|
name = "site"
|
||||||
|
description = "RGBCube's homepage."
|
||||||
|
authors = [ "RGBCube" ]
|
||||||
|
license = "GPL"
|
||||||
|
version = "0.1.0"
|
||||||
|
homepage = "https://rgbcube.github.io"
|
||||||
|
repositoty = "https://github.com/RGBCube/rgbcube.github.io"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.75"
|
||||||
|
axum = "0.7.2"
|
||||||
|
env_logger = "0.10.1"
|
||||||
|
log = "0.4.20"
|
||||||
|
maud = { git = "https://github.com/vidhanio/maud", branch = "patch-1", features = [ "axum" ] }
|
||||||
|
minify-js = "0.5.6"
|
||||||
|
tokio = { version = "1.35.1", features = [ "full" ] }
|
||||||
|
|
||||||
|
[build]
|
||||||
|
incremental = true
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
127
index.html
127
index.html
|
@ -1,127 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<meta property="og:type" content="website">
|
|
||||||
|
|
||||||
<title>RGBCube</title>
|
|
||||||
<meta name="author" content="RGBCube" />
|
|
||||||
|
|
||||||
<meta property="og:site_name" content="RGBCube" />
|
|
||||||
<meta property="og:title" content="RGBCube" />
|
|
||||||
|
|
||||||
<meta name="description" content="The official website and link portal of RGBCube and his work." />
|
|
||||||
<meta property="og:description" content="The official website and link portal of RGBCube and his work." />
|
|
||||||
|
|
||||||
<link rel="icon" href="favicon.gif" type="image/gif">
|
|
||||||
|
|
||||||
<meta property="og:image" content="/thumbnail.png" />
|
|
||||||
<meta property="og:image:type" content="image/png" />
|
|
||||||
<meta property="og:image:height" content="" />
|
|
||||||
<meta property="og:image:width" content="" />
|
|
||||||
|
|
||||||
<meta property="og:url" content="https://rgbcube.github.io/" />
|
|
||||||
<link rel="canonical" href="https://rgbcube.github.io/">
|
|
||||||
|
|
||||||
<link href="cube.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<style>
|
|
||||||
.frame:hover {
|
|
||||||
background-color: #FFFF00;
|
|
||||||
}
|
|
||||||
|
|
||||||
.face::after {
|
|
||||||
z-index: -1;
|
|
||||||
|
|
||||||
content: "";
|
|
||||||
|
|
||||||
height: inherit;
|
|
||||||
width: inherit;
|
|
||||||
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.front {
|
|
||||||
background: linear-gradient(to bottom, cyan, blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
.front::after {
|
|
||||||
background: linear-gradient(to bottom, white, magenta);
|
|
||||||
mask-image: linear-gradient(to left, magenta, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.top {
|
|
||||||
background: linear-gradient(to bottom, lime, cyan);
|
|
||||||
}
|
|
||||||
|
|
||||||
.top::after {
|
|
||||||
background: linear-gradient(to bottom, yellow, white);
|
|
||||||
mask-image: linear-gradient(to left, white, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.back {
|
|
||||||
background: linear-gradient(to bottom, yellow, red);
|
|
||||||
}
|
|
||||||
|
|
||||||
.back::after {
|
|
||||||
background: linear-gradient(to bottom, lime, black);
|
|
||||||
mask-image: linear-gradient(to left, black, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.bottom {
|
|
||||||
background: linear-gradient(to bottom, blue, black);
|
|
||||||
}
|
|
||||||
|
|
||||||
.bottom::after {
|
|
||||||
background: linear-gradient(to bottom, magenta, red);
|
|
||||||
mask-image: linear-gradient(to left, red, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
|
||||||
background: linear-gradient(to bottom, white, magenta);
|
|
||||||
}
|
|
||||||
|
|
||||||
.right::after {
|
|
||||||
background: linear-gradient(to bottom, yellow, red);
|
|
||||||
mask-image: linear-gradient(to left, red, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.left {
|
|
||||||
background: linear-gradient(to bottom, lime, black);
|
|
||||||
}
|
|
||||||
|
|
||||||
.left::after {
|
|
||||||
background: linear-gradient(to bottom, cyan, blue);
|
|
||||||
mask-image: linear-gradient(to left, blue, transparent);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="scene">
|
|
||||||
<div class="cube">
|
|
||||||
<div class="face front">
|
|
||||||
<a href="contact">
|
|
||||||
<div class="frame">contact</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="face top">
|
|
||||||
<a href="https://github.com/RGBCube">
|
|
||||||
<div class="frame">github</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="face back"></div>
|
|
||||||
<div class="face bottom"></div>
|
|
||||||
<div class="face right"></div>
|
|
||||||
<div class="face left"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="cube.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
1
src/constants.rs
Normal file
1
src/constants.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub const URL: &'static str = "https://rgbcube.github.io/";
|
31
src/cube.rs
Normal file
31
src/cube.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use maud::{
|
||||||
|
html,
|
||||||
|
Markup,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::page;
|
||||||
|
|
||||||
|
const FACES: [&str; 6] = ["front", "top", "back", "bottom", "right", "left"];
|
||||||
|
|
||||||
|
pub fn create(styling: &str, faces: [Markup; 6]) -> Markup {
|
||||||
|
page::create(
|
||||||
|
html! {
|
||||||
|
link href="cube.css" rel="stylesheet";
|
||||||
|
},
|
||||||
|
html! {
|
||||||
|
style {
|
||||||
|
(styling)
|
||||||
|
}
|
||||||
|
|
||||||
|
div class="scene" {
|
||||||
|
div class="cube" {
|
||||||
|
@for (name, content) in FACES.iter().zip(faces) {
|
||||||
|
div class=(format!("face {name}")) {
|
||||||
|
(content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
34
src/main.rs
Normal file
34
src/main.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
mod constants;
|
||||||
|
mod cube;
|
||||||
|
mod page;
|
||||||
|
mod pages;
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
|
use axum::{
|
||||||
|
routing::get,
|
||||||
|
Router,
|
||||||
|
};
|
||||||
|
use constants::*;
|
||||||
|
use env_logger::Target;
|
||||||
|
use log::LevelFilter;
|
||||||
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
env_logger::Builder::new()
|
||||||
|
.filter_level(LevelFilter::Info)
|
||||||
|
.target(Target::Stdout)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
let app = Router::new().route("/", get(pages::index));
|
||||||
|
|
||||||
|
let listener = TcpListener::bind("0.0.0.0:80")
|
||||||
|
.await
|
||||||
|
.with_context(|| "Failed to bind to 0.0.0.0:80")?;
|
||||||
|
|
||||||
|
axum::serve(listener, app)
|
||||||
|
.await
|
||||||
|
.with_context(|| "Server crashed")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
65
src/page.rs
Normal file
65
src/page.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
use maud::{
|
||||||
|
html,
|
||||||
|
Markup,
|
||||||
|
PreEscaped,
|
||||||
|
DOCTYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn property(name: &str, content: &str) -> Markup {
|
||||||
|
PreEscaped(
|
||||||
|
html! {
|
||||||
|
meta property=(name) content=(content);
|
||||||
|
}
|
||||||
|
.into_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pname(name: &str, content: &str) -> Markup {
|
||||||
|
PreEscaped(
|
||||||
|
html! {
|
||||||
|
meta name=(name) content=(content);
|
||||||
|
}
|
||||||
|
.into_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create(head: Markup, body: Markup) -> Markup {
|
||||||
|
html! {
|
||||||
|
(DOCTYPE)
|
||||||
|
|
||||||
|
head {
|
||||||
|
meta charset="UTF-8";
|
||||||
|
|
||||||
|
(pname("viewport", "width=device-width, initial-scale=1.0"))
|
||||||
|
(property("og:type", "website"))
|
||||||
|
|
||||||
|
@let name = "RGBCube";
|
||||||
|
|
||||||
|
title { (name) }
|
||||||
|
(pname("author", name))
|
||||||
|
|
||||||
|
(property("og:site_name", name))
|
||||||
|
(property("og:title", name))
|
||||||
|
|
||||||
|
@let description = "The official website and link portal of RGBCube and his work.";
|
||||||
|
(pname("description", description))
|
||||||
|
(property("og:description", description))
|
||||||
|
|
||||||
|
link rel="icon" href="icon.gif" type="image/gif";
|
||||||
|
|
||||||
|
(property("og:image", "thumbnail.png"))
|
||||||
|
(property("og:image:type", "image/png"))
|
||||||
|
(property("og:image:height", "1080"))
|
||||||
|
(property("og:image:width", "600"))
|
||||||
|
|
||||||
|
(property("og:url", crate::URL))
|
||||||
|
link rel="canonical" href=(crate::URL);
|
||||||
|
|
||||||
|
(PreEscaped(head.into_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
(PreEscaped(body.into_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
103
src/pages/index.rs
Normal file
103
src/pages/index.rs
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
use maud::{
|
||||||
|
html,
|
||||||
|
Markup,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::cube;
|
||||||
|
|
||||||
|
pub async fn generate() -> Markup {
|
||||||
|
cube::create(
|
||||||
|
STYLING,
|
||||||
|
[
|
||||||
|
html! {
|
||||||
|
a href="contact" {
|
||||||
|
div class="frame" {
|
||||||
|
"contact"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
html! {
|
||||||
|
a href="github" {
|
||||||
|
div class="frame" {
|
||||||
|
"github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
html! {},
|
||||||
|
html! {},
|
||||||
|
html! {},
|
||||||
|
html! {},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const STYLING: &str = r#"
|
||||||
|
.frame:hover {
|
||||||
|
background-color: #FFFF00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.face::after {
|
||||||
|
z-index: -1;
|
||||||
|
|
||||||
|
content: "";
|
||||||
|
|
||||||
|
height: inherit;
|
||||||
|
width: inherit;
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front {
|
||||||
|
background: linear-gradient(to bottom, cyan, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
.front::after {
|
||||||
|
background: linear-gradient(to bottom, white, magenta);
|
||||||
|
mask-image: linear-gradient(to left, magenta, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.top {
|
||||||
|
background: linear-gradient(to bottom, lime, cyan);
|
||||||
|
}
|
||||||
|
|
||||||
|
.top::after {
|
||||||
|
background: linear-gradient(to bottom, yellow, white);
|
||||||
|
mask-image: linear-gradient(to left, white, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.back {
|
||||||
|
background: linear-gradient(to bottom, yellow, red);
|
||||||
|
}
|
||||||
|
|
||||||
|
.back::after {
|
||||||
|
background: linear-gradient(to bottom, lime, black);
|
||||||
|
mask-image: linear-gradient(to left, black, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom {
|
||||||
|
background: linear-gradient(to bottom, blue, black);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom::after {
|
||||||
|
background: linear-gradient(to bottom, magenta, red);
|
||||||
|
mask-image: linear-gradient(to left, red, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
background: linear-gradient(to bottom, white, magenta);
|
||||||
|
}
|
||||||
|
|
||||||
|
.right::after {
|
||||||
|
background: linear-gradient(to bottom, yellow, red);
|
||||||
|
mask-image: linear-gradient(to left, red, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
background: linear-gradient(to bottom, lime, black);
|
||||||
|
}
|
||||||
|
|
||||||
|
.left::after {
|
||||||
|
background: linear-gradient(to bottom, cyan, blue);
|
||||||
|
mask-image: linear-gradient(to left, blue, transparent);
|
||||||
|
}
|
||||||
|
"#;
|
10
src/pages/mod.rs
Normal file
10
src/pages/mod.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
macro_rules! import {
|
||||||
|
($($ident:ident),*) => {
|
||||||
|
$(
|
||||||
|
mod $ident;
|
||||||
|
pub use $ident::generate as $ident;
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
import! { index }
|
Loading…
Add table
Add a link
Reference in a new issue