Render category descriptions differently on the categories page
This commit is contained in:
parent
bd1b4d3130
commit
f62c421c91
|
@ -13,12 +13,21 @@
|
|||
<th class='num'>{{i18n age}}</th>
|
||||
</tr>
|
||||
|
||||
{{#if description_excerpt}}
|
||||
<tr class="category-description">
|
||||
<td colspan="3">
|
||||
{{{description_excerpt}}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
{{#each topics}}
|
||||
<tr {{bindAttr class="archived"}}>
|
||||
<td class='main-link'>
|
||||
<div class='topic-inset'>
|
||||
{{topicStatus topic=this}}
|
||||
{{{topicLink this}}}
|
||||
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts unread="unread"}}'>{{unbound unread}}</a>
|
||||
{{/if}}
|
||||
|
@ -40,7 +49,6 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
</td>
|
||||
<td class='num'><span class='badge-posts'>{{number posts_count}}</span></td>
|
||||
|
|
|
@ -54,6 +54,11 @@
|
|||
vertical-align: top;
|
||||
margin-top: 2px;
|
||||
}
|
||||
&.category-description {
|
||||
td {
|
||||
color: lighten($topic-list-td-color, 5%);
|
||||
}
|
||||
}
|
||||
}
|
||||
th,
|
||||
td {
|
||||
|
|
|
@ -23,7 +23,7 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
|||
admin.admin = true
|
||||
admin.id = -1
|
||||
|
||||
query = TopicQuery.new(admin, per_page: SiteSetting.category_featured_topics)
|
||||
query = TopicQuery.new(admin, per_page: SiteSetting.category_featured_topics, except_topic_id: c.topic_id)
|
||||
results = query.list_category(c)
|
||||
if results.present?
|
||||
results.topic_ids.each_with_index do |topic_id, idx|
|
||||
|
|
|
@ -10,6 +10,7 @@ class CategoryDetailedSerializer < ApplicationSerializer
|
|||
:topics_month,
|
||||
:topics_year,
|
||||
:description,
|
||||
:description_excerpt,
|
||||
:is_uncategorized
|
||||
|
||||
has_many :featured_users, serializer: BasicUserSerializer
|
||||
|
@ -39,4 +40,8 @@ class CategoryDetailedSerializer < ApplicationSerializer
|
|||
return displayable_topics.present?
|
||||
end
|
||||
|
||||
def description_excerpt
|
||||
PrettyText.excerpt(description,300) if description
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -16,7 +16,8 @@ describe CategoryFeaturedTopic do
|
|||
category.allow(Group[:trust_level_1])
|
||||
category.save
|
||||
|
||||
post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world")
|
||||
uncategorized_post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world")
|
||||
category_post = PostCreator.create(user, raw: "I put this post in the category", title: "categorize THIS", category: category.name)
|
||||
|
||||
CategoryFeaturedTopic.feature_topics_for(category)
|
||||
CategoryFeaturedTopic.count.should == 1
|
||||
|
|
Loading…
Reference in New Issue