# Development

**URL:** https://meta.discourse.org/c/dev/7.md?page=108

[最新版本](https://meta.discourse.org/latest.md) · [分類](https://meta.discourse.org/categories.md) · [標簽](https://meta.discourse.org/tags.md)

**Page:** 109

---

## [使用 API 按 ID 获取分类](https://meta.discourse.org/t/category-by-id-using-api/118621)

<div class="topic-metadata">

**Author:** [@mcki0127](https://meta.discourse.org/u/mcki0127)\
**回覆:** 2\
**Last updated:** [2019年五月24日 20:57 UTC](https://meta.discourse.org/t/category-by-id-using-api/118621 "2019-05-24T20:57:02Z")

</div>

是否可以通过 API 根据 ID 获取分类？目前我正在使用 categories.json 并遍历结果。这听起来像个愚蠢的问题，如果是的话请见谅。

---

## [如何使用 API 隐藏图标](https://meta.discourse.org/t/how-to-use-api-to-hide-icons/118682)

<div class="topic-metadata">

**Author:** [@Ellibereth](https://meta.discourse.org/u/Ellibereth)\
**回覆:** 2\
**Last updated:** [2019年五月26日 08:21 UTC](https://meta.discourse.org/t/how-to-use-api-to-hide-icons/118682 "2019-05-26T08:21:44Z")

</div>

是否有类似 api.replaceIcon 替换图标的方法可以隐藏图标？

---

## [如何将实时备份加载到本地开发环境](https://meta.discourse.org/t/how-to-load-live-backup-into-local-dev-environment/118550)

<div class="topic-metadata">

**Author:** [@Ellibereth](https://meta.discourse.org/u/Ellibereth)\
**回覆:** 1\
**Last updated:** [2019年五月23日 20:56 UTC](https://meta.discourse.org/t/how-to-load-live-backup-into-local-dev-environment/118550 "2019-05-23T20:56:11Z")

</div>

如何从实时实例加载 .tar.gz 备份到本地开发环境？

---

## [API user\_badges /users/username/activity/badges.json API 与 /user-badges/username.json 对比](https://meta.discourse.org/t/api-user-badges-users-username-activity-badges-json-api-vs-user-badges-username-json/117958)

<div class="topic-metadata">

**Author:** [@kimardenmiller](https://meta.discourse.org/u/kimardenmiller)\
**回覆:** 4\
**Last updated:** [2019年五月20日 19:36 UTC](https://meta.discourse.org/t/api-user-badges-users-username-activity-badges-json-api-vs-user-badges-username-json/117958 "2019-05-20T19:36:06Z")

</div>

在 API 中我们看到： def user\_badges(username) response = get("/users/#{username}/activity/badges.json") response.body\['badges'\] end 但这并未获取用户的所有徽章。从 Discourse \> user \> badges 开始…

---

## [新用户自动激活](https://meta.discourse.org/t/auto-activation-of-new-users/117583)

<div class="topic-metadata">

**Author:** [@Vishal\_Kaushik](https://meta.discourse.org/u/Vishal_Kaushik)\
**回覆:** 8\
**Last updated:** [2019年五月20日 07:12 UTC](https://meta.discourse.org/t/auto-activation-of-new-users/117583 "2019-05-20T07:12:35Z")

</div>

我希望自动激活新创建的用户，因为我将为已验证用户的网站创建用户。我该如何在此处实现？

---

## [版本不匹配：启动器与 hub.docker.com](https://meta.discourse.org/t/version-mismatch-launcher-vs-hub-docker-com/118009)

<div class="topic-metadata">

**Author:** [@salvamucche](https://meta.discourse.org/u/salvamucche)\
**回覆:** 1\
**Last updated:** [2019年五月17日 10:33 UTC](https://meta.discourse.org/t/version-mismatch-launcher-vs-hub-docker-com/118009 "2019-05-17T10:33:23Z")

</div>

discourse\_docker/launcher 在 master · discourse/discourse\_docker · GitHub 上安装的版本是 discourse/base:2.0.20190429-1058，这与 discourse/base 上可用的最新版本 2.0.20190512-2317 不同…

---

## [\`script/osx\_dev\` 脚本问题较多](https://meta.discourse.org/t/script-osx-dev-script-is-pretty-broken/81932)

<div class="topic-metadata">

**Author:** [@shoshber](https://meta.discourse.org/u/shoshber)\
**回覆:** 3\
**Last updated:** [2019年五月17日 01:55 UTC](https://meta.discourse.org/t/script-osx-dev-script-is-pretty-broken/81932 "2019-05-17T01:55:32Z")

</div>

我目前遇到的问题： Brewfile 已损坏（Brewfile 是否已过时？） apple-gcc42 在 Mavericks 之后无法工作 它强制安装并使用 ruby 2.0.0，但 rails 要求版本 \>= 2.2.2（这位于…

---

## [回复按钮自定义行为](https://meta.discourse.org/t/reply-button-custom-behavior/117960)

<div class="topic-metadata">

**Author:** [@eatcodetravel](https://meta.discourse.org/u/eatcodetravel)\
**回覆:** 0\
**Last updated:** [2019年五月16日 20:39 UTC](https://meta.discourse.org/t/reply-button-custom-behavior/117960 "2019-05-16T20:39:16Z")

</div>

我想自定义“回复”按钮的行为，例如传递额外的类或数据属性（用于弹出窗口）。 我认为我已将该功能缩小到此函数 https://github.com/discourse/discourse…

---

## [导入的图片缺少缩略图，导致进程被终止](https://meta.discourse.org/t/imported-images-missing-thumbnails-getting-tombstoned/85011)

<div class="topic-metadata">

**Author:** [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**回覆:** 3\
**Last updated:** [2019年五月15日 21:20 UTC](https://meta.discourse.org/t/imported-images-missing-thumbnails-getting-tombstoned/85011 "2019-05-15T21:20:11Z")

</div>

继续讨论“我投身于大规模帖子重制工作”的话题： 因此，我一直在为一个非常喜欢大量超大图片的社区进行导入工作。这些图片的总大小约为 160GB。 在导入……

---

## [如何获取用户互动过的所有帖子？](https://meta.discourse.org/t/how-to-get-all-posts-a-user-interacted-with/117814)

<div class="topic-metadata">

**Author:** [@nisevi](https://meta.discourse.org/u/nisevi)\
**回覆:** 1\
**Last updated:** [2019年五月15日 15:37 UTC](https://meta.discourse.org/t/how-to-get-all-posts-a-user-interacted-with/117814 "2019-05-15T15:37:40Z")

</div>

大家好！我正在尝试获取用户互动过的所有帖子。我需要每个帖子的以下信息： 作者； 访问次数； 回复次数； 是否可以通过 API 获取这些信息？ 我曾考虑获取所有用户……

---

## [是否有用于在分类中启用投票的 API 端点？](https://meta.discourse.org/t/is-there-an-api-endpoint-for-enabling-voting-in-a-category/117734)

<div class="topic-metadata">

**Author:** [@lol](https://meta.discourse.org/u/lol)\
**回覆:** 1\
**Last updated:** [2019年五月14日 21:11 UTC](https://meta.discourse.org/t/is-there-an-api-endpoint-for-enabling-voting-in-a-category/117734 "2019-05-14T21:11:42Z")

</div>

是否有用于在类别中启用投票的 API 端点？

---

## [\[Api\] 能否向帖子/主题添加不可更改的条目？](https://meta.discourse.org/t/api-can-i-add-an-entry-to-a-post-topic-that-cannot-be-changed/117482)

<div class="topic-metadata">

**Author:** [@shaco](https://meta.discourse.org/u/shaco)\
**回覆:** 5\
**Last updated:** [2019年五月13日 22:13 UTC](https://meta.discourse.org/t/api-can-i-add-an-entry-to-a-post-topic-that-cannot-be-changed/117482 "2019-05-13T22:13:38Z")

</div>

我能否向无法更改的帖子/主题添加条目？ 它可以是 JavaScript/HTML 吗？ 听了您的建议，我决定学习如何创建插件。根据 API 文档，我看到可以更新帖子（PU…

---

## [API: Can I authenticate without putting the key in the URL?](https://meta.discourse.org/t/api-can-i-authenticate-without-putting-the-key-in-the-url/29425)

<div class="topic-metadata">

**Author:** [@mc0e](https://meta.discourse.org/u/mc0e)\
**回覆:** 13\
**Last updated:** [2019年五月10日 23:18 UTC](https://meta.discourse.org/t/api-can-i-authenticate-without-putting-the-key-in-the-url/29425 "2019-05-10T23:18:51Z")

</div>

Continuing the discussion from Discourse API Documentation: An unfortunate (in this context) characteristic of GET parameters is that they get logged all over the place, possibly including the discourse server, load ba…

---

## [生成新密钥时 user-api-key 返回错误](https://meta.discourse.org/t/user-api-key-returning-error-on-generating-new-key/117269)

<div class="topic-metadata">

**Author:** [@kristoferlund](https://meta.discourse.org/u/kristoferlund)\
**回覆:** 1\
**Last updated:** [2019年五月9日 13:22 UTC](https://meta.discourse.org/t/user-api-key-returning-error-on-generating-new-key/117269 "2019-05-09T13:22:27Z")

</div>

您好，我正在开发一个希望通过用户 API 访问 Discourse 的应用。一切正常，直到 Discourse 应该使用新生成的用户 API 密钥进行重定向为止。API 日志中的错误消息…

---

## [编写 Ruby 插件测试的建议](https://meta.discourse.org/t/advice-on-writing-ruby-tests-for-plugins/108110)

<div class="topic-metadata">

**Author:** [@kleinfreund](https://meta.discourse.org/u/kleinfreund)\
**回覆:** 14\
**Last updated:** [2019年五月3日 03:54 UTC](https://meta.discourse.org/t/advice-on-writing-ruby-tests-for-plugins/108110 "2019-05-03T03:54:47Z")

</div>

可以为插件的后端编写测试。例如，我在插件目录中创建了以下文件： spec/lib/route\_store\_spec.rb： require 'rails\_helper' describe MyPlugin::RouteStore do describe ".get…

---

## [如何在开发模式下创建具有已验证电子邮件的新用户？](https://meta.discourse.org/t/how-to-create-new-user-with-verified-email-in-development-mode/116617)

<div class="topic-metadata">

**Author:** [@Lotts](https://meta.discourse.org/u/Lotts)\
**回覆:** 4\
**Last updated:** [2019年五月2日 08:59 UTC](https://meta.discourse.org/t/how-to-create-new-user-with-verified-email-in-development-mode/116617 "2019-05-02T08:59:18Z")

</div>

你好，我是 Discourse 的新手，已经搜索过相关内容。我打算开发一些插件，需要创建用户进行测试。我尝试使用临时邮箱创建用户，但 Discourse 从未发送过电子邮件……

---

## [检查是帖子还是线程 - Ruby](https://meta.discourse.org/t/checking-if-post-or-thread-ruby/116437)

<div class="topic-metadata">

**Author:** [@jackkelly-bayliss](https://meta.discourse.org/u/jackkelly-bayliss)\
**回覆:** 16\
**Last updated:** [2019年四月30日 18:13 UTC](https://meta.discourse.org/t/checking-if-post-or-thread-ruby/116437 "2019-04-30T18:13:22Z")

</div>

各位 Discourse 用户，大家好， 我目前正在尝试基于一个现有的插件“discourse-chat-integration”进行开发。我已经对该插件进行了分叉，并尝试为某个特定社区进行自定义，但我遇到了……

---

## [如何使用 onebox gem 仅从缓存读取？](https://meta.discourse.org/t/how-to-read-from-cache-only-using-onebox-gem/116121)

<div class="topic-metadata">

**Author:** [@enigmaty](https://meta.discourse.org/u/enigmaty)\
**回覆:** 1\
**Last updated:** [2019年四月30日 09:57 UTC](https://meta.discourse.org/t/how-to-read-from-cache-only-using-onebox-gem/116121 "2019-04-30T09:57:14Z")

</div>

我正在将 onebox 作为独立 gem 使用。在我的使用场景中，我只想从缓存中读取。有没有一种简单的方法可以仅从缓存中获取 URL，而不进行任何网络请求？ 我使用的是 Rails 5.1。 谢谢。

---

## [当收到 Discourse 通知时 WordPress 通知](https://meta.discourse.org/t/wordpress-notification-when-you-get-discourse-notification/85371)

<div class="topic-metadata">

**Author:** [@LKNickname](https://meta.discourse.org/u/LKNickname)\
**回覆:** 5\
**Last updated:** [2019年四月30日 09:22 UTC](https://meta.discourse.org/t/wordpress-notification-when-you-get-discourse-notification/85371 "2019-04-30T09:22:57Z")

</div>

我目前正在尝试将 Discourse 集成到我的现有 WordPress 安装中，目前进展顺利（顺便提一下，我非常喜欢 WP-Discourse 插件和 SSO）。 但此刻我遇到了一些停滞…… 我正在使用 t…

---

## [Discourse 移动应用的委托认证](https://meta.discourse.org/t/delegated-authentication-for-discourse-mobile-app/110414)

<div class="topic-metadata">

**Author:** [@sam](https://meta.discourse.org/u/sam)\
**回覆:** 13\
**Last updated:** [2019年四月29日 14:48 UTC](https://meta.discourse.org/t/delegated-authentication-for-discourse-mobile-app/110414 "2019-04-29T14:48:16Z")

</div>

最初，当我们开发移动应用时，苹果提供了在移动应用中无缝嵌入 Safari 的功能。 一切都很顺利，您可以登录 Safari，然后只需点击一次，应用即可神奇地完成认证。 然而，fas…

---

## [修改 head\_tag.html 模板](https://meta.discourse.org/t/modifying-head-tag-html-template/116012)

<div class="topic-metadata">

**Author:** [@sodevious](https://meta.discourse.org/u/sodevious)\
**回覆:** 3\
**Last updated:** [2019年四月26日 01:40 UTC](https://meta.discourse.org/t/modifying-head-tag-html-template/116012 "2019-04-26T01:40:11Z")

</div>

我正在开发一个自定义主题，对于如何访问和编辑 \`\` 中的内容感到有些困惑。我看到了 \`head\_tag.html\` 文件，当然，编辑它会覆盖现有模板。很好，但是……

---

## [如何在邮件中稳健地确定论坛 URL？](https://meta.discourse.org/t/robust-way-to-determine-forum-url-in-a-mail/113996)

<div class="topic-metadata">

**Author:** [@distfp](https://meta.discourse.org/u/distfp)\
**回覆:** 3\
**Last updated:** [2019年四月25日 15:11 UTC](https://meta.discourse.org/t/robust-way-to-determine-forum-url-in-a-mail/113996 "2019-04-25T15:11:59Z")

</div>

你好， （如果这不是合适的分类，请见谅，因为这是关于客户端开发而非 Discourse 核心开发的内容，但看起来这是最接近的分类。） 我正在为 Emacs 的 G… 编写一个 Discourse 邮件“处理”方案。

---

## [使用 API 更新帖子内容时出现 500 或 400 错误](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825)

<div class="topic-metadata">

**Author:** [@jviotti](https://meta.discourse.org/u/jviotti)\
**回覆:** 4\
**Last updated:** [2019年四月24日 12:14 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825 "2019-04-24T12:14:51Z")

</div>

我正在尝试使用 API 更新帖子的内容。Discourse API 文档中提到，我应该使用 PUT /posts/:id.json，并将 post\[raw\] 作为请求体发送。 但这导致了 400 错误，并返回： errors: \[ 'param is mi…

---

## [Discourse中的帖子追踪是如何工作的](https://meta.discourse.org/t/how-does-post-tracking-work-in-discourse/115790)

<div class="topic-metadata">

**Author:** [@sam](https://meta.discourse.org/u/sam)\
**回覆:** 4\
**Last updated:** [2019年四月24日 07:06 UTC](https://meta.discourse.org/t/how-does-post-tracking-work-in-discourse/115790 "2019-04-24T07:06:26Z")

</div>

Discourse tracks read time for every post users see on the screen. This system has evolved over the years and I find I often need to refer back to the code to figure out how this works and why it exists. This post cover…

---

## [Sidekiq 未运行时链接无法自动嵌入](https://meta.discourse.org/t/links-not-oneboxed-when-sidekiq-isnt-running/115490)

<div class="topic-metadata">

**Author:** [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)\
**回覆:** 3\
**Last updated:** [2019年四月24日 02:18 UTC](https://meta.discourse.org/t/links-not-oneboxed-when-sidekiq-isnt-running/115490 "2019-04-24T02:18:14Z")

</div>

通过 API 创建主题时，我发现链接没有被自动转换为单行预览卡片。 curl \\ -X POST \\ -H "Content-Type: application/json" \\ -d '{"title": "Sample title here", "raw": "https://twitter.com/SE23life/status/1115640590…

---

## [直接连接到 Discourse 数据库](https://meta.discourse.org/t/direct-connect-to-the-discourse-database/115485)

<div class="topic-metadata">

**Author:** [@Shashikant\_Sharma](https://meta.discourse.org/u/Shashikant_Sharma)\
**回覆:** 1\
**Last updated:** [2019年四月19日 17:47 UTC](https://meta.discourse.org/t/direct-connect-to-the-discourse-database/115485 "2019-04-19T17:47:03Z")

</div>

您好， 我正在寻找一些自定义聚合和统计信息。我已经查看了 PostgreSQL 的架构表，可以通过连接和查询获取所需内容。我使用 NodeJS 连接 PostgreSQL。此外，此服务器与……不同。

---

## [插件创建的 user custom\_fields 更新出现问题](https://meta.discourse.org/t/problem-updating-user-custom-fields-created-by-a-plugin/115344)

<div class="topic-metadata">

**Author:** [@jezra](https://meta.discourse.org/u/jezra)\
**回覆:** 9\
**Last updated:** [2019年四月18日 21:34 UTC](https://meta.discourse.org/t/problem-updating-user-custom-fields-created-by-a-plugin/115344 "2019-04-18T21:34:13Z")

</div>

一点背景故事：2018 年 8 月，我受命为 Discourse 开发一个插件，以便在 User 模型中添加几个自定义字段。经过一番代码折腾，一个可用的插件诞生了，同时还有一个 Ruby 脚本…

---

## [Custom Push Notifications: allowed user api push urls](https://meta.discourse.org/t/custom-push-notifications-allowed-user-api-push-urls/54644)

<div class="topic-metadata">

**Author:** [@skoota](https://meta.discourse.org/u/skoota)\
**回覆:** 11\
**Last updated:** [2019年四月18日 07:12 UTC](https://meta.discourse.org/t/custom-push-notifications-allowed-user-api-push-urls/54644 "2019-04-18T07:12:36Z")

</div>

I am keen to do some modifications to the Discourse Mobile app to get push notifications working for our self-hosted installation of Discourse, particularly on iOS. From reading the What if I want to white-label the Disc…

---

## [失败/错误：UserOption.create(user\_id: id)](https://meta.discourse.org/t/failure-error-useroption-create-user-id-id/115347)

<div class="topic-metadata">

**Author:** [@Kids\_Unleashed](https://meta.discourse.org/u/Kids_Unleashed)\
**回覆:** 0\
**Last updated:** [2019年四月17日 20:31 UTC](https://meta.discourse.org/t/failure-error-useroption-create-user-id-id/115347 "2019-04-17T20:31:34Z")

</div>

我正在运行 \`RAILS\_ENV=test bundle exec rake db:create db:migrate\`，但执行失败了。 大多数情况下报错：\`Failure/Error: UserOption.create(user\_id: id)\`。 请问我是否遗漏了某些步骤？

---

## [存储有关用户会话的额外数据](https://meta.discourse.org/t/storing-extra-data-about-a-users-session/115197)

<div class="topic-metadata">

**Author:** [@LeoMcA](https://meta.discourse.org/u/LeoMcA)\
**回覆:** 4\
**Last updated:** [2019年四月17日 12:51 UTC](https://meta.discourse.org/t/storing-extra-data-about-a-users-session/115197 "2019-04-17T12:51:04Z")

</div>

近期，我们的一些用户一直受到一个棘手漏洞的困扰，我终于找到了原因： Discourse 使用两个 Cookie 来存储有关用户会话的数据：一个身份验证令牌 Cookie（whic…

[上一頁](https://meta.discourse.org/c/dev/7.md?page=107)

[下一頁](https://meta.discourse.org/c/dev/7.md?page=109)
