自动链接词

@danekhollas

Unfortunately I still have the issue. I tried changing the order of the regexes in the theme settings, yet the “shorter” entry is still triggered first.

Hello @jrgong! Were you able to do bulk uploads using a CSV file? Trying to figure it out but I’m not quite sure where to click. I am not a developer btw :smiley:

I am using this :slight_smile:

https://meta.discourse.org/t/discourse-linkify-google-sheets/163985/4

So do we. I note that:

discourse,https://discourse.org
discourse meta,https://meta.discourse.org
meta discourse,https://meta.discourse.org

Gives us:

discourse
discourse meta
meta discourse

The order that these are in the Theme Settings (and presumably the database beneath) doesn’t seem to make a difference. Rather, if you extend an existing linkified word, it will pick up the difference. If you add a word in front, it doesn’t.

1 个赞

Hmm, that’s a bit strange. You’re right, the order in the settings shouldn’t matter, because we sort the words by length:

https://github.com/discourse/discourse-linkify-words/blob/a516d488dc23f401a7062808b98a231af9a16ef1/javascripts/discourse-linkify/lib/utilities.js.es6#L99

Not sure how much time should be invested in this since AFAIK this feature is being ported to Discourse core.

4 个赞

Hi,

Just noticed that the linkified words don’t have that click counter as other links have (which would be a nice feature to have, in my opinion). Is it on purpose or just a bug?

2 个赞

can this be restricted to specific categories/tags so that a post would have to be in the category or tagged to generate links?

1 个赞

Is it possible to specify a title for the link? So “ghost” becomes “ghost (see warning!)”?

Possibly using markdown link syntax:

ghost,[ghost (see warning!)](https://warning.example.com)

Or specifying the title as a third parameter:

ghost,https://warning.example.com,ghost (see warning!)

@Paracelsus the click counter is not supported in this theme, sorry.

Not really a bug, the theme is only a JavaScript code running in your browser. It doesn’t talk to the server so there’s no way to store the number of clicks.

2 个赞

Now in discourse under replace words:
/admin/customize/watched_words/action/replace

If I just enter the word and then just put the URL without any markdown, it works! So that is how to get it to work without the autolink theme component.

(Whereas in the theme component you put the word/phrase then a comma then the link to use, in watched word replace you enter the word in one field and JUST the link in another… do not try to enter markdown in the replacement string like I originally tried.)

4 个赞

嘿,这是一个很棒的组件!感谢您完成这项工作。

但是这里有一个小问题,似乎链接化需要特定单词后的空格,因此该组件在中国和日本(也许还有韩语?我不会这门语言)的 Discourse 实例上无法正常工作。

我是中文母语者,也会说日语。在中国,人们有时会在书写中使用一些固定的外来词,例如 Apple、Office、BB(Blackboard)、DNA 等,这些词的翻译在日常语言中很少使用。而且在非正式写作中,当这些词被中文包围时,我们通常不会在它们前面/后面添加空格。

这是一个例子:

你会用Office吗?
Do you know how to use Office suite?

日语中也类似。

革新に満ちたAppleの世界へようこそ。(来自 Apple 日本官网)
Welcome to the world of Apple, which is full of revolutions.

我知道要为这两种语言调整此组件可能需要大量工作,因为这可能会导致使用字母的语言中出现意外的链接化。所以,只是指出这个小瑕疵的存在。再次感谢您提出这个很棒的组件想法。:smiley_cat:

2 个赞

这效果很好。是否可以追溯运行,还是需要手动搜索所有链接并更改它们?

您应该能够重新烘焙那些帖子。您可以单击扳手并重建 HTML。当您看到它有效时,您可以搜索如何重新烘焙匹配的帖子 rake 任务。

实际上,此主题会在浏览器加载帖子时动态地为帖子添加链接,因此无需执行任何操作。 :slight_smile:

3 个赞

哦。非常酷。我没意识到,但这是有道理的。

3 个赞

我们的 FOSS 家谱软件术语表对于发帖或链接来说过于庞大。

如果我们只链接了每个术语,那么每个帖子都会淹没在一片蓝色的链接海洋中。用户可能会停止点击链接。而且我们希望有一个术语表的审计跟踪。

因此,我将“Gramps 术语表”链接到我们由 MediaWiki 支持的 wiki 中的那篇文章。现在使用类似“(参见我们 Gramps 术语表 中的 [术语]”的注释。

(我们还有一个第二个家谱术语表,用于与家谱主题相关的术语,而不是特定于我们的软件。)

1 个赞

是否已允许使用管道?

我现在使用此作为解决方法:
image


另外,是否有办法在嵌套在排除的类的祖祖祖…子代中的某个世界不被链接化?
我正在构建一个带有“文档”类别的论坛,我不希望其中的单词被链接化,因为这会是多余的:其他类别的单词将被链接化,并链接到此文档类别中的主题。
此外,链接化的单词会在新窗口中打开。

所以,这不起作用:
image

这是我遇到的问题的示例。这是文档主题内文本的一部分。

如果我点击 22° halo,它将打开一个链接到……同一个页面、同一个位置的页面。
我可以排除标题中的单词,尤其是因为它包含一个目录,但后面的段落没有特定的类。它们是常规段落。


也许排除的类设置可以接受 CSS 选择器?
例如,d-toc-cooked \u003e *


编辑:另外,我无法理解为什么这不起作用,因为我的单词是排除类的直接子项:

image

“22° Halo”仍然被链接化:

<h3 id="toc-h3-22-halo" data-d-toc="toc-h3-22-halo" class="d-toc-post-heading">
    <a name="h-22-halo-7" class="anchor" href="#h-22-halo-7"></a>
    <a href="https://discourse.canapin.com/t/ice-halos-information-and-list/28#h-22-halo-7" rel="nofollow" target="_blank" class="linkify-word no-track-link">22° Halo</a>
</h3>

是因为目录的 HTML 代码可能在“链接化”之后生成吗?

1 个赞

是的,这很可能是问题所在,这两个都是 JavaScript 组件,所以存在竞态条件,结果将取决于哪个组件先运行。

4 个赞

在 HTML 允许列表中添加了一个类,因此我绕过了这个问题。

但是,能够有一个按钮排除属性可以提供更大的灵活性,以防止链接化单词,使用内置的 data-(anything) HTML 属性,因为 Discourse 默认允许它。

示例:
<span> text </span><span> text </span>

如果我设法将此添加到主题组件中,是否会接受推送请求?

1 个赞

这不幸地阻止了链接化明确包含任何这些字符的单词(尤其是“.”,这在链接缩写如 ID.1 或 id2.5 时很有用)。

这也许最好在核心中修复,但目前这里有一个修复上述问题的 PR:

https://github.com/discourse/discourse-linkify-words/pull/21

示例正则表达式规则(将匹配 id1.1id10.100(包括变体 id m.nIDm.nID m.n

/(ID¦id)\\s?(([1-9]¦10)\\.([1-9]¦[1-9][0-9]¦100))/, https://example.com/id$2