Sha256: cff54b41cd42b1f17ffb271b5cbb87a56c5cf55649b0ebf207f9c67c5ef32e42

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

require 'active_record/errors'

module IrwiMod::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 = IrwiMod.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

2 entries across 2 versions & 1 rubygems

Version Path
irwi_mod-0.0.2 lib/irwi_mod/helpers/wiki_page_attachments_helper.rb
irwi_mod-0.0.1 lib/irwi_mod/helpers/wiki_page_attachments_helper.rb