Mercurial > hg > soundsoftware-site
changeset 741:496b3cfa2f36 feature_318
Finish adding download link
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Mon, 07 Nov 2011 17:29:43 +0000 |
parents | 8873bc7c1af5 |
children | 2034af722d02 286127f3f505 |
files | app/helpers/repositories_helper.rb app/views/repositories/_navigation.rhtml app/views/repositories/revision.rhtml app/views/repositories/show.rhtml config/locales/en.yml public/themes/soundsoftware/stylesheets/application.css |
diffstat | 6 files changed, 37 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/app/helpers/repositories_helper.rb Fri Nov 04 17:56:58 2011 +0000 +++ b/app/helpers/repositories_helper.rb Mon Nov 07 17:29:43 2011 +0000 @@ -281,4 +281,24 @@ ) + '<br />' + l(:text_scm_path_encoding_note)) end + + # Generates a link to a downloadable archive for a revision + # Options: + # * :text - Link text (default to the formatted revision) + def link_to_revision_archive(repository, revision, project, options={}) + method = repository.class.name.demodulize.underscore + "_link_to_revision_archive" + if repository.is_a?(Repository) && + respond_to?(method) && method != 'link_to_revision_archive' + send(method, repository, revision, project, options) + end + end + + def mercurial_link_to_revision_archive(repository, revision, project, options={}) + text = options.delete(:text) || format_revision(revision) + rev = revision.respond_to?(:identifier) ? revision.identifier : revision + if rev.blank? then rev = 'tip' end + content_tag('a', h(text), + { :href => "/hg/#{project.identifier}/archive/#{rev}.zip" }.merge(options)); + end + end
--- a/app/views/repositories/_navigation.rhtml Fri Nov 04 17:56:58 2011 +0000 +++ b/app/views/repositories/_navigation.rhtml Mon Nov 07 17:29:43 2011 +0000 @@ -2,12 +2,7 @@ <%= javascript_include_tag 'repository_navigation' %> <% end %> -<%= link_to l(:label_statistics), {:action => 'stats', :id => @project}, :class => 'icon icon-stats' %> - -| <a href="/hg/<%= h(@project.identifier) %>/archive/<%= - rev_text = @changeset.nil? ? @rev : format_revision(@changeset); - rev_text.blank? ? "tip" : rev_text -%>.zip">Download this revision</a> +<%= link_to_revision_archive(@repository, @changeset, @project, { :text => l(:label_download_revision), :class => 'icon icon-package' }) %> <% form_tag({:action => controller.action_name, :id => @project, :path => to_path_param(@path), :rev => ''}, {:method => :get, :id => 'revision_selector'}) do -%> <!-- Branches Dropdown --> @@ -24,3 +19,5 @@ | <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 8 %> <% end -%> + +
--- a/app/views/repositories/revision.rhtml Fri Nov 04 17:56:58 2011 +0000 +++ b/app/views/repositories/revision.rhtml Mon Nov 07 17:29:43 2011 +0000 @@ -1,11 +1,15 @@ <div class="contextual"> + + <%= link_to_revision_archive(@repository, @changeset, @project, { :text => l(:label_download_revision), :class => 'icon icon-package' }) %> + + « <% unless @changeset.previous.nil? -%> <%= link_to_revision(@changeset.previous, @project, :text => l(:label_previous)) %> <% else -%> <%= l(:label_previous) %> <% end -%> -| + <% unless @changeset.next.nil? -%> <%= link_to_revision(@changeset.next, @project, :text => l(:label_next)) %> <% else -%> @@ -21,6 +25,7 @@ <%= text_field_tag 'rev', @rev, :size => 8 %> <%= submit_tag 'OK', :name => nil %> <% end %> + </div> <h2><%= l(:label_revision) %> <%= format_revision(@changeset) %></h2>
--- a/app/views/repositories/show.rhtml Fri Nov 04 17:56:58 2011 +0000 +++ b/app/views/repositories/show.rhtml Mon Nov 07 17:29:43 2011 +0000 @@ -51,9 +51,14 @@ :id => @project, :page => nil, :key => User.current.rss_key})) %> <% end %> +<p class="statistics"> +<%= link_to l(:label_statistics), {:action => 'stats', :id => @project}, :class => 'icon icon-stats' %> +</p> + <% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:action => 'revisions', :id => @project, :key => User.current.rss_key} %> <% end %> + <% end %> <% end %>
--- a/config/locales/en.yml Fri Nov 04 17:56:58 2011 +0000 +++ b/config/locales/en.yml Mon Nov 07 17:29:43 2011 +0000 @@ -698,6 +698,7 @@ label_latest_revision_plural: Latest revisions label_view_revisions: View revisions label_view_all_revisions: View all revisions + label_download_revision: Download as Zip label_max_size: Maximum size label_sort_highest: Move to top label_sort_higher: Move up
--- a/public/themes/soundsoftware/stylesheets/application.css Fri Nov 04 17:56:58 2011 +0000 +++ b/public/themes/soundsoftware/stylesheets/application.css Mon Nov 07 17:29:43 2011 +0000 @@ -134,6 +134,8 @@ #footer { background-color: #fdfbf5; border: 0; border-top: 2px solid #a9b680; color: #3e442c; text-align: right; } #footer a { color: #be5700; font-weight: bold; } +p.statistics { text-align: right; font-size:0.9em; color: #666; } + #main { margin-top: 135px; font:95%; background: #fdfaf0; } #main a { font-weight: medium; color: #be5700;} #main a:hover { color: #be5700; text-decoration: underline; }