converted haml templates
This commit is contained in:
@@ -29,4 +29,16 @@ class CurrentUser
|
|||||||
def self.ip_addr
|
def self.ip_addr
|
||||||
Thread.current[:current_ip_addr]
|
Thread.current[:current_ip_addr]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.id
|
||||||
|
user.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.method_missing(method, *params, &block)
|
||||||
|
if user.respond_to?(method)
|
||||||
|
user.__send__(method, *params, &block)
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
13
app/views/comments/index.html.erb
Normal file
13
app/views/comments/index.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="comments">
|
||||||
|
<div class="index">
|
||||||
|
<% @posts.each do |post| %>
|
||||||
|
<div class="post">
|
||||||
|
<div class="preview">
|
||||||
|
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
|
||||||
|
</div>
|
||||||
|
<%= render :partial => "comments/partials/index/list", :locals => {:post => post, :comments => post.comments.recent.reverse, :show_header => true} %>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
%div{:class => "comments"}
|
|
||||||
%div{:class => "index"}
|
|
||||||
- @posts.each do |post|
|
|
||||||
%div{:class => "post"}
|
|
||||||
%div{:class => "preview"}
|
|
||||||
= link_to image_tag(post.preview_file_url), post_path(post)
|
|
||||||
= render :partial => "comments/partials/index/list", :locals => {:post => post, :comments => post.comments.recent.reverse, :show_header => true}
|
|
||||||
%div{:class => "clearfix"}
|
|
||||||
46
app/views/comments/partials/index/_header.html.erb
Normal file
46
app/views/comments/partials/index/_header.html.erb
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<div class="header">
|
||||||
|
<div class="row">
|
||||||
|
<span class="info">
|
||||||
|
<time>Date</time>
|
||||||
|
<%= compact_time(post.created_at) %>
|
||||||
|
</span>
|
||||||
|
<span class="info">
|
||||||
|
<strong>User</strong>
|
||||||
|
<%= link_to(post.uploader_name, user_path(post.uploader_id)) %>
|
||||||
|
</span>
|
||||||
|
<span class="info">
|
||||||
|
<strong>Rating</strong>
|
||||||
|
<%= post.rating %>
|
||||||
|
</span>
|
||||||
|
<span class="info">
|
||||||
|
<strong>Score</strong>
|
||||||
|
<span id="score-for-post-<%= post.id %>"%>
|
||||||
|
<span><%= post.score %></span>
|
||||||
|
<% if CurrentUser.user.is_privileged? %>
|
||||||
|
(vote <%= link_to("up", post_votes_path(:score => "up", :post_id => post.id), :remote => true, :method => :post) %>/<%= link_to("down", post_votes_path(:score => "down", :post_id => post.id), :remote => true, :method => :post) %>)
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="row list-of-tags">
|
||||||
|
<strong>Tags</strong>
|
||||||
|
<% post.tag_array.each do |tag_name| %>
|
||||||
|
<span class="tag-type-<%= Tag.category_for(tag_name) %>">
|
||||||
|
<%= link_to(tag_name.tr("_", " "), posts_path(:tags => tag_name)) %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="row notices">
|
||||||
|
<% if post.comments.count > 6 %>
|
||||||
|
<span class="info" id="hidden-comments-notice-for-<%= post.id %>"%>
|
||||||
|
<%= link_to "#{pluralize(post.comments.size, 'comment')} hidden", comments_path(:post_id => post.id), :remote => true %>.
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
<% if post.comments.hidden(CurrentUser.user).count > 0 %>
|
||||||
|
<span class="info" id="threshold-comments-notice-for-<%= post.id %>"%>
|
||||||
|
<%= link_to "#{pluralize(post.comments.hidden(CurrentUser.user).count, 'comment')} below threshold", comments_path(:post_id => post.id, :include_hidden => true), :remote => true %>.
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
%div{:class => "header"}
|
|
||||||
%div{:class => "row"}
|
|
||||||
%span{:class => "info"}
|
|
||||||
%time Date
|
|
||||||
= compact_time(post.created_at)
|
|
||||||
%span{:class => "info"}
|
|
||||||
%strong User
|
|
||||||
= link_to(post.uploader_name, user_path(post.uploader_id))
|
|
||||||
%span{:class => "info"}
|
|
||||||
%strong Rating
|
|
||||||
= post.rating
|
|
||||||
%span{:class => "info"}
|
|
||||||
%strong Score
|
|
||||||
%span{:id => "score-for-post-#{post.id}"}
|
|
||||||
%span= post.score
|
|
||||||
- if CurrentUser.user.is_privileged?
|
|
||||||
== (vote #{link_to("up", post_votes_path(:score => "up", :post_id => post.id), :remote => true, :method => :post)}/#{link_to("down", post_votes_path(:score => "down", :post_id => post.id), :remote => true, :method => :post)})
|
|
||||||
%div{:class => "row list-of-tags"}
|
|
||||||
%strong Tags
|
|
||||||
- post.tag_array.each do |tag_name|
|
|
||||||
%span{:class => "tag-type-#{Tag.category_for(tag_name)}"}
|
|
||||||
= link_to(tag_name.tr("_", " "), posts_path(:tags => tag_name))
|
|
||||||
%div{:class => "row notices"}
|
|
||||||
- if post.comments.count > 6
|
|
||||||
%span{:class => "info", :id => "hidden-comments-notice-for-#{post.id}"}
|
|
||||||
== #{link_to "#{pluralize(post.comments.size - 6, 'comment')} hidden", comments_path(:post_id => post.id), :remote => true}.
|
|
||||||
- if post.comments.hidden(CurrentUser.user).count > 0
|
|
||||||
%span{:class => "info", :id => "threshold-comments-notice-for-#{post.id}"}
|
|
||||||
== #{link_to "#{pluralize(post.comments.hidden(CurrentUser.user).count, 'comment')} below threshold", comments_path(:post_id => post.id, :include_hidden => true), :remote => true}.
|
|
||||||
16
app/views/comments/partials/index/_list.html.erb
Normal file
16
app/views/comments/partials/index/_list.html.erb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<div class="comments-for-post" data-post-id="<%= post.id %>">
|
||||||
|
<% if show_header %>
|
||||||
|
<%= render :partial => "comments/partials/index/header", :locals => {:post => post} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="list-of-comments">
|
||||||
|
<%= render :partial => "comments/partials/show/comment", :collection => comments %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
|
<div class="new-comment">
|
||||||
|
<p><%= link_to "Post comment", new_comment_path, :class => "expand-comment-response" %></p>
|
||||||
|
<%= render :partial => "comments/partials/new/form", :locals => {:post => post} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
%div{:class => "comments-for-post", "data-post-id" => post.id}
|
|
||||||
- if show_header
|
|
||||||
= render :partial => "comments/partials/index/header", :locals => {:post => post}
|
|
||||||
%div{:class => "list-of-comments"}
|
|
||||||
= render :partial => "comments/partials/show/comment", :collection => comments
|
|
||||||
%div{:class => "clearfix"}
|
|
||||||
%div{:class => "new-comment"}
|
|
||||||
%p= link_to "Post comment", new_comment_path, :class => "expand-comment-response"
|
|
||||||
= render :partial => "comments/partials/new/form", :locals => {:post => post}
|
|
||||||
9
app/views/comments/partials/new/_form.html.erb
Normal file
9
app/views/comments/partials/new/_form.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="comment-preview dtext">
|
||||||
|
<%= form_tag(comments_path, :remote => true) do %>
|
||||||
|
<%= hidden_field "comment", "post_id", :value => post.id %>
|
||||||
|
<%= text_area "comment", "body", :size => "60x7" %>
|
||||||
|
<br>
|
||||||
|
<%= submit_tag "Post" %>
|
||||||
|
<%= submit_tag "Preview" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
%div{:class => "comment-preview dtext"}
|
|
||||||
= form_tag(comments_path, :remote => true) do
|
|
||||||
= hidden_field "comment", "post_id", :value => post.id
|
|
||||||
= text_area "comment", "body", :size => "60x7"
|
|
||||||
%br
|
|
||||||
= submit_tag "Post"
|
|
||||||
= submit_tag "Preview"
|
|
||||||
22
app/views/comments/partials/show/_comment.html.erb
Normal file
22
app/views/comments/partials/show/_comment.html.erb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<article data-comment-id="<%= comment.id %>">
|
||||||
|
<div class="author">
|
||||||
|
<h1><%= link_to comment.creator_name, user_path(comment.creator_id) %></h1>
|
||||||
|
<time datetime="<%= comment.created_at %>">
|
||||||
|
<%= time_ago_in_words(comment.created_at) %> ago
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div>
|
||||||
|
<%= format_text(comment.body) %>
|
||||||
|
</div>
|
||||||
|
<menu>
|
||||||
|
<li><span class="link">Reply</span></li>
|
||||||
|
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
|
||||||
|
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li>
|
||||||
|
<% end %>
|
||||||
|
<li><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
||||||
|
<li><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</article>
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
%article{"data-comment-id" => comment.id}
|
|
||||||
%div{:class => "author"}
|
|
||||||
%h1= link_to comment.creator_name, user_path(comment.creator_id)
|
|
||||||
%time{:datetime => comment.created_at}
|
|
||||||
= time_ago_in_words(comment.created_at)
|
|
||||||
= " ago"
|
|
||||||
%div{:class => "content"}
|
|
||||||
%div= format_text(comment.body)
|
|
||||||
%menu
|
|
||||||
%li
|
|
||||||
%span{:class => "link"} Reply
|
|
||||||
- if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id
|
|
||||||
%li= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete
|
|
||||||
%li= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true
|
|
||||||
%li= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true
|
|
||||||
%div{:class => "clearfix"}
|
|
||||||
Reference in New Issue
Block a user