Compare commits
10 commits
70bccc9ffc
...
d97d02c0df
Author | SHA1 | Date | |
---|---|---|---|
d97d02c0df | |||
fec4912476 | |||
56a4dc46c1 | |||
2a093b3a88 | |||
065ab4979d | |||
717d343acc | |||
ba6cb5ea6d | |||
aa594ec1d8 | |||
a14bf93302 | |||
25931b97cf |
6 changed files with 61 additions and 44 deletions
35
.forgejo/workflows/deploy.yml
Normal file
35
.forgejo/workflows/deploy.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
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
|
|
@ -1,25 +0,0 @@
|
|||
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
|
|
@ -5,10 +5,10 @@ WORKDIR /app
|
|||
|
||||
RUN cargo build --release
|
||||
|
||||
FROM archlinux
|
||||
FROM debian:buster
|
||||
|
||||
RUN pacman -Syu --noconfirm
|
||||
RUN pacman -S --noconfirm gnupg ca-certificates openssl-1.1
|
||||
RUN apt update && apt upgrade -y
|
||||
RUN apt install -y gnupg ca-certificates openssl
|
||||
|
||||
COPY --from=builder /app/target/release/me-site /me-site
|
||||
COPY ./rocket.toml /rocket.toml
|
||||
|
|
|
@ -11,21 +11,17 @@ async fn download_file(url: &str, file: &str) {
|
|||
|
||||
#[get("/bootstrap.min.css")]
|
||||
pub async fn bootstrap_css() -> Option<NamedFile> {
|
||||
NamedFile::open("./cache/bootstrap.mi.await.ok()n.css")
|
||||
.await
|
||||
.ok()
|
||||
NamedFile::open("./cache/bootstrap.min.css").await.ok()
|
||||
}
|
||||
|
||||
#[get("/bootstrap-icons.css")]
|
||||
pub async fn bootstrap_icons() -> Option<NamedFile> {
|
||||
NamedFile::open("./cache/bootstrap-icon.await.ok()s.css")
|
||||
.await
|
||||
.ok()
|
||||
NamedFile::open("./cache/bootstrap-icons.css").await.ok()
|
||||
}
|
||||
|
||||
#[get("/bootstrap.bundle.min.js")]
|
||||
pub async fn bootstrap_js() -> Option<NamedFile> {
|
||||
NamedFile::open("./cache/bootstrap.b.await.ok()undle.min.js")
|
||||
NamedFile::open("./cache/bootstrap.bundle.min.js")
|
||||
.await
|
||||
.ok()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::config::Config;
|
||||
use maud::{html, PreEscaped, DOCTYPE};
|
||||
use rocket::http::ContentType;
|
||||
use rocket::request::{FromRequest, Outcome, Request};
|
||||
|
||||
pub enum RequestClient {
|
||||
|
@ -24,7 +25,7 @@ impl<'r> FromRequest<'r> for RequestClient {
|
|||
pub fn is_browser(req: &Request) -> bool {
|
||||
let ua = req
|
||||
.headers()
|
||||
.get("usesr-agent")
|
||||
.get("User-Agent")
|
||||
.next()
|
||||
.unwrap()
|
||||
.to_lowercase();
|
||||
|
@ -37,7 +38,7 @@ pub async fn build_site(
|
|||
disable_color: bool,
|
||||
shadow: bool,
|
||||
config: &Config,
|
||||
) -> String {
|
||||
) -> (ContentType, 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();
|
||||
|
@ -64,7 +65,10 @@ pub async fn build_site(
|
|||
};
|
||||
};
|
||||
|
||||
build_site_from_body(title, &body.into_string())
|
||||
(
|
||||
ContentType::HTML,
|
||||
build_site_from_body(title, &body.into_string()),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_site_from_body(title: &str, body: &str) -> String {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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};
|
||||
|
||||
|
@ -19,7 +20,7 @@ pub async fn message_post(msg: Form<MessageForm>, config: &State<config::Config>
|
|||
}
|
||||
|
||||
#[get("/message")]
|
||||
pub async fn message_page(config: &State<config::Config>) -> String {
|
||||
pub async fn message_page(config: &State<config::Config>) -> (ContentType, String) {
|
||||
let post_uri = uri!(message_post).to_string();
|
||||
|
||||
let resp = html! {
|
||||
|
@ -39,7 +40,10 @@ pub async fn message_page(config: &State<config::Config>) -> String {
|
|||
}
|
||||
|
||||
#[get("/mirrors.txt")]
|
||||
pub async fn mirrors(r: RequestClient, config: &State<config::Config>) -> Option<String> {
|
||||
pub async fn mirrors(
|
||||
r: RequestClient,
|
||||
config: &State<config::Config>,
|
||||
) -> Option<(ContentType, 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) {
|
||||
|
@ -53,14 +57,17 @@ pub async fn mirrors(r: RequestClient, config: &State<config::Config>) -> Option
|
|||
|
||||
return Some(build_site(resp.into_string(), "Mirrors", false, true, config).await);
|
||||
}
|
||||
return Some(content);
|
||||
return Some((ContentType::Plain, content));
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
#[get("/public_key")]
|
||||
pub async fn public_key(r: RequestClient, config: &State<config::Config>) -> Option<String> {
|
||||
pub async fn public_key(
|
||||
r: RequestClient,
|
||||
config: &State<config::Config>,
|
||||
) -> Option<(ContentType, String)> {
|
||||
if matches!(r, RequestClient::Browser) {
|
||||
let host = config.base_url();
|
||||
let key = std::io::read_to_string(
|
||||
|
@ -90,7 +97,7 @@ pub async fn public_key(r: RequestClient, config: &State<config::Config>) -> Opt
|
|||
|
||||
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(key_data);
|
||||
return Some((ContentType::Plain, key_data));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +167,7 @@ fn build_donation_block(conf: &config::Config) -> String {
|
|||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn index(conf: &State<config::Config>) -> String {
|
||||
pub async fn index(conf: &State<config::Config>) -> (ContentType, String) {
|
||||
let information_block = build_information_block(conf);
|
||||
let contact_block = build_contact_block(conf);
|
||||
let donation_block = build_donation_block(conf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue