feat: add truncating repo description and commit messages in lists
- max_commit_message_length
- max_repo_desc_length
Diff
rgit.conf.example | 6 +++++-
src/configuration/mod.rs | 16 ++++++++++++++++
templates/index.html | 6 +++++-
templates/repo/macros/refs.html | 10 +++++++++-
4 files changed, 35 insertions(+), 3 deletions(-)
@@ -27,4 +27,8 @@ enable_index_owner = true
# Generate HTTPS clone urls
clone_prefix = 'https://git.mydomain.tld'
# Generate SSH clone urls
ssh_clone_prefix = 'ssh://git.mydomain.tld:/srv/git'
\ No newline at end of file
ssh_clone_prefix = 'ssh://git.mydomain.tld:/srv/git'
# Limit length of commit messages in the log to this; use 0 for no limit
max_commit_message_length = 80
# Limit length of repository descriptions; use 0 for no limit
max_repo_desc_length = 80
\ No newline at end of file
@@ -72,6 +72,20 @@ pub struct AppConfig {
pub ssh_clone_prefix: String,
pub max_commit_message_length: usize,
pub max_repo_desc_length: usize,
}
impl ::std::default::Default for AppConfig {
@@ -94,6 +108,8 @@ impl ::std::default::Default for AppConfig {
enable_index_owner: true,
clone_prefix: String::new(),
ssh_clone_prefix: String::new(),
max_commit_message_length: 0,
max_repo_desc_length: 0,
}
}
}
@@ -34,7 +34,11 @@
<td>
<a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
{%- if let Some(description) = repository.description -%}
{{- description -}}
{% if config.max_repo_desc_length > 0 %}
{{- description|truncate(config.max_repo_desc_length.clone()) -}}
{% else %}
{{- description -}}
{% endif %}
{%- else -%}
Unnamed repository; edit this file 'description' to name the repository.
{%- endif -%}
@@ -78,7 +78,15 @@
{{- commit.committer.time.clone()|timeago -}}
</time>
</td>
<td><a href="/{{ repo.display() }}/commit/?id={{ commit.hash|hex }}">{{ commit.summary }}</a></td>
<td>
<a href="/{{ repo.display() }}/commit/?id={{ commit.hash|hex }}">
{% if config.max_commit_message_length.clone() > 0 %}
{{ commit.summary|truncate(config.max_commit_message_length.clone()) }}
{% else %}
{{ commit.summary }}
{% endif %}
</a>
</td>
<td>
<img src="https://www.gravatar.com/avatar/{{ commit.author.email|md5 }}?s=13&d=retro" width="13" height="13">
{{ commit.author.name }}