Compare commits

..

No commits in common. "d97d02c0df0f2bdae5c9dc23b6f40bb55c016f0d" and "70bccc9ffcf759b42a3e3e6657143f7cc09f52a3" have entirely different histories.

6 changed files with 44 additions and 61 deletions

View file

@ -1,35 +0,0 @@
name: deploy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: host
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
registry: git.hydrar.de
username: ${{ secrets.registry_user }}
password: ${{ secrets.registry_password }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: git.hydrar.de/jmarya/me-site:latest

View file

@ -0,0 +1,25 @@
name: deploy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Docker
run: curl -fsSL https://get.docker.com | sh
- name: Log in to Docker registry
run: echo "${{ secrets.registry_password }}" | docker login -u "${{ secrets.registry_user }}" --password-stdin git.hydrar.de
- name: Build and push Docker image
run: |
docker build -t git.hydrar.de/jmarya/me-site:latest -t git.hydrar.de/jmarya/me-site:latest-amd64 .
docker push git.hydrar.de/jmarya/me-site:latest

View file

@ -5,10 +5,10 @@ WORKDIR /app
RUN cargo build --release
FROM debian:buster
FROM archlinux
RUN apt update && apt upgrade -y
RUN apt install -y gnupg ca-certificates openssl
RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm gnupg ca-certificates openssl-1.1
COPY --from=builder /app/target/release/me-site /me-site
COPY ./rocket.toml /rocket.toml

View file

@ -11,17 +11,21 @@ async fn download_file(url: &str, file: &str) {
#[get("/bootstrap.min.css")]
pub async fn bootstrap_css() -> Option<NamedFile> {
NamedFile::open("./cache/bootstrap.min.css").await.ok()
NamedFile::open("./cache/bootstrap.mi.await.ok()n.css")
.await
.ok()
}
#[get("/bootstrap-icons.css")]
pub async fn bootstrap_icons() -> Option<NamedFile> {
NamedFile::open("./cache/bootstrap-icons.css").await.ok()
NamedFile::open("./cache/bootstrap-icon.await.ok()s.css")
.await
.ok()
}
#[get("/bootstrap.bundle.min.js")]
pub async fn bootstrap_js() -> Option<NamedFile> {
NamedFile::open("./cache/bootstrap.bundle.min.js")
NamedFile::open("./cache/bootstrap.b.await.ok()undle.min.js")
.await
.ok()
}

View file

@ -1,6 +1,5 @@
use crate::config::Config;
use maud::{html, PreEscaped, DOCTYPE};
use rocket::http::ContentType;
use rocket::request::{FromRequest, Outcome, Request};
pub enum RequestClient {
@ -25,7 +24,7 @@ impl<'r> FromRequest<'r> for RequestClient {
pub fn is_browser(req: &Request) -> bool {
let ua = req
.headers()
.get("User-Agent")
.get("usesr-agent")
.next()
.unwrap()
.to_lowercase();
@ -38,7 +37,7 @@ pub async fn build_site(
disable_color: bool,
shadow: bool,
config: &Config,
) -> (ContentType, String) {
) -> String {
let mut c_class = "bg-dark text-white justify-content-center text-center".to_string();
let mut c_style = String::new();
let mut g_style = "a {text-decoration: none; font-weight: bold; color: white}".to_string();
@ -65,10 +64,7 @@ pub async fn build_site(
};
};
(
ContentType::HTML,
build_site_from_body(title, &body.into_string()),
)
build_site_from_body(title, &body.into_string())
}
pub fn build_site_from_body(title: &str, body: &str) -> String {

View file

@ -1,6 +1,5 @@
use crate::config;
use maud::{html, PreEscaped};
use rocket::http::ContentType;
use rocket::{form::Form, get, post, response::Redirect, uri, FromForm, State};
use serde::{Deserialize, Serialize};
@ -20,7 +19,7 @@ pub async fn message_post(msg: Form<MessageForm>, config: &State<config::Config>
}
#[get("/message")]
pub async fn message_page(config: &State<config::Config>) -> (ContentType, String) {
pub async fn message_page(config: &State<config::Config>) -> String {
let post_uri = uri!(message_post).to_string();
let resp = html! {
@ -40,10 +39,7 @@ pub async fn message_page(config: &State<config::Config>) -> (ContentType, Strin
}
#[get("/mirrors.txt")]
pub async fn mirrors(
r: RequestClient,
config: &State<config::Config>,
) -> Option<(ContentType, String)> {
pub async fn mirrors(r: RequestClient, config: &State<config::Config>) -> Option<String> {
if let Ok(mirror_file) = std::fs::File::open("./config/mirrors.txt") {
let content = std::io::read_to_string(mirror_file).ok()?;
if matches!(r, RequestClient::Browser) {
@ -57,17 +53,14 @@ pub async fn mirrors(
return Some(build_site(resp.into_string(), "Mirrors", false, true, config).await);
}
return Some((ContentType::Plain, content));
return Some(content);
}
None
}
#[get("/public_key")]
pub async fn public_key(
r: RequestClient,
config: &State<config::Config>,
) -> Option<(ContentType, String)> {
pub async fn public_key(r: RequestClient, config: &State<config::Config>) -> Option<String> {
if matches!(r, RequestClient::Browser) {
let host = config.base_url();
let key = std::io::read_to_string(
@ -97,7 +90,7 @@ pub async fn public_key(
if let Ok(key_f) = std::fs::File::open("./config/pub.key") {
if let Ok(key_data) = std::io::read_to_string(key_f) {
return Some((ContentType::Plain, key_data));
return Some(key_data);
}
}
@ -167,7 +160,7 @@ fn build_donation_block(conf: &config::Config) -> String {
}
#[get("/")]
pub async fn index(conf: &State<config::Config>) -> (ContentType, String) {
pub async fn index(conf: &State<config::Config>) -> String {
let information_block = build_information_block(conf);
let contact_block = build_contact_block(conf);
let donation_block = build_donation_block(conf);