summaryrefslogtreecommitdiffstats
path: root/app/views
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-26 15:42:37 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-26 15:42:37 +0000
commitf8ef65e8f64111b5bfa45abd42e0e684afd61f07 (patch)
treef38d893e289b9eb42f7732eeb33c225b8379ad41 /app/views
parent6446c312beab7e23162827a79bd9ab6f9e4d7958 (diff)
downloadredmine-f8ef65e8f64111b5bfa45abd42e0e684afd61f07.tar.gz
redmine-f8ef65e8f64111b5bfa45abd42e0e684afd61f07.zip
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments.
Attached images can be displayed inline, using textile image tag (for wiki pages, issue descriptions and forum messages). git-svn-id: http://redmine.rubyforge.org/svn/trunk@541 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/views')
-rw-r--r--app/views/attachments/_form.rhtml4
-rw-r--r--app/views/attachments/_links.rhtml13
-rw-r--r--app/views/issues/show.rhtml26
-rw-r--r--app/views/messages/_form.rhtml5
-rw-r--r--app/views/messages/show.rhtml13
-rw-r--r--app/views/wiki/_preview.rhtml2
-rw-r--r--app/views/wiki/show.rhtml14
7 files changed, 43 insertions, 34 deletions
diff --git a/app/views/attachments/_form.rhtml b/app/views/attachments/_form.rhtml
new file mode 100644
index 000000000..18f08c6be
--- /dev/null
+++ b/app/views/attachments/_form.rhtml
@@ -0,0 +1,4 @@
+<p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
+<%= image_to_function "add.png", "addFileField();return false" %></label>
+
+<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
diff --git a/app/views/attachments/_links.rhtml b/app/views/attachments/_links.rhtml
new file mode 100644
index 000000000..93d6b2a7d
--- /dev/null
+++ b/app/views/attachments/_links.rhtml
@@ -0,0 +1,13 @@
+<div class="attachments">
+<% for attachment in attachments %>
+ <p><%= link_to attachment.filename, {:controller => 'attachments', :action => 'download', :id => attachment }, :class => 'icon icon-attachment' %>
+ (<%= number_to_human_size attachment.filesize %>)
+ <% unless options[:no_author] %>
+ <em><%= attachment.author.display_name %>, <%= format_date(attachment.created_on) %></em>
+ <% end %>
+ <% if options[:delete_url] %>
+ <%= link_to image_tag('delete.png'), options[:delete_url].update({:attachment_id => attachment}), :confirm => l(:text_are_you_sure), :method => :post %>
+ <% end %>
+ </p>
+<% end %>
+</div>
diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml
index 1895e7cef..2c4905e9d 100644
--- a/app/views/issues/show.rhtml
+++ b/app/views/issues/show.rhtml
@@ -52,7 +52,7 @@ end %>
<% end %>
<b><%=l(:field_description)%> :</b><br /><br />
-<%= textilizable @issue.description %>
+<%= textilizable @issue.description, :attachments => @issue.attachments %>
<br />
<div class="contextual">
@@ -92,24 +92,14 @@ end %>
<div class="box">
<h3><%=l(:label_attachment_plural)%></h3>
-<table width="100%">
-<% for attachment in @issue.attachments %>
-<tr>
-<td><%= link_to attachment.filename, { :action => 'download', :id => @issue, :attachment_id => attachment }, :class => 'icon icon-attachment' %> (<%= number_to_human_size(attachment.filesize) %>)</td>
-<td><%= format_date(attachment.created_on) %></td>
-<td><%= attachment.author.display_name %></td>
-<td><div class="contextual"><%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy_attachment', :id => @issue, :attachment_id => attachment }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></div></td>
-</tr>
-<% end %>
-</table>
-<br />
+<%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
+
<% if authorize_for('issues', 'add_attachment') %>
- <% form_tag({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") do %>
- <p id="attachments_p"><label><%=l(:label_attachment_new)%>
- <%= image_to_function "add.png", "addFileField();return false" %></label>
- <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
- <%= submit_tag l(:button_add) %>
- <% end %>
+<p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
+<% form_tag({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
+ <%= render :partial => 'attachments/form' %>
+<%= submit_tag l(:button_add) %>
+<% end %>
<% end %>
</div>
diff --git a/app/views/messages/_form.rhtml b/app/views/messages/_form.rhtml
index 453bd8b2a..93e4311b9 100644
--- a/app/views/messages/_form.rhtml
+++ b/app/views/messages/_form.rhtml
@@ -10,8 +10,5 @@
<!--[eoform:message]-->
<span class="tabular">
-<p id="attachments_p"><label><%=l(:label_attachment)%>
-<%= image_to_function "add.png", "addFileField();return false" %></label>
-<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
-</span>
+<%= render :partial => 'attachments/form' %>
</div>
diff --git a/app/views/messages/show.rhtml b/app/views/messages/show.rhtml
index 8068da011..c18eb524e 100644
--- a/app/views/messages/show.rhtml
+++ b/app/views/messages/show.rhtml
@@ -2,15 +2,10 @@
<p><em><%= @message.author.name %>, <%= format_time(@message.created_on) %></em></p>
<div class="wiki">
-<%= textilizable(@message.content) %>
+<%= textilizable(@message.content, :attachments => @message.attachments) %>
</div>
-<div class="attachments">
-<% @message.attachments.each do |attachment| %>
-<%= link_to attachment.filename, { :action => 'download', :id => @message, :attachment_id => attachment }, :class => 'icon icon-attachment' %>
-(<%= number_to_human_size(attachment.filesize) %>)<br />
-<% end %>
-</div>
-<br />
+<%= link_to_attachments @message.attachments, :no_author => true %>
+
<h3 class="icon22 icon22-comment"><%= l(:label_reply_plural) %></h3>
<% @message.children.each do |message| %>
<a name="<%= "message-#{message.id}" %>"></a>
@@ -28,4 +23,4 @@
<p><%= submit_tag l(:button_submit) %></p>
<% end %>
</div>
-<% end %> \ No newline at end of file
+<% end %>
diff --git a/app/views/wiki/_preview.rhtml b/app/views/wiki/_preview.rhtml
index 7865d9159..e3bfc3a25 100644
--- a/app/views/wiki/_preview.rhtml
+++ b/app/views/wiki/_preview.rhtml
@@ -1,3 +1,3 @@
<fieldset class="preview"><legend><%= l(:label_preview) %></legend>
-<%= textilizable @text %>
+<%= textilizable @text, :attachments => @attachements %>
</fieldset>
diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml
index c2deba02b..8bb757ac0 100644
--- a/app/views/wiki/show.rhtml
+++ b/app/views/wiki/show.rhtml
@@ -21,12 +21,22 @@
<div class="wiki">
<% cache "wiki/show/#{@page.id}/#{@content.version}" do %>
-<%= textilizable @content.text %>
+<%= textilizable @content.text, :attachments => @page.attachments %>
<% end %>
</div>
+<%= link_to_attachments @page.attachments, :delete_url => (authorize_for('wiki', 'destroy_attachment') ? {:controller => 'wiki', :action => 'destroy_attachment', :page => @page.title} : nil) %>
+
<div class="contextual">
<%= l(:label_export_to) %>
<%= link_to 'HTML', {:export => 'html', :version => @content.version}, :class => 'icon icon-html' %>,
<%= link_to 'TXT', {:export => 'txt', :version => @content.version}, :class => 'icon icon-txt' %>
-</div> \ No newline at end of file
+</div>
+
+<% if authorize_for('wiki', 'add_attachment') %>
+<p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
+<% form_tag({ :controller => 'wiki', :action => 'add_attachment', :page => @page.title }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
+ <%= render :partial => 'attachments/form' %>
+<%= submit_tag l(:button_add) %>
+<% end %>
+<% end %>