0033-Add-images-to-the-wiki-export-functionality.patch

Aaron Fischer, 2009-10-29 18:31

Download (2.85 KB)

View differences:

app/helpers/application_helper.rb
371 371
        filename = $6.downcase
372 372
        # search for the picture in attachments
373 373
        if found = attachments.detect { |att| att.filename.downcase == filename }
374
          image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
375
          desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
376
          alt = desc.blank? ? nil : "(#{desc})"
377
          "!#{style}#{image_url}#{alt}!"
374
          case options[:wiki_links]
375
          when :local
376
            "!#{style}data:#{found.content_type};base64,#{Base64.b64encode(File.read(found.diskfile)).gsub(/\n/,"")}!"
377
          when :anchor
378
            "!#{style}data:#{found.content_type};base64,#{Base64.b64encode(File.read(found.diskfile)).gsub(/\n/,"")}!"
379
          else
380
            image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
381
            desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
382
            alt = desc.blank? ? nil : "(#{desc})"
383
            "!#{style}#{image_url}#{alt}!"
384
          end
378 385
        else
379 386
          m
380 387
        end
app/views/wiki/export.rhtml
13 13
</style>
14 14
</head>
15 15
<body>
16
<%= textilizable @content, :text, :wiki_links => :local %>
16
<%= textilizable @content, :text, :wiki_links => :local, :attachments => @content.page.attachments %>
17 17
</body>
18 18
</html>
app/views/wiki/export_multiple.rhtml
20 20
<% @pages.each do |page| %>
21 21
<hr />
22 22
<a name="<%= page.title %>" />
23
<%= textilizable page.content ,:text, :wiki_links => :anchor %>
23
<%= textilizable page.content ,:text, :wiki_links => :anchor, :attachments => page.attachments %>
24 24
<% end %>
25 25

  
26 26
</body>
27
-