FEATURE: show pinned topics for TL0 on top/year page

BUGFIX: word-wrap on topic-excerpt
This commit is contained in:
Régis Hanol 2014-01-18 19:03:09 +01:00
parent 59ab71b060
commit b49e448556
3 changed files with 26 additions and 12 deletions

View File

@ -135,6 +135,7 @@
font-size: 14px;
margin-top: 8px;
color: $dark_gray;
word-break: break-word;
}
@include medium-width {

View File

@ -82,9 +82,12 @@ class TopicQuery
def list_top_for(period)
score = "#{period}_score"
create_list(:top, unordered: true) do |topics|
topics.joins(:top_topic)
.where("top_topics.#{score} > 0")
.order("top_topics.#{score} DESC, topics.bumped_at DESC")
topics = topics.joins(:top_topic).where("top_topics.#{score} > 0")
if period == :yearly && @user.try(:trust_level) == TrustLevel.levels[:newuser]
topics.order(TopicQuerySQL.order_top_with_pinned_category_for(score))
else
topics.order(TopicQuerySQL.order_top_for(score))
end
end
end

View File

@ -15,6 +15,10 @@ module TopicQuerySQL
"3000-01-01"
end
def order_by_category_sql(dir)
"CASE WHEN categories.id = #{SiteSetting.uncategorized_category_id.to_i} THEN '' ELSE categories.name END #{dir}"
end
# If you've clearned the pin, use bumped_at, otherwise put it at the top
def order_with_pinned_sql
"CASE
@ -24,10 +28,6 @@ module TopicQuerySQL
END DESC"
end
def order_by_category_sql(dir)
"CASE WHEN categories.id = #{SiteSetting.uncategorized_category_id.to_i} THEN '' ELSE categories.name END #{dir}"
end
# If you've clearned the pin, use bumped_at, otherwise put it at the top
def order_nocategory_with_pinned_sql
"CASE
@ -37,14 +37,24 @@ module TopicQuerySQL
END DESC"
end
# For anonymous users
def order_nocategory_basic_bumped
"CASE WHEN topics.category_id = #{SiteSetting.uncategorized_category_id.to_i} and (topics.pinned_at IS NOT NULL) THEN 0 ELSE 1 END, topics.bumped_at DESC"
end
def order_basic_bumped
"CASE WHEN (topics.pinned_at IS NOT NULL) THEN 0 ELSE 1 END, topics.bumped_at DESC"
end
def order_nocategory_basic_bumped
"CASE WHEN topics.category_id = #{SiteSetting.uncategorized_category_id.to_i} and (topics.pinned_at IS NOT NULL) THEN 0 ELSE 1 END, topics.bumped_at DESC"
end
def order_top_for(score)
"top_topics.#{score} DESC, topics.bumped_at DESC"
end
def order_top_with_pinned_category_for(score)
# display pinned topics first
"CASE WHEN COALESCE(topics.pinned_at, '#{lowest_date}') > COALESCE(tu.cleared_pinned_at, '#{lowest_date}') THEN 1 ELSE 0 END DESC,
top_topics.#{score} DESC,
topics.bumped_at DESC"
end
end
end