I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas? ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
There is ZnHtmlOutputStream, not really a DSL, but it might help.
On 9 Sep 2017, at 00:15, Sean P. DeNigris <sean@clipperadams.com> wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Sven Van Caekenberghe-2 wrote
not really a DSL
I disagree ;) It looks perfect! ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Hi sean I want the same :). Now I have to finish my lectures for within two weeks and I should not read this mailing-list :) I do not remember what we did in Pillar. Now if you extract the canvas/builder from Seaside and rename it to avoid conflict I'm all ears. Stef On Sat, Sep 9, 2017 at 12:15 AM, Sean P. DeNigris <sean@clipperadams.com> wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
On 9/9/17, Sean P. DeNigris <sean@clipperadams.com> wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
Hello Sean 1. One idea is _not_ to go for a HTML builder DSL but for a document model plus a generator. The generator is a visitor for the document object model. There is the Pillar document model and a visitor already in place. The current challenge - actually it is not a challenge - but just needs some time - is to extract the Pillar document model (easy) and the tests (needs more time) so that it can be loaded as a stand-alone package. See a long discussion in a thread in August about including Pillar in the image. The same then applies for the HTML generator. That is just a file-out from an image which has the full Pillar loaded. So IMHO it is not so much about inventing a new HTML builder DSL but to "mold" exisiting infrastructure into shape. This has the advantage that you can generate other representations easily. 2. Another idea is to look at HttpView2 done 10 years ago and come up with a revised version. http://wiki.squeak.org/squeak/182 "No Files. No HTML. Just Smalltalk code!" A builder: http://wiki.squeak.org/squeak/637 The element hierarchy: http://wiki.squeak.org/squeak/840 Discussion --------------- Comparison of 1 and 2 In 1 you use a document model (DOM) which is independent from the representation in HTML code. Than you have a generator generating the HTML code. The DOM is actually quite close to the HTML DOM. The Pillar DOM is nicely supported in Pharo with the inspector. Neither 1 nor 2 actually take CSS into account. An issue which is important when you generate web pages. So from the Smalltalk data model point of view (web document modeling) you have a Smalltalk object which is then rendered on two output streams - HTML - CSS Things get interesting in particular if you want to generate responsive web sites. The you need to do more on the CSS side and with generating pictures as well. Regards Hannes
----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Sean, the question is of course - is it the HTML only model you are interested in or is it rather a 'web document model' (i.e. something which is displayed in a browser) thus including HTML and CSS. --HH. On 9/9/17, H. Hirzel <hannes.hirzel@gmail.com> wrote:
On 9/9/17, Sean P. DeNigris <sean@clipperadams.com> wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
Hello Sean
1. One idea is _not_ to go for a HTML builder DSL but for a document model plus a generator. The generator is a visitor for the document object model.
There is the Pillar document model and a visitor already in place.
The current challenge - actually it is not a challenge - but just needs some time - is to extract the Pillar document model (easy) and the tests (needs more time) so that it can be loaded as a stand-alone package.
See a long discussion in a thread in August about including Pillar in the image.
The same then applies for the HTML generator. That is just a file-out from an image which has the full Pillar loaded.
So IMHO it is not so much about inventing a new HTML builder DSL but to "mold" exisiting infrastructure into shape.
This has the advantage that you can generate other representations easily.
2. Another idea is to look at HttpView2 done 10 years ago and come up with a revised version. http://wiki.squeak.org/squeak/182
"No Files. No HTML. Just Smalltalk code!"
A builder: http://wiki.squeak.org/squeak/637 The element hierarchy: http://wiki.squeak.org/squeak/840
Discussion ---------------
Comparison of 1 and 2
In 1 you use a document model (DOM) which is independent from the representation in HTML code.
Than you have a generator generating the HTML code. The DOM is actually quite close to the HTML DOM.
The Pillar DOM is nicely supported in Pharo with the inspector.
Neither 1 nor 2 actually take CSS into account. An issue which is important when you generate web pages.
So from the Smalltalk data model point of view (web document modeling) you have a Smalltalk object which is then rendered on two output streams
- HTML - CSS
Things get interesting in particular if you want to generate responsive web sites. The you need to do more on the CSS side and with generating pictures as well.
Regards Hannes
----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Hannes Hirzel wrote
the question is of course - is it the HTML only model you are interested in or is it rather a 'web document model'
Thanks for the detailed replies! Yes, you are right. I should've given more info about my use case. I had some HTML that I was using for an email signature for my organization. Every time we have a new officer, I would dig out and hand edit an existing signature in a dumb text file. This worked as far as it goes, but when I wanted to make a change to the design, I'd have to hand edit them all. So, I thought, let's just do it automagically in Pharo! But then I ended up with a weird hybrid approach where: - PRO: I broke the HTML up into smaller logical pieces in Pharo methods - CON: The individual pieces were still just dumb text (e.g. I had to read through a string to pick out which parts belong to which tag/attribute/inner-text) - CON: I lost the ability to deal with the HTML in its own domain (e.g. open it in Dreamweaver and live edit) I reckoned that I should fully commit to one approach. Either have an HTML template file(s) which Pharo manipulates, or break up the HTML fully into a domain representation. So my goal is to have something which outputs HTML suitable for an email signature based on HTML which I already have in text/file form. ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
On Fri, Sep 08, 2017 at 03:15:56PM -0700, Sean P. DeNigris wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
I wrote this but subsequently decided that loading the whole of Seaside into my image just for this functionality is ok and stopped. http://smalltalkhub.com/#!/~PierceNg/WaterMint-HTML Pierce
I don't know how modular it is, but maybe loading only the 'Seaside-Canvas' package you can use the WAHtmlCanvas to create the HTML content. I used it together with Mandrill client by creating the mail body with the result of `WAHtmlCanvas builder render: [ :html | ... ]`. HTH. Regards, Esteban A. Maringolo 2017-09-11 7:31 GMT-03:00 Pierce Ng <pierce@samadhiweb.com>:
On Fri, Sep 08, 2017 at 03:15:56PM -0700, Sean P. DeNigris wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
I wrote this but subsequently decided that loading the whole of Seaside into my image just for this functionality is ok and stopped.
http://smalltalkhub.com/#!/~PierceNg/WaterMint-HTML
Pierce
On Mon, Sep 11, 2017 at 10:14:54AM -0300, Esteban A. Maringolo wrote:
I don't know how modular it is, but maybe loading only the 'Seaside-Canvas' package you can use the WAHtmlCanvas to create the HTML content.
I also experimented with loading enough of Seaside in bits and pieces to get the canvas thing working. Was not successful back then. Pierce
Hi Pierce Ng How different is the API from Seaside? Because I would like to use it. I like to think modularly :) Stef On Mon, Sep 11, 2017 at 12:31 PM, Pierce Ng <pierce@samadhiweb.com> wrote:
On Fri, Sep 08, 2017 at 03:15:56PM -0700, Sean P. DeNigris wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
I wrote this but subsequently decided that loading the whole of Seaside into my image just for this functionality is ok and stopped.
http://smalltalkhub.com/#!/~PierceNg/WaterMint-HTML
Pierce
Interestingly the Seaside team has realized this as well https://github.com/SeasideSt/Seaside/issues/976 .... On 9/11/17, Stephane Ducasse <stepharo.self@gmail.com> wrote:
Hi Pierce Ng
How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Stef
On Mon, Sep 11, 2017 at 12:31 PM, Pierce Ng <pierce@samadhiweb.com> wrote:
On Fri, Sep 08, 2017 at 03:15:56PM -0700, Sean P. DeNigris wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
I wrote this but subsequently decided that loading the whole of Seaside into my image just for this functionality is ok and stopped.
http://smalltalkhub.com/#!/~PierceNg/WaterMint-HTML
Pierce
Stephane Ducasse wrote:
Hi Pierce Ng
How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Stef
Maybe porting Silk and let it write to some simulated DOM could be interesting as well... :-) https://lolg.it/herby/silk Herby
On Mon, Sep 11, 2017 at 12:31 PM, Pierce Ng<pierce@samadhiweb.com> wrote:
On Fri, Sep 08, 2017 at 03:15:56PM -0700, Sean P. DeNigris wrote:
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas? I wrote this but subsequently decided that loading the whole of Seaside into my image just for this functionality is ok and stopped.
http://smalltalkhub.com/#!/~PierceNg/WaterMint-HTML
Pierce
On Mon, Sep 11, 2017 at 06:25:55PM +0200, Stephane Ducasse wrote:
Hi Pierce Ng How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Hi Stef, I modeled it after Seaside's API. However, it was really just a start and needs much more work. I created this when investigating writing web apps in Cuis, hence the perceived need for a standalone library. Eventually I ran out of time and decided to stick to full Seaside loaded into Pharo. Pierce
Am 17.09.2017 um 12:12 schrieb Pierce Ng <pierce@samadhiweb.com>:
On Mon, Sep 11, 2017 at 06:25:55PM +0200, Stephane Ducasse wrote: Hi Pierce Ng How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Hi Stef,
I modeled it after Seaside's API. However, it was really just a start and needs much more work. I created this when investigating writing web apps in Cuis, hence the perceived need for a standalone library. Eventually I ran out of time and decided to stick to full Seaside loaded into Pharo.
So you've built something like seaside canvas? I like to emphasize that seaside is not really a standalone HTML model but (as the name says) a canvas which streams markup. What we should explore is the possibility of having a HTML model that can be used for streaming, too, instead just the streaming. There could be a lot of synergies here because web frameworks, pillar, PharoJS are all working close to something like that. my 2 cents, Norbert
Norbert can you explain the difference between "a HTML model that can be used for streaming, too, instead just the streaming." because indeed in Pillar we have another HTML exporter and I would like to reuse :) On Sun, Sep 17, 2017 at 1:29 PM, Norbert Hartl <norbert@hartl.name> wrote:
Am 17.09.2017 um 12:12 schrieb Pierce Ng <pierce@samadhiweb.com>:
On Mon, Sep 11, 2017 at 06:25:55PM +0200, Stephane Ducasse wrote: Hi Pierce Ng How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Hi Stef,
I modeled it after Seaside's API. However, it was really just a start and needs much more work. I created this when investigating writing web apps in Cuis, hence the perceived need for a standalone library. Eventually I ran out of time and decided to stick to full Seaside loaded into Pharo.
So you've built something like seaside canvas? I like to emphasize that seaside is not really a standalone HTML model but (as the name says) a canvas which streams markup. What we should explore is the possibility of having a HTML model that can be used for streaming, too, instead just the streaming. There could be a lot of synergies here because web frameworks, pillar, PharoJS are all working close to something like that.
my 2 cents,
Norbert
Am 17.09.2017 um 13:34 schrieb Stephane Ducasse <stepharo.self@gmail.com>:
Norbert can you explain the difference between "a HTML model that can be used for streaming, too, instead just the streaming." because indeed in Pillar we have another HTML exporter and I would like to reuse :)
The difference is having a streaming API like seaside that uses brushes to write a HTML tag with its attributes and uses blocks to nest tags. This way at the end of the code you don't have a document model but a serialized form of the DOM that depends on the canvas you use. The standalone HTML model would be a DOM on which you can work afterwards. You can navigate, decorate etc. before serializing this the a html string. For the PharoJS this would ease the development in the pharo image. For pillar it would be a theoretical improvement to convert a pillar DOM to a HTML DOM and this to a HTML string representation. But as long as the benefits aren't clear the intermediate step for pillar likes a bit too much. But I have the strong feeling it would be good if there would be more directions you can go. We have a good XML parser that produces a XML DOM. We have pillar with its own DOM that can be converted to HTML. I don't know what SOUP is producing. And we have web frameworks where people have different ways producing for the web. I see potential in supporting multiple ways of reading and writing HTML and making this experience much more powerful. Norbert
On Sun, Sep 17, 2017 at 1:29 PM, Norbert Hartl <norbert@hartl.name> wrote:
Am 17.09.2017 um 12:12 schrieb Pierce Ng <pierce@samadhiweb.com>:
On Mon, Sep 11, 2017 at 06:25:55PM +0200, Stephane Ducasse wrote: Hi Pierce Ng How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Hi Stef,
I modeled it after Seaside's API. However, it was really just a start and needs much more work. I created this when investigating writing web apps in Cuis, hence the perceived need for a standalone library. Eventually I ran out of time and decided to stick to full Seaside loaded into Pharo.
So you've built something like seaside canvas? I like to emphasize that seaside is not really a standalone HTML model but (as the name says) a canvas which streams markup. What we should explore is the possibility of having a HTML model that can be used for streaming, too, instead just the streaming. There could be a lot of synergies here because web frameworks, pillar, PharoJS are all working close to something like that.
my 2 cents,
Norbert
Ok I will try to digest it :) I do not remember how this is done in Pillar but this is a visitor and it could call a streaming generator. Stef On Sun, Sep 17, 2017 at 2:10 PM, Norbert Hartl <norbert@hartl.name> wrote:
Am 17.09.2017 um 13:34 schrieb Stephane Ducasse <stepharo.self@gmail.com>:
Norbert can you explain the difference between "a HTML model that can be used for streaming, too, instead just the streaming." because indeed in Pillar we have another HTML exporter and I would like to reuse :)
The difference is having a streaming API like seaside that uses brushes to write a HTML tag with its attributes and uses blocks to nest tags. This way at the end of the code you don't have a document model but a serialized form of the DOM that depends on the canvas you use. The standalone HTML model would be a DOM on which you can work afterwards. You can navigate, decorate etc. before serializing this the a html string. For the PharoJS this would ease the development in the pharo image. For pillar it would be a theoretical improvement to convert a pillar DOM to a HTML DOM and this to a HTML string representation. But as long as the benefits aren't clear the intermediate step for pillar likes a bit too much. But I have the strong feeling it would be good if there would be more directions you can go. We have a good XML parser that produces a XML DOM. We have pillar with its own DOM that can be converted to HTML. I don't know what SOUP is producing. And we have web frameworks where people have different ways producing for the web. I see potential in supporting multiple ways of reading and writing HTML and making this experience much more powerful.
Norbert
On Sun, Sep 17, 2017 at 1:29 PM, Norbert Hartl <norbert@hartl.name> wrote:
Am 17.09.2017 um 12:12 schrieb Pierce Ng <pierce@samadhiweb.com>:
On Mon, Sep 11, 2017 at 06:25:55PM +0200, Stephane Ducasse wrote: Hi Pierce Ng How different is the API from Seaside? Because I would like to use it. I like to think modularly :)
Hi Stef,
I modeled it after Seaside's API. However, it was really just a start and needs much more work. I created this when investigating writing web apps in Cuis, hence the perceived need for a standalone library. Eventually I ran out of time and decided to stick to full Seaside loaded into Pharo.
So you've built something like seaside canvas? I like to emphasize that seaside is not really a standalone HTML model but (as the name says) a canvas which streams markup. What we should explore is the possibility of having a HTML model that can be used for streaming, too, instead just the streaming. There could be a lot of synergies here because web frameworks, pillar, PharoJS are all working close to something like that.
my 2 cents,
Norbert
NorbertHartl wrote
There could be a lot of synergies here because web frameworks, pillar, PharoJS are all working close to something like that.
I first thought along these lines when using Amber. I was writing Bootstrap support and saw that it was already available for Seaside and thought, darn it feels like unnecessary fragmentation here because these are all common, well-defined concepts! ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Hi Sean--
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
In Pharo on the SqueakJS virtual machine in a web browser[1], I sketch with live DOM objects, and write them out as HTML. This way, the DSL is the actual JavaScript DOM API which is sitting in the web browser anyway, although driven with Smalltalk messages over the JS bridge. I'm also assured that everything I do with the DOM objects is legitimate, and I can handle DOM API errors live in Smalltalk. -C [1] https://caffeine.js.org/pharo -- Craig Latta Black Page Digital Amsterdam :: San Francisco craig@blackpagedigital.com +31 6 2757 7177 (SMS ok) + 1 415 287 3547 (no SMS)
Am 18.09.2017 um 09:03 schrieb Craig Latta <craig@blackpagedigital.com>:
Hi Sean--
I'd like to create HTML via a DSL, like Seaside's canvas builder, but without loading a whole web framework. Any ideas?
In Pharo on the SqueakJS virtual machine in a web browser[1], I sketch with live DOM objects, and write them out as HTML. This way, the DSL is the actual JavaScript DOM API which is sitting in the web browser anyway, although driven with Smalltalk messages over the JS bridge. I'm also assured that everything I do with the DOM objects is legitimate, and I can handle DOM API errors live in Smalltalk.
Sure you can do the same with PharoJS. But there are scenarios where you want to have DOM actions without having a browser. You don't have that problem because you are in the browser Norbert
-C
[1] https://caffeine.js.org/pharo
-- Craig Latta Black Page Digital Amsterdam :: San Francisco craig@blackpagedigital.com +31 6 2757 7177 (SMS ok) + 1 415 287 3547 (no SMS)
Hi Norbert--
In Pharo on the SqueakJS virtual machine in a web browser[1], I sketch with live DOM objects, and write them out as HTML. This way, the DSL is the actual JavaScript DOM API which is sitting in the web browser anyway, although driven with Smalltalk messages over the JS bridge. I'm also assured that everything I do with the DOM objects is legitimate, and I can handle DOM API errors live in Smalltalk.
Sure you can do the same with PharoJS.
Really? I wasn't aware that one can livecode JS objects with PharoJS, only that PharoJS generates JS source which eventually runs in a browser. Can you give an example?
But there are scenarios where you want to have DOM actions without having a browser.
Oh, it wasn't clear to me that this was one of Sean's requirements. thanks, -C -- Craig Latta Black Page Digital Amsterdam :: San Francisco craig@blackpagedigital.com +31 6 2757 7177 (SMS ok) + 1 415 287 3547 (no SMS)
I wrote:
I wasn't aware that one can livecode JS objects with PharoJS, only that PharoJS generates JS source which eventually runs in a browser. Can you give an example?
Well, I evaluated the PharoJS playground expressions, and browsed around the proxy support in the index.js that gets installed in a web browser. I could inject the PjLoadForTest class into the web browser and invoke its JS functions via Smalltalk messages from Pharo. I could send #at:put: to the exposed "window" proxy of the web browser (as long as the arguments were JS literals or proxies), and I could also inspect the "document" proxy, but I got an exception when I tried to invoke document.getElementWithId (via "bridge evalBlock: [document getElementById: 'someID']"). Are arbitrary JS messages supposed to work? There isn't much exception handling support beyond relaying JS error messages. (I guess one way to go would be to use the Chrome Debugging Protocol.) I didn't see how to refer to Smalltalk objects from JS (only JS objects from Smalltalk), so it seems the only Smalltalk blocks one can use as JS callback functions are those which only use objects and functions in JS-land. This might be okay for smoke-testing PharoJS apps, but I think the kind of interactive DOM object sketching I mentioned before would be uncomfortable. -C -- Craig Latta Black Page Digital Amsterdam :: San Francisco craig@blackpagedigital.com +31 6 2757 7177 (SMS ok) + 1 415 287 3547 (no SMS)
Craig Latta wrote
Oh, it wasn't clear to me that this was one of Sean's requirements.
I would say "sorry" but I'm glad I wasn't clear because I learned something cool from your reply ;) ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
participants (9)
-
Craig Latta -
Esteban A. Maringolo -
H. Hirzel -
Herby VojÄÃk -
Norbert Hartl -
Pierce Ng -
Sean P. DeNigris -
Stephane Ducasse -
Sven Van Caekenberghe