# HG changeset patch
# User Chris Cannam
# Date 1300880016 0
# Node ID 2de308601155de912e7df6af4e9313eed0cd15d9
# Parent 8b569484ba955e27a464d94773a7deaefa42986a# Parent fa07572ee073d0e660162633b012dd2610b25972
Merge from branch "bug_95"
diff -r fa07572ee073 -r 2de308601155 app/controllers/application_controller.rb
--- a/app/controllers/application_controller.rb Wed Mar 23 11:31:14 2011 +0000
+++ b/app/controllers/application_controller.rb Wed Mar 23 11:33:36 2011 +0000
@@ -263,6 +263,12 @@
uri = URI.parse(back_url)
# do not redirect user to another host or to the login or register page
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
+ # soundsoftware: if login page is https but back_url http,
+ # switch back_url to https to ensure cookie validity (#83)
+ if (uri.scheme == "http") && (URI.parse(request.url).scheme == "https")
+ uri.scheme = "https"
+ back_url = uri.to_s
+ end
redirect_to(back_url)
return
end
diff -r fa07572ee073 -r 2de308601155 app/controllers/attachments_controller.rb
--- a/app/controllers/attachments_controller.rb Wed Mar 23 11:31:14 2011 +0000
+++ b/app/controllers/attachments_controller.rb Wed Mar 23 11:33:36 2011 +0000
@@ -16,9 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class AttachmentsController < ApplicationController
+
before_filter :find_project
before_filter :file_readable, :read_authorize, :except => :destroy
before_filter :delete_authorize, :only => :destroy
+ before_filter :active_authorize, :only => :toggle_active
verify :method => :post, :only => :destroy
@@ -54,6 +56,12 @@
redirect_to :controller => 'projects', :action => 'show', :id => @project
end
+ def toggle_active
+ @attachment.active = !@attachment.active?
+ @attachment.save!
+ render :layout => false
+ end
+
private
def find_project
@attachment = Attachment.find(params[:id])
@@ -77,6 +85,10 @@
@attachment.deletable? ? true : deny_access
end
+ def active_authorize
+ true
+ end
+
def detect_content_type(attachment)
content_type = attachment.content_type
if content_type.blank?
diff -r fa07572ee073 -r 2de308601155 app/controllers/files_controller.rb
--- a/app/controllers/files_controller.rb Wed Mar 23 11:31:14 2011 +0000
+++ b/app/controllers/files_controller.rb Wed Mar 23 11:33:36 2011 +0000
@@ -8,8 +8,9 @@
include SortHelper
def index
- sort_init 'filename', 'asc'
+ sort_init 'active', 'asc'
sort_update 'filename' => "#{Attachment.table_name}.filename",
+ 'active' => "#{Attachment.table_name}.active",
'created_on' => "#{Attachment.table_name}.created_on",
'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads"
@@ -33,4 +34,5 @@
end
redirect_to project_files_path(@project)
end
+
end
diff -r fa07572ee073 -r 2de308601155 app/controllers/members_controller.rb
--- a/app/controllers/members_controller.rb Wed Mar 23 11:31:14 2011 +0000
+++ b/app/controllers/members_controller.rb Wed Mar 23 11:33:36 2011 +0000
@@ -54,8 +54,8 @@
errors = members.collect {|m|
m.errors.full_messages
}.flatten.uniq
-
- page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
+
+ # page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
}
}
diff -r fa07572ee073 -r 2de308601155 app/views/attachments/toggle_active.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/views/attachments/toggle_active.rhtml Wed Mar 23 11:33:36 2011 +0000
@@ -0,0 +1,7 @@
+<%=
+file = Attachment.find(params[:id])
+active_id = "active-" + file.id.to_s
+link_to_remote image_tag(file.active? ? 'fav.png' : 'fav_off.png'),
+ :url => {:controller => 'attachments', :action => 'toggle_active', :project_id => @project.id, :id => file},
+ :update => active_id
+%>
diff -r fa07572ee073 -r 2de308601155 app/views/files/index.html.erb
--- a/app/views/files/index.html.erb Wed Mar 23 11:31:14 2011 +0000
+++ b/app/views/files/index.html.erb Wed Mar 23 11:33:36 2011 +0000
@@ -5,29 +5,51 @@
<%=l(:label_attachment_plural)%>
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
+<% active_change_allowed = delete_allowed %>
+ <%= sort_header_tag('active', :caption => l(:field_active)) %>
<%= sort_header_tag('filename', :caption => l(:field_filename)) %>
<%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc') %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %>
- <%= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %>
+ <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc') %>
MD5 |
|
+<% have_file = false %>
<% @containers.each do |container| %>
<% next if container.attachments.empty? -%>
<% if container.is_a?(Version) -%>
-
+ |
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
|
<% end -%>
<% container.attachments.each do |file| %>
- ">
- <%= link_to_attachment file, :download => true, :title => file.description %> |
+
<%= "active" if file.active? %>">
+
+ <% have_file = true %>
+ <% if active_change_allowed
+ active_id = "active-" + file.id.to_s -%>
+
+ <%= link_to_remote image_tag(file.active? ? 'fav.png' : 'fav_off.png'),
+ :url => {:controller => 'attachments', :action => 'toggle_active', :project_id => @project.id, :id => file},
+ :update => active_id
+ %>
+
+ <% else -%>
+ <%= image_tag('fav.png') if file.active? %>
+ <% end -%>
+ |
+ <% if file.active? %>
+ <%= link_to_attachment file, :download => true %> <%= h(file.description) %> |
+ <% else %>
+ <%= link_to_attachment file, :download => true, :title => file.description %>
+ <% end %>
+ |
<%= format_time(file.created_on) %> |
<%= number_to_human_size(file.filesize) %> |
<%= file.downloads %> |
@@ -43,4 +65,6 @@
+<%= l(:text_files_active_change) if active_change_allowed and have_file %>
+
<% html_title(l(:label_attachment_plural)) -%>
diff -r fa07572ee073 -r 2de308601155 config/locales/en-GB.yml
--- a/config/locales/en-GB.yml Wed Mar 23 11:31:14 2011 +0000
+++ b/config/locales/en-GB.yml Wed Mar 23 11:33:36 2011 +0000
@@ -899,6 +899,7 @@
text_wiki_page_reassign_children: "Reassign child pages to this parent page"
text_own_membership_delete_confirmation: "You are about to remove some or all of your permissions and may no longer be able to edit this project after that.\nAre you sure you want to continue?"
text_settings_repo_creation: The repository for a project should be set up automatically within a few minutes of the project being created.
You should not have to adjust any settings here; please check again in ten minutes.
+ text_files_active_change:
Click the star to switch active status for a download on or off.
Active files will be shown more prominently in the download page.
default_role_manager: Manager
default_role_developer: Developer
diff -r fa07572ee073 -r 2de308601155 config/locales/en.yml
--- a/config/locales/en.yml Wed Mar 23 11:31:14 2011 +0000
+++ b/config/locales/en.yml Wed Mar 23 11:33:36 2011 +0000
@@ -859,6 +859,7 @@
version_status_closed: closed
field_active: Active
+ field_current: Current
text_select_mail_notifications: Select actions for which email notifications should be sent.
text_regexp_info: eg. ^[A-Z0-9]+$
@@ -924,7 +925,8 @@
text_zoom_in: Zoom in
text_zoom_out: Zoom out
text_settings_repo_creation: The repository for a project should be set up automatically within a few minutes of the project being created.
You should not have to adjust any settings here.
Please check again in ten minutes, and contact us if there is any problem.
-
+ text_files_active_change:
Click the star to switch active status for a download on or off.
Active files will be shown more prominently in the download page.
+
default_role_manager: Manager
default_role_developer: Developer
default_role_reporter: Reporter
diff -r fa07572ee073 -r 2de308601155 db/migrate/20110303152903_add_active_column_to_attachments.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/db/migrate/20110303152903_add_active_column_to_attachments.rb Wed Mar 23 11:33:36 2011 +0000
@@ -0,0 +1,9 @@
+class AddActiveColumnToAttachments < ActiveRecord::Migration
+ def self.up
+ add_column :attachments, :active, :boolean
+ end
+
+ def self.down
+ remove_column :attachments, :active
+ end
+end
diff -r fa07572ee073 -r 2de308601155 public/stylesheets/application.css
--- a/public/stylesheets/application.css Wed Mar 23 11:31:14 2011 +0000
+++ b/public/stylesheets/application.css Wed Mar 23 11:33:36 2011 +0000
@@ -157,7 +157,7 @@
tr.changeset td.committed_on { text-align: center; width: 15%; }
table.files tr.file td { text-align: center; }
-table.files tr.file td.filename { text-align: left; padding-left: 24px; }
+table.files tr.file td.filename { text-align: left; }
table.files tr.file td.digest { font-size: 80%; }
table.members td.roles, table.memberships td.roles { width: 45%; }
diff -r fa07572ee073 -r 2de308601155 public/themes/soundsoftware/stylesheets/application.css
--- a/public/themes/soundsoftware/stylesheets/application.css Wed Mar 23 11:31:14 2011 +0000
+++ b/public/themes/soundsoftware/stylesheets/application.css Wed Mar 23 11:33:36 2011 +0000
@@ -37,16 +37,41 @@
body,p,h2,h3,h4,li,table,.wiki h1 {
font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif;
+ line-height: 1.34;
}
h2,h3,h4,.wiki h1 {
color: #3e442c;
+ font-weight: bold;
+}
+
+.wiki h2,.wiki h3,.wiki h4 {
+ color: #000;
}
h2,.wiki h1 {
- font-size: 1.8em;
+ font-size: 1.8em;
}
+.wiki h2 {
+ margin-top: 1em;
+}
+
+.splitcontentleft p:first-child {
+ margin-top: 0;
+}
+
+div.attachments {
+ margin-top: 2em;
+}
+#wiki_add_attachment {
+ margin-top: 1.5em;
+}
+
+/* Hide these (the paragraph markers that show anchors) -- they confuse more than they help */
+a.wiki-anchor:hover { display: none; }
+h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display: none; }
+
.box {
padding: 6px;
margin-bottom: 10px;
@@ -81,6 +106,10 @@
ul.projects .public, ul.projects .private { padding-left: 0.5em; color: #3e442c; font-size: 0.95em }
+table.files tr.active td { padding-top: 0.5em; padding-bottom: 0.5em; }
+table.files .file .active { font-weight: bold; }
+table.files .file .description { font-weight: normal; color: #3e442c; }
+
#top-menu { position: absolute; top: 0; z-index: 1; left: 0px; width: 100%; font-size: 90%; /* height: 2em; */ margin: 0; padding: 0; padding-top: 0.5em; background-color: #3e442c; }
#top-menu ul { margin-left: 10px; }
#top-menu a { font-weight: bold; }
@@ -98,7 +127,7 @@
#project-jump-box { float: right; margin-right: 6px; margin-top: 5px; color: #000; }
#project-ancestors-title {
margin-bottom: 0px;
- margin-left: 10px;
+ margin-left: 12px;
margin-top: 6px;
font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
font-weight: normal;