Sha256: 5c1fc42ee1e05d47efd1eb654f4653487d03c9afd33ea97da1b0ff6e3e317130

Contents?: true

Size: 711 Bytes

Versions: 4

Compression:

Stored size: 711 Bytes

Contents

require 'active_record/errors'

module Irwi::Helpers::WikiPageAttachmentsHelper

  def wiki_add_page_attachment_path(page)
    page = page.path if page.respond_to? :path
    url_for(:action => 'add_attachment', :path => page)
  end

  def wiki_remove_page_attachment_path(attachment_id)
    url_for(:action => 'remove_attachment', :attachment_id => attachment_id)
  end

  def wiki_show_attachments(str)
    str.gsub /Attachment_([\d]+)_([\w]+)/ do |m|
      begin
        attachment = Irwi.config.page_attachment_class.find($1)
        image_tag attachment.wiki_page_attachment.url($2.to_sym), :class => 'wiki_page_attachment'
      rescue ActiveRecord::RecordNotFound
        nil
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
irwi-0.5.0 lib/irwi/helpers/wiki_page_attachments_helper.rb
irwi-0.4.2 lib/irwi/helpers/wiki_page_attachments_helper.rb
irwi-0.4.1 lib/irwi/helpers/wiki_page_attachments_helper.rb
irwi-0.4.0 lib/irwi/helpers/wiki_page_attachments_helper.rb