From d0d3487fc89093e8d79151f690d8d868689e44cd Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 28 Oct 2010 20:11:17 -0400 Subject: [PATCH] converted haml templates --- app/logical/current_user.rb | 12 +++++ app/views/comments/index.html.erb | 13 ++++++ app/views/comments/index.html.haml | 8 ---- .../comments/partials/index/_header.html.erb | 46 +++++++++++++++++++ .../comments/partials/index/_header.html.haml | 29 ------------ .../comments/partials/index/_list.html.erb | 16 +++++++ .../comments/partials/index/_list.html.haml | 9 ---- ...hreshold.html.haml => _threshold.html.erb} | 0 .../comments/partials/new/_form.html.erb | 9 ++++ .../comments/partials/new/_form.html.haml | 7 --- .../comments/partials/show/_comment.html.erb | 22 +++++++++ .../comments/partials/show/_comment.html.haml | 16 ------- 12 files changed, 118 insertions(+), 69 deletions(-) create mode 100644 app/views/comments/index.html.erb delete mode 100644 app/views/comments/index.html.haml create mode 100644 app/views/comments/partials/index/_header.html.erb delete mode 100644 app/views/comments/partials/index/_header.html.haml create mode 100644 app/views/comments/partials/index/_list.html.erb delete mode 100644 app/views/comments/partials/index/_list.html.haml rename app/views/comments/partials/index/{_threshold.html.haml => _threshold.html.erb} (100%) create mode 100644 app/views/comments/partials/new/_form.html.erb delete mode 100644 app/views/comments/partials/new/_form.html.haml create mode 100644 app/views/comments/partials/show/_comment.html.erb delete mode 100644 app/views/comments/partials/show/_comment.html.haml diff --git a/app/logical/current_user.rb b/app/logical/current_user.rb index 11699b1a9..964229899 100644 --- a/app/logical/current_user.rb +++ b/app/logical/current_user.rb @@ -29,4 +29,16 @@ class CurrentUser def self.ip_addr Thread.current[:current_ip_addr] 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 diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb new file mode 100644 index 000000000..d2fb5dbf9 --- /dev/null +++ b/app/views/comments/index.html.erb @@ -0,0 +1,13 @@ +
+
+ <% @posts.each do |post| %> +
+
+ <%= 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} %> +
+
+ <% end %> +
+
diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml deleted file mode 100644 index dc8dbc9f6..000000000 --- a/app/views/comments/index.html.haml +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/app/views/comments/partials/index/_header.html.erb b/app/views/comments/partials/index/_header.html.erb new file mode 100644 index 000000000..5a21ccea4 --- /dev/null +++ b/app/views/comments/partials/index/_header.html.erb @@ -0,0 +1,46 @@ +
+
+ + + <%= compact_time(post.created_at) %> + + + User + <%= link_to(post.uploader_name, user_path(post.uploader_id)) %> + + + Rating + <%= post.rating %> + + + Score + + <%= 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) %>) + <% end %> + + +
+
+ Tags + <% post.tag_array.each do |tag_name| %> + + <%= link_to(tag_name.tr("_", " "), posts_path(:tags => tag_name)) %> + + <% end %> +
+
+ <% if post.comments.count > 6 %> + + <%= link_to "#{pluralize(post.comments.size, 'comment')} hidden", comments_path(:post_id => post.id), :remote => true %>. + + <% end %> + <% if post.comments.hidden(CurrentUser.user).count > 0 %> + + <%= link_to "#{pluralize(post.comments.hidden(CurrentUser.user).count, 'comment')} below threshold", comments_path(:post_id => post.id, :include_hidden => true), :remote => true %>. + + <% end %> +
+
+ diff --git a/app/views/comments/partials/index/_header.html.haml b/app/views/comments/partials/index/_header.html.haml deleted file mode 100644 index e66ab8548..000000000 --- a/app/views/comments/partials/index/_header.html.haml +++ /dev/null @@ -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}. diff --git a/app/views/comments/partials/index/_list.html.erb b/app/views/comments/partials/index/_list.html.erb new file mode 100644 index 000000000..9c1686cbc --- /dev/null +++ b/app/views/comments/partials/index/_list.html.erb @@ -0,0 +1,16 @@ +
+ <% if show_header %> + <%= render :partial => "comments/partials/index/header", :locals => {:post => post} %> + <% end %> + +
+ <%= render :partial => "comments/partials/show/comment", :collection => comments %> +
+ +
+ +
+

<%= link_to "Post comment", new_comment_path, :class => "expand-comment-response" %>

+ <%= render :partial => "comments/partials/new/form", :locals => {:post => post} %> +
+
diff --git a/app/views/comments/partials/index/_list.html.haml b/app/views/comments/partials/index/_list.html.haml deleted file mode 100644 index 1a7c7cb84..000000000 --- a/app/views/comments/partials/index/_list.html.haml +++ /dev/null @@ -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} diff --git a/app/views/comments/partials/index/_threshold.html.haml b/app/views/comments/partials/index/_threshold.html.erb similarity index 100% rename from app/views/comments/partials/index/_threshold.html.haml rename to app/views/comments/partials/index/_threshold.html.erb diff --git a/app/views/comments/partials/new/_form.html.erb b/app/views/comments/partials/new/_form.html.erb new file mode 100644 index 000000000..776b24c3b --- /dev/null +++ b/app/views/comments/partials/new/_form.html.erb @@ -0,0 +1,9 @@ +
+ <%= form_tag(comments_path, :remote => true) do %> + <%= hidden_field "comment", "post_id", :value => post.id %> + <%= text_area "comment", "body", :size => "60x7" %> +
+ <%= submit_tag "Post" %> + <%= submit_tag "Preview" %> + <% end %> +
diff --git a/app/views/comments/partials/new/_form.html.haml b/app/views/comments/partials/new/_form.html.haml deleted file mode 100644 index 5d5dbdbc8..000000000 --- a/app/views/comments/partials/new/_form.html.haml +++ /dev/null @@ -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" diff --git a/app/views/comments/partials/show/_comment.html.erb b/app/views/comments/partials/show/_comment.html.erb new file mode 100644 index 000000000..645841d41 --- /dev/null +++ b/app/views/comments/partials/show/_comment.html.erb @@ -0,0 +1,22 @@ +
+
+

<%= link_to comment.creator_name, user_path(comment.creator_id) %>

+ +
+
+
+ <%= format_text(comment.body) %> +
+ +
  • Reply
  • + <% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %> +
  • <%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %>
  • + <% end %> +
  • <%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %>
  • +
  • <%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %>
  • +
    +
    +
    +
    diff --git a/app/views/comments/partials/show/_comment.html.haml b/app/views/comments/partials/show/_comment.html.haml deleted file mode 100644 index 62c5c3ef7..000000000 --- a/app/views/comments/partials/show/_comment.html.haml +++ /dev/null @@ -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"}