Skip to content

Commit

Permalink
feat: setup
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenLoc committed Dec 11, 2024
1 parent cbf1e5d commit 98716ae
Show file tree
Hide file tree
Showing 14 changed files with 1,699 additions and 52 deletions.
1,356 changes: 1,306 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ version = "0.1.0"
edition = "2021"

[dependencies]
rocket ={version = "0.5.0"}
maud = {version = "0.26"}
octocrab = "0.42.1"
webbrowser = "1.0.3"

[profile.dev]
opt-level = 0
54 changes: 54 additions & 0 deletions assets/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@



.fixed-container{
height: 300px;
padding-bottom: 3px;
}

.sidebar{
margin: 0;
padding: 0;
width: 100px;
height: 100%;
}

.flexcontainer{
display: flex;
flex-direction: row;
}

.border{
border-style: solid;
border-width: 2px;
border-color: white;
}

.full{
width: 100%;
height: 100%;
}

.nowrap{
white-space: nowrap;
}

.left-margin{
margin-left: 70px;
}

.skill-tag {
display: inline-block;
padding: 0.2rem 0.8rem;
margin: 0.2rem;
background: var(--primary);
color: var(--primary-inverse);
border-radius: 20px;
font-size: 0.9rem;
}
.interests {
background: var(--card-background-color);
padding: 1rem;
border-radius: var(--border-radius);
}

1 change: 1 addition & 0 deletions assets/htmx.min.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions assets/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use maud::{html, Markup};

#[allow(dead_code)]
pub fn list_of(any_vec: Vec<Markup>) -> Markup {
html! {
div {
@for m in &any_vec {
div { (m) }
}
}
}
}

#[allow(dead_code)]
pub fn grid_of(any_vec: Vec<Markup>) -> Markup {
html! {
div .container {
div class="grid"{
@for m in &any_vec {
div { (m) }
}
}
}
}
}

pub fn nav_button_with_class(text: &str, path: &str, class: &str) -> Markup {
html! {
button class=(class) hx-get=(path) hx-target="#body" { (text) }
}
}
4 changes: 4 additions & 0 deletions assets/pico.violet.min.css

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions assets/pico_ext.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@



:root {
--pico-font-family-sans-serif: Inter, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, Helvetica, Arial, "Helvetica Neue", sans-serif, var(--pico-font-family-emoji);
--pico-font-size: 87.5%;
/* Original: 100% */
--pico-line-height: 1.25;
/* Original: 1.5 */
--pico-form-element-spacing-vertical: 0.5rem;
/* Original: 1rem */
--pico-form-element-spacing-horizontal: 1.0rem;
/* Original: 1.25rem */
--pico-border-radius: 0.375rem;
/* Original: 0.25rem */
}

@media (min-width: 576px) {
:root {
--pico-font-size: 87.5%;
/* Original: 106.25% */
}
}

@media (min-width: 768px) {
:root {
--pico-font-size: 87.5%;
/* Original: 112.5% */
}
}

@media (min-width: 1024px) {
:root {
--pico-font-size: 87.5%;
/* Original: 118.75% */
}
}

@media (min-width: 1280px) {
:root {
--pico-font-size: 87.5%;
/* Original: 125% */
}
}

@media (min-width: 1536px) {
:root {
--pico-font-size: 87.5%;
/* Original: 131.25% */
}
}

h1,
h2,
h3,
h4,
h5,
h6 {
--pico-font-weight: 600;
/* Original: 700 */
}

article {
border: 1px solid var(--pico-muted-border-color);
/* Original doesn't have a border */
border-radius: calc(var(--pico-border-radius) * 2);
/* Original: var(--pico-border-radius) */
}

article>footer {
border-radius: calc(var(--pico-border-radius) * 2);
/* Original: var(--pico-border-radius) */
}
Binary file added assets/small_candle.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/assets/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use rocket::{response::content, Build, Rocket};

#[get("/pico.violet.min.css")]
fn pico_code() -> content::RawCss<&'static str> {
let pico = include_str!("../../assets/pico.violet.min.css");
content::RawCss(pico)
}

