Mercurial > hg > soundsoftware-site
changeset 971:b80f97c892bc cannam
Merge from branch "get_statistics"
author | Chris Cannam |
---|---|
date | Fri, 19 Oct 2012 14:47:14 +0100 |
parents | e632838adb35 (diff) 6bd8364eafae (current diff) |
children | 710921c48f06 198f764e734c |
files | |
diffstat | 6 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/attachments_controller.rb Fri Oct 19 13:47:57 2012 +0100 +++ b/app/controllers/attachments_controller.rb Fri Oct 19 14:47:14 2012 +0100 @@ -17,6 +17,9 @@ class AttachmentsController < ApplicationController + include AttachmentsHelper + helper :attachments + before_filter :find_project before_filter :file_readable, :read_authorize, :except => :destroy before_filter :delete_authorize, :only => :destroy @@ -49,7 +52,9 @@ end def download - if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project) + # cc: formerly this happened only if "@attachment.container.is_a?(Version)" + # or Project. Not good for us, we want to tally all downloads [by humans] + if not user_is_search_bot? @attachment.increment_download end
--- a/app/controllers/sys_controller.rb Fri Oct 19 13:47:57 2012 +0100 +++ b/app/controllers/sys_controller.rb Fri Oct 19 14:47:14 2012 +0100 @@ -21,7 +21,7 @@ def projects p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => 'identifier') # extra_info attribute from repository breaks activeresource client - render :xml => p.to_xml(:only => [:id, :identifier, :name, :is_public, :status], :include => {:repository => {:only => [:id, :url]}}) + render :xml => p.to_xml(:only => [:id, :identifier, :name, :is_public, :status], :include => {:repository => {:only => [:id, :url, :is_external, :external_url]}}) end def create_project_repository
--- a/app/helpers/attachments_helper.rb Fri Oct 19 13:47:57 2012 +0100 +++ b/app/helpers/attachments_helper.rb Fri Oct 19 14:47:14 2012 +0100 @@ -42,4 +42,11 @@ api.created_on attachment.created_on end end + + # Returns true if user agent appears (approximately) to be a search + # bot or crawler + def user_is_search_bot? + agent = request.env['HTTP_USER_AGENT'] + agent and agent =~ /(bot|slurp|crawler|spider)\b/i + end end
--- a/app/views/attachments/_links.html.erb Fri Oct 19 13:47:57 2012 +0100 +++ b/app/views/attachments/_links.html.erb Fri Oct 19 14:47:14 2012 +0100 @@ -2,7 +2,7 @@ <% for attachment in attachments %> <p><%= link_to_attachment attachment, :class => 'icon icon-attachment' -%> <%= h(" - #{attachment.description}") unless attachment.description.blank? %> - <span class="size">(<%= number_to_human_size attachment.filesize %>)</span> + <span class="size_and_count"><%= number_to_human_size attachment.filesize %><%= ", " + l(:label_x_downloads, :count => attachment.downloads) unless attachment.downloads == 0 %></span> <% if options[:deletable] %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :confirm => l(:text_are_you_sure),
--- a/config/locales/en.yml Fri Oct 19 13:47:57 2012 +0100 +++ b/config/locales/en.yml Fri Oct 19 14:47:14 2012 +0100 @@ -487,6 +487,10 @@ zero: no projects one: 1 project other: "%{count} projects" + label_x_downloads: + zero: never downloaded + one: downloaded once + other: "downloaded %{count} times" label_project_all: All Projects label_project_latest: Latest projects label_projects_more: More projects
--- a/public/stylesheets/application.css Fri Oct 19 13:47:57 2012 +0100 +++ b/public/stylesheets/application.css Fri Oct 19 14:47:14 2012 +0100 @@ -506,7 +506,8 @@ div.attachments { margin-top: 12px; } div.attachments p { margin:4px 0 2px 0; } div.attachments img { vertical-align: middle; } -div.attachments span.author { font-size: 0.9em; color: #888; } +div.attachments span.author { font-size: 0.9em; color: #888; font-style: italic; padding-left: 4px } +div.attachments span.size_and_count { font-size: 0.9em; color: #888; padding-left: 4px; } p.other-formats { text-align: right; font-size:0.9em; color: #666; } .other-formats span + span:before { content: "| "; }