Feature #550 » 0033-Add-images-to-the-wiki-export-functionality.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
|
filename = $6.downcase
|
||
|
# search for the picture in attachments
|
||
|
if found = attachments.detect { |att| att.filename.downcase == filename }
|
||
|
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
|
||
|
desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
|
||
|
alt = desc.blank? ? nil : "(#{desc})"
|
||
|
"!#{style}#{image_url}#{alt}!"
|
||
|
case options[:wiki_links]
|
||
|
when :local
|
||
|
"!#{style}data:#{found.content_type};base64,#{Base64.b64encode(File.read(found.diskfile)).gsub(/\n/,"")}!"
|
||
|
when :anchor
|
||
|
"!#{style}data:#{found.content_type};base64,#{Base64.b64encode(File.read(found.diskfile)).gsub(/\n/,"")}!"
|
||
|
else
|
||
|
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
|
||
|
desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
|
||
|
alt = desc.blank? ? nil : "(#{desc})"
|
||
|
"!#{style}#{image_url}#{alt}!"
|
||
|
end
|
||
|
else
|
||
|
m
|
||
|
end
|
||
| app/views/wiki/export.rhtml | ||
|---|---|---|
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<%= textilizable @content, :text, :wiki_links => :local %>
|
||
|
<%= textilizable @content, :text, :wiki_links => :local, :attachments => @content.page.attachments %>
|
||
|
</body>
|
||
|
</html>
|
||
| app/views/wiki/export_multiple.rhtml | ||
|---|---|---|
|
<% @pages.each do |page| %>
|
||
|
<hr />
|
||
|
<a name="<%= page.title %>" />
|
||
|
<%= textilizable page.content ,:text, :wiki_links => :anchor %>
|
||
|
<%= textilizable page.content ,:text, :wiki_links => :anchor, :attachments => page.attachments %>
|
||
|
<% end %>
|
||
|
</body>
|
||