Good job, this is nice and succint!
No advance on the tutorial, but I have made fairly good progress on a website I’m developing which I think is a good example of where Prolog is a better choice than Ruby/Python/Node etc because it uses AI to play strategy games.
The site is http://www.newsgames.biz/
So far I’ve got it to play checkers (not brilliantly, but reasonably well) and now I’m working on chess.
Developing it has been very educational for me. The trick is to explain what I’ve learned to other people, besides a computer.
Hi Joe,
I’ve found this pretty useful. Have you considered using Github/ Gitlab pages to host it? At least for now. Definitely write it down, I want to read it!
I’m a bit overwhelmed at the moment with my own application development, but I do like the idea of a SWI-Prolog blog where we can share posts on topics of interest as well as tutorials. If others in the community want such a service, perhaps we can develop it as a community?
Kind regards,
Paul
Many thanks for the encouragement Paul. I found your blog on using SWI Prolog’s unit testing package very helpful.
I’ve started what will hopefully grow into a seven part series at https://github.com/roblaing/swipl-webapp-howto
Thanks Joe, I still check that post myself more often than I’m prepared to admit! But then this is why I made the blog, it’s as much notes for myself as others.
Keep us up-to-date as you write up the next 6 units!
I’ve completed unit 2 which covers the basics of forms.
This all looks incredible.
If I can help, just let me know how. As soon as it finds a stable home, I’ll add a link to it from my tutorial if that’s OK.
If you want to host it on pathways, I’d be happy to give you shell access.
email me at anne@swi-prolog.org and I’ll set you up.
I had some unexpected free time today, so I set about building a multi-user blog platform. My intention is to create a place where folks can easily share how-to’s, news, and other information. It’s to be an aid to community and publicity.
Only had one day on it, but it can handle editors and moderators. We’ve got rich-text editing, code-blocks, images, categories and tags. There’s no executable code segments, no comments, and no content yet! It’s also sans domain name, I was considering prologhub.pl
and borrowing Poland’s extension seen as it’s the common Prolog file extension.
A sneak preview is available at: http://139.162.216.240/ But there’s really nothing to see until I can get some posts on there. I’ve got a full-on schedule for the next couple of days, but I’ll try to transfer a couple of my old posts over to kick-start it. I’d love to start adding some user accounts if you’re interested in creating content.
Update: OK, I put one old post on there, but now I really must get some sleep!
Looks nice. Just, there is a typo that needs correction, since it’s likely to confuse beginners:
my_append([H|Tail1], List, [H|Tail2]) :- append(Tail1, List, Tail2).
should be
my_append([H|Tail1], List, [H|Tail2]) :- my_append(Tail1, List, Tail2).
Many thanks Anne. I think where it is on github is a good permanent home for it since it’s easy for people to find the code. My knowledge of how to use git and github is fairly basic, but that’s all part of the learning exercise.
Thank you! Shows the perils of working 'til the early hours.
I only discovered the swish site through this forum which I found very user friendly while putting up:
https://swish.swi-prolog.org/p/yeQhnQSk.swinb
A problem I have with it is finding what other tutorials people have written, so a key issue seems to be the fragmentation of information out there, so I’m not sure if yet another website is a good idea.
Though I spend a lot of time on http://www.swi-prolog.org, I only found the page on quasiquoting via chance and google. I’ve subsequently become a big fan of quasiquoting, rewriting Unit 1 of my web app tutorial instead of soldiering ahead with the database stuff in Unit 3.
Anyone know how to use quasiquoting with odbc_query?
Someone has to write a quasi quoter for SQL. It isn’t needed that much as you can use parameterized queries though. Writing such a beast typically requires either writing a full parser or at least a tokenizer such that you know in what context you are interpolating Prolog values. This is required to embed the Prolog value in a safe way in the target language.
Handling statements from other languages as plain strings and manipulating them using simple string operations is one of the most well understood routes to security issues. It is very much common practice as it seems so easy. Still, don’t The main design guideline for the web services and most other interaction with other languages through strings is to avoid this and assemble expressions in the target language from data structures using code that fully supports the target language syntax and thus properly escapes special characters.
Agreed. It doesn’t make much difference for SQL since the queries are usually short. The key thing is to get examples of the various ways to do things out there, which is what I’m trying to do.
I’ve finally completed Unit 4 of my web application tutorial at https://github.com/roblaing/swipl-webapp-howto, which involved writing a safe user authentication system which involved learning both SWI Prolog’s and Javascript’s encryption libraries, along with brushing up my understanding of cookies… very educational for me which I hope other people can understand.
As far as I recall the Python-based Udacity course I’m redoing in SWI Prolog, the authentication unit was the toughest, and the rest just involved tying the previous parts together to create a fully functional blog.
But I now need to go back to Unit 2 and redo form basics correctly with http_redirect using my improved knowledge from writing the registration and login pages.
Dear Joe,
I am currently trying to understand unit4 of your nice tutorial (the one with the user authentication). This part does not seem to work in the script (signup_form.js, lines 23-38):
fetch('/check_name', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({"userName": document.forms.signup.elements.username.value})
})
.then(res => res.json())
.then(response =>
{if (response.nameOk === document.forms.signup.elements.username.value) {
document.getElementById('error_username').textContent = ''
} else {
valid = false;
document.getElementById('error_username').textContent = response.nameOk;
}})
.catch(error => document.getElementById('error_email').textContent = 'Caught Exception: ' + error.description);
Unsure what to do with it. The server in unit4 does not handle json queries, and duplicate usernames seem to be catched at a different place. I am also unsure how about the last line, is the id “error_email” correct in this context?
Best wishes,
Matthias
I must confess I haven’t looked at that code in a long time. Polishing up my tutorials is on my to do list for one day.
I’ll try test it and see what the problem is when I get a chance.
is the serving of plain html and javascript files by the swi-prolog server also integrated and implemented in this example? if so then it is more complete