Compare commits
41 Commits
Author | SHA1 | Date |
---|---|---|
Kolan Sh | 6125ca1246 | |
Kolan Sh | 6978a86c97 | |
Kolan Sh | b4e5f6cd0d | |
Kolan Sh | 5e370b720b | |
Kolan Sh | 9ebbce7ba3 | |
Kolan Sh | efe53a60c5 | |
Kolan Sh | 8e78e2d78b | |
Kolan Sh | 19f2859e1b | |
Holger Just | 7efc8dbb19 | |
Holger Just | eb41ffd854 | |
Holger Just | f9180b1dc8 | |
Andrew Smith | b43e8186c4 | |
Holger Just | 4c4383ff71 | |
Andrew Smith | 72e9805b72 | |
Felix Schäfer | 5cefd6a425 | |
Felix Schäfer | 7437eaea53 | |
Holger Just | f6ebdb3405 | |
Andrew Smith | 1a28b5a281 | |
Romano Licker | a57691369e | |
Holger Just | d91b297846 | |
Felix Schäfer | 45f628591e | |
Andrew Smith | 9017d14054 | |
Felix Schäfer | 037bb192ac | |
Felix Schäfer | f0f0171a59 | |
Andrew Smith | 03e68da23c | |
Holger Just | 8e80e65e0a | |
Holger Just | 5350f4323a | |
Holger Just | abfc04973e | |
Andrew Smith | 8478e6a115 | |
Andrew Smith | c9bec63b7d | |
Andrew Smith | 90c4453b58 | |
Jan Vlnas | 935b2c8635 | |
Holger Just | fe19c6c5be | |
Holger Just | a91563e194 | |
Felix Schäfer | 645f44a419 | |
Holger Just | 1ed846cd01 | |
Holger Just | 02d2deeae6 | |
Kolan Sh | 1e908da66c | |
Kolan Sh | e5de5f43cc | |
Kolan Sh | 65b94d2014 | |
Kolan Sh | 786e92349b |
42
.travis.yml
42
.travis.yml
|
@ -5,48 +5,30 @@ rvm:
|
|||
- 1.9.3
|
||||
- rbx-18mode
|
||||
env:
|
||||
- "TEST_SUITE=units RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- "TEST_SUITE=units RAILS_ENV=test DB=mysql2 BUNDLE_WITHOUT=rmagick:mysql:postgres:sqlite"
|
||||
- "TEST_SUITE=units RAILS_ENV=test DB=postgres BUNDLE_WITHOUT=rmagick:mysql:mysql2:sqlite"
|
||||
- "TEST_SUITE=units RAILS_ENV=test DB=sqlite BUNDLE_WITHOUT=rmagick:mysql:mysql2:postgres"
|
||||
- "TEST_SUITE=functionals RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- "TEST_SUITE=functionals RAILS_ENV=test DB=mysql2 BUNDLE_WITHOUT=rmagick:mysql:postgres:sqlite"
|
||||
- "TEST_SUITE=functionals RAILS_ENV=test DB=postgres BUNDLE_WITHOUT=rmagick:mysql:mysql2:sqlite"
|
||||
- "TEST_SUITE=functionals RAILS_ENV=test DB=sqlite BUNDLE_WITHOUT=rmagick:mysql:mysql2:postgres"
|
||||
- "TEST_SUITE=integration RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- "TEST_SUITE=integration RAILS_ENV=test DB=mysql2 BUNDLE_WITHOUT=rmagick:mysql:postgres:sqlite"
|
||||
- "TEST_SUITE=integration RAILS_ENV=test DB=postgres BUNDLE_WITHOUT=rmagick:mysql:mysql2:sqlite"
|
||||
- "TEST_SUITE=integration RAILS_ENV=test DB=sqlite BUNDLE_WITHOUT=rmagick:mysql:mysql2:postgres"
|
||||
- "RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- "RAILS_ENV=test DB=mysql2 BUNDLE_WITHOUT=rmagick:mysql:postgres:sqlite"
|
||||
- "RAILS_ENV=test DB=postgres BUNDLE_WITHOUT=rmagick:mysql:mysql2:sqlite"
|
||||
- "RAILS_ENV=test DB=sqlite BUNDLE_WITHOUT=rmagick:mysql:mysql2:postgres"
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 1.9.2
|
||||
env: "TEST_SUITE=units RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: 1.9.2
|
||||
env: "TEST_SUITE=functionals RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: 1.9.2
|
||||
env: "TEST_SUITE=integration RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
env: "RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: 1.9.3
|
||||
env: "TEST_SUITE=units RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: 1.9.3
|
||||
env: "TEST_SUITE=functionals RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: 1.9.3
|
||||
env: "TEST_SUITE=integration RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
env: "RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: rbx-18mode
|
||||
env: "TEST_SUITE=units RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: rbx-18mode
|
||||
env: "TEST_SUITE=functionals RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
- rvm: rbx-18mode
|
||||
env: "TEST_SUITE=integration RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
env: "RAILS_ENV=test DB=mysql BUNDLE_WITHOUT=rmagick:mysql2:postgres:sqlite"
|
||||
allow_failures:
|
||||
- rvm: rbx-18mode
|
||||
before_install:
|
||||
- "sudo apt-get update -qq"
|
||||
- "sudo apt-get --no-install-recommends install bzr cvs git mercurial subversion"
|
||||
|
||||
# Our tests don't work on Darcs >= 2.5, so we use Darcs 2.3 from Ubuntu Lucy
|
||||
- "sudo apt-get --no-install-recommends install libc6 libcurl3-gnutls libgmp3c2 libncurses5 zlib1g"
|
||||
- "wget http://de.archive.ubuntu.com/ubuntu/pool/main/libf/libffi/libffi5_3.0.9-1_i386.deb -O /tmp/libffi5_3.0.9-1_i386.deb; sudo dpkg -i /tmp/libffi5_3.0.9-1_i386.deb"
|
||||
- "wget http://de.archive.ubuntu.com/ubuntu/pool/universe/d/darcs/darcs_2.3.0-3_i386.deb -O /tmp/darcs_2.3.0-3_i386.deb; sudo dpkg -i /tmp/darcs_2.3.0-3_i386.deb"
|
||||
before_script:
|
||||
- "rvm rubygems 1.8.25" # Rubygems 2.0.x fails with Rails 2.3
|
||||
- "rake ci:travis:prepare"
|
||||
- "rm -rf tmp/test/darcs_repository" # Don't test Darcs on Travis. It breaks there :(
|
||||
script: "bundle exec rake test:$TEST_SUITE"
|
||||
branches:
|
||||
only:
|
||||
- unstable
|
||||
|
|
6
Gemfile
6
Gemfile
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
source "https://rubygems.org"
|
||||
source :rubygems
|
||||
|
||||
gem "rails", "2.3.18"
|
||||
gem "rails", "2.3.17"
|
||||
|
||||
gem "json", "~> 1.7.7"
|
||||
gem "coderay", "~> 1.0.0"
|
||||
|
@ -13,6 +13,8 @@ gem "acts-as-taggable-on", "= 2.1.0"
|
|||
gem 'gravatarify', '~> 3.0.0'
|
||||
# Needed only on RUBY_VERSION = 1.8, ruby 1.9+ compatible interpreters should bring their csv
|
||||
gem "fastercsv", "~> 1.5.0", :platforms => [:ruby_18, :jruby, :mingw_18]
|
||||
# need for automatic encoding detection in diff,annotate and cat
|
||||
gem "chardet", ">= 0.9.0"
|
||||
gem "tzinfo", "~> 0.3.31" # Fixes #903. Not required for Rails >= 3.2
|
||||
|
||||
group :test do
|
||||
|
|
|
@ -54,14 +54,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# FIXME: This doesn't work with Rails >= 3.0 anymore
|
||||
# Possible workaround: https://github.com/rails/rails/issues/671#issuecomment-1780159
|
||||
rescue_from ActionController::RoutingError, :with => proc{
|
||||
# manually apply basic before_filters which aren't applied by default here
|
||||
user_setup
|
||||
check_if_login_required
|
||||
set_localization
|
||||
|
||||
render_404
|
||||
}
|
||||
rescue_from ActionController::RoutingError, :with => proc{render_404}
|
||||
|
||||
include Redmine::Search::Controller
|
||||
include Redmine::MenuManager::MenuController
|
||||
|
|
|
@ -36,6 +36,7 @@ class WikiController < ApplicationController
|
|||
verify :method => :post, :only => [:protect], :redirect_to => { :action => :show }
|
||||
|
||||
include AttachmentsHelper
|
||||
include Redmine::Export::PDF
|
||||
|
||||
# List of pages, sorted alphabetically and by parent (hierarchy)
|
||||
def index
|
||||
|
@ -69,7 +70,10 @@ class WikiController < ApplicationController
|
|||
end
|
||||
@content = @page.content_for_version(params[:version])
|
||||
if User.current.allowed_to?(:export_wiki_pages, @project)
|
||||
if params[:format] == 'html'
|
||||
if params[:format] == 'pdf'
|
||||
send_data(wiki_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
|
||||
return
|
||||
elsif params[:format] == 'html'
|
||||
export = render_to_string :action => 'export', :layout => false
|
||||
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
|
||||
return
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
# See doc/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
require 'rubygems'
|
||||
require 'UniversalDetector'
|
||||
|
||||
module AttachmentsHelper
|
||||
# Displays view/delete links to the attachments of the given object
|
||||
# Options:
|
||||
|
@ -26,18 +29,16 @@ module AttachmentsHelper
|
|||
end
|
||||
|
||||
def to_utf8_for_attachments(str)
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
return str if str.valid_encoding?
|
||||
else
|
||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||
end
|
||||
|
||||
begin
|
||||
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
||||
rescue Iconv::InvalidEncoding
|
||||
# "UTF-8//IGNORE" is not supported on some OS
|
||||
str
|
||||
end
|
||||
return nil if str.nil?
|
||||
iconv_str = str
|
||||
detected = UniversalDetector::chardet(str)
|
||||
enc = detected['encoding']
|
||||
if !enc.nil?
|
||||
begin
|
||||
iconv_str = Iconv.conv('UTF-8', enc, str)
|
||||
rescue Iconv::Failure => err
|
||||
end
|
||||
end
|
||||
iconv_str
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<td class="buttons"><%= link_to l(:button_delete), group, :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
</div>
|
||||
|
||||
<div class="splitcontentright">
|
||||
<p><%= f.date_field :start_date, :size => 10, :disabled => !@issue.leaf? %><%= calendar_for('issue_start_date') if @issue.leaf? %></p>
|
||||
<p><%= f.date_field :due_date, :size => 10, :disabled => !@issue.leaf? %><%= calendar_for('issue_due_date') if @issue.leaf? %></p>
|
||||
<p><%= f.date_field :start_date, :size => 10, :disabled => !@issue.leaf? %></p>
|
||||
<p><%= f.date_field :due_date, :size => 10, :disabled => !@issue.leaf? %></p>
|
||||
<p><%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf? %> <%= l(:field_hours) %></p>
|
||||
<% if @issue.leaf? && Issue.use_field_for_done_ratio? %>
|
||||
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
|
||||
<%= f.link_to 'PDF', :url => {:id => @page.title, :version => @content.version} %>
|
||||
<%= f.link_to 'HTML', :url => {:id => @page.title, :version => @content.version} %>
|
||||
<%= f.link_to 'TXT', :url => {:id => @page.title, :version => @content.version} %>
|
||||
<%= call_hook(:view_wiki_show_other_formats, {:link_builder => f, :url_params => {:id => @page.title, :version => @content.version}}) %>
|
||||
|
|
|
@ -50,6 +50,7 @@ class UpdateJournalsForActsAsJournalized < ActiveRecord::Migration
|
|||
t.string :journalized_type, :limit => 30, :default => "", :null => false
|
||||
end
|
||||
|
||||
custom_field_names = CustomField.all.group_by(&:type)[IssueCustomField].collect(&:name)
|
||||
Journal.all.each do |j|
|
||||
# Can't used j.journalized.class.name because the model changes make it nil
|
||||
j.update_attribute(:journalized_type, j.type.to_s.sub("Journal","")) if j.type.present?
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
= ChiliProject Changelog
|
||||
|
||||
== 2013-03-19 v3.8.0
|
||||
|
||||
* Bug #1121: Date Picker Icons disappear when changing the Tracker
|
||||
* Bug #1164: Error in "rake db:migrate:down VERSION=20100714111652"
|
||||
* Bug #1248: Routing issue
|
||||
* Security - Bug #1252: Update Rails to 2.3.18
|
||||
|
||||
== 2013-02-13 v3.7.0
|
||||
|
||||
* Security - Feature #1233: Bump rails to 2.3.17 to address [CVE-2013-0276]
|
||||
|
|
|
@ -18,7 +18,7 @@ module ChiliProject
|
|||
module VERSION #:nodoc:
|
||||
|
||||
MAJOR = 3
|
||||
MINOR = 8
|
||||
MINOR = 7
|
||||
PATCH = 0
|
||||
TINY = PATCH # Redmine compat
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ require 'redmine/notifiable'
|
|||
require 'redmine/wiki_formatting'
|
||||
require 'redmine/scm/base'
|
||||
|
||||
RMAGICK_BYPASS_VERSION_TEST = true
|
||||
|
||||
begin
|
||||
require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
|
||||
rescue LoadError
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
require 'iconv'
|
||||
|
||||
module Redmine
|
||||
module CodesetUtil
|
||||
|
||||
def self.replace_invalid_utf8(str)
|
||||
return str if str.nil?
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
if ! str.valid_encoding?
|
||||
str = str.encode("US-ASCII", :invalid => :replace,
|
||||
:undef => :replace, :replace => '?').encode("UTF-8")
|
||||
end
|
||||
elsif RUBY_PLATFORM == 'java'
|
||||
begin
|
||||
ic = Iconv.new('UTF-8', 'UTF-8')
|
||||
str = ic.iconv(str)
|
||||
rescue
|
||||
str = str.gsub(%r{[^\r\n\t\x20-\x7e]}, '?')
|
||||
end
|
||||
else
|
||||
ic = Iconv.new('UTF-8', 'UTF-8')
|
||||
txtar = ""
|
||||
begin
|
||||
txtar += ic.iconv(str)
|
||||
rescue Iconv::IllegalSequence
|
||||
txtar += $!.success
|
||||
str = '?' + $!.failed[1,$!.failed.length]
|
||||
retry
|
||||
rescue
|
||||
txtar += $!.success
|
||||
end
|
||||
str = txtar
|
||||
end
|
||||
str
|
||||
end
|
||||
|
||||
def self.to_utf8(str, encoding)
|
||||
return str if str.nil?
|
||||
str.force_encoding("ASCII-8BIT") if str.respond_to?(:force_encoding)
|
||||
if str.empty?
|
||||
str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
|
||||
return str
|
||||
end
|
||||
enc = encoding.blank? ? "UTF-8" : encoding
|
||||
if str.respond_to?(:force_encoding)
|
||||
if enc.upcase != "UTF-8"
|
||||
str.force_encoding(enc)
|
||||
str = str.encode("UTF-8", :invalid => :replace,
|
||||
:undef => :replace, :replace => '?')
|
||||
else
|
||||
str.force_encoding("UTF-8")
|
||||
if ! str.valid_encoding?
|
||||
str = str.encode("US-ASCII", :invalid => :replace,
|
||||
:undef => :replace, :replace => '?').encode("UTF-8")
|
||||
end
|
||||
end
|
||||
elsif RUBY_PLATFORM == 'java'
|
||||
begin
|
||||
ic = Iconv.new('UTF-8', enc)
|
||||
str = ic.iconv(str)
|
||||
rescue
|
||||
str = str.gsub(%r{[^\r\n\t\x20-\x7e]}, '?')
|
||||
end
|
||||
else
|
||||
ic = Iconv.new('UTF-8', enc)
|
||||
txtar = ""
|
||||
begin
|
||||
txtar += ic.iconv(str)
|
||||
rescue Iconv::IllegalSequence
|
||||
txtar += $!.success
|
||||
str = '?' + $!.failed[1,$!.failed.length]
|
||||
retry
|
||||
rescue
|
||||
txtar += $!.success
|
||||
end
|
||||
str = txtar
|
||||
end
|
||||
str
|
||||
end
|
||||
|
||||
def self.to_utf8_by_setting(str)
|
||||
return str if str.nil?
|
||||
str = self.to_utf8_by_setting_internal(str)
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
end
|
||||
str
|
||||
end
|
||||
|
||||
def self.to_utf8_by_setting_internal(str)
|
||||
return str if str.nil?
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('ASCII-8BIT')
|
||||
end
|
||||
return str if str.empty?
|
||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
end
|
||||
encodings = Setting.repositories_encodings.split(',').collect(&:strip)
|
||||
encodings.each do |encoding|
|
||||
begin
|
||||
return Iconv.conv('UTF-8', encoding, str)
|
||||
rescue Iconv::Failure
|
||||
# do nothing here and try the next encoding
|
||||
end
|
||||
end
|
||||
str = self.replace_invalid_utf8(str)
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
end
|
||||
str
|
||||
end
|
||||
|
||||
def self.from_utf8(str, encoding)
|
||||
str ||= ''
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
if encoding.upcase != 'UTF-8'
|
||||
str = str.encode(encoding, :invalid => :replace,
|
||||
:undef => :replace, :replace => '?')
|
||||
else
|
||||
str = self.replace_invalid_utf8(str)
|
||||
end
|
||||
elsif RUBY_PLATFORM == 'java'
|
||||
begin
|
||||
ic = Iconv.new(encoding, 'UTF-8')
|
||||
str = ic.iconv(str)
|
||||
rescue
|
||||
str = str.gsub(%r{[^\r\n\t\x20-\x7e]}, '?')
|
||||
end
|
||||
else
|
||||
ic = Iconv.new(encoding, 'UTF-8')
|
||||
txtar = ""
|
||||
begin
|
||||
txtar += ic.iconv(str)
|
||||
rescue Iconv::IllegalSequence
|
||||
txtar += $!.success
|
||||
str = '?' + $!.failed[1, $!.failed.length]
|
||||
retry
|
||||
rescue
|
||||
txtar += $!.success
|
||||
end
|
||||
str = txtar
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -74,6 +74,24 @@ module Redmine
|
|||
SetX(-30)
|
||||
RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
|
||||
end
|
||||
|
||||
def fix_text_encoding(txt)
|
||||
RDMPdfEncoding::rdm_from_utf8(txt, l(:general_pdf_encoding))
|
||||
end
|
||||
|
||||
def formatted_text(text)
|
||||
html = Redmine::WikiFormatting.to_html(Setting.text_formatting, text)
|
||||
# Strip {{toc}} tags
|
||||
html.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i, '')
|
||||
html
|
||||
end
|
||||
|
||||
def RDMwriteHTMLCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
|
||||
@attachments = attachments
|
||||
writeHTMLCell(w, h, x, y,
|
||||
fix_text_encoding(formatted_text(txt)),
|
||||
border, ln, fill)
|
||||
end
|
||||
end
|
||||
|
||||
class IFPDF < FPDF
|
||||
|
@ -441,6 +459,67 @@ module Redmine
|
|||
pdf.Output
|
||||
end
|
||||
|
||||
# Returns a PDF string of a single wiki page
|
||||
def wiki_to_pdf(page, project)
|
||||
pdf = ITCPDF.new(current_language)
|
||||
pdf.SetTitle("#{project} - #{page.title}")
|
||||
pdf.alias_nb_pages
|
||||
pdf.footer_date = format_date(Date.today)
|
||||
pdf.AddPage
|
||||
pdf.SetFontStyle('B',11)
|
||||
pdf.RDMMultiCell(190,5,
|
||||
"#{project} - #{page.title} - # #{page.content.version}")
|
||||
pdf.Ln
|
||||
|
||||
# Set resize image scale
|
||||
pdf.SetImageScale(1.6)
|
||||
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.RDMwriteHTMLCell(190,5,0,0,
|
||||
page.content.text.to_s, page.attachments, "TLRB")
|
||||
|
||||
if page.attachments.any?
|
||||
pdf.Ln
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
|
||||
pdf.Ln
|
||||
for attachment in page.attachments
|
||||
pdf.SetFontStyle('',8)
|
||||
pdf.RDMCell(80,5, attachment.filename)
|
||||
pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
|
||||
pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R")
|
||||
pdf.RDMCell(65,5, attachment.author.name,0,0,"R")
|
||||
pdf.Ln
|
||||
end
|
||||
end
|
||||
|
||||
pdf.Output
|
||||
end
|
||||
end
|
||||
|
||||
class RDMPdfEncoding
|
||||
def self.rdm_from_utf8(txt, encoding)
|
||||
txt ||= ''
|
||||
txt = Redmine::CodesetUtil.from_utf8(txt, encoding)
|
||||
if txt.respond_to?(:force_encoding)
|
||||
txt.force_encoding('ASCII-8BIT')
|
||||
end
|
||||
txt
|
||||
end
|
||||
|
||||
def self.attach(attachments, filename, encoding)
|
||||
filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
|
||||
atta = nil
|
||||
if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
|
||||
atta = Attachment.latest_attach(attachments, filename_utf8)
|
||||
end
|
||||
if atta && atta.readable? && atta.visible?
|
||||
return atta
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
require_dependency 'redmine/scm/adapters/abstract_adapter'
|
||||
require 'cgi'
|
||||
require 'rubygems'
|
||||
require 'UniversalDetector'
|
||||
|
||||
module Redmine
|
||||
module Scm
|
||||
|
@ -239,7 +241,18 @@ module Redmine
|
|||
diff = []
|
||||
hg *hg_args do |io|
|
||||
io.each_line do |line|
|
||||
diff << line
|
||||
iconv_line = line
|
||||
if !line.nil?
|
||||
detected = UniversalDetector::chardet(line)
|
||||
enc = detected['encoding']
|
||||
if !enc.nil?
|
||||
begin
|
||||
iconv_line = Iconv.conv('UTF-8', enc, line)
|
||||
rescue Iconv::Failure => err
|
||||
end
|
||||
end
|
||||
end
|
||||
diff << iconv_line
|
||||
end
|
||||
end
|
||||
diff
|
||||
|
@ -251,7 +264,18 @@ module Redmine
|
|||
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
|
||||
hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io|
|
||||
io.binmode
|
||||
io.read
|
||||
str = io.read
|
||||
return nil if str.nil?
|
||||
iconv_str = str
|
||||
detected = UniversalDetector::chardet(str)
|
||||
enc = detected['encoding']
|
||||
if !enc.nil?
|
||||
begin
|
||||
iconv_str = Iconv.conv('UTF-8', enc, str)
|
||||
rescue Iconv::Failure => err
|
||||
end
|
||||
end
|
||||
return iconv_str
|
||||
end
|
||||
rescue HgCommandAborted
|
||||
nil # means not found
|
||||
|
@ -266,7 +290,19 @@ module Redmine
|
|||
next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
|
||||
r = Revision.new(:author => $1.strip, :revision => $2, :scmid => $3,
|
||||
:identifier => $3)
|
||||
blame.add_line($4.rstrip, r)
|
||||
str = $4.rstrip
|
||||
iconv_str = str
|
||||
if !str.nil?
|
||||
detected = UniversalDetector::chardet(str)
|
||||
enc = detected['encoding']
|
||||
if !enc.nil?
|
||||
begin
|
||||
iconv_str = Iconv.conv('UTF-8', enc, str)
|
||||
rescue Iconv::Failure => err
|
||||
end
|
||||
end
|
||||
end
|
||||
blame.add_line(iconv_str, r)
|
||||
end
|
||||
end
|
||||
blame
|
||||
|
|
|
@ -3377,7 +3377,7 @@ class TCPDF
|
|||
#Extract attributes
|
||||
# get tag name
|
||||
tag = element.scan(/([a-zA-Z0-9]*)/).flatten.delete_if {|x| x.length == 0}
|
||||
tag = tag[0].downcase;
|
||||
tag = tag[0].to_s.downcase;
|
||||
|
||||
# get attributes
|
||||
attr_array = element.scan(/([^=\s]*)=["\']?([^"\']*)["\']?/)
|
||||
|
|
Loading…
Reference in New Issue