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



5
6
7
8
# File 'lib/irwi/helpers/wiki_page_attachments_helper.rb', line 5

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



10
11
12
# File 'lib/irwi/helpers/wiki_page_attachments_helper.rb', line 10

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

#wiki_show_attachments(str) ⇒ Object



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

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