feat: add displaying custom logo, logo url, and logo alt text
Diff
src/methods/repo/about.rs | 4 ++++
src/methods/repo/commit.rs | 4 ++++
src/methods/repo/diff.rs | 4 ++++
src/methods/repo/log.rs | 4 ++++
src/methods/repo/refs.rs | 4 ++++
src/methods/repo/summary.rs | 4 ++++
src/methods/repo/tag.rs | 4 ++++
src/methods/repo/tree.rs | 6 ++++++
templates/base.html | 8 +++++++-
9 files changed, 41 insertions(+), 1 deletion(-)
@@ -5,6 +5,7 @@ use axum::{extract::Query, response::IntoResponse, Extension};
use serde::Deserialize;
use crate::{
configuration::AppConfig,
git::ReadmeFormat,
into_response,
methods::{
@@ -26,12 +27,14 @@ pub struct View {
repo: Repository,
readme: Option<(ReadmeFormat, Arc<str>)>,
branch: Option<Arc<str>>,
config: AppConfig,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
Extension(git): Extension<Arc<Git>>,
Extension(config): Extension<AppConfig>,
Query(query): Query<UriQuery>,
) -> Result<impl IntoResponse> {
let open_repo = git
@@ -44,5 +47,6 @@ pub async fn handle(
repo,
readme,
branch: query.branch,
config,
}))
}
@@ -5,6 +5,7 @@ use axum::{extract::Query, response::IntoResponse, Extension};
use serde::Deserialize;
use crate::{
configuration::AppConfig,
git::Commit,
into_response,
methods::{
@@ -22,6 +23,7 @@ pub struct View {
pub branch: Option<Arc<str>>,
pub dl_branch: Arc<str>,
pub id: Option<String>,
pub config: AppConfig,
}
#[derive(Deserialize)]
@@ -35,6 +37,7 @@ pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
Extension(git): Extension<Arc<Git>>,
Extension(config): Extension<AppConfig>,
Query(query): Query<UriQuery>,
) -> Result<impl IntoResponse> {
let open_repo = git.repo(repository_path, query.branch.clone()).await?;
@@ -65,5 +68,6 @@ pub async fn handle(
branch: query.branch,
id: query.id,
dl_branch,
config,
}))
}
@@ -9,6 +9,7 @@ use axum::{
};
use crate::{
configuration::AppConfig,
git::Commit,
http, into_response,
methods::{
@@ -24,12 +25,14 @@ pub struct View {
pub repo: Repository,
pub commit: Arc<Commit>,
pub branch: Option<Arc<str>>,
pub config: AppConfig,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
Extension(git): Extension<Arc<Git>>,
Extension(config): Extension<AppConfig>,
Query(query): Query<UriQuery>,
) -> Result<impl IntoResponse> {
let open_repo = git.repo(repository_path, query.branch.clone()).await?;
@@ -43,6 +46,7 @@ pub async fn handle(
repo,
commit,
branch: query.branch,
config,
}))
}
@@ -6,6 +6,7 @@ use axum::{extract::Query, response::IntoResponse, Extension};
use serde::Deserialize;
use crate::{
configuration::AppConfig,
database::schema::{commit::YokedCommit, repository::YokedRepository},
into_response,
methods::{
@@ -29,11 +30,13 @@ pub struct View {
commits: Vec<YokedCommit>,
next_offset: Option<u64>,
branch: Option<String>,
config: AppConfig,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(db): Extension<Arc<rocksdb::DB>>,
Extension(config): Extension<AppConfig>,
Query(query): Query<UriQuery>,
) -> Result<impl IntoResponse> {
tokio::task::spawn_blocking(move || {
@@ -56,6 +59,7 @@ pub async fn handle(
commits,
next_offset,
branch: query.branch,
config,
}))
})
.await
@@ -5,6 +5,7 @@ use askama::Template;
use axum::{response::IntoResponse, Extension};
use crate::{
configuration::AppConfig,
into_response,
methods::{
filters,
@@ -18,11 +19,13 @@ pub struct View {
repo: Repository,
refs: Refs,
branch: Option<Arc<str>>,
config: AppConfig,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(db): Extension<Arc<rocksdb::DB>>,
Extension(config): Extension<AppConfig>,
) -> Result<impl IntoResponse> {
tokio::task::spawn_blocking(move || {
let repository = crate::database::schema::repository::Repository::open(&db, &*repo)?
@@ -44,6 +47,7 @@ pub async fn handle(
repo,
refs: Refs { heads, tags },
branch: None,
config,
}))
})
.await
@@ -5,6 +5,7 @@ use askama::Template;
use axum::{response::IntoResponse, Extension};
use crate::{
configuration::AppConfig,
database::schema::{commit::YokedCommit, repository::YokedRepository},
into_response,
methods::{
@@ -20,11 +21,13 @@ pub struct View {
refs: Refs,
commit_list: Vec<YokedCommit>,
branch: Option<Arc<str>>,
config: AppConfig,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(db): Extension<Arc<rocksdb::DB>>,
Extension(config): Extension<AppConfig>,
) -> Result<impl IntoResponse> {
tokio::task::spawn_blocking(move || {
let repository = crate::database::schema::repository::Repository::open(&db, &*repo)?
@@ -48,6 +51,7 @@ pub async fn handle(
refs: Refs { heads, tags },
commit_list: commits,
branch: None,
config,
}))
})
.await
@@ -5,6 +5,7 @@ use axum::{extract::Query, response::IntoResponse, Extension};
use serde::Deserialize;
use crate::{
configuration::AppConfig,
git::DetailedTag,
into_response,
methods::{
@@ -26,12 +27,14 @@ pub struct View {
repo: Repository,
tag: DetailedTag,
branch: Option<Arc<str>>,
config: AppConfig,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
Extension(git): Extension<Arc<Git>>,
Extension(config): Extension<AppConfig>,
Query(query): Query<UriQuery>,
) -> Result<impl IntoResponse> {
let open_repo = git.repo(repository_path, Some(query.name.clone())).await?;
@@ -41,5 +44,6 @@ pub async fn handle(
repo,
tag,
branch: Some(query.name),
config,
}))
}
@@ -8,6 +8,7 @@ use axum::{extract::Query, response::IntoResponse, Extension};
use serde::Deserialize;
use crate::{
configuration::AppConfig,
git::{FileWithContent, PathDestination, TreeItem},
into_response,
methods::{
@@ -51,6 +52,7 @@ pub struct TreeView {
pub items: Vec<TreeItem>,
pub query: UriQuery,
pub branch: Option<Arc<str>>,
pub config: AppConfig,
}
#[derive(Template)]
@@ -59,6 +61,7 @@ pub struct FileView {
pub repo: Repository,
pub file: FileWithContent,
pub branch: Option<Arc<str>>,
pub config: AppConfig,
}
pub async fn handle(
@@ -66,6 +69,7 @@ pub async fn handle(
Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
Extension(ChildPath(child_path)): Extension<ChildPath>,
Extension(git): Extension<Arc<Git>>,
Extension(config): Extension<AppConfig>,
Query(query): Query<UriQuery>,
) -> Result<impl IntoResponse> {
let open_repo = git.repo(repository_path, query.branch.clone()).await?;
@@ -81,6 +85,7 @@ pub async fn handle(
items,
branch: query.branch.clone(),
query,
config,
})))
}
PathDestination::File(file) if query.raw => ResponseEither::Right(file.content),
@@ -89,6 +94,7 @@ pub async fn handle(
repo,
file,
branch: query.branch,
config,
})))
}
},
@@ -11,7 +11,13 @@
<body>
<header>
<h1>
<a href="/" class="no-hover">🏡</a>
<a href="{{ config.logo_link }}" class="no-hover">
{% if config.logo.is_empty() %}
{{ config.logo_alt }}
{% else %}
<img src="{{ config.logo }}" alt="{{ config.logo_alt }}">
{% endif %}
</a>
{% block header -%}{{ config.root_title }}{%- endblock %}
</h1>
</header>