diff --git a/app/controllers/application.rb b/app/controllers/application.rb index abf621641..2daee50de 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -61,11 +61,11 @@ class ApplicationController < ActionController::Base def set_localization User.current.language = nil unless User.current.logged? lang = begin - if !User.current.language.blank? and GLoc.valid_languages.include? User.current.language.to_sym + if !User.current.language.blank? && GLoc.valid_language?(User.current.language) User.current.language elsif request.env['HTTP_ACCEPT_LANGUAGE'] - accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first - if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym + accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase + if !accept_lang.blank? && (GLoc.valid_language?(accept_lang) || GLoc.valid_language?(accept_lang = accept_lang.split('-').first)) User.current.language = accept_lang end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index ca3309c46..568abc3d4 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -149,7 +149,7 @@ class IssuesController < ApplicationController attach_files(@issue, params[:attachments]) flash[:notice] = l(:notice_successful_create) Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added') - redirect_to :controller => 'issues', :action => 'show', :id => @issue, :project_id => @project + redirect_to :controller => 'issues', :action => 'show', :id => @issue return end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 47a251053..589b054f3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -90,6 +90,11 @@ module ApplicationHelper include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) end + # Truncates and returns the string as a single line + def truncate_single_line(string, *args) + truncate(string, *args).gsub(%r{[\r\n]+}m, ' ') + end + def html_hours(text) text.gsub(%r{(\d+)\.(\d+)}, '\1.\2') end @@ -301,7 +306,7 @@ module ApplicationHelper if project && (changeset = project.changesets.find_by_revision(oid)) link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid}, :class => 'changeset', - :title => truncate(changeset.comments, 100)) + :title => truncate_single_line(changeset.comments, 100)) end elsif sep == '#' oid = oid.to_i @@ -340,7 +345,9 @@ module ApplicationHelper end when 'commit' if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) - link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision}, :class => 'changeset', :title => truncate(changeset.comments, 100) + link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision}, + :class => 'changeset', + :title => truncate_single_line(changeset.comments, 100) end when 'source', 'export' if project && project.repository diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ffbf25e83..49a2e5721 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -21,6 +21,10 @@ module ProjectsHelper link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options end + def format_activity_title(text) + h(truncate_single_line(text, 100)) + end + def format_activity_day(date) date == Date.today ? l(:label_today).titleize : format_date(date) end diff --git a/app/models/project.rb b/app/models/project.rb index 8c32c8562..fff5df758 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -144,7 +144,8 @@ class Project < ActiveRecord::Base end def to_param - identifier + # id is used for projects with a numeric identifier (compatibility) + @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier) end def active? diff --git a/app/views/common/feed.atom.rxml b/app/views/common/feed.atom.rxml index b5cbeeed9..8ceffc91c 100644 --- a/app/views/common/feed.atom.rxml +++ b/app/views/common/feed.atom.rxml @@ -1,6 +1,6 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do - xml.title @title + xml.title truncate_single_line(@title, 100) xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false})) xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) xml.id url_for(:controller => 'welcome', :only_path => false) @@ -10,11 +10,11 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do @items.each do |item| xml.entry do url = url_for(item.event_url(:only_path => false)) - xml.title truncate(item.event_title, 100) + xml.title truncate_single_line(item.event_title, 100) xml.link "rel" => "alternate", "href" => url xml.id url xml.updated item.event_datetime.xmlschema - author = item.event_author if item.respond_to?(:author) + author = item.event_author if item.respond_to?(:event_author) xml.author do xml.name(author) xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank? diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml index c2f2f9ebd..d4fe51dc4 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -7,7 +7,8 @@
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<%= format_time(e.event_datetime, false) %> - <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> <%= link_to h(truncate(e.event_title, 100)), e.event_url %>
+ <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> + <%= link_to format_activity_title(e.event_title), e.event_url %>
<% unless e.event_description.blank? -%> <%= format_activity_description(e.event_description) %>
<% end %> diff --git a/app/views/repositories/diff.rhtml b/app/views/repositories/diff.rhtml index eaef1abf5..73c1e8c9e 100644 --- a/app/views/repositories/diff.rhtml +++ b/app/views/repositories/diff.rhtml @@ -11,82 +11,78 @@ <%= select_tag 'type', options_for_select([[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], @diff_type), :onchange => "if (this.value != '') {this.form.submit()}" %>

<% end %> -<% cache(@cache_key) do %> -<% @diff.each do |table_file| %> +<% cache(@cache_key) do -%> +<% @diff.each do |table_file| -%>
-<% if @diff_type == 'sbs' %> - - - - - - - - - - - - <% table_file.keys.sort.each do |key| %> - - - - - - - <% end %> - -
- <%= table_file.file_name %> -
@<%= format_revision @rev %>@<%= format_revision @rev_to %>
- <%= table_file[key].nb_line_left %> - -
<%=to_utf8 table_file[key].line_left %>
-
- <%= table_file[key].nb_line_right %> - -
<%=to_utf8 table_file[key].line_right %>
-
+<% if @diff_type == 'sbs' -%> + + + + + + + + + +<% prev_line_left, prev_line_right = nil, nil -%> +<% table_file.keys.sort.each do |key| -%> +<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%> + +<% end -%> + + + + + + +<% prev_line_left, prev_line_right = table_file[key].nb_line_left.to_i, table_file[key].nb_line_right.to_i -%> +<% end -%> + +
<%= table_file.file_name %>
@<%= format_revision @rev %>@<%= format_revision @rev_to %>
<%= table_file[key].nb_line_left %> +
<%=to_utf8 table_file[key].line_left %>
+
<%= table_file[key].nb_line_right %> +
<%=to_utf8 table_file[key].line_right %>
+
+ +<% else -%> + + + + + + + + + + +<% prev_line_left, prev_line_right = nil, nil -%> +<% table_file.keys.sort.each do |key, line| %> +<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%> + +<% end -%> + + + + <% if table_file[key].line_left.empty? -%> + + <% else -%> + + <% end -%> + +<% prev_line_left = table_file[key].nb_line_left.to_i if table_file[key].nb_line_left.to_i > 0 -%> +<% prev_line_right = table_file[key].nb_line_right.to_i if table_file[key].nb_line_right.to_i > 0 -%> +<% end -%> + +
<%= table_file.file_name %>
@<%= format_revision @rev %>@<%= format_revision @rev_to %>
<%= table_file[key].nb_line_left %><%= table_file[key].nb_line_right %> +
<%=to_utf8 table_file[key].line_right %>
+
+
<%=to_utf8 table_file[key].line_left %>
+
+<% end -%> -<% else %> - - - - - - - - - - - - - <% table_file.keys.sort.each do |key, line| %> - - - - <% if table_file[key].line_left.empty? %> - - <% else %> - - <% end %> - - <% end %> - -
- <%= table_file.file_name %> -
@<%= format_revision @rev %>@<%= format_revision @rev_to %>
- <%= table_file[key].nb_line_left %> - - <%= table_file[key].nb_line_right %> - -
<%=to_utf8 table_file[key].line_right %>
-
-
<%=to_utf8 table_file[key].line_left %>
-
-<% end %>
-<% end %> -<% end %> +<% end -%> +<% end -%> <% html_title(with_leading_slash(@path), 'Diff') -%> diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 2c254d48d..8fbae9ff8 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -279,7 +279,6 @@ module Redmine end else if line =~ /^[^\+\-\s@\\]/ - self.delete(self.keys.sort.last) @parsing = false return false elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/ diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake index 48a774eef..5341fa14a 100644 --- a/lib/tasks/migrate_from_trac.rake +++ b/lib/tasks/migrate_from_trac.rake @@ -126,6 +126,10 @@ namespace :redmine do File.open("#{trac_fullpath}", 'rb').read end + def description + read_attribute(:description).to_s.slice(0,255) + end + private def trac_fullpath attachment_type = read_attribute(:type) @@ -408,6 +412,7 @@ namespace :redmine do a.file = attachment a.author = find_or_create_user(attachment.author) a.container = i + a.description = attachment.description migrated_ticket_attachments += 1 if a.save end @@ -456,6 +461,7 @@ namespace :redmine do a = Attachment.new :created_on => attachment.time a.file = attachment a.author = find_or_create_user(attachment.author) + a.description = attachment.description a.container = p migrated_wiki_attachments += 1 if a.save end diff --git a/public/javascripts/calendar/lang/calendar-he.js b/public/javascripts/calendar/lang/calendar-he.js index bd92e0073..9d4c87db0 100644 --- a/public/javascripts/calendar/lang/calendar-he.js +++ b/public/javascripts/calendar/lang/calendar-he.js @@ -113,7 +113,7 @@ Calendar._TT["DAY_FIRST"] = "הצג %s קודם"; // This may be locale-dependent. It specifies the week-end days, as an array // of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1 // means Monday, etc. -Calendar._TT["WEEKEND"] = "6,7"; +Calendar._TT["WEEKEND"] = "5,6"; Calendar._TT["CLOSE"] = "סגור"; Calendar._TT["TODAY"] = "היום"; diff --git a/public/stylesheets/scm.css b/public/stylesheets/scm.css index 66847af8c..d1495a5ef 100644 --- a/public/stylesheets/scm.css +++ b/public/stylesheets/scm.css @@ -2,7 +2,7 @@ table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; } table.filecontent th { border: 1px solid #ccc; background-color: #eee; } table.filecontent th.filename { background-color: #ddc; text-align: left; } -table.filecontent tr.spacing { border: 1px solid #d7d7d7; } +table.filecontent tr.spacing td { border: 1px solid #d7d7d7; height: 0.4em; } table.filecontent th.line-num { border: 1px solid #d7d7d7; font-size: 0.8em; diff --git a/test/functional/welcome_controller_test.rb b/test/functional/welcome_controller_test.rb index 18146c6aa..df565a751 100644 --- a/test/functional/welcome_controller_test.rb +++ b/test/functional/welcome_controller_test.rb @@ -46,4 +46,18 @@ class WelcomeControllerTest < Test::Unit::TestCase get :index assert_equal :fr, @controller.current_language end + + def test_browser_language_alternate + Setting.default_language = 'en' + @request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW' + get :index + assert_equal :"zh-tw", @controller.current_language + end + + def test_browser_language_alternate_not_valid + Setting.default_language = 'en' + @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr-CA' + get :index + assert_equal :fr, @controller.current_language + end end diff --git a/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb b/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb index f6d71ade2..e5d87b233 100644 --- a/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb +++ b/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb @@ -122,7 +122,7 @@ module Scanners end when :include_expected - if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/) + if scan(/[^\n]+/) kind = :include state = :initial