1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Merged r1473, r1476, r1477, r1478, r1481, r1482, r1484 to r1487, r1491 from trunk.

git-svn-id: http://redmine.rubyforge.org/svn/branches/0.7-stable@1528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-06-14 11:59:59 +00:00
parent 2074f0ab41
commit 15ecbbf928
14 changed files with 116 additions and 88 deletions

View File

@ -61,11 +61,11 @@ class ApplicationController < ActionController::Base
def set_localization def set_localization
User.current.language = nil unless User.current.logged? User.current.language = nil unless User.current.logged?
lang = begin 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 User.current.language
elsif request.env['HTTP_ACCEPT_LANGUAGE'] elsif request.env['HTTP_ACCEPT_LANGUAGE']
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym if !accept_lang.blank? && (GLoc.valid_language?(accept_lang) || GLoc.valid_language?(accept_lang = accept_lang.split('-').first))
User.current.language = accept_lang User.current.language = accept_lang
end end
end end

View File

@ -149,7 +149,7 @@ class IssuesController < ApplicationController
attach_files(@issue, params[:attachments]) attach_files(@issue, params[:attachments])
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added') 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 return
end end
end end

View File

@ -90,6 +90,11 @@ module ApplicationHelper
include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
end 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) def html_hours(text)
text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>') text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
end end
@ -301,7 +306,7 @@ module ApplicationHelper
if project && (changeset = project.changesets.find_by_revision(oid)) 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}, link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
:class => 'changeset', :class => 'changeset',
:title => truncate(changeset.comments, 100)) :title => truncate_single_line(changeset.comments, 100))
end end
elsif sep == '#' elsif sep == '#'
oid = oid.to_i oid = oid.to_i
@ -340,7 +345,9 @@ module ApplicationHelper
end end
when 'commit' when 'commit'
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) 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 end
when 'source', 'export' when 'source', 'export'
if project && project.repository if project && project.repository

View File

@ -21,6 +21,10 @@ module ProjectsHelper
link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options
end end
def format_activity_title(text)
h(truncate_single_line(text, 100))
end
def format_activity_day(date) def format_activity_day(date)
date == Date.today ? l(:label_today).titleize : format_date(date) date == Date.today ? l(:label_today).titleize : format_date(date)
end end

View File

@ -144,7 +144,8 @@ class Project < ActiveRecord::Base
end end
def to_param def to_param
identifier # id is used for projects with a numeric identifier (compatibility)
@to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier)
end end
def active? def active?

View File

@ -1,6 +1,6 @@
xml.instruct! xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do 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" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false}))
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
xml.id 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| @items.each do |item|
xml.entry do xml.entry do
url = url_for(item.event_url(:only_path => false)) 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.link "rel" => "alternate", "href" => url
xml.id url xml.id url
xml.updated item.event_datetime.xmlschema 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.author do
xml.name(author) xml.name(author)
xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank? xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank?

View File

@ -7,7 +7,8 @@
<dl> <dl>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<dt class="<%= e.event_type %>"><span class="time"><%= format_time(e.event_datetime, false) %></span> <dt class="<%= e.event_type %>"><span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= 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 %></dt> <%= 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 %></dt>
<dd><% unless e.event_description.blank? -%> <dd><% unless e.event_description.blank? -%>
<span class="description"><%= format_activity_description(e.event_description) %></span><br /> <span class="description"><%= format_activity_description(e.event_description) %></span><br />
<% end %> <% end %>

View File

