Linkify Words

on linkify or abbr plugin ?

Linkify should be better as a starting point.

You’d need to modify this function:

https://github.com/discourse/discourse-linkify-words/blob/b45105d50a00f69621b464325737fd5f4ea6e49a/javascripts/discourse-linkify/initializers/initialize-discourse-linkify.js.es6#L31

4 Likes

I just did a google sheets api integration for @jrgong so that the linkify data can be fetched from a google sheet. It needs some more work before I launch it on meta though.

I did fork the TC in the process. I was wondering whether any data hook can be provided in the TC to switch/add data sources from another plugin or TC? I can make a PR but haven’t seen such a pattern earlier. Maybe something on the lines of replaceDataSource or addDataSource methods in the plugin api.

3 Likes

Isn’t it easier to just add an extra theme setting?

new setting for what?

For the integration with GSheets? I’m not sure I got what you’re asking but it seems to me it would be easier if you could submit a PR merge your changes upstream.

1 Like

The integration is in form of a plugin as we need to authenticate for bringing data from the sheet. Also the data needs to be cached to the db in order to avoid API calls for every post.

if I write safe-mode here in meta, it gets linked automatically to the related topic (note that I haven’t hyperlinked any words as can be seen in the image, I’ve only written safe-mode).

is it a result of this theme (adding some topics and the related word) or is it some kind of new magic which hasn’t been announced yet :smiley:?

3 Likes

Yeah this is the component and a very handy usage of it

@codinghorror this is a pretty legitimate reason for wanting this in core, if we had this in core we could implement back links for cases like this, the component can not do this, only plugins

9 Likes

That’s fine as long as it is in the Watched Words area, where it should be…

1 Like

I use linkify to transform url to affiliate link, and I just found that it transform user email too.

Ex : If someone has an email like helen@amazon.com and I have a linkify affiliate link with amazon (ex : amazon.com/affiliate35)

It transform the email like that : helen@amazon.com/affiliate35 and people don’t receive emails.

If someone have an idea to exclude user email with the “excluded tags” & “excluded classes” options.

Thank you

2 Likes

Here is an idea that might be super useful and easy to implement:

How about adding a third setting to each line for a custom CSS class?
That way one can change the looks for each individual link.

In our particular case, we want to have different looks for:

  • product links and even product categories -> affiliate links to partner shops
  • technical terms -> glossary entry
  • internal pages -> toc, faq, beginner-guide, etc

In the past we just installed a second instance of linkify component and adjusted the css class in the component. That way it’s not update safe and has to be edited manually with each update.

In addition we are using a custom fork with a google sheet to manage the entries (kudos to @fzngagan and thepavillion team :wink: )

2 Likes

Hey @jrgong we’re in discussion and planning to launch the plugin to the world with instructions.

2 Likes

Hey guys

how does the theme component deal with somewhat similar or overlapping regex matches

In my specific case I have following entries

/super.?skunk/gi,https://link1.com
/skunk(?:(?: #?|#)?1)?/gi,https://link2.com

For the term super skunk current output is: Super Skunk
Desired result is: Super Skunk

How can I achieve that?

You can try changing the order of regexes in the theme settings.

ne 23. 8. 2020 v 19:06 odesĂ­latel jrgong via Discourse Meta <meta@discoursemail.com> napsal:

1 Like

This theme component only works for a list of static associations between words and a url as defined in a google spreadsheet or defined through the admin panel. What if there was a pattern of words that would connect to a url using a javascript? For example, “Name1” would be connected to “url/1.jpg” where the association between “Name1” and “1” would always be the same but would be defined through an api?

Not sure what you mean but the theme component is written entirely in JS so you’ll welcome to modify it as needed.

2 Likes

Can u share this plugin?

1 Like
1 Like

Our site has something like this that another admin created.

The site is for the Programming language SWI-Prolog and in post we regularly refer to the predicates (think methods in imperative languages) and the predicates are distinquished by the number of parameters which is a number. So regularly we input append/2, append/3, append/2,3 etc. Before the custom plug-in we spent a measurable amount of time inserting the links to the documentation by hand, e.g. append/2 append/3.
When a predicate name with the arity are combined together they are called a predicate indicator.

With the plug-in, now we just input the predicate indicator and the link is added automatically.

Our site is open and has test page that demonstrates this is action.

See: Post for testing installed component themes and plugins
( Auto linkify Prolog predicates)

The plug-in is on GitHub but required some changes on the documentation server to make it work.

See: jamesnvc/ discourse-linkify-prolog-predicates :slightly_smiling_face:

Please don’t ask me questions about this as I only know it works. Yes I could figure it out if I need to but that would take me a few hours that I don’t have. :frowning_face:

2 Likes