comments: simplify highlighting, use css selector - merged with i18n

This commit is contained in:
Carl Chenet 2017-05-23 13:28:25 +02:00
parent 6668b1a992
commit 6a336b7cee
5 changed files with 17 additions and 28 deletions

View File

@ -487,7 +487,7 @@ li div.details {
opacity: 0.5;
}
.comment.highlighted {
.comment:target {
background-color: #fffcd7;
border-radius: 20px;
}
@ -560,6 +560,12 @@ li .comment_folder_button:checked ~ ol.comments li {
display: none;
}
/* try to force a highlighted comment to stay visible */
li .comment_folder_button:checked ~ div.comment div.comment_text,
li .comment_folder_button:checked ~ div.comment div.voters {
display: block;
}
li .byline {
color: #888;
font-size: 9.5pt;

View File

@ -136,18 +136,6 @@ class StoriesController < ApplicationController
@comments = @story.merged_comments.includes(:user, :story, :hat,
:votes => :user).arrange_for_user(@user)
@force_show_thread_id = nil
if params[:comment_short_id]
@comments.each do |c,x|
if c.short_id == params[:comment_short_id]
c.highlighted = true
@force_show_thread_id = c.thread_id
break
end
end
end
respond_to do |format|
format.html {
@comment = @story.comments.build

View File

@ -10,7 +10,7 @@ class Comment < ActiveRecord::Base
:class_name => "Moderation"
belongs_to :hat
attr_accessor :current_vote, :previewing, :indent_level, :highlighted
attr_accessor :current_vote, :previewing, :indent_level
before_validation :on => :create do
self.assign_short_id_and_upvote
@ -429,10 +429,6 @@ class Comment < ActiveRecord::Base
self.upvotes - self.downvotes
end
def short_id_path
self.story.short_id_path + "/c/#{self.short_id}"
end
def short_id_url
Rails.application.root_url + "c/#{self.short_id}"
end
@ -446,7 +442,7 @@ class Comment < ActiveRecord::Base
end
def url
self.story.comments_url + "/comments/#{self.short_id}#c_#{self.short_id}"
self.story.comments_path + "#c_#{self.short_id}"
end
def vote_summary_for_user(u)

View File

@ -1,13 +1,10 @@
<input id="comment_folder_<%= comment.short_id %>"
class="comment_folder_button" type="checkbox"
<%= comment.score <= Comment::DOWNVOTABLE_MIN_SCORE &&
!(@force_show_thread_id && @force_show_thread_id == comment.thread_id) ?
"checked" : "" %>>
<div id="comment_<%= comment.short_id %>"
<%= comment.score <= Comment::DOWNVOTABLE_MIN_SCORE ? "checked" : "" %>>
<div id="c_<%= comment.short_id %>"
data-shortid="<%= comment.short_id if comment.persisted? %>"
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
"upvoted" : "downvoted") : "" %>
<%= comment.highlighted ? "highlighted" : "" %>
<%= comment.score <= -1 ? "negative_1" : "" %>
<%= comment.score <= -3 ? "negative_3" : "" %>
<%= comment.score <= -5 ? "negative_5" : "" %>">
@ -64,7 +61,7 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<% if !comment.previewing %>
|
<a href="<%= comment.short_id_url %>"><%= t('.link') %></a>
<a href="<%= comment.url %>"><%= t('.link') %></a>
<% if comment.is_editable_by_user?(@user) %>
|

View File

@ -91,12 +91,14 @@ Lobsters::Application.routes.draw do
post "keep_as_new"
end
get "/s/:id/:title/comments/:comment_short_id" => "stories#show"
get "/s/:id/(:title)" => "stories#show", :format => /html|json/
get "/c/:id" => "comments#redirect_from_short_id"
get "/c/:id.json" => "comments#show_short_id", :format => "json"
# deprecated
get "/s/:story_id/:title/comments/:id" => "comments#redirect_from_short_id"
get "/s/:id/(:title)" => "stories#show", :format => /html|json/
get "/u" => "users#tree"
get "/u/:username" => "users#show", :as => "user", :format => /html|json/