@ -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()}" %></p> <%= 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()}" %></p>
<% end %> <% end %>
<% cache(@cache_key) do %> <% cache(@cache_key) do -%>
<% @diff.each do |table_file| %> <% @diff.each do |table_file| -%>
<div class="autoscroll"> <div class="autoscroll">
<% if @diff_type == 'sbs' %> <% if @diff_type == 'sbs' -%>
<table class="filecontent CodeRay"> <table class="filecontent CodeRay">
<thead> <thead>
<tr> <tr><th colspan="4" class="filename"><%= table_file.file_name %></th></tr>
<th colspan="4" class="filename"> <tr>
<%= table_file.file_name %> <th colspan="2">@<%= format_revision @rev %></th>
</th> <th colspan="2">@<%= format_revision @rev_to %></th>
</tr> </tr>
<tr> </thead>
<th colspan="2">@<%= format_revision @rev %></th> <tbody>
<th colspan="2">@<%= format_revision @rev_to %></th> <% prev_line_left, prev_line_right = nil, nil -%>
</tr> <% table_file.keys.sort.each do |key| -%>
</thead> <% 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) -%>
<tbody> <tr class="spacing"><td colspan="4"></td></tr>
<% table_file.keys.sort.each do |key| %> <% end -%>
<tr> <tr>
<th class="line-num"> <th class="line-num"><%= table_file[key].nb_line_left %></th>
<%= table_file[key].nb_line_left %> <td class="line-code <%= table_file[key].type_diff_left %>">
</th> <pre><%=to_utf8 table_file[key].line_left %></pre>
<td class="line-code <%= table_file[key].type_diff_left %>"> </td>
<pre><%=to_utf8 table_file[key].line_left %></pre> <th class="line-num"><%= table_file[key].nb_line_right %></th>
</td> <td class="line-code <%= table_file[key].type_diff_right %>">
<th class="line-num"> <pre><%=to_utf8 table_file[key].line_right %></pre>
<%= table_file[key].nb_line_right %> </td>
</th> </tr>
<td class="line-code <%= table_file[key].type_diff_right %>"> <% prev_line_left, prev_line_right = table_file[key].nb_line_left.to_i, table_file[key].nb_line_right.to_i -%>
<pre><%=to_utf8 table_file[key].line_right %></pre> <% end -%>
</td> </tbody>
</tr> </table>
<% end %>
</tbody> <% else -%>
</table> <table class="filecontent CodeRay">
<thead>
<tr><th colspan="3" class="filename"><%= table_file.file_name %></th></tr>
<tr>
<th>@<%= format_revision @rev %></th>
<th>@<%= format_revision @rev_to %></th>
<th></th>
</tr>
</thead>
<tbody>
<% 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) -%>
<tr class="spacing"><td colspan="3"></td></tr>
<% end -%>
<tr>
<th class="line-num"><%= table_file[key].nb_line_left %></th>
<th class="line-num"><%= table_file[key].nb_line_right %></th>
<% if table_file[key].line_left.empty? -%>
<td class="line-code <%= table_file[key].type_diff_right %>">
<pre><%=to_utf8 table_file[key].line_right %></pre>
</td>
<% else -%>
<td class="line-code <%= table_file[key].type_diff_left %>">
<pre><%=to_utf8 table_file[key].line_left %></pre>
</td>
<% end -%>
</tr>
<% 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 -%>
</tbody>
</table>
<% end -%>
<% else %>
<table class="filecontent CodeRay">
<thead>
<tr>
<th colspan="3" class="filename">
<%= table_file.file_name %>
</th>
</tr>
<tr>
<th>@<%= format_revision @rev %></th>
<th>@<%= format_revision @rev_to %></th>
<th></th>
</tr>
</thead>
<tbody>
<% table_file.keys.sort.each do |key, line| %>
<tr>
<th class="line-num">
<%= table_file[key].nb_line_left %>
</th>
<th class="line-num">
<%= table_file[key].nb_line_right %>
</th>
<% if table_file[key].line_left.empty? %>
<td class="line-code <%= table_file[key].type_diff_right %>">
<pre><%=to_utf8 table_file[key].line_right %></pre>
</td>
<% else %>
<td class="line-code <%= table_file[key].type_diff_left %>">
<pre><%=to_utf8 table_file[key].line_left %></pre>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div> </div>
<% end %> <% end -%>
<% end %> <% end -%>
<% html_title(with_leading_slash(@path), 'Diff') -%> <% html_title(with_leading_slash(@path), 'Diff') -%>

View File

@ -279,7 +279,6 @@ module Redmine
end end
else else
if line =~ /^[^\+\-\s@\\]/ if line =~ /^[^\+\-\s@\\]/
self.delete(self.keys.sort.last)
@parsing = false @parsing = false
return false return false
elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/ elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/

View File

@ -126,6 +126,10 @@ namespace :redmine do
File.open("#{trac_fullpath}", 'rb').read File.open("#{trac_fullpath}", 'rb').read
end end
def description
read_attribute(:description).to_s.slice(0,255)
end
private private
def trac_fullpath def trac_fullpath
attachment_type = read_attribute(:type) attachment_type = read_attribute(:type)
@ -408,6 +412,7 @@ namespace :redmine do
a.file = attachment a.file = attachment
a.author = find_or_create_user(attachment.author) a.author = find_or_create_user(attachment.author)
a.container = i a.container = i
a.description = attachment.description
migrated_ticket_attachments += 1 if a.save migrated_ticket_attachments += 1 if a.save
end end
@ -456,6 +461,7 @@ namespace :redmine do
a = Attachment.new :created_on => attachment.time a = Attachment.new :created_on => attachment.time
a.file = attachment a.file = attachment
a.author = find_or_create_user(attachment.author) a.author = find_or_create_user(attachment.author)
a.description = attachment.description
a.container = p a.container = p
migrated_wiki_attachments += 1 if a.save migrated_wiki_attachments += 1 if a.save
end end

View File

@ -113,7 +113,7 @@ Calendar._TT["DAY_FIRST"] = "הצג %s קודם";
// This may be locale-dependent. It specifies the week-end days, as an array // 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 // of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
// means Monday, etc. // means Monday, etc.
Calendar._TT["WEEKEND"] = "6,7"; Calendar._TT["WEEKEND"] = "5,6";
Calendar._TT["CLOSE"] = "סגור"; Calendar._TT["CLOSE"] = "סגור";
Calendar._TT["TODAY"] = "היום"; Calendar._TT["TODAY"] = "היום";

View File

@ -2,7 +2,7 @@
table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; } table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; }
table.filecontent th { border: 1px solid #ccc; background-color: #eee; } table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
table.filecontent th.filename { background-color: #ddc; text-align: left; } 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 { table.filecontent th.line-num {
border: 1px solid #d7d7d7; border: 1px solid #d7d7d7;
font-size: 0.8em; font-size: 0.8em;

View File

@ -46,4 +46,18 @@ class WelcomeControllerTest < Test::Unit::TestCase
get :index get :index
assert_equal :fr, @controller.current_language assert_equal :fr, @controller.current_language
end 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 end

View File

@ -122,7 +122,7 @@ module Scanners
end end
when :include_expected when :include_expected
if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/) if scan(/[^\n]+/)
kind = :include kind = :include
state = :initial state = :initial