##// END OF EJS Templates
Hide Redmine version in atom feeds and pdf properties (#794)....
Jean-Philippe Lang -
r2001:5166213fd314
parent child
Show More
@@ -1,85 +1,85
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'iconv'
18 require 'iconv'
19 require 'rfpdf/chinese'
19 require 'rfpdf/chinese'
20
20
21 module IfpdfHelper
21 module IfpdfHelper
22
22
23 class IFPDF < FPDF
23 class IFPDF < FPDF
24 include GLoc
24 include GLoc
25 attr_accessor :footer_date
25 attr_accessor :footer_date
26
26
27 def initialize(lang)
27 def initialize(lang)
28 super()
28 super()
29 set_language_if_valid lang
29 set_language_if_valid lang
30 case current_language.to_s
30 case current_language.to_s
31 when 'ja'
31 when 'ja'
32 extend(PDF_Japanese)
32 extend(PDF_Japanese)
33 AddSJISFont()
33 AddSJISFont()
34 @font_for_content = 'SJIS'
34 @font_for_content = 'SJIS'
35 @font_for_footer = 'SJIS'
35 @font_for_footer = 'SJIS'
36 when 'zh'
36 when 'zh'
37 extend(PDF_Chinese)
37 extend(PDF_Chinese)
38 AddGBFont()
38 AddGBFont()
39 @font_for_content = 'GB'
39 @font_for_content = 'GB'
40 @font_for_footer = 'GB'
40 @font_for_footer = 'GB'
41 when 'zh-tw'
41 when 'zh-tw'
42 extend(PDF_Chinese)
42 extend(PDF_Chinese)
43 AddBig5Font()
43 AddBig5Font()
44 @font_for_content = 'Big5'
44 @font_for_content = 'Big5'
45 @font_for_footer = 'Big5'
45 @font_for_footer = 'Big5'
46 else
46 else
47 @font_for_content = 'Arial'
47 @font_for_content = 'Arial'
48 @font_for_footer = 'Helvetica'
48 @font_for_footer = 'Helvetica'
49 end
49 end
50 SetCreator("redMine #{Redmine::VERSION}")
50 SetCreator(Redmine::Info.app_name)
51 SetFont(@font_for_content)
51 SetFont(@font_for_content)
52 end
52 end
53
53
54 def SetFontStyle(style, size)
54 def SetFontStyle(style, size)
55 SetFont(@font_for_content, style, size)
55 SetFont(@font_for_content, style, size)
56 end
56 end
57
57
58 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
58 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
59 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
59 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
60 # these quotation marks are not correctly rendered in the pdf
60 # these quotation marks are not correctly rendered in the pdf
61 txt = txt.gsub(/[β€œβ€]/, '"') if txt
61 txt = txt.gsub(/[β€œβ€]/, '"') if txt
62 txt = begin
62 txt = begin
63 # 0x5c char handling
63 # 0x5c char handling
64 txtar = txt.split('\\')
64 txtar = txt.split('\\')
65 txtar << '' if txt[-1] == ?\\
65 txtar << '' if txt[-1] == ?\\
66 txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
66 txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
67 rescue
67 rescue
68 txt
68 txt
69 end || ''
69 end || ''
70 super w,h,txt,border,ln,align,fill,link
70 super w,h,txt,border,ln,align,fill,link
71 end
71 end
72
72
73 def Footer
73 def Footer
74 SetFont(@font_for_footer, 'I', 8)
74 SetFont(@font_for_footer, 'I', 8)
75 SetY(-15)
75 SetY(-15)
76 SetX(15)
76 SetX(15)
77 Cell(0, 5, @footer_date, 0, 0, 'L')
77 Cell(0, 5, @footer_date, 0, 0, 'L')
78 SetY(-15)
78 SetY(-15)
79 SetX(-30)
79 SetX(-30)
80 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
80 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
81 end
81 end
82
82
83 end
83 end
84
84
85 end
85 end
@@ -1,31 +1,31
1 xml.instruct!
1 xml.instruct!
2 xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
2 xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
3 xml.title truncate_single_line(@title, 100)
3 xml.title truncate_single_line(@title, 100)
4 xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false}))
4 xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false}))
5 xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
5 xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
6 xml.id url_for(:controller => 'welcome', :only_path => false)
6 xml.id url_for(:controller => 'welcome', :only_path => false)
7 xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
7 xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
8 xml.author { xml.name "#{Setting.app_title}" }
8 xml.author { xml.name "#{Setting.app_title}" }
9 xml.generator(:uri => Redmine::Info.url, :version => Redmine::VERSION) { xml.text! Redmine::Info.versioned_name; }
9 xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; }
10 @items.each do |item|
10 @items.each do |item|
11 xml.entry do
11 xml.entry do
12 url = url_for(item.event_url(:only_path => false))
12 url = url_for(item.event_url(:only_path => false))
13 if @project
13 if @project
14 xml.title truncate_single_line(item.event_title, 100)
14 xml.title truncate_single_line(item.event_title, 100)
15 else
15 else
16 xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100)
16 xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100)
17 end
17 end
18 xml.link "rel" => "alternate", "href" => url
18 xml.link "rel" => "alternate", "href" => url
19 xml.id url
19 xml.id url
20 xml.updated item.event_datetime.xmlschema
20 xml.updated item.event_datetime.xmlschema
21 author = item.event_author if item.respond_to?(:event_author)
21 author = item.event_author if item.respond_to?(:event_author)
22 xml.author do
22 xml.author do
23 xml.name(author)
23 xml.name(author)
24 xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank?
24 xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank?
25 end if author
25 end if author
26 xml.content "type" => "html" do
26 xml.content "type" => "html" do
27 xml.text! textilizable(item.event_description)
27 xml.text! textilizable(item.event_description)
28 end
28 end
29 end
29 end
30 end
30 end
31 end
31 end
General Comments 0
You need to be logged in to leave comments. Login now