/// Landing Page Handler
///
/// Generates HTML landing page for the Nostr relay.
use crate::config::Config;
/// Generate the HTML landing page
pub fn get_html(config: &Config) -> String {
format!(
include_str!("../../templates/landing.html"),
relay_name = config.relay_name,
relay_description = config.relay_description,
domain = config.domain,
bind_address = config.bind_address,
)
}
/// Generate a generic 404 page for unknown paths
///
/// Used for any path that doesn't match a known route
pub fn get_generic_404_html(config: &Config, path: &str) -> String {
format!(
r#"
Not Found - {relay_name}
404
Not Found
The page you're looking for doesn't exist.
"#,
relay_name = config.relay_name,
path = path,
)
}
/// Generate a 404 page for a non-existent repository
///
/// GRASP-01: "...and a 404 page for repositories it doesn't host"
pub fn get_404_html(config: &Config, npub: &str, identifier: &str) -> String {
format!(
r#"
Repository Not Found - {relay_name}
404
Repository Not Found
The repository you're looking for doesn't exist on this GRASP server.
Owner: {npub}
Repository: {identifier}
This repository may not have been announced to this server, or the URL may be incorrect.
"#,
relay_name = config.relay_name,
npub = npub,
identifier = identifier,
)
}
/// Generate a webpage for an existing repository
///
/// GRASP-01: "SHOULD serve a webpage at the same endpoint linking to git nostr client(s)
/// to browse the repository"
pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String {
let clone_url = format!(
"http://{}/{}/{}.git",
config.domain, npub, identifier
);
format!(
r#"
{identifier} - {relay_name}
📦 {identifier}
Git repository hosted on {relay_name}
📋 Repository Information
Owner: {npub}
Repository: {identifier}
🔗 Clone this Repository
git clone {clone_url}
🌐 Browse with Git Nostr Clients
You can browse this repository using these Git Nostr clients:
gitworkshop.dev - Web-based repository browser
Visit →
ngit - Command-line Git + Nostr tool
GitHub →
📚 About GRASP
This repository is hosted using the GRASP (Git Relays Authorized via Signed-Nostr Proofs) protocol.
"#,
relay_name = config.relay_name,
npub = npub,
identifier = identifier,
clone_url = clone_url,
)
}