Jagster
(Jakke Lehtonen)
1
/latest(以及其他所有内容)看起来是这样的:
Replies(回复数)显示了一个主题有多活跃,Activity(活动时间)显示了上次发生变化的时间。这些都是有用的数据。但 Views(浏览量)……它对管理员和 OP(原帖发帖人)来说可能是一个有价值的指标,但对普通用户来说却毫无价值——他们不会看一眼然后想“嗯,这个话题肯定不有趣,因为很少有人打开过它”(反之亦然)。
但如果我们能看到创建/开始日期,就能立即知道一个主题是古老的还是全新的。
我之所以截取这张截图,是因为我回复了那个主题。如果我知道那是一个相当古老的主题,我可能会置之不理——所以,对于讨论来说,显示日期可能是一把双刃剑,我知道。
我猜想这可以通过一个主题组件来改变。但这有多难呢?
我说“难”的意思是……有没有人愿意免费做这件事?我不会编程。我是复制粘贴博士,仅此而已。而且我绝对没有预算。
但我也很想知道,是否只有我一个人认为显示浏览量主要是为了满足管理员的好奇心(例如,我们可以通过 SQL 获取日志和浏览量),以及填补空白空间,所以我们可以用同样的空间做更有成效的事情?
3 个赞
你好 Jakke,
不确定你是否还需要这个,但这是你要找的!
你可以通过覆盖相关的模板来替换“views”列(topic-list-header 和 topic-list-item)。
不幸的是,它有一个缺点,就是你必须复制粘贴大量的原始代码,这可能会根据你的主题/插件/组件而无法正常工作。另外,如果 Discourse 更新了这些部分,你可能也需要更新它。
这是你可以复制粘贴到 component 中的代码:
Head
<script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
{{raw-plugin-outlet name="topic-list-header-before"}}
{{#if bulkSelectEnabled}}
<th class="bulk-select topic-list-data">
{{#if canBulkSelect}}
{{raw "flat-button" class="bulk-select" icon="list" title="topics.bulk.toggle"}}
{{/if}}
</th>
{{/if}}
{{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect canDoBulkActions=canDoBulkActions}}
{{raw-plugin-outlet name="topic-list-header-after-main-link"}}
{{#if showPosters}}
{{raw "topic-list-header-column" order='posters' ariaLabel=(i18n "category.sort_options.posters")}}
{{/if}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies' ariaLabel=(i18n "sr_replies")}}
{{#if showLikes}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='likes' name='likes' ariaLabel=(i18n "sr_likes")}}
{{/if}}
{{#if showOpLikes}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='op_likes' name='likes' ariaLabel=(i18n "sr_op_likes")}}
{{/if}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='created' name='created' ariaLabel=(i18n "sr_created")}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='activity' name='activity' ariaLabel=(i18n "sr_activity")}}
{{raw-plugin-outlet name="topic-list-header-after"}}
</script>
<script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
{{raw-plugin-outlet name="topic-list-before-columns"}}
{{#if bulkSelectEnabled}}
<td class="bulk-select topic-list-data">
<label for="bulk-select-{{topic.id}}">
<input type="checkbox" class="bulk-select" id="bulk-select-{{topic.id}}">
</label>
</td>
{{/if}}
{{!--
The `~` syntax strip spaces between the elements, making it produce
`<a>Some text</span>`
with no space between them.
This causes the topic-post-badge to be considered the same word as "text"
at the end of the link, preventing it from line wrapping onto its own line.
--}}
<td class='main-link clearfix topic-list-data' colspan="1">
{{raw-plugin-outlet name="topic-list-before-link"}}
<span class='link-top-line'>
{{raw-plugin-outlet name="topic-list-before-status"}}
{{raw "topic-status" topic=topic}}
{{topic-link topic class="raw-link raw-topic-link"}}
{{#if topic.featured_link}}
{{topic-featured-link topic}}
{{/if}}
{{raw-plugin-outlet name="topic-list-after-title"}}
{{raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
topicId=topic.id
unreadClass=unreadClass}}
{{#if showTopicPostBadges}}
{{raw "topic-post-badges" unreadPosts=topic.unread_posts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{/if}}
</span>
<div class="link-bottom-line">
{{#unless hideCategory}}
{{#unless topic.isPinnedUncategorized}}
{{raw-plugin-outlet name="topic-list-before-category"}}
{{category-link topic.category}}
{{/unless}}
{{/unless}}
{{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
</div>
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}
{{raw-plugin-outlet name="topic-list-main-link-bottom"}}
</td>
{{raw-plugin-outlet name="topic-list-after-main-link"}}
{{#if showPosters}}
{{raw "list/posters-column" posters=topic.featuredUsers}}
{{/if}}
{{raw "list/posts-count-column" topic=topic}}
{{#if showLikes}}
<td class="num likes topic-list-data">
{{#if hasLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.like_count}} {{d-icon "heart"}}
</a>
{{/if}}
</td>
{{/if}}
{{#if showOpLikes}}
<td class="num likes">
{{#if hasOpLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.op_like_count}} {{d-icon "heart"}}
</a>
{{/if}}
</td>
{{/if}}
<td class="num topic-list-data {{cold-age-class topic.createdAt startDate=topic.bumpedAt class=""}} activity" title="{{html-safe topic.bumpedAtTitle}}">
<a class="post-activity" href="{{topic.url}}">
{{raw-plugin-outlet name="topic-list-before-relative-date"}}
{{format-date topic.createdAt format="tiny" noTitle="true"}}
</a>
</td>
{{raw "list/activity-column" topic=topic class="num topic-list-data" tagName="td"}}
</script>
注意:它在悬停时的标题与“Activity”相同,单击日期会重定向到帖子的开头。
1 个赞
感谢测试!
如果您使用 https://meta.discourse.org/t/topic-list-previews-theme-component/209973(插件版本已弃用),您可以从仓库中复制粘贴以下内容,使用 topic-list-item code。
头部
<script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
{{raw-plugin-outlet name="topic-list-header-before"}}
{{#if bulkSelectEnabled}}
<th class="bulk-select topic-list-data">
{{#if canBulkSelect}}
{{raw "flat-button" class="bulk-select" icon="list" title="topics.bulk.toggle"}}
{{/if}}
</th>
{{/if}}
{{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect canDoBulkActions=canDoBulkActions}}
{{raw-plugin-outlet name="topic-list-header-after-main-link"}}
{{#if showPosters}}
{{raw "topic-list-header-column" order='posters' ariaLabel=(i18n "category.sort_options.posters")}}
{{/if}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies' ariaLabel=(i18n "sr_replies")}}
{{#if showLikes}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='likes' name='likes' ariaLabel=(i18n "sr_likes")}}
{{/if}}
{{#if showOpLikes}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='op_likes' name='likes' ariaLabel=(i18n "sr_op_likes")}}
{{/if}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='created' name='created' ariaLabel=(i18n "sr_created")}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='activity' name='activity' ariaLabel=(i18n "sr_activity")}}
{{raw-plugin-outlet name="topic-list-header-after"}}
</script>
<script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
{{#if bulkSelectEnabled}}
<td class='star'>
<input type="checkbox" class="bulk-select">
</td>
{{/if}}
{{#if tilesStyle}}
<div class="tiles-grid-item-content main-link">
<div class="image">
{{#if hasThumbnail}}
{{raw "list/topic-thumbnail" topic=topic thumbnails=thumbnails currentUser=currentUser site=site category=category opts=thumbnailOpts}}
{{/if}}
<a href='{{topic.url}}'>
<div class="image-mask" style="{{backgroundGradient}}"></div>
</a>
</div>
<div class="topic-details">
<div class="topic-header-grid">
{{raw "list/topic-list-title" topic=topic tilesStyle=tilesStyle showTopicPostBadges=showTopicPostBadges}}
<div class="topic-category">
{{#if showCategoryBadge}}
{{category-link topic.category}}
{{/if}}
{{#if topic.tags}}
{{discourse-tags topic mode="list"}}
{{/if}}
</div>
</div>
{{#if showExcerpt}}
<a href='{{topic.url}}'>
{{raw "list/topic-excerpt" topic=topic}}
</a>
{{/if}}
<div class="topic-footer">
{{raw 'list/topic-meta' likesHeat=likesHeat title=view.title topic=topic}}
{{raw "list/topic-users" tilesStyle=tilesStyle abbreviatePosters=abbreviatePosters posters=abbreviatedPosters posterNames=posterNames}}
{{#if showActions}}
{{raw "list/topic-actions" likeCount=likeCount topicActions=topicActions topic=topic}}
{{/if}}
</div>
</div>
</div>
{{else}}
{{~raw-plugin-outlet name="topic-list-before-columns"}}
{{!--
The `~` syntax strip spaces between the elements, making it produce
`<a>Some text</a><span>`,
with no space between them.
This causes the topic-post-badge to be considered the same word as "text"
at the end of the link, preventing it from line wrapping onto its own line.
--}}
<td class='main-link clearfix topic-list-data' colspan="1">
{{#if hasThumbnail}}
{{raw "list/topic-thumbnail" topic=topic thumbnails=thumbnails category=category opts=thumbnailOpts}}
{{/if}}
{{~raw-plugin-outlet name="topic-list-before-link"}}
<span class='link-top-line'>
{{~raw-plugin-outlet name="topic-list-before-status"}}
{{~raw "topic-status" topic=topic}}
{{~topic-link topic class="raw-link raw-topic-link"}}
{{~#if topic.featured_link}}
{{~topic-featured-link topic}}
{{~/if}}
{{~raw-plugin-outlet name="topic-list-after-title"}}
{{~raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
topicId=topic.id
unreadClass=unreadClass~}}
{{~#if showTopicPostBadges}}
{{~raw "topic-post-badges" unreadPosts=topic.unread_posts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{~/if}}
</span>
<div class="link-bottom-line">
{{#unless hideCategory}}
{{#unless topic.isPinnedUncategorized}}
{{~raw-plugin-outlet name="topic-list-before-category"}}
{{category-link topic.category}}
{{/unless}}
{{/unless}}
{{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}
{{#if showActions}}
{{raw "list/topic-actions" likeCount=likeCount topicActions=topicActions}}
{{/if}}
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
</div>
</td>
{{#if showPosters}}
{{raw "list/posters-column" posters=topic.featuredUsers}}
{{/if}}
{{raw "list/posts-count-column" topic=topic}}
{{#if showLikes}}
<td class="num likes topic-list-data">
{{#if hasLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.like_count}} {{d-icon "heart"}}
</a>
{{/if}}
</td>
{{/if}}
{{#if showOpLikes}}
<td class="num likes">
{{#if hasOpLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.op_like_count}} {{d-icon "heart"}}
</a>
{{/if}}
</td>
{{/if}}
<td class="num topic-list-data {{cold-age-class topic.createdAt startDate=topic.bumpedAt class=""}} activity" title="{{html-safe topic.bumpedAtTitle}}">
<a class="post-activity" href="{{topic.url}}">
{{~raw-plugin-outlet name="topic-list-before-relative-date"~}}
{{~format-date topic.createdAt format="tiny" noTitle="true"~}}
</a>
</td>
{{raw "list/activity-column" topic=topic class="num topic-list-data" tagName="td"}}
{{/if}}
</script>
请告诉我这是否对您有帮助。 
Jagster
(Jakke Lehtonen)
5
两者都用。边车插件没有被弃用,对吧?
不过我今天晚些时候会试试。我这里快下午五点了,这意味着我得开始热桑拿了
所以,最重要的事情先来 
(给版主和管理员:这不是离题,而是现实世界的用户体验……)