Sam 的简易主题

大家好

我需要修改头部代码中的哪一部分才能恢复精选主题摘要?

另外,在更新主题组件后,我的头像在主题列表中消失了:

1 个赞

我猜你运行的是一个分支版本,最新版本包含头像。

1 个赞

刚检查过,我的主题源链接指向 https://github.com/discourse/discourse-simple-theme.git
另外,刚从源链接重新安装了该主题,主题预览中仍存在相同问题。

1 个赞

或许可以将 Discourse 更新到最新版本?

1 个赞

我使用的是 2.4.1 版本。您指的是 2.5 测试版吗?

2 个赞

是的,头像的更改是在 2.5.0 beta 2 版本中进行的。

2 个赞

啊,我明白了。我刚往上翻,找到了你的临时解决方案

@Steven,你能告诉我需要调整那段头部代码的哪一部分,才能重新显示置顶主题的摘要吗?

1 个赞

已经存在一个摘要引用,所以你可能想先删除第 16 行

  {{raw "list/topic-excerpt" topic=model}}

然后,我会添加以下内容

  {{#if expandPinned}}
    {{raw "list/topic-excerpt" topic=topic}}
  {{/if}}

紧接在这段代码之后

{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
   </div>

也就是在 </td> 之前

如果你使用旧的头部代码,它应该看起来像这样

<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}}

<td class='main-link clearfix'>
  {{raw "topic-status" topic=topic}}
  {{topic-link topic}}
  {{#if controller.showTopicPostBadges}}
    {{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}}
  {{/if}}
  {{discourse-tags topic mode="list"}}
  <div class='creator'>
  {{#if showCategory}}
     {{category-link topic.category}}
   {{/if}}
  {{~#if topic.creator ~}}
  <a href="/users/{{topic.creator.username}}" data-auto-route="true" data-user-card="{{topic.creator.username}}">{{topic.creator.username}}</a> <a href={{topic.url}}>{{format-date topic.createdAt format="tiny"}}</a>
  {{~/if ~}}
   {{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}}
</td>

{{#if controller.showLikes}}
<td class="num likes">
  {{number topic.like_count}} <i class='fa fa-heart'></i>
</td>
{{/if}}

{{#if controller.showOpLikes}}
<td class="num likes">
  {{number topic.op_like_count}} <i class='fa fa-heart'></i>
</td>
{{/if}}

{{raw "list/posts-count-column" topic=topic}}

<td class="last-post">
<div class='poster-avatar'>
<a href="{{topic.lastPostUr}}" data-user-card="{{topic.last_poster_username}}">{{avatar topic.lastPoster usernamePath="username" imageSize="medium"}}</a>
</div>
<div class='poster-info'>
<a href="{{topic.lastPostUrl}}">
{{format-date topic.bumpedAt format="tiny"}}
</a>
<span class='editor'><a href="/users/{{topic.last_poster_username}}" data-auto-route="true" data-user-card="{{topic.last_poster_username}}">{{topic.last_poster_username}}</a></span>
</div>
</td>
</script>

<script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
  {{#if bulkSelectEnabled}}
  <th class='star'>
    {{#if canBulkSelect}}
        <button class='btn bulk-select' title='{{i18n "topics.bulk.toggle"}}'><i class='fa fa-list'></i></button>
    {{/if}}
  </th>
  {{/if}}
  {{raw "topic-list-header-column" order='default' name='topic.title' bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect}}

  {{#if showLikes}}
     {{raw "topic-list-header-column" sortable='true' order='likes' number='true' forceName=(theme-i18n 'likes')}}
  {{/if}}
  {{#if showOpLikes}}
     {{raw "topic-list-header-column" sortable='true' order='op_likes' number='true' forceName=(theme-i18n 'likes')}}
  {{/if}}
  {{raw "topic-list-header-column" sortable='true' number='true' order='posts' forceName=(theme-i18n 'replies') }}
  {{raw "topic-list-header-column" sortable='true' order='activity' forceName=(theme-i18n 'last_post')}}
</script>

<script>

(function(){

var TopicListItemView = require('discourse/components/topic-list-item').default;


TopicListItemView.reopen({
    showCategory: function(){
        return !this.get('controller.hideCategory') &&
                this.get('topic.creator') &&
                this.get('topic.category.name') !== 'uncategorized';
    }.property()
});

})();

</script>
1 个赞

我刚刚将这段代码添加到了主题的页眉部分,但头像仍然没有显示。我是不是漏掉了什么?

我也尝试了这段代码,头像仍未显示。甚至尝试了安全模式并禁用了所有插件。

提示:与“主题列表预览”的冲突导致即使使用了提供的代码,摘要也无法显示。

1 个赞

我编辑了之前的帖子,我对所有不同的版本感到有些困惑。

你添加的代码是针对 Discourse 最新版本的。如果我的理解正确,你需要为旧版本的 Discourse 编辑头部,因此我在上一帖中更新了一个适用于 2.5.0 b2 之前版本的代码。

不过,升级 Discourse 会更简单,它会带来许多很酷的新功能:grin:

1 个赞

我也很期待 :wink:

但我还是更倾向于保持稳定版本 :wink:

感谢更新!

2 个赞

@sam 近期是否有计划使主题组件与 主题列表预览 插件兼容?

暂无具体计划

1 个赞

我该如何在帖子标题和回复数之间添加一个“用户”列,显示发起每个帖子的用户的姓名和/或头像?这可以通过自定义功能或主题创建器实现吗?

1 个赞

我通常在 meta 上使用“Sam 的简单主题”(我非常喜欢)。但从昨天开始,在我这边似乎出现了问题!?我尝试在另一个浏览器的全新安装(用 Firefox 代替 Chrome)上运行,问题似乎依旧:顶部横幅不见了,只显示少量话题,而且点击话题无法打开。切换到其他主题后一切正常。

1 个赞

问题应该已经修复了。感谢反馈此问题 @Mevo :+1:

3 个赞

有没有办法在移动端的主题标题下方显示主题发起者的用户名,就像桌面端那样?

移动端:

IMG_5113

桌面端:

desktop

1 个赞

看起来该主题与深色模式方案不兼容 :(,因此也与 Automatic Dark Mode color scheme switching 不兼容。

3 个赞

我已更新主题以改善暗色模式的兼容性,拉取最新更改后您应该会看到改进。

8 个赞

谢谢 :slight_smile:

但是分类名称仍然显示异常。


2 个赞