atproto-static-web 0.3.0

A simple web viewer for AT Proto.
//! atproto-static-web   A simple web viewer for AT Proto.
//! Copyright (C) 2025  AverageHelper
//!
//! This program is free software: you can redistribute it and/or modify
//! it under the terms of the GNU General Public License as published by
//! the Free Software Foundation, either version 3 of the License, or
//! (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program.  If not, see <https://www.gnu.org/licenses/>.

mod atproto;
mod constants;
mod env;
mod server;
mod templates;
mod xrpc;

use crate::{
	constants::{COPYRIGHT_YEAR, PKG_AUTHORS, PKG_NAME},
	env::Env,
};
use std::process::ExitCode;

#[macro_use]
extern crate rust_i18n;

i18n!("locales", fallback = "en");

#[rocket::main]
async fn main() -> ExitCode {
	// Print license on request
	if let Some(arg) = std::env::args_os().nth(1)
		&& arg == "license"
	{
		println!("{}", include_str!("../LICENSE"));
		return ExitCode::SUCCESS;
	}

	let env = match Env::new() {
		Ok(e) => e,
		Err(err) => {
			eprintln!("{err}");
			return ExitCode::FAILURE;
		}
	};

	// GPL notice
	println!(
		"{}  Copyright (C) {}  {}

This program comes with ABSOLUTELY NO WARRANTY.  This is
free software, and you are welcome to redistribute it
under certain conditions; type `{} license'
for details.",
		PKG_NAME, COPYRIGHT_YEAR, PKG_AUTHORS, PKG_NAME,
	);

	let rocket = match server::http_service(env).ignite().await {
		Ok(r) => r,
		Err(err) => {
			eprintln!("{err}");
			return ExitCode::FAILURE;
		}
	};

	if let Err(err) = rocket.launch().await {
		eprintln!("{err}");
		return ExitCode::FAILURE;
	}

	ExitCode::SUCCESS
}