diff --git a/app/views/base_wiki_pages/_wiki_page_attachments.html.erb b/app/views/base_wiki_pages/_wiki_page_attachments.html.erb new file mode 100644 index 0000000..5abaad3 --- /dev/null +++ b/app/views/base_wiki_pages/_wiki_page_attachments.html.erb @@ -0,0 +1,14 @@ +<% page.attachments.each do |attachment| %> + <%= image_tag(attachment.wiki_page_attachment.url(:thumb)) %> + Attachment_<%= attachment.id %> + <%= link_to(wt('Remove'), wiki_remove_page_attachment_path(attachment.id), method: :delete) %> +<% end %> + +<%= form_for(Irwi.config.page_attachment_class.new, + as: :wiki_page_attachment, + url: wiki_add_page_attachment_path(page), + html: { multipart: true }) do |form| %> + <%= form.file_field :wiki_page_attachment %> + <%= form.hidden_field :page_id, value: page.id %> + <%= form.submit 'New Attachment' %> +<% end %> diff --git a/lib/irwi/helpers/wiki_pages_helper.rb b/lib/irwi/helpers/wiki_pages_helper.rb index 70b4907..c696deb 100644 --- a/lib/irwi/helpers/wiki_pages_helper.rb +++ b/lib/irwi/helpers/wiki_pages_helper.rb @@ -124,21 +124,6 @@ def wiki_page_history(page = nil, versions = nil) end def wiki_page_attachments(page = @page) - return unless Irwi.config.page_attachment_class_name - - page.attachments.each do |attachment| - concat image_tag(attachment.wiki_page_attachment.url(:thumb)) - concat "Attachment_#{attachment.id}" - concat link_to(wt('Remove'), wiki_remove_page_attachment_path(attachment.id), method: :delete) - end - - form_for(Irwi.config.page_attachment_class.new, - as: :wiki_page_attachment, - url: wiki_add_page_attachment_path(page), - html: { multipart: true }) do |form| - concat form.file_field :wiki_page_attachment - concat form.hidden_field :page_id, value: page.id - concat form.submit 'Add Attachment' - end + render partial: "#{template_dir '_wiki_page_actions'}/wiki_page_attachments", locals: { page: page } end end