RedmineのPDF文字化けと日付表示と統計表示
PDFの文字化けの対応
完璧ではないらしいが、やってみる。
- 参考URL
PDFおよびCSVの文字化けを回避する — Redmine.JP
Google グループ
Redmineの文字化けとか勝手にまとめ: これ本番ですか?
徒然さめざめ Redmine Hack! - pdfの文字化け fix編 -
http://www.maruhisa.org/2009/07/redmine_pdf_problem/
徒然さめざめ 続・何回目? Redmine pdf日本語化hack
- config/locales/ja.yml
- general_csv_encoding: CP932 - general_pdf_encoding: CP932 + general_csv_encoding: SJIS + general_pdf_encoding: SJIS
pdf.rbのMultiCellの引数(文字列)にひたすら.tosjisをかます。
- lib/redmine/export/pdf.rb
- pdf.MultiCell(155,5, (show_value custom_value),"R") + pdf.MultiCell(155,5, (show_value.tosjis custom_value.tosjis),"R") - pdf.MultiCell(155,5, @issue.description,"BR") + pdf.MultiCell(155,5, @issue.description.tosjis,"BR") - pdf.MultiCell(190,5, changeset.comments) + pdf.MultiCell(190,5, changeset.comments.tosjis) - pdf.MultiCell(190,5, journal.notes) + pdf.MultiCell(190,5, journal.notes.tosjis)
履歴に何か書くと次のエラーを吐いて落ちる・・・
Processing IssuesController#show to pdf (for 192.168.24.83 at 2010-07-09 01:10:36) [GET] Parameters: {"format"=>"pdf", "action"=>"show", "id"=>"3", "controller"=>"issues"} TypeError (nil can't be coerced into Fixnum): lib/redmine/export/pdf.rb:294:in `issue_to_pdf' lib/redmine/export/pdf.rb:283:in `each' lib/redmine/export/pdf.rb:283:in `issue_to_pdf' app/controllers/issues_controller.rb:128:in `show' app/controllers/issues_controller.rb:123:in `show' passenger (2.2.11) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request' passenger (2.2.11) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application' passenger (2.2.11) lib/phusion_passenger/utils.rb:184:in `safe_fork' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `__send__' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `main_loop' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:163:in `start' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:213:in `start' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application' passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application' passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize' passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `__send__' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `main_loop' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' Rendering /var/redmine/public/500.html (500 Internal Server Error)
とりあえず履歴と関連するリビジョンは印字してもらう必要ないので、その印字処理を削除する。
# if issue.changesets.any? && User.current.allowed_to?(:view_changesets, issue.project) # pdf.SetFontStyle('B',9) # pdf.Cell(190,5, l(:label_associated_revisions), "B") # pdf.Ln # for changeset in issue.changesets # pdf.SetFontStyle('B',8) # pdf.Cell(190,5, format_time(changeset.committed_on) + " - " + changeset.author.to_s) # pdf.Ln # unless changeset.comments.blank? # pdf.SetFontStyle('',8) # pdf.MultiCell(190,5, changeset.comments.tosjis) # end # pdf.Ln # end # end # pdf.SetFontStyle('B',9) # pdf.Cell(190,5, l(:label_history), "B") # pdf.Ln # for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") # pdf.SetFontStyle('B',8) # pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name) # pdf.Ln # pdf.SetFontStyle('I',8) # for detail in journal.details # pdf.Cell(190,5, "- " + show_detail(detail, true)) # pdf.Ln # end # unless journal.notes.blank? # pdf.SetFontStyle('',8) # pdf.MultiCell(190,5, journal.notes.tosjis) # end # pdf.Ln # end
ブラウザの機能で印字する場合は、次のツールで余計な部分を取り除くことにしよう。
https://addons.mozilla.org/ja/firefox/addon/193270/
ガントチャートに日付表示
- 参考URL
http://labo-ss.net/blog/itroom/item_46.html
プロジェクト管理ツールRedMineのガントチャートカスタマイズ - + YOSHIKI & Violet UK FAN SITE -Blind Tears- 管理人の日記 +
- app/views/gantts/show.html.erb(r3756)
44 headers_height = header_heigth 45 show_weeks = false 46 show_days = false 47 show_day_num = false #★追加★ 48 49 if @gantt.zoom >1 50 show_weeks = true 51 headers_height = 2*header_heigth 52 if @gantt.zoom > 2 53 show_days = true 54 headers_height = 3*header_heigth 55 if @gantt.zoom > 3 #★追加★ 56 show_day_num = true #★追加★ 57 headers_height = 4*header_heigth #★追加★ 58 end #★追加★ 59 end 60 end 150 <!-- ★追加★ start --> 151 <% 152 # 153 # Days headers Num 154 # 155 if show_day_num 156 left = 0 157 height = g_height + header_heigth * 2 - 1 158 wday = @gantt.date_from.cwday 159 day_num = @gantt.date_from 160 (@gantt.date_to - @gantt.date_from + 1).to_i.times do 161 width = zoom - 1 162 %> 163 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %><%= "color:blue;" if wday == 6 %> <%= "color:red;" if wday == 7 % >" class="gantt_hdr"> 164 <%= day_num.day %> 165 </div> 166 <% 167 left = left + width+1 168 day_num = day_num + 1 169 wday = wday + 1 170 wday = 1 if wday > 7 171 end 172 end %> 173 <!-- ★追加★ end --> 175 <% 176 # 177 # Days headers 178 # 179 if show_days 180 left = 0 181 height = g_height + header_heigth - 1 182 top = (show_day_num ? 55 : 37) #★追加★ 183 wday = @gantt.date_from.cwday 184 (@gantt.date_to - @gantt.date_from + 1).to_i.times do 185 width = zoom - 1 186 %> 187 <!-- <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr"> --> 188 <div style="left:<%= left %>px;top:<%= top %>px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %><%= "color:blue;" if wday == 6 %><%= "color:red;" if wday == 7 %>" class="gantt_hdr"> <!-- ★変更★ --> 189 <%= day_name(wday).first %> 190 </div> 191 <% 192 left = left + width+1 193 wday = wday + 1 194 wday = 1 if wday > 7 195 end 196 end %>
最大の大きさの時(拡大+4)に日付を表示してくれる。
なかなかいい感じ。先人の方々に感謝。
統計が表示されない
ruby1.8のバグらしい。
Redmineで統計を表示する: これ本番ですか?
下記の通り修正すれば表示出きるようになった。
- /usr/lib/ruby/1.8/rexml/document.rb
186 # if transitive 187 if trans