Feature #13051 » pdf_macro.patch
| ./app/helpers/application_helper.rb 2013-10-04 15:10:20.743888546 +0000 | ||
|---|---|---|
|
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
||
|
# search for the picture in attachments
|
||
|
if found = Attachment.latest_attach(attachments, filename)
|
||
|
image_url = download_named_attachment_path(found, found.filename, :only_path => only_path)
|
||
|
image_url = download_named_attachment_path(found, found.filename, :only_path => only_path, :host=>Setting.host_name)
|
||
|
desc = found.description.to_s.gsub('"', '')
|
||
|
if !desc.blank? && alttext.blank?
|
||
|
alt = " title=\"#{desc}\" alt=\"#{desc}\""
|
||
| ... | ... | |
|
else
|
||
|
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
||
|
parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
|
||
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
||
|
url_for(:only_path => only_path, :host=>Setting.host_name, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
||
|
:id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent)
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
# project.changesets.visible raises an SQL error because of a double join on repositories
|
||
|
if repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(repository.id, identifier))
|
||
|
link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.revision},
|
||
|
link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"), {:only_path => only_path, :host=>Setting.host_name, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.revision},
|
||
|
:class => 'changeset',
|
||
|
:title => truncate_single_line(changeset.comments, :length => 100))
|
||
|
end
|
||
| ... | ... | |
|
when nil
|
||
|
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status)
|
||
|
anchor = comment_id ? "note-#{comment_id}" : nil
|
||
|
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
||
|
link = link_to("##{oid}", {:only_path => only_path, :host=>Setting.host_name, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
||
|
:class => issue.css_classes,
|
||
|
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
||
|
end
|
||
|
when 'document'
|
||
|
if document = Document.visible.find_by_id(oid)
|
||
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
||
|
link = link_to h(document.title), {:only_path => only_path, :host=>Setting.host_name, :controller => 'documents', :action => 'show', :id => document},
|
||
|
:class => 'document'
|
||
|
end
|
||
|
when 'version'
|
||
|
if version = Version.visible.find_by_id(oid)
|
||
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||
|
link = link_to h(version.name), {:only_path => only_path, :host=>Setting.host_name, :controller => 'versions', :action => 'show', :id => version},
|
||
|
:class => 'version'
|
||
|
end
|
||
|
when 'message'
|
||
|
if message = Message.visible.find_by_id(oid, :include => :parent)
|
||
|
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
||
|
link = link_to_message(message, {:only_path => only_path, :host=>Setting.host_name}, :class => 'message')
|
||
|
end
|
||
|
when 'forum'
|
||
|
if board = Board.visible.find_by_id(oid)
|
||
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||
|
link = link_to h(board.name), {:only_path => only_path, :host=>Setting.host_name, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||
|
:class => 'board'
|
||
|
end
|
||
|
when 'news'
|
||
|
if news = News.visible.find_by_id(oid)
|
||
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||
|
link = link_to h(news.title), {:only_path => only_path, :host=>Setting.host_name, :controller => 'news', :action => 'show', :id => news},
|
||
|
:class => 'news'
|
||
|
end
|
||
|
when 'project'
|
||
|
if p = Project.visible.find_by_id(oid)
|
||
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
||
|
link = link_to_project(p, {:only_path => only_path, :host=>Setting.host_name}, :class => 'project')
|
||
|
end
|
||
|
end
|
||
|
elsif sep == ':'
|
||
| ... | ... | |
|
case prefix
|
||
|
when 'document'
|
||
|
if project && document = project.documents.visible.find_by_title(name)
|
||
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
||
|
link = link_to h(document.title), {:only_path => only_path, :host=>Setting.host_name, :controller => 'documents', :action => 'show', :id => document},
|
||
|
:class => 'document'
|
||
|
end
|
||
|
when 'version'
|
||
|
if project && version = project.versions.visible.find_by_name(name)
|
||
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||
|
link = link_to h(version.name), {:only_path => only_path, :host=>Setting.host_name, :controller => 'versions', :action => 'show', :id => version},
|
||
|
:class => 'version'
|
||
|
end
|
||
|
when 'forum'
|
||
|
if project && board = project.boards.visible.find_by_name(name)
|
||
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||
|
link = link_to h(board.name), {:only_path => only_path, :host=>Setting.host_name, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||
|
:class => 'board'
|
||
|
end
|
||
|
when 'news'
|
||
|
if project && news = project.news.visible.find_by_title(name)
|
||
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||
|
link = link_to h(news.title), {:only_path => only_path, :host=>Setting.host_name, :controller => 'news', :action => 'show', :id => news},
|
||
|
:class => 'news'
|
||
|
end
|
||
|
when 'commit', 'source', 'export'
|
||
| ... | ... | |
|
end
|
||
|
if prefix == 'commit'
|
||
|
if repository && (changeset = Changeset.visible.where("repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%").first)
|
||
|
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
|
||
|
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :host=>Setting.host_name, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
|
||
|
:class => 'changeset',
|
||
|
:title => truncate_single_line(changeset.comments, :length => 100)
|
||
|
end
|
||
| ... | ... | |
|
when 'attachment'
|
||
|
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
||
|
if attachments && attachment = Attachment.latest_attach(attachments, name)
|
||
|
link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment')
|
||
|
link = link_to_attachment(attachment, :only_path => only_path, :host=>Setting.host_name, :download => true, :class => 'attachment')
|
||
|
end
|
||
|
when 'project'
|
||
|
if p = Project.visible.where("identifier = :s OR LOWER(name) = :s", :s => name.downcase).first
|
||
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
||
|
link = link_to_project(p, {:only_path => only_path, :host=>Setting.host_name}, :class => 'project')
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./lib/redmine/export/pdf.rb 2013-10-17 09:15:10.199885955 +0000 | ||
|---|---|---|
|
module PDF
|
||
|
include ActionView::Helpers::TextHelper
|
||
|
include ActionView::Helpers::NumberHelper
|
||
|
include IssuesHelper
|
||
|
class ITCPDF < TCPDF
|
||
|
include ::ActionView::Helpers
|
||
|
include ActionDispatch::Routing
|
||
|
include Rails.application.routes.url_helpers
|
||
|
include ERB::Util
|
||
|
include IssuesHelper
|
||
|
include Redmine::I18n
|
||
|
attr_accessor :footer_date
|
||
| ... | ... | |
|
end
|
||
|
def formatted_text(text)
|
||
|
html = Redmine::WikiFormatting.to_html(Setting.text_formatting, text)
|
||
|
html = textilizable(text, {:host=>Setting.host_name, :only_path=>false})
|
||
|
# Strip {{toc}} tags
|
||
|
html.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i, '')
|
||
|
html
|
||
|
end
|
||
|
# Encodes an UTF-8 string to UTF-16BE
|
||
- « Previous
- 1
- 2
- 3
- Next »