Module: Irwi::Helpers::WikiPageAttachmentsHelper

Included in:
WikiPagesHelper
Defined in:
lib/irwi/helpers/wiki_page_attachments_helper.rb

Instance Method Summary collapse

Instance Method Details

#wiki_add_page_attachment_path(page) ⇒ Object



3
4
5
6
# File 'lib/irwi/helpers/wiki_page_attachments_helper.rb', line 3

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

#wiki_remove_page_attachment_path(attachment_id) ⇒ Object



8
9
10
# File 'lib/irwi/helpers/wiki_page_attachments_helper.rb', line 8

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

#wiki_show_attachments(str) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/irwi/helpers/wiki_page_attachments_helper.rb', line 12

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