/
show.rhtml
150 lines (114 loc) · 5.42 KB
/
show.rhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<% title h(@topic.title) %>
<% crumb "Home", index_url %>
<% crumb @topic.forum.title, forum_url(@topic.forum) %>
<% crumb @topic.category.title, category_url(@topic.category) %>
<% crumb h(@topic.title), category_post_url(@topic.category, @topic), :class => 'active' %>
<table id="topic" cellpadding="0" cellspacing="0">
<tr id="topic-head">
<td class="author-img <%= 'admin' if @topic.user.admin? %>">
<div class="user-img">
<address class="gravatar" style="display:none"><%= Digest::MD5.hexdigest(@topic.user.email) %></address>
</div>
</td>
<td class="author-details">
<h2><%= h(@topic.title) %></h2>
<p><% if @topic.user != nil %> by <%= link_to h(@topic.user.name), :controller => 'users', :action => 'show', :id => @topic.user.id %> <% else %> Unknown User <% end %> - <%= @topic.user.title %> - <%= formatted_date @topic.created_at %></p>
</td>
</tr>
<tr id="topic-body">
<td colspan="2">
<% if @topic.closed? %>
<p class="closed-thread small">This topic has been closed!</p>
<% end %>
<div><%= @topic.body_html %></div>
<div class="sig"><%= sig @topic.user %></div>
<% if not @topic.images.empty? %>
<div class="images">
<% @topic.images.each do |image| %>
<%= link_to image_tag(image.public_filename(:thumb)), image.public_filename, :rel => "lightbox[#{@topic.id}]", :title => "#{@topic.title} - #{image.filename} "%>
<% end %>
</div>
<% end %>
<% if @topic.edited_at %>
<p class="small">Last edited <%= formatted_date(@topic.edited_at) %></p>
<% end %>
<% if @topic.editable? and @topic.owner?(@user) %>
<p>
<span class="orange-link small"><%= link_to 'Edit this post', edit_category_post_url(@topic.category, @topic) %></span> | <span class="orange-link small"><%= link_to_function 'Attach file', "$('attach-file-#{@topic.id}').toggle()" %></span>
</p>
<div style="display:none" id="attach-file-<%= @topic.id %>">
<% form_for(:image, :url => category_post_images_path(@topic.category, @topic), :html => { :multipart => true }) do |f| %>
<p>
<label for="image_uploaded_data">Image:</label> <%= f.file_field :uploaded_data %> <%= submit_tag 'Upload' %>
</p>
<% end %>
</div>
<% end %>
<p class="c green-link"><a href="#comments">Jump to comment form</a> | <%= link_to "subscribe to this topic", category_post_url(@topic.category, @topic, :format => 'xml') %></p>
</td>
</tr>
</table>
<%= render :partial => 'comments_table', :object => @topic.comments %>
<div id="comments">
<% unless @topic.closed? %>
<% if allowed_to_post? %>
<div id="preview" style="display:none">
<h3>Preview</h3>
<div id="preview-body">
Loading Preview…
</div>
</div>
<div id="comment-wrap">
<%= form_tag({:action => 'create', :topic => @topic}, {:multipart => true}) %>
<div id="post-comment">
<dl>
<% unless @user %>
<dt>
<label for="comment-spam2">Spam protection</label>
<span class="hint">only appears if you are not logged in</span>
</dt>
<dd>
<input name="verify[nospam]" type="checkbox" id="comment-spam1" checked="checked" style="display:none"/>
</dd>
<dd>
<input name="verify[spam]" type="checkbox" id="comment-spam2" checked="checked" /> I am a spambot!
</dd>
<% end %>
<dt>
<label for="comment-body">Comment</label>
</dt>
<dd><textarea name="comment[body]" id="comment-body" rows="16" cols="60"></textarea></dd>
</dl>
</div>
<div id="formatting-guide" class="fl" style="font-size: 90%">
<%= render :partial => 'formatting_guide' %>
</div>
<p class="orange-link small clear"><%= link_to_function 'Attach file...', "$('attach-new-post-file').toggle(); this.hide()" %></p>
<div id="attach-new-post-file" style="display:none">
<% fields_for :image do |i| %>
<label for="image_uploaded_data">Attach an image:</label> <%= i.file_field :uploaded_data %>
<% end %>
</div>
<p class="clear" ><%= submit_tag 'Post', :disable_with => 'Posting comment…' %> or <%= link_to_function 'Preview', "new Ajax.Updater('preview-body','/tools/preview_textile', {postBody: $F('comment-body') });$('preview').show()" %></p>
</form>
</div>
<% else %>
<div id="login-notification">
<p>You must <%= link_to 'login', :controller => 'accounts', :action => 'index' %> to post a comment!</p>
<p class="small">Don't have an account yet? <%= link_to 'Sign up', :controller => "accounts", :action => 'new' %> for one.</p>
</div>
<% end %>
<% end %>
</div>
<% if moderator? %>
<div id="administration">
<h3>Administration</h3>
<div>Status of this post: </div>
<div>
<%= select :post, :status, %w{ normal sticky closed }, {}, :onchange => "new Ajax.Request('/categories/#{@topic.category.to_param}/posts/'+#{@topic.id}+'?post[status]='+$('post_status').value, {evalScripts:true, method: 'put'});" %>
</div>
<div style="float:right; margin: 9px">
<%= link_to 'Delete this topic', category_post_url(@topic.category, @topic), :method => 'delete', :confirm => "Are you sure you want to delete the topic #{h @topic.title}?" %>
</div>
</div>
<% end %>