#[get("/app.css")]
fn app_css() -> content::RawCss<&'static str> {
let app = include_str!("../../assets/app.css");
content::RawCss(app)
}

#[get("/htmx.min.js")]
fn htmx_code() -> content::RawJavaScript<&'static str> {
let app = include_str!("../../assets/htmx.min.js");
content::RawJavaScript(app)
}

#[get("/pico_ext.css")]
fn pico_ext_css() -> content::RawCss<&'static str> {
let app = include_str!("../../assets/pico_ext.css");
content::RawCss(app)
}

pub fn mount_assets(rocket: Rocket<Build>) -> Rocket<Build> {
rocket.mount(
"/_assets",
routes![htmx_code, app_css, pico_code, pico_ext_css,],
)
}
31 changes: 29 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
fn main() {
println!("Hello, world!");
use rocket::{Build, Rocket};

#[macro_use]
extern crate rocket;

mod assets;
mod view;

#[launch]
fn rocket() -> _ {
let port = 12500;
let address = "0.0.0.0";

let config = rocket::Config::figment()
.merge(("port", port))
.merge(("address", address));
let rocket = rocket::custom(config);

webbrowser::open(&format!("http://{}:{}", address, port)).unwrap_or_default();
mount(rocket)
}

fn mount(rocket: Rocket<Build>) -> Rocket<Build> {
let with_index = rocket.mount(
"/",
routes![view::index, view::nav::get, view::dashboard::get,],
);

assets::mount_assets(with_index)
}
31 changes: 31 additions & 0 deletions src/view/components/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use maud::{html, Markup};

#[allow(dead_code)]
pub fn list_of(any_vec: Vec<Markup>) -> Markup {
html! {
div {
@for m in &any_vec {
div { (m) }
}
}
}
}

#[allow(dead_code)]
pub fn grid_of(any_vec: Vec<Markup>) -> Markup {
html! {
div .container {
div class="grid"{
@for m in &any_vec {
div { (m) }
}
}
}
}
}

pub fn nav_button_with_class(text: &str, path: &str, class: &str) -> Markup {
html! {
button class=(class) hx-get=(path) hx-target="#body" { (text) }
}
}
35 changes: 35 additions & 0 deletions src/view/dashboard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use maud::html;
use rocket::response::content;

#[get("/dashboard")]
pub fn get() -> content::RawHtml<String> {
let raw = html! {


article {

header {
h2 { "Dashboard" }

}

}

body{
div {
// GitHub
h3 { "GitHub" }
}
}


footer {
p{
"This is a work in progress."
}
}

}
.into_string();
content::RawHtml(raw)
}
60 changes: 60 additions & 0 deletions src/view/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use maud::{html, Markup, PreEscaped};
use rocket::response::content;

mod components;
pub mod dashboard;
pub mod nav;

#[get("/")]
pub fn index() -> content::RawHtml<String> {
let raw = page(html! {
header {
// load nav always
div hx-get="/nav" hx-trigger="load" {}
// load home first
div hx-get="/dashboard" hx-trigger="load" hx-target="#body" {}
}

body {
div #body {}
}
})
.into_string();
content::RawHtml(raw)
}

const CSS: &str = r#"<link rel="stylesheet" href="_assets/app.css">"#;
const PICO_EXT: &str = r#"<link rel="stylesheet" href="_assets/pico_ext.css">"#;
const HTMX: &str = r#"<script src="/_assets/htmx.min.js"></script>"#;
const PICO: &str = r#"<link rel="stylesheet" href="_assets/pico.violet.min.css">"#;

pub fn page(markup: Markup) -> Markup {
html! {
html {

head {
({scripts()})
({title("Candle")})
}

body class="container" {
(markup)
}
}
}
}

fn scripts() -> Markup {
html! {
(PreEscaped(CSS))
(PreEscaped(HTMX))
(PreEscaped(PICO_EXT))
(PreEscaped(PICO))
}
}

fn title(title: impl Into<String>) -> Markup {
html! {
title { ({title.into()}) }
}
}
Loading

0 comments on commit 98716ae

Please sign in to comment.