Added Linkify words in post Theme

Something of note as I am leaning about Discourse that might be of help, a curse, etc.

The text for a post is stored in a PostgreSQL database in a table named posts. There are however two fields that hold the text for a post, raw and cooked. raw appears to hold the text as entered and cooked also appears to hold all of the text with changes. Please don’t ask me why, when they are used, how they are created, what is the difference at this point.

The URL for a normal post such as Use Prolog References

https://swi-prolog.discourse.group/t/useful-prolog-references/1089

but one can also get the raw using

https://swi-prolog.discourse.group/raw/1089

Personal Notes

Discourse API Documentation
URL endpoints

https://swi-prolog.discourse.group/site/basic-info
https://swi-prolog.discourse.group/site/statistics
https://swi-prolog.discourse.group/srv/status
https://swi-prolog.discourse.group/groups#show

https://swi-prolog.discourse.group/t/1089.json
https://swi-prolog.discourse.group/t/1089.json?include_raw=true

Regarding:

$ curl https://www.swi-prolog.org/doc_link?for=<predicate_indicator>

What if you had two modules with the same predicate indicator? Would it return a json array with the two predicates?

That is not handled now (you get the first answer). It is needed for only a couple of cases, but should probably be added at some point. This was a quick hack in between that should be enough to play with the idea.

1 Like

Okay! That was a little annoying, but I’ve made a little component theme that’s active now that should automatically format valid links; e.g. member/2, memberchk/2, integer//1, but not not_a_predicate/2.

EDIT: disabled while I try to figure out this issue

1 Like

Hm…but looking at this now, there seem to be maybe a race condition, since the checking happens asynchronously; some more investigation will be required :confused:

Okay, did some refactoring, it seems to be somewhat working now…please let me know if you see any issues!

How can we set the theme? I looked in Profile -> interface but it doesn’t show a new theme.

It’s a component that’s been added to the existing themes. I think if you refresh, it should be active if you’re using the Light or Dark theme (Eric was saying that it doesn’t apply to the Default theme, so that might not work).

Okay, let’s see if member/2 works. I am using the light theme.

EDIT: I did a refresh before posting this, so I guess it is not working. SWI-Prolog works fine.

Shows up as a link for me :+1:

There are what I call two types of themes, primary themes that a user selects and component themes that can be included in a primary theme.

What James is doing is to take the exiting component theme and enhance it. Then the component theme is manually included in selected primary themes. If the component theme is included in all the themes then everyone gets the ability of the component theme by default.

As I write this I see that James did add the enhanced component theme to both the Dark, Light and the Neutral primary themes but the earlier component theme needs to be removed.

Give me a few to work with James on this.

Do you mean the member/2 in my post shows up as a link for you? It doesn’t on mine.

1 Like

I see, I switched to the Neutral theme and it works. I’ll wait 'till you add it to the Light theme

I put a second pair of eyes on the change, the component theme (discourse-linkify-prolog-predicates) is included in Light, Dark and Neutral.

AFAIK the Default theme no longer exist as a primary theme that can be selected by users. When I did this the option to select Default disappeared.

EDIT

I just did a quick check and the component theme James added is working on multiple themes, retains the basic functionality of Linkify words in post now has the ablity to link to SWI-Prolog documentation when predicate indicators are used.

Nice job James. :+1:

1 Like

I switched back to the Light theme and it doesn’t work; but it worked on the Dark theme (and also the Neutral).

I see it, checking it out.

I removed the older component theme that is no longer needed and expected to see three primary themes each with three component themes, but the Light theme is only showing two, but in checking the settings it is showing three. :thinking:

Can you also check to see if the Neutral has the same problem? I think Neutral was not really working. Definitely the Dark theme is working though. Good work James.

1 Like

@EricGT, the Light is working now! Good job both of you. Thanks!

EDIT: I did have to refresh after changing the theme to light. But it is working great!

1 Like

Not yet, we lost the ability to link for words in the link table like SWISH and SWI-Prolog.

I am creating a test page for all the things that should work so I don’t have to keep hunting around for test cases.

1 Like

@jamesnvc

I created Post for testing installed component themes and had to include the component theme Linkify words in post to get all of the test to work. Does Auto linkify Prolog predicates extend Linkify words in post? If so then there may be a bug, it not then all works as expected.