Auto-Linkify Words

This should already work via regex, try this input:

/discourse/i,https://discourse.org

See this part of OP

Let me know if I should make that description clearer.

4 Likes

Whoops, I totally misread what youā€™re trying to do. Indeed, if you want to have case sensitive words, just make them into regexes i.e. /Discourse/ , without the i modifier. Not sure we need extra site setting if the workaround is so simple?

3 Likes

A post was split to a new topic: Re-categorise lot of topics with bulk action

@sam It has been discussed before here: managing the list via CSV file

I am now managing a large set of linkified terms and links in two locations: The linkify settings + a spreadsheet (as backup). Itā€™s a hassle to maintain the list in those 2 locations and keep it in sync when entering new data.

Is there any way we gonna see a feature to manage those settings lists via CSV?

I would love to get an option to simply point to an external CSV URL where the list is pulled from either manually or via cronjob.

Strongly suggest you put together a budget and ask in marketplace for someone to build this for you :wink:

2 Likes

I found a strange bug. When you have 0 linked words (you must delete the default words to see that) youā€™re Discourse turns white - Itā€™s a blank page and you canā€™t use it anymore.

I had to use safe mode to get things back on track.

This is strange, I think I fixed that bug. Do you have the most up-to-date version?

3 Likes

I updated yesterday, Iā€™m on Discourse v2.3.0.beta4 +20. Here is the error:

Uncaught TypeError: Cannot read property 'trim' of undefined Url: https://mywebsite.com/assets/ember_jquery-716f4989c2eb49ad65163ffb56185407340c2b195b81b9392b62cde3e992cade.js Line: 1 Column: 42780 Window

TypeError: Cannot read property 'trim' of undefined
    at https://mywebsite.com/theme-javascripts/4eb9aa70ad8aa90b1fd248cd745670ff01215caa.js?__ws=mywebsite.com:29:34
    at Array.forEach (<anonymous>)
    at https://mywebsite.com/theme-javascripts/4eb9aa70ad8aa90b1fd248cd745670ff01215caa.js?__ws=mywebsite.com:19:40
    at z (https://mywebsite.com/assets/application-56d715e16ae5d262d0073be59c0b878f76dd67b1b3dd13c44b737b77e22c7a2e.js:1:398826)
    at Object.initialize (https://mywebsite.com/assets/application-56d715e16ae5d262d0073be59c0b878f76dd67b1b3dd13c44b737b77e22c7a2e.js:1:197880)
    at https://mywebsite.com/assets/ember_jquery-716f4989c2eb49ad65163ffb56185407340c2b195b81b9392b62cde3e992cade.js:1:108617
    at e.each (https://mywebsite.com/assets/ember_jquery-716f4989c2eb49ad65163ffb56185407340c2b195b81b9392b62cde3e992cade.js:2:95418)
    at e.walk (https://mywebsite.com/assets/ember_jquery-716f4989c2eb49ad65163ffb56185407340c2b195b81b9392b62cde3e992cade.js:2:94442)
    at e.each (https://mywebsite.com/assets/ember_jquery-716f4989c2eb49ad65163ffb56185407340c2b195b81b9392b62cde3e992cade.js:2:93789)
    at e.topsort (https://mywebsite.com/assets/ember_jquery-716f4989c2eb49ad65163ffb56185407340c2b195b81b9392b62cde3e992cade.js:2:93835)
3 Likes

Okay, thanks for the report, that error is useful. Iā€™ll try to have a look next week.

4 Likes

Can you add the feature that shows only first keyword occurs in the topic. Thank you.

4 Likes

Interesting request, we have theme settings happy for a setting for this to be added

6 Likes

Or even better: able to configure to linkify a keyword for the first n occurrences in a topic. :slight_smile:

The problem I see with this is that in long topics, one would lose the link when ā€œarriving lateā€.

Maybe something like the <abbr> HTML tag, where the first occurrence uses a title attribute, then the following ones do not need it, and let the browser interpret it.

With linkified words, the first (few) links in the current view of the current user would be linkified, then only ā€œtitledā€ ā€“ maybe clickable, but not displayed as links to avoid information overflow.

1 Like

This should now be fixed, thanks again for reporting!

Iā€™ve looked into this and it would be tricky to implement without a major rewrite. The current code works per individual paragraphs. Moreover, it works backwards from the last one to the first, so the code would probably need to do an additional forward pass to remove the extra links. This is further complicated by dynamic loading of posts. Not sure all this is worth it for this feature.

What I can do with a bit of code refactor is to remove the duplicities within an individual paragraph. This seems like a reasonable defualt that perhaps does not even require an extra theme setting.

EDIT: @hellekin heh, you were just a bit faster :smiley:

Yeah, this would also be tricky to ensure if you land in the middle of a topic.

6 Likes

Yes, Itā€™s all good now. Thanks! :+1:t2:

1 Like

This is now merged. Only the first instance of a word in a paragraph will get autolinked (but if you match words using regexes all instances will be autolinked as before).

It did require a rather large refactor during which I fixed some corner cases, but it is possible I introduced some others so please test carefully after you update to latest. @Southpaw I know you use this theme extensively so if you could confirm everything looks OK that would be great!

FYI: @azzaazeel

4 Likes

Hi @danekhollas,

Everything looks good this morning, and the one-link-per-paragraph limit is an appreciated upgrade. Iā€™ve alerted my power users that there has been an update, and weā€™ll certainly let you know if we see any new oddness arise.

4 Likes

Hi @sam, I do see if there are more than one word in a sentence for linkify then it only shows hyperlink for the first word. is this limitation?

Itā€™s a feature. See 2 posts up :arrow_up:

And like @danekhollas says, if you want to linkify all occurences, you can use regexes instead.

3 Likes

Ok, thank you! got it now