feat: add clone url display
- clone_prefix
- ssh_clone_prefix
- enable_http_clone
Diff
src/configuration/mod.rs | 5 +++++
src/database/indexer.rs | 5 +++++
src/database/schema/repository.rs | 4 ++++
src/methods/repo/summary.rs | 2 ++
templates/repo/summary.html | 35 +++++++++++++++++++++++++++++++++++
5 files changed, 51 insertions(+)
@@ -101,4 +101,9 @@ impl AppConfig {
pub fn load(path: String) -> Self {
confy::load_path(path).unwrap_or_default()
}
pub fn http_clone_enabled(&self) -> bool {
(!self.clone_prefix.is_empty() || !self.ssh_clone_prefix.is_empty())
&& self.enable_http_clone
}
}
@@ -88,6 +88,7 @@ fn update_repository_metadata(scan_path: &Path, db: &rocksdb::DB) {
.ok()
.flatten()
.map(Cow::Owned),
exported: is_repository_exported(repository_path.as_path()),
}
.insert(db, relative);
@@ -417,3 +418,7 @@ fn find_gitweb_owner(repository_path: &Path) -> Option<Cow<'_, str>> {
.map(String::from)
.map(Cow::Owned)
}
fn is_repository_exported(repository_path: &Path) -> Cow<'_, bool> {
Cow::Owned(repository_path.join("git-daemon-export-ok").exists())
}
@@ -33,6 +33,10 @@ pub struct Repository<'a> {
#[serde(borrow)]
pub default_branch: Option<Cow<'a, str>>,
pub exported: Cow<'a, bool>,
}
pub type YokedRepository = Yoked<Repository<'static>>;
@@ -22,6 +22,7 @@ pub struct View {
commit_list: Vec<YokedCommit>,
branch: Option<Arc<str>>,
config: AppConfig,
repo_exported: bool,
}
pub async fn handle(
@@ -52,6 +53,7 @@ pub async fn handle(
commit_list: commits,
branch: None,
config,
repo_exported: *repository.get().exported,
}))
})
.await
@@ -61,6 +61,41 @@
</tr>
</tbody>
{%- endif %}
{%- if repo_exported && config.http_clone_enabled() %}
<tbody>
<tr class="separator">
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="no-background">
<th>Clone</th>
<th></th>
<th></th>
<th></th>
</tr>
{% if !config.clone_prefix.is_empty() %}
<tr>
<td colspan="4">
<a rel="vcs-git" href="{{ config.clone_prefix }}/{{ repo.display() }}" title="{{ repo.display() }} Git repository">
{{ config.clone_prefix }}/{{ repo.display() }}
</a>
</td>
</tr>
{% endif %}
{% if !config.ssh_clone_prefix.is_empty() %}
<tr>
<td colspan="4">
<a rel="vcs-git" href="{{ config.ssh_clone_prefix }}/{{ repo.display() }}" title="{{ repo.display() }} Git repository">
{{ config.ssh_clone_prefix }}/{{ repo.display() }}
</a>
</td>
</tr>
{% endif %}
</tbody>
{%- endif %}
</table>
</div>
{% endblock %}