Skip to content

Commit 7dbe54f

Browse files
author
root
committed
Rework repo sidebar
1 parent a770b78 commit 7dbe54f

File tree

9 files changed

+39
-35
lines changed

9 files changed

+39
-35
lines changed

Diff for: app/helpers/extend_repositories_helper.rb

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ def encoding_field(form, repository)
1010
end
1111

1212

13+
def available_download_format(repository, rev = nil)
14+
%w(zip tar tar.gz).map { |f| [f, download_git_revision_repository_path(repository, rev: rev, download_format: f)] }
15+
end
16+
17+
1318
def create_readme_field(form, repository)
1419
content_tag(:p) do
1520
hidden_field_tag('repository[create_readme]', 'false', id: '') +

Diff for: app/views/repositories/_download_revision.html.haml

+8-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
- if @repository.is_a?(Repository::Xitolite) && RedmineGitHosting::Config.download_revision_enabled?
2-
- if @repository.downloadable?
3-
4-
%div{ style: 'clear: both;' }
5-
6-
#git_hosting_download_buttons
7-
%ul
8-
%li
9-
= link_to label_with_icon(l(:label_download_format, :archive_format => '.tar'), 'fa-download'),
10-
download_git_revision_repository_path(@repository, :rev => @rev, :download_format => 'tar'),
11-
:class => 'button'
12-
13-
%li
14-
= link_to label_with_icon(l(:label_download_format, :archive_format => '.tar.gz'), 'fa-download'),
15-
download_git_revision_repository_path(@repository, :rev => @rev, :download_format => 'tar.gz'),
16-
:class => 'button'
17-
18-
%li
19-
= link_to label_with_icon(l(:label_download_format, :archive_format => '.zip'), 'fa-download'),
20-
download_git_revision_repository_path(@repository, :rev => @rev, :download_format => 'zip'),
21-
:class => 'button'
22-
23-
- content_for :header_tags do
24-
= bootstrap_load_module(:font_awesome)
1+
- if repository.downloadable?
2+
- content_for :header_tags do
3+
= bootstrap_load_module(:font_awesome)
4+
5+
= label_with_icon(l(:label_download_format), 'fa-download')
6+
= select_tag :download, options_for_select(available_download_format(repository, @rev)),
7+
prompt: l(:label_download_select_format),
8+
onchange: "if (this.value != '') { window.location = this.value; }"

Diff for: app/views/repositories/_show_top.html.haml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- if @repository.is_a?(Repository::Xitolite)
2+
.git_hosting_urls.box
3+
.container
4+
.row
5+
.col-md-8{ style: 'vertical-align: middle;' }
6+
= render 'common/git_urls', repository: @repository if RedmineGitHosting::Config.show_repositories_url?
7+
.col-md-4{ style: 'text-align: right; vertical-align: middle;' }
8+
= render 'repositories/download_revision', repository: @repository if RedmineGitHosting::Config.download_revision_enabled?

Diff for: app/views/repositories/_sidebar.html.haml

-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@
44
= link_to_repository(repo, @repository)
55
= link_to "(#{l(:label_settings)})", edit_repository_path(repo) if User.current.allowed_to?(:manage_repository, @project)
66

7-
- if @repository.is_a?(Repository::Xitolite) && RedmineGitHosting::Config.show_repositories_url?
8-
.git_hosting_urls
9-
%h3= l(:label_repository_access_url)
10-
= render 'common/git_urls', repository: @repository
11-
12-
= render 'repositories/download_revision'
13-
147
:javascript
158
$(document).ready(function() { $('#sidebar p').remove(); });

Diff for: assets/stylesheets/application.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ REPOSITORY VIEW
9797

9898
.git_hosting_urls {
9999
display: block;
100-
height: 90px;
101-
margin-bottom: 20px;
100+
margin-top: 10px;
101+
margin-bottom: 10px;
102+
}
103+
104+
.git_hosting_urls .repository-urls {
105+
margin-top: 0;
102106
}
103107

104108
#git_hosting_download_buttons i {

Diff for: config/locales/models/repository_xitolite/en.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ en:
4949
label_git_annex: GitAnnex
5050

5151
# Repository code browser
52-
label_download_format: Download as %{archive_format}
52+
label_download_format: Download as
53+
label_download_select_format: Select format
5354
error_download_revision_no_such_commit: "No such commit %{commit}"
5455

5556
# Repositories URL (labels)

Diff for: config/locales/models/repository_xitolite/fr.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fr:
4949
label_git_annex: GitAnnex
5050

5151
# Repository code browser
52-
label_download_format: Télécharger au format %{archive_format}
52+
label_download_format: Télécharger au format
53+
label_download_select_format: Sélectionnez un format
5354
error_download_revision_no_such_commit: "Le commit %{commit} n'a pas été trouvé"
5455

5556
# Repositories URL (labels)

Diff for: lib/redmine_git_hosting.rb

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
require 'redmine_git_hosting/hooks/add_public_keys_link'
2020
require 'redmine_git_hosting/hooks/display_git_urls_on_project'
2121
require 'redmine_git_hosting/hooks/display_git_urls_on_repository_edit'
22+
require 'redmine_git_hosting/hooks/display_git_urls_on_repository_show'
2223
require 'redmine_git_hosting/hooks/display_repository_extras'
2324
require 'redmine_git_hosting/hooks/display_repository_readme'
2425
require 'redmine_git_hosting/hooks/display_repository_sidebar'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module RedmineGitHosting
2+
module Hooks
3+
class DisplayGitUrlsOnRepositoryShow < Redmine::Hook::ViewListener
4+
render_on :view_repositories_show_contextual, partial: 'repositories/show_top'
5+
end
6+
end
7+
end

0 commit comments

Comments
 (0)