index : sparkle-git.git

ascending towards madness

author holly sparkles <sparkles@holly.sh> 2023-12-08 17:23:09.0 +00:00:00
committer holly sparkles <sparkles@holly.sh> 2024-05-14 6:40:09.0 +00:00:00
commit
129083b88fe66facf8ec30c25b69db35de2fbb2d [patch]
tree
afc88a2288cf1d867bdd72c4bee5c2a0f7fd1dd0
parent
000c5dca60170c4efee0ecf91cac956211c48ead
download
129083b88fe66facf8ec30c25b69db35de2fbb2d.tar.gz

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(-)

diff --git a/src/methods/repo/about.rs b/src/methods/repo/about.rs
index b597f31..dd526d8 100644
--- a/src/methods/repo/about.rs
+++ b/src/methods/repo/about.rs
@@ -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,
    }))
}
diff --git a/src/methods/repo/commit.rs b/src/methods/repo/commit.rs
index e089ab7..eaea9aa 100644
--- a/src/methods/repo/commit.rs
+++ b/src/methods/repo/commit.rs
@@ -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,
    }))
}
diff --git a/src/methods/repo/diff.rs b/src/methods/repo/diff.rs
index 0a6a6c6..93fad14 100644
--- a/src/methods/repo/diff.rs
+++ b/src/methods/repo/diff.rs
@@ -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,
    }))
}

diff --git a/src/methods/repo/log.rs b/src/methods/repo/log.rs
index 1882317..eb0b1ef 100644
--- a/src/methods/repo/log.rs
+++ b/src/methods/repo/log.rs
@@ -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
diff --git a/src/methods/repo/refs.rs b/src/methods/repo/refs.rs
index 9ed2814..c94730a 100644
--- a/src/methods/repo/refs.rs
+++ b/src/methods/repo/refs.rs
@@ -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
diff --git a/src/methods/repo/summary.rs b/src/methods/repo/summary.rs
index d5cd176..24ed16b 100644
--- a/src/methods/repo/summary.rs
+++ b/src/methods/repo/summary.rs
@@ -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
diff --git a/src/methods/repo/tag.rs b/src/methods/repo/tag.rs
index 0b7dab4..036c845 100644
--- a/src/methods/repo/tag.rs
+++ b/src/methods/repo/tag.rs
@@ -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,
    }))
}
diff --git a/src/methods/repo/tree.rs b/src/methods/repo/tree.rs
index 485c2da..6fc8150 100644
--- a/src/methods/repo/tree.rs
+++ b/src/methods/repo/tree.rs
@@ -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,
                })))
            }
        },
diff --git a/templates/base.html b/templates/base.html
index d573141..95abc2b 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -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>