DuckDuckGo 搜索建议

https://github.com/notriddle/discourse-duckduckgo-search

Solves Is there a way to suggest DuckDuckGo instead of Google for failed search UI?.

A Discourse theme component to use DuckDuckGo as the suggested search system, instead of Google!

p.s. You’ll probably want to customize some of the text strings to stop mentioning Google, too.

18 个赞

Here’s what I’ve noted to be the places to alter the text:

  • js.search.or_search_google
  • js.search.search_google
  • js.search.search_google_button
  • page_not_found.search_google
    • is that search also adjusted to DDG in the theme? If not, that should be fixed too
  • js.google_search
    • that looks like it’s editable to put in DDG directly, not sure how that’s related

Is that it?

2 个赞

Okay, I’m writing this down, because 404 handling in Discourse is weird. Try this link on for size:

https://meta.discourse.org/nonexistant-page

If you open it in a new tab, you’ll notice that your user menu (the one in the upper-right of the page) doesn’t render. In fact, the Discourse Ember app doesn’t get loaded at all in this case. It’s being rendered by the Rails server following app/views/exceptions/not_found.html.erb

Obviously, if you click the link directly in this page, the Ember app remains resident. Try hitting the link with a .json at the end, and instead of sending the app a full 404 page, it sends an HTML fragment, with the heading and stuff removed, which the Ember app just plops into place.

2 个赞

Oh weird. But if that’s less trivial to fix, at least it can be documented and the easier parts all fixed. Thanks for working on this!

1 个赞

https://github.com/notriddle/discourse-duckduckgo-search/commit/17c849c5b8c22476720a07ee7ebfa4536feecedc

Added a commit to do the form rewriting to make the 404 page work, both within and without the Ember app.

5 个赞

Great! So the only remaining thing is to document (probably both here and at the repo README) the confirmed list of text items theme-users will need to customize in the admin UI?

1 个赞

I got this working, but it’s a little strange to have the page-not-found version start with the form using site:xxx… with no search term alongside that. Maybe that’s as good as it gets, but it would be ideal if it were feasible to get the text of the URL after the TLD for the not-found page and use that as the default search before the site: part…

Given

Google is no longer used at 404 pages. So, this theme probably needs updating to leave 404 pages alone, let them be the regular internal search as is now standard.

Discourse is still using Google for extra searching when internal searches fail though. So, for that, this DDG option still applies.

3 个赞

It wasn’t actually breaking anything, but I did go ahead and revert it. It also made the code simpler, since I can just replace the template again.

https://github.com/notriddle/discourse-duckduckgo-search/commit/39e5501c35f2b73dd3eb9a7977de0c472d85711c

6 个赞

is there any reason Google is still the default for Discourse when extra searching occurs? DuckDuckGo is more in tune with the mindset of Discourse than Google is.

4 个赞

我也赞同,目前有变通方法吗?

也可以与 Discourse AI 一起使用 :slight_smile:

1 个赞

此主题组件就是解决方法。

3 个赞

我没看到这个话题,也不知道主题组件,所以我直接把整个谷歌搜索的东西都删掉了……不过我现在不太愿意再添加一个非官方的主题组件了。如果默认是 DuckDuckGo 或者有一个站点设置就好了。

1 个赞

……允许更改提供商,或者完全删除此备用搜索建议。

在此期间,你是如何“完全删除搜索功能”的? 假设你创建了一个主题组件,但你能在这里分享实际的代码吗(这样我就不必自己去弄清楚了)?

我fork了它并更改了URL。通用的标准应该是将其留空,并允许用户更改它。

这就是营销的运作方式,通过最高级别的社会工程学。

我已推送一项更新以使用 插件出口,但这需要将该出口添加到 Discourse 本身。

6 个赞