Linkify words in post

I know some don’t like needing another click. But for destructive actions that are not (easily) reversible it makes sense to me. A lot easier than a progress indicator that indicates a need to be patient…

1 Like

Makes sense when the setting is LARGE and has LOTS of content in it, so I think it should be conditional not “mindlessly confirm everything all the time”.

We are slotting making this control work better for lists, additionally I will slot adding history for theme settings for 2.1

So sorry you lost the list

7 Likes

It was backed up, so rebuilding it took only half an hour or so. The experience just made me wonder if anything new had happened in this topic. I’m glad it sparked some ideas. :slight_smile:

3 Likes

Definitely on the top of my list for 2.1

6 Likes

Did you figure out how to get outbound links to open in new tab? I have my global set to open all outbound links in new tab. It is functioning on the site. Just not here.

The permalinks page seems somewhat similar and it too is fairly painful. It’s impossible to see what values are if they are too long to display.

Yes, fairly easy, found in this fork:
https://github.com/jrgong420/discourse-linkify-words/commit/0d4b55ac72e2ee9b59bd1f0cf7304284abd69f00

3 Likes

Thanks much! It appears to be an easy addition to the code… if you know where to put it and what format. I didn’t. I sure appreciate your response and providing the link. It works exactly as I want it to, now. Cheers!

Is there any way to host + edit the list externally as a workaround? e.g. a hosted txt or CSV file which is updated in the discourse settings automatically?

//EDIT: Also I have an issue with the theme component. When it’s active, new posts cannot be created. After hitting the reply button and typing the first two letters, the tab immediately freezes!

I am running on 2.1.0.beta1

1 Like

Hmm what web browser is this, what is the exact version? How long is your list?

My users reported the issue…I reproduced the issue with Chrome 66.0.3359.181

Issue shows even with default or empty list.

In which section would this be added?

have you checked the link? here is it again:
https://github.com/jrgong420/discourse-linkify-words/commit/0d4b55ac72e2ee9b59bd1f0cf7304284abd69f00

As you can see, the code was added to common/head_tag.html file right after line 36.

I am having another issue (unrelated to the one above, since I downgraded back to 2.0 stable):

It seems that the ~ character in URLs breaks links generated by linkify.
I tried to escape it like this: \~. but then the output is /~.

Any ideas?

Yeah where exactly is that file to place it? looking thru /var/ I couldnt see anything and not not that experienced with docker.

Under themes, common in the head section I dont seen any file where I can place it after line 36.

just copy the theme component to your own github repo and make the change there.
then you can install the theme from git. check the link in the first post. it’s all documented

2 Likes

Ah makes sense. Thank you!

I was able to resolve the issue myself.

Solution: urlencode the special character(s) or even the whole URL on a site like https://www.url-encode-decode.com/

So the ~ becomes a %7E in the URL. That way the link will be added in the correct manner.

It seems that linkify is not able to detect phrases e.g. when they are surronded by special characters like brackets (). Anyone have an idea how to fix that?

I have an experience building such feature, on Drupal (word_link module) websites and then in an SPA (word-link lib) websites.

The way it currently works, I have a spreadhead on Google docs with words and links. Google docs have a possibility to share documents as CSV files.

On a website, you have a js file which requests that Google Docs Spreadsheet, and replaces text with given links using word-link lib.

Benefits of that method are, you get for free a sort of links management page with access settings, so you can let only a few people edit it. And google caches it for you.

As a downside, you may need to write your own CORS proxy for that.

JavaScript code on a client will look like below:

const text = 'foo bar baz';
const words = [
  {
    text: 'foo',
    url: 'https://foo.com'
  }
];

function replace(text, words) {
  return words.reduce(function(text, word) {
    return WordLink.apply(text, word.text, word.url)
  }, text);
}

console.log(replce(text, words)); // "<a href="https://foo.com">foo</a> bar baz"
2 Likes