Skip to content

Commit

Permalink
Rework repo sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 24, 2016
1 parent a770b78 commit 7dbe54f
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 35 deletions.
5 changes: 5 additions & 0 deletions app/helpers/extend_repositories_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def encoding_field(form, repository)
end


def available_download_format(repository, rev = nil)
%w(zip tar tar.gz).map { |f| [f, download_git_revision_repository_path(repository, rev: rev, download_format: f)] }
end


def create_readme_field(form, repository)
content_tag(:p) do
hidden_field_tag('repository[create_readme]', 'false', id: '') +
Expand Down
32 changes: 8 additions & 24 deletions app/views/repositories/_download_revision.html.haml
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
- if @repository.is_a?(Repository::Xitolite) && RedmineGitHosting::Config.download_revision_enabled?
- if @repository.downloadable?

%div{ style: 'clear: both;' }

#git_hosting_download_buttons
%ul
%li
= link_to label_with_icon(l(:label_download_format, :archive_format => '.tar'), 'fa-download'),
download_git_revision_repository_path(@repository, :rev => @rev, :download_format => 'tar'),
:class => 'button'

%li
= link_to label_with_icon(l(:label_download_format, :archive_format => '.tar.gz'), 'fa-download'),
download_git_revision_repository_path(@repository, :rev => @rev, :download_format => 'tar.gz'),
:class => 'button'

%li
= link_to label_with_icon(l(:label_download_format, :archive_format => '.zip'), 'fa-download'),
download_git_revision_repository_path(@repository, :rev => @rev, :download_format => 'zip'),
:class => 'button'

- content_for :header_tags do
= bootstrap_load_module(:font_awesome)
- if repository.downloadable?
- content_for :header_tags do
= bootstrap_load_module(:font_awesome)

= label_with_icon(l(:label_download_format), 'fa-download')
= select_tag :download, options_for_select(available_download_format(repository, @rev)),
prompt: l(:label_download_select_format),
onchange: "if (this.value != '') { window.location = this.value; }"
8 changes: 8 additions & 0 deletions app/views/repositories/_show_top.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- if @repository.is_a?(Repository::Xitolite)
.git_hosting_urls.box
.container
.row
.col-md-8{ style: 'vertical-align: middle;' }
= render 'common/git_urls', repository: @repository if RedmineGitHosting::Config.show_repositories_url?
.col-md-4{ style: 'text-align: right; vertical-align: middle;' }
= render 'repositories/download_revision', repository: @repository if RedmineGitHosting::Config.download_revision_enabled?
7 changes: 0 additions & 7 deletions app/views/repositories/_sidebar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,5 @@
= link_to_repository(repo, @repository)
= link_to "(#{l(:label_settings)})", edit_repository_path(repo) if User.current.allowed_to?(:manage_repository, @project)

- if @repository.is_a?(Repository::Xitolite) && RedmineGitHosting::Config.show_repositories_url?
.git_hosting_urls
%h3= l(:label_repository_access_url)
= render 'common/git_urls', repository: @repository

= render 'repositories/download_revision'

:javascript
$(document).ready(function() { $('#sidebar p').remove(); });
8 changes: 6 additions & 2 deletions assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ REPOSITORY VIEW

.git_hosting_urls {
display: block;
height: 90px;
margin-bottom: 20px;
margin-top: 10px;
margin-bottom: 10px;
}

.git_hosting_urls .repository-urls {
margin-top: 0;
}

#git_hosting_download_buttons i {
Expand Down
3 changes: 2 additions & 1 deletion config/locales/models/repository_xitolite/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ en:
label_git_annex: GitAnnex

# Repository code browser
label_download_format: Download as %{archive_format}
label_download_format: Download as
label_download_select_format: Select format
error_download_revision_no_such_commit: "No such commit %{commit}"

# Repositories URL (labels)
Expand Down
3 changes: 2 additions & 1 deletion config/locales/models/repository_xitolite/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ fr:
label_git_annex: GitAnnex

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

# Repositories URL (labels)
Expand Down
1 change: 1 addition & 0 deletions lib/redmine_git_hosting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require 'redmine_git_hosting/hooks/add_public_keys_link'
require 'redmine_git_hosting/hooks/display_git_urls_on_project'
require 'redmine_git_hosting/hooks/display_git_urls_on_repository_edit'
require 'redmine_git_hosting/hooks/display_git_urls_on_repository_show'
require 'redmine_git_hosting/hooks/display_repository_extras'
require 'redmine_git_hosting/hooks/display_repository_readme'
require 'redmine_git_hosting/hooks/display_repository_sidebar'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module RedmineGitHosting
module Hooks
class DisplayGitUrlsOnRepositoryShow < Redmine::Hook::ViewListener
render_on :view_repositories_show_contextual, partial: 'repositories/show_top'
end
end
end

0 comments on commit 7dbe54f

Please sign in to comment.