Render category descriptions differently on the categories page
This commit is contained in:
parent
bd1b4d3130
commit
f62c421c91
|
@ -13,34 +13,42 @@
|
||||||
<th class='num'>{{i18n age}}</th>
|
<th class='num'>{{i18n age}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
{{#if description_excerpt}}
|
||||||
|
<tr class="category-description">
|
||||||
|
<td colspan="3">
|
||||||
|
{{{description_excerpt}}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#each topics}}
|
{{#each topics}}
|
||||||
<tr {{bindAttr class="archived"}}>
|
<tr {{bindAttr class="archived"}}>
|
||||||
<td class='main-link'>
|
<td class='main-link'>
|
||||||
<div class='topic-inset'>
|
<div class='topic-inset'>
|
||||||
{{topicStatus topic=this}}
|
{{topicStatus topic=this}}
|
||||||
{{{topicLink 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}}
|
|
||||||
{{#if new_posts}}
|
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts new_posts="new_posts"}}'>{{unbound new_posts}}</a>
|
|
||||||
{{/if}}
|
|
||||||
{{#if unseen}}
|
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if hasExcerpt}}
|
{{#if unread}}
|
||||||
<div class="topic-excerpt">
|
<a href="{{unbound lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts unread="unread"}}'>{{unbound unread}}</a>
|
||||||
{{{excerpt}}}
|
{{/if}}
|
||||||
{{#if excerptTruncated}}
|
{{#if new_posts}}
|
||||||
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts new_posts="new_posts"}}'>{{unbound new_posts}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if canClearPin}}
|
{{#if unseen}}
|
||||||
<a href="#" {{action clearPin this}} title="{{unbound i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
|
{{#if hasExcerpt}}
|
||||||
|
<div class="topic-excerpt">
|
||||||
|
{{{excerpt}}}
|
||||||
|
{{#if excerptTruncated}}
|
||||||
|
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if canClearPin}}
|
||||||
|
<a href="#" {{action clearPin this}} title="{{unbound i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class='num'><span class='badge-posts'>{{number posts_count}}</span></td>
|
<td class='num'><span class='badge-posts'>{{number posts_count}}</span></td>
|
||||||
|
|
|
@ -54,6 +54,11 @@
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
|
&.category-description {
|
||||||
|
td {
|
||||||
|
color: lighten($topic-list-td-color, 5%);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
th,
|
th,
|
||||||
td {
|
td {
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
||||||
admin.admin = true
|
admin.admin = true
|
||||||
admin.id = -1
|
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)
|
results = query.list_category(c)
|
||||||
if results.present?
|
if results.present?
|
||||||
results.topic_ids.each_with_index do |topic_id, idx|
|
results.topic_ids.each_with_index do |topic_id, idx|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class CategoryDetailedSerializer < ApplicationSerializer
|
||||||
:topics_month,
|
:topics_month,
|
||||||
:topics_year,
|
:topics_year,
|
||||||
:description,
|
:description,
|
||||||
|
:description_excerpt,
|
||||||
:is_uncategorized
|
:is_uncategorized
|
||||||
|
|
||||||
has_many :featured_users, serializer: BasicUserSerializer
|
has_many :featured_users, serializer: BasicUserSerializer
|
||||||
|
@ -39,4 +40,8 @@ class CategoryDetailedSerializer < ApplicationSerializer
|
||||||
return displayable_topics.present?
|
return displayable_topics.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def description_excerpt
|
||||||
|
PrettyText.excerpt(description,300) if description
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,8 @@ describe CategoryFeaturedTopic do
|
||||||
category.allow(Group[:trust_level_1])
|
category.allow(Group[:trust_level_1])
|
||||||
category.save
|
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.feature_topics_for(category)
|
||||||
CategoryFeaturedTopic.count.should == 1
|
CategoryFeaturedTopic.count.should == 1
|
||||||
|
|
Loading…
Reference in New Issue