On 15/11/2018 12:02, Raivo Laanemets wrote:
> Welcome to Estonia. If we are lucky we get some snow during Christmas,
> not the usual rainy muddy mess :)
Like the Netherlands, only there is the probability of a white
Christmas really low :(
> In that code example I meant a HTTP handler like this:
>
> handle_request(Request):-
> do_something(Request),
> http_redirect(moved,'/something_else',Request),
> log('Did something and redirected user').
> |
>
> In this handler the last line with the log predicate call is not
> executed as http_redirect/3 throws an exception.
> Various http_ predicates in http_dispatch all use exceptions to
> implement what they do. This can be an
> interesting surprise as some of the code does not execute yet you get no
> error. I once debugged it 2 hours.
For a long time that was the only way it could due to the way the
cgi-stream was implemented that could only handle 200 replies. Since
there are many non-error replies that are not 200 and have content the
cgi-stream has been extended a lot. You can now simply write
Status: 302
Location: /go/here
as part of the header and the system will reply using a redirect
(not tested, details may matter but it surely can work).
I'm surely in favour of a proper redesign of the web server library.
There are too many layers of incremental patches to accomodate new
standards and practices as well as support for outdated stuff such
as not using threads.
Ideally, I guess the existing low-level support should be rationalised
and then it should accomodate multiple high level APIs including the
current one for compatibility.
Cheers --- Jan
> I'm thinking about implementing blocks for simple_template. The vdom
> engine I built can be used for
> templates as well and it supports blocks through the concept of
> components which are represented
> by custom HTML elements and they pass around the children elements.
Also note that the HTML quasi quotations can be used for templating,
e.g.
{|html(Text)||<div class="myclass">Text</div>|}
AFAIK, and attribute or content that matches one of the qq arguments is
replaced. Not saying that is ideal, but quasi quotations may be part of
the puzzle.
> On Saturday, November 10, 2018 at 7:13:22 PM UTC+2, Paul Brown wrote:
>
> Tere Raivo! I will be visiting Estonia for Christmas, especially
> looking forward to seeing the Old Town in Tallinn during winter.
>
> I haven't worked with web applications enough in SWI to understand
> reply_something(X), log_replied(X) vs throw(http_reply()). If you
> could expand more, please do email me.
>
> I know Simple Template lacks some useful features, but it's still
> the best we have. I am secretly hoping that Simple Web will attract
> enough attention that someone might try to develop these features
> for Simple Template. I'm afraid templating is not my area of
> expertise, I looked over the code but have no idea about how to go
> about implementing these features. Currently I work around the
> issues by rendering a base template with dynamic includes for
> blocks. I think I'll add an example of this to that repository.
>
> To support the development of Simple Web, I am eating my own dog
> food. I am using it firstly in an "electron" style desktop
> application, with Vue.js. I am also porting my personal website over
> from Python/Flask to SWI-Prolog, just trying to get my head around
> SWI-Prolog's RDF support to get that done. Plus I'll have to change
> hosts as my current one only supports Python web applications. Plus,
> developing the examples helps, I've found one bug that way and added
> one feature I discovered that I wanted.
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
swi-prolog+...@googlegroups.com
> <mailto:
swi-prolog+...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/swi-prolog.
> For more options, visit
https://groups.google.com/d/optout.