Compare commits

...

41 Commits

Author SHA1 Message Date
Kolan Sh 6125ca1246 Good export but png files not found. ;-( 2013-02-26 17:21:01 +04:00
Kolan Sh 6978a86c97 Merge tag 'v3.7.0' into backbone.ws 2013-02-14 00:52:45 +04:00
Kolan Sh b4e5f6cd0d Merge tag 'v3.6.0' into backbone.ws 2013-01-30 11:14:50 +04:00
Kolan Sh 5e370b720b Merge branch 'master' into backbone.ws 2013-01-17 11:46:07 +04:00
Kolan Sh 9ebbce7ba3 Merge branch 'master' into backbone.ws 2013-01-09 19:17:57 +04:00
Kolan Sh efe53a60c5 Merge branch 'rmagick_bypass_version_test' into backbone.ws 2013-01-07 17:25:24 +04:00
Kolan Sh 8e78e2d78b RMagic: bypass version test. 2013-01-07 17:24:53 +04:00
Kolan Sh 19f2859e1b v3.4.0 merged to backbone.ws 2013-01-07 17:14:21 +04:00
Holger Just 7efc8dbb19 Bump version to 3.3.0 2012-08-11 10:27:32 +04:00
Holger Just eb41ffd854 Update Changelog for v3.3.0 2012-08-11 10:27:32 +04:00
Holger Just f9180b1dc8 Add copyright statement 2012-08-11 10:27:32 +04:00
Andrew Smith b43e8186c4 Replace the progress bars with a copied jQuery version. Fixes #1056 2012-08-11 10:27:32 +04:00
Holger Just 4c4383ff71 Add gravatar no-op library.
This helps to not break on plugins having require "gravatar"
in their init.rb. This statement is not needed anymore in any
supported version of ChiliProject (or Redmine for that matter) and
should thus be removed from all plugins.
2012-08-11 10:27:32 +04:00
Andrew Smith 72e9805b72 Replace the JS calendar with a jQueryUI version. 2012-08-11 10:27:32 +04:00
Felix Schäfer 5cefd6a425 Add date_field and date_field_tag form helpers #817 2012-08-11 10:27:32 +04:00
Felix Schäfer 7437eaea53 Bump net-ldap #1078 2012-08-11 10:27:32 +04:00
Holger Just f6ebdb3405 Make list style for ul and ol elements more specific. #1075 2012-08-11 10:27:32 +04:00
Andrew Smith 1a28b5a281 Update jQuery/UI to 1.7.2/1.8.21. Fixes #1076 2012-08-11 10:27:32 +04:00
Romano Licker a57691369e [#935] Setting improperly set up for default values
having a fixed call order resolves a problem where
'value=' was called before 'name=' resulting in no
serialization
2012-08-11 10:27:32 +04:00
Holger Just d91b297846 Load rake tasks from plugins in chiliproject_plugins #1074 2012-08-11 10:27:31 +04:00
Felix Schäfer 45f628591e Fix migrating from Redmine 1.4 #1067
Contributed by Steffen Schüssler
2012-08-11 10:27:31 +04:00
Andrew Smith 9017d14054 Losslessly recompress all the image files. Fixes #1070 2012-08-11 10:27:31 +04:00
Felix Schäfer 037bb192ac Don't show the search field when it's not needed #979
Contributed by Harald Klimach
2012-08-11 10:27:31 +04:00
Felix Schäfer f0f0171a59 Show the register link everywhere it's needed #979
Contributed by Harald Klimach
2012-08-11 10:27:31 +04:00
Andrew Smith 03e68da23c Force the hover colour so that even rows highlight. Fixes #1063 2012-08-11 10:27:31 +04:00
Holger Just 8e80e65e0a Format date in user's prefered format by default 2012-08-11 10:27:31 +04:00
Holger Just 5350f4323a Fix the Strainer patch to enforce a filter array
Up until now, the patch used to be a no-op. While the filters class
attribute was set correctly, the methods using it were not actually
overridden as they are only included above the existing methods in
the module chain.

This resulted in an arbitrary load order of filters on Ruby 1.8. As
such, our overridden standard filters might not have actually
overridden anything.

Still, the patch can be completely removed once we either require
Ruby 1.9 (as we have ordered ahshes by default then) or once
https://github.com/Shopify/liquid/pull/87 was merged and released
upstream.
2012-08-11 10:27:31 +04:00
Holger Just abfc04973e Define today variable for liquid #1055 2012-08-11 10:27:31 +04:00
Andrew Smith 8478e6a115 Include a minimal Modernizr JS build. Fixes #1054 2012-08-11 10:27:31 +04:00
Andrew Smith c9bec63b7d Set the users language on the HTML tag. Fixes #1051 2012-08-11 10:27:31 +04:00
Andrew Smith 90c4453b58 Change to an HTML5 doctype #1018 2012-08-11 10:27:31 +04:00
Jan Vlnas 935b2c8635 Correct engine tests to work on Ruby 1.9 #952 #944 2012-08-11 10:27:31 +04:00
Holger Just fe19c6c5be Require bundler 1.0.14 to use the rbx platform in Gemfile 2012-08-11 10:27:31 +04:00
Holger Just a91563e194 Set $KCODE to UTF-8 on Ruby 1.8 to mimic Rails 3 behavior 2012-08-11 10:27:31 +04:00
Felix Schäfer 645f44a419 Enable project-specific css #1017 2012-08-11 10:27:30 +04:00
Holger Just 1ed846cd01 Fix failing tests for Ruby 1.9 #1046 2012-08-11 10:27:30 +04:00
Holger Just 02d2deeae6 Add "me" to user custom fields filters #1046
Adapted from
28f9605fe2
by Jean-Philippe Lang
2012-08-11 10:27:30 +04:00
Kolan Sh 1e908da66c Merge branch 'master' into backbone.ws 2012-06-15 00:12:40 +04:00
Kolan Sh e5de5f43cc v3.1.0 merged 2012-04-05 13:22:02 +04:00
Kolan Sh 65b94d2014 Character encoding detection in attachments is now automatic 2012-03-24 23:39:46 +04:00
Kolan Sh 786e92349b Automatic character encoding detection in Mercurial repos. 2012-03-24 23:39:33 +04:00
9 changed files with 292 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}}) %>

View File

@ -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

149
lib/redmine/codeset_util.rb Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]*)=["\']?([^"\']*)["\']?/)