Optionally link to listing from repo pages
A little more vanity for the public instance won't hurt
- Id
- 3568e28ea3f5f263c23430be5f65688347e25909
- Author
- Caio
- Commit time
- 2024-03-09T10:22:37+01:00
Modified caca/src/config.rs
base_url: String::from("http://localhost:42080"),
clone_base_url: None,
reverse_proxy_base: None,
+ repo_to_listing_name: None,
},
max_file_size_bytes: 2 * 1024 * 1024,
rename_similarity_threshold: Some(0.7),
pub base_url: String,
// for mounting it as a subfolder when reverse proxying
pub reverse_proxy_base: Option<String>,
+ // fscking terrible name, but when set, a link to the index
+ // will appear before the repo name in every repo page header
+ pub repo_to_listing_name: Option<String>,
// override the url displayed for clone
// gets the repo name appended
base_url: "https://caio.co".to_string(),
reverse_proxy_base: Some("/de".to_string()),
clone_base_url: None,
+ repo_to_listing_name: Some("caio.co/de".to_string()),
},
global_mailmap: Some("/etc/caca/mailmap".into()),
listen_mode: ListenMode::External,
)
}
+ pub fn listing_url(&self) -> String {
+ format!(
+ "{}/",
+ self.site.reverse_proxy_base.as_deref().unwrap_or_default()
+ )
+ }
+
pub fn repo_clone_url(&self, name: &str) -> String {
if let Some(ref url) = self.site.clone_base_url {
format!("{url}/{name}",)
}
"reverse-proxy-base" => {
config.site.reverse_proxy_base =
+ Some(String::from_utf8_lossy(value).into_owned());
+ }
+ "repo-to-listing-name" => {
+ config.site.repo_to_listing_name =
Some(String::from_utf8_lossy(value).into_owned());
}
_ => {
listing-html-header = <h1>caio.<strong>co/de</strong></h1>
base-url = https://caio.co
reverse-proxy-base = /de
+repo-to-listing-name = caio.co/de
[core]
listen = external
Modified caca/theme/repo.html
{% extends "base.html" %}
{% block title %}{{ repo.name }}{% if repo.description %} - {{ repo.description }}{% endif %} {% endblock title %}
{% block header %}
-<h3><a class="nodec" href="{{ repo.url }}">{{ repo.name }}</a></h3>
+<h3>{% if repo.listing_name %}<a class="nodec" href="{{ repo.listing_url }}">{{ repo.listing_name }}</a>/{% endif %}<a
+ class="nodec" href="{{ repo.url }}">{{
+ repo.name }}</a></h3>
{% if nav %}
<nav>
<ol>
Modified caca/src/repo/mod.rs
pub name: String,
pub clone_url: String,
pub repo_url: String,
+ pub listing_url: String,
+ pub listing_name: Option<String>,
pub feed_base_url: String,
pub reverse_proxy_base: String,
pub snapshot: Snapshot,
let clone_url = config.repo_clone_url(&name);
let repo_url = config.repo_url(&name);
+ let listing_url = config.listing_url();
+ let listing_name = config.site.repo_to_listing_name.clone();
let reverse_proxy_base = config
.site
name,
repo_url,
clone_url,
+ listing_url,
+ listing_name,
feed_base_url: config.feed_base_url(),
snapshot,
mailmap,
name: &self.name,
url: &self.repo_url,
clone_url: &self.clone_url,
+ listing_url: &self.listing_url,
+ listing_name: self.listing_name.as_deref(),
description: self.snapshot.metadata.description.as_deref(),
}
}
description: Option<&'a str>,
url: &'a str,
clone_url: &'a str,
+ listing_url: &'a str,
+ listing_name: Option<&'a str>,
}
#[derive(Debug, serde::Serialize)]