Added Linkify words in post Theme

@jamesnvc

As the theme Default is not available in the admin’s themes page, for the theme Light I am selecting Theme is enabled by default

Hopefully this will make Light the new default and those who have not changed their theme setting will see the changes made by the added component themes as the component themes are included in the Light theme. :crossed_fingers:

The check mark, which was not present in any theme, is now present for the Light theme indicating, based on what I read, that it is the default theme.

image

More of a response for anyone reading this.

AFAIK, anyone can create a Discourse theme and we can use it here.

The common way to get Discourse themes is to find them in the Discourse theme list, find the GitHub link noted in the theme, then as an admin install the theme using the GitHub link.

As noted above there are additional locations that can be used for installing, GitHub, any Git repository including one on your system or another system, installing from a local system (I don’t know if/the required format). Also admins have an option to create a new one.

The only option I have used thus far is to install from GitHub.

And yes a user could suggest a theme be installed and they would be considered but this is not like a one day sale, there is no rush.

1 Like

@jamesnvc, it would be great if you get the doc-link feature working!! That would be extremely useful.

$ time curl https://www.swi-prolog.org/doc_link?for=member/2
{
  "class":"autoload",
  "library":"lists",
  "summary":"True if Elem is a member of List.",
  "url":"https://www.swi-prolog.org/pldoc/doc_for?object=member/2"
}
real	0m0.384s
user	0m0.005s
sys	0m0.005s
$ curl https://www.swi-prolog.org/doc_link?for=atom_codes/2
{
  "class":"iso",
  "summary":"Convert between an atom and a list of character codes.",
  "url":"https://www.swi-prolog.org/pldoc/doc_for?object=atom_codes/2"
}
$ curl https://www.swi-prolog.org/doc_link?for=http_open/3
{
  "class":"library",
  "library":"http/http_open",
  "summary":"Open the data at the HTTP server as a Prolog stream.",
  "url":"https://www.swi-prolog.org/pldoc/doc_for?object=http_open/3"
}

This gives 404 and JSON null:

curl https://www.swi-prolog.org/doc_link?for=not_swi/3
null

The main worry is the round trip time. This is nice for you to experiment with. If we really go for it, the plugin should probably collect all candidates and then do a POST on this handler with a JSON array of candidate documentation links.

2 Likes

@jamesnvc

See: Need proofread of this advise about using theme preview

1 Like

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).