WAComponent and HTML Emails?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

WAComponent and HTML Emails?

Ramon Leon-5
Has anyone ever rendered a WAComponent to a string for use in an HTML
formatted email?

Ramon Leon
http://onsmalltalk.com

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: WAComponent and HTML Emails?

Boris Popov, DeepCove Labs (SNN)
I've rendered components to feed our PDF generator, sounds like it would
be similar to just get the HTML back. You'll need to add a bit of
context yourself, as this is ripped straight out of the system, see last
line there in #renderPDF that would be the string you need.

Component>>asPDF: contact
  ^WACurrentSession
    use: (self createPDFSession: contact)
    during: [self renderPDF].

Component>>createPDFSession: contact
 ^(PDFSession new)
        setParent: MyAppRoot application;
        attachContact: contact;
        yourself.

Component>>renderPDF
 | handler response |
 handler := WARenderHandler root: (PDFRoot for: self).
 response := WAResponse new.
 handler
        context:
                ((WARenderingContext new)
                        session: self session;
                        actionUrl: WAUrl new;
                        yourself).
 handler processRendering: response.
 ^response contents contents.

Hope this helps,

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

> -----Original Message-----
> From: [hidden email] [mailto:seaside-
> [hidden email]] On Behalf Of Ramon Leon
> Sent: Thursday, August 09, 2007 11:43 AM
> To: 'Seaside - general discussion'
> Subject: [Seaside] WAComponent and HTML Emails?
>
> Has anyone ever rendered a WAComponent to a string for use in an HTML
> formatted email?
>
> Ramon Leon
> http://onsmalltalk.com
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: WAComponent and HTML Emails?

Sebastian Sastre-2
Hi Boris,

        can you tell which pdf generation tool are you using? I'm not sure
about understanding right the contact part in "Component>>asPDF: contact"

        cheers,

Sebastian Sastre

> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Boris Popov
> Enviado el: Jueves, 09 de Agosto de 2007 15:49
> Para: Seaside - general discussion
> Asunto: RE: [Seaside] WAComponent and HTML Emails?
>
> I've rendered components to feed our PDF generator, sounds
> like it would be similar to just get the HTML back. You'll
> need to add a bit of context yourself, as this is ripped
> straight out of the system, see last line there in #renderPDF
> that would be the string you need.
>
> Component>>asPDF: contact
>   ^WACurrentSession
>     use: (self createPDFSession: contact)
>     during: [self renderPDF].
>
> Component>>createPDFSession: contact
>  ^(PDFSession new)
> setParent: MyAppRoot application;
> attachContact: contact;
> yourself.
>
> Component>>renderPDF
>  | handler response |
>  handler := WARenderHandler root: (PDFRoot for: self).
>  response := WAResponse new.
>  handler
> context:
> ((WARenderingContext new)
> session: self session;
> actionUrl: WAUrl new;
> yourself).
>  handler processRendering: response.
>  ^response contents contents.
>
> Hope this helps,
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the
> message header. Unless otherwise indicated, it contains
> information that is private and confidential. If you have
> received it in error, please notify the sender and delete the
> entire message including any attachments.
>
> Thank you.
>
> > -----Original Message-----
> > From: [hidden email] [mailto:seaside-
> > [hidden email]] On Behalf Of Ramon Leon
> > Sent: Thursday, August 09, 2007 11:43 AM
> > To: 'Seaside - general discussion'
> > Subject: [Seaside] WAComponent and HTML Emails?
> >
> > Has anyone ever rendered a WAComponent to a string for use
> in an HTML
> > formatted email?
> >
> > Ramon Leon
> > http://onsmalltalk.com
> >
> > _______________________________________________
> > Seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAComponent and HTML Emails?

Boris Popov, DeepCove Labs (SNN)
In reply to this post by Ramon Leon-5
Re: [Seaside] WAComponent and HTML Emails?

1. Google for PDFReactor, I really enjoy the degree to which the documents can be customized and its rendering engine with support for SVG creates great results.
2. Ignore it, our application is built around sessions owned by contacts, so this just simulates full context for components to render on a stream that is later fed to a PDF generator with matching styles.

Cheers!

-Boris
(Sent from a BlackBerry)

----- Original Message -----
From: [hidden email] <[hidden email]>
To: 'Seaside - general discussion' <[hidden email]>
Sent: Fri Aug 10 08:47:14 2007
Subject: RE: [Seaside] WAComponent and HTML Emails?

Hi Boris,

        can you tell which pdf generation tool are you using? I'm not sure
about understanding right the contact part in "Component>>asPDF: contact"

        cheers,

Sebastian Sastre

> -----Mensaje original-----
> De: [hidden email]
> [[hidden email]] En nombre
> de Boris Popov
> Enviado el: Jueves, 09 de Agosto de 2007 15:49
> Para: Seaside - general discussion
> Asunto: RE: [Seaside] WAComponent and HTML Emails?
>
> I've rendered components to feed our PDF generator, sounds
> like it would be similar to just get the HTML back. You'll
> need to add a bit of context yourself, as this is ripped
> straight out of the system, see last line there in #renderPDF
> that would be the string you need.
>
> Component>>asPDF: contact
>   ^WACurrentSession
>     use: (self createPDFSession: contact)
>     during: [self renderPDF].
>
> Component>>createPDFSession: contact
>  ^(PDFSession new)
>       setParent: MyAppRoot application;
>       attachContact: contact;
>       yourself.
>
> Component>>renderPDF
>  | handler response |
>  handler := WARenderHandler root: (PDFRoot for: self).
>  response := WAResponse new.
>  handler
>       context:
>               ((WARenderingContext new)
>                       session: self session;
>                       actionUrl: WAUrl new;
>                       yourself).
>  handler processRendering: response.
>  ^response contents contents.
>
> Hope this helps,
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the
> message header. Unless otherwise indicated, it contains
> information that is private and confidential. If you have
> received it in error, please notify the sender and delete the
> entire message including any attachments.
>
> Thank you.
>
> > -----Original Message-----
> > From: [hidden email] [[hidden email]
> > [hidden email]] On Behalf Of Ramon Leon
> > Sent: Thursday, August 09, 2007 11:43 AM
> > To: 'Seaside - general discussion'
> > Subject: [Seaside] WAComponent and HTML Emails?
> >
> > Has anyone ever rendered a WAComponent to a string for use
> in an HTML
> > formatted email?
> >
> > Ramon Leon
> > http://onsmalltalk.com
> >
> > _______________________________________________
> > Seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: WAComponent and HTML Emails?

Ramon Leon-5
In reply to this post by Boris Popov, DeepCove Labs (SNN)
> I've rendered components to feed our PDF generator, sounds
> like it would be similar to just get the HTML back. You'll
> need to add a bit of context yourself, as this is ripped
> straight out of the system, see last line there in #renderPDF
> that would be the string you need.
>
>
> Hope this helps,
>
> -Boris

Yup, looks good (only works in 2.8), though I think this should be something
that's easy to get to.  What about something like this added to WAComponent
to allow printString and asString on any WAComponent?

WARenderHandler>>context: aContext
        context := aContext

WAComponent>>printOn: aStream
    "setup a fake rendering context and response so I can render myself to a
stream for asString and printString"
    | response handler |
    handler := WARenderHandler root: self.
    response := WAResponse new.
    "had to create set accessor for context"
    handler context: (WARenderingContext new session: WACurrentSession
value;
                 actionUrl: WAUrl new;
                 yourself).
    handler processRendering: response.
    aStream nextPutAll: response contents contents

Lukas, Phillip, any objection to me committing this?  It would become really
easy to get the rendered html for any component, so you could do things like
this...

SomePage>>renderContentOn: html
    html anchor
        callback:[self emailPage: self printString];
        text: 'email me this page'.

SomePage>>emailMe: aPageHtml
    SeasidePlatformSupport
        deliverMailFrom: '[hidden email]'
        to: #('[hidden email]' )
        text: (String streamContents: [:stream |
            stream nextPutAll: 'Subject: The Page You Requested';
                cr; nextPutAll: 'Content-type:text/html';
                cr; nextPutAll: aPageHtml])

The real reason I want it, is to do something like this...

[self someThingThatBlowsUp]
on:Error do:[:error |
    self emailPage: (WAWalkback exception: error) displayString]

So I can get Seaside's nice walk back page emailed to me for unexpected
errors that happen in production.  

Ramon Leon
http://onsmalltalk.com

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: WAComponent and HTML Emails?

Sebastian Sastre-2
>...
> The real reason I want it, is to do something like this...
>
> [self someThingThatBlowsUp]
> on:Error do:[:error |
>     self emailPage: (WAWalkback exception: error) displayString]
>
> So I can get Seaside's nice walk back page emailed to me for
> unexpected
> errors that happen in production.  
>
> Ramon Leon
> http://onsmalltalk.com
>

Hey! I think we really need to have this. Will allow to react sonner and
with more accuracy (friendly with our agendas).

Cheers,
Sebastian

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAComponent and HTML Emails?

Philippe Marschall
In reply to this post by Ramon Leon-5
2007/8/10, Ramon Leon <[hidden email]>:

> > I've rendered components to feed our PDF generator, sounds
> > like it would be similar to just get the HTML back. You'll
> > need to add a bit of context yourself, as this is ripped
> > straight out of the system, see last line there in #renderPDF
> > that would be the string you need.
> >
> >
> > Hope this helps,
> >
> > -Boris
>
> Yup, looks good (only works in 2.8), though I think this should be something
> that's easy to get to.  What about something like this added to WAComponent
> to allow printString and asString on any WAComponent?
>
> WARenderHandler>>context: aContext
>         context := aContext
>
> WAComponent>>printOn: aStream
>     "setup a fake rendering context and response so I can render myself to a
> stream for asString and printString"
>     | response handler |
>     handler := WARenderHandler root: self.
>     response := WAResponse new.
>     "had to create set accessor for context"
>     handler context: (WARenderingContext new session: WACurrentSession
> value;
>                  actionUrl: WAUrl new;
>                  yourself).
>     handler processRendering: response.
>     aStream nextPutAll: response contents contents
>
> Lukas, Phillip, any objection to me committing this?  It would become really
> easy to get the rendered html for any component, so you could do things like
> this...

We have this functionality already in several places:
Comet: one time
RSRSS: 4 times
Seaside Tests: 2 times

In most of these cases it it's more general and allows you to render
any kind of renderable object, in most cases a render block. So I'd
prefer something like one or two convenience methods in WARenderCanvas
that can used to render a full html page or the body content only.

Cheers
Philippe

> SomePage>>renderContentOn: html
>     html anchor
>         callback:[self emailPage: self printString];
>         text: 'email me this page'.
>
> SomePage>>emailMe: aPageHtml
>     SeasidePlatformSupport
>         deliverMailFrom: '[hidden email]'
>         to: #('[hidden email]' )
>         text: (String streamContents: [:stream |
>             stream nextPutAll: 'Subject: The Page You Requested';
>                 cr; nextPutAll: 'Content-type:text/html';
>                 cr; nextPutAll: aPageHtml])
>
> The real reason I want it, is to do something like this...
>
> [self someThingThatBlowsUp]
> on:Error do:[:error |
>     self emailPage: (WAWalkback exception: error) displayString]
>
> So I can get Seaside's nice walk back page emailed to me for unexpected
> errors that happen in production.
>
> Ramon Leon
> http://onsmalltalk.com
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAComponent and HTML Emails?

Philippe Marschall
In reply to this post by Ramon Leon-5
2007/8/10, Ramon Leon <[hidden email]>:

> > I've rendered components to feed our PDF generator, sounds
> > like it would be similar to just get the HTML back. You'll
> > need to add a bit of context yourself, as this is ripped
> > straight out of the system, see last line there in #renderPDF
> > that would be the string you need.
> >
> >
> > Hope this helps,
> >
> > -Boris
>
> Yup, looks good (only works in 2.8), though I think this should be something
> that's easy to get to.  What about something like this added to WAComponent
> to allow printString and asString on any WAComponent?
>
> WARenderHandler>>context: aContext
>         context := aContext
>
> WAComponent>>printOn: aStream
>     "setup a fake rendering context and response so I can render myself to a
> stream for asString and printString"
>     | response handler |
>     handler := WARenderHandler root: self.
>     response := WAResponse new.
>     "had to create set accessor for context"
>     handler context: (WARenderingContext new session: WACurrentSession
> value;
>                  actionUrl: WAUrl new;
>                  yourself).
>     handler processRendering: response.
>     aStream nextPutAll: response contents contents
>
> Lukas, Phillip, any objection to me committing this?  It would become really
> easy to get the rendered html for any component, so you could do things like
> this...

Can you have a look at Seaside2.8a1-pmm.434. It introduces the
somewhat unfortunatetly named WAHtmlBuilder (I'm open for better
suggestions). This already helped to reduce duplication in tests and
could further reduce duplaction in Coment and RSRSS2.

htmlString would look somehting like this:

htmlString
    ^WAHtmlCanvas builder
        fullDocument: true;
        rootBlock: [ :root | self updateRoot: root ];
        render: self

> SomePage>>renderContentOn: html
>     html anchor
>         callback:[self emailPage: self printString];
>         text: 'email me this page'.
>
> SomePage>>emailMe: aPageHtml
>     SeasidePlatformSupport
>         deliverMailFrom: '[hidden email]'
>         to: #('[hidden email]' )
>         text: (String streamContents: [:stream |
>             stream nextPutAll: 'Subject: The Page You Requested';
>                 cr; nextPutAll: 'Content-type:text/html';
>                 cr; nextPutAll: aPageHtml])
>
> The real reason I want it, is to do something like this...
>
> [self someThingThatBlowsUp]
> on:Error do:[:error |
>     self emailPage: (WAWalkback exception: error) displayString]
>
> So I can get Seaside's nice walk back page emailed to me for unexpected
> errors that happen in production.

Wouldn't you want something more customed that includes the full stack
and not html?

Cheers
Philippe

> Ramon Leon
> http://onsmalltalk.com
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: WAComponent and HTML Emails?

Ramon Leon-5

> Can you have a look at Seaside2.8a1-pmm.434. It introduces
> the somewhat unfortunately named WAHtmlBuilder (I'm open for
> better suggestions). This already helped to reduce
> duplication in tests and could further reduce duplication in
> Comet and RSRSS2.

Looks great, glad to see it was immediately useful.

> htmlString would look something like this:
>
> htmlString
>     ^WAHtmlCanvas builder
>         fullDocument: true;
>         rootBlock: [ :root | self updateRoot: root ];
>         render: self

Any reason you wouldn't want that method in WAComponent?

> Wouldn't you want something more customized that includes the
> full stack and not html?
>
> Cheers
> Philippe

Sure, there's lots of things I'd want, but there's the matter of how much
time I have available, tossing in the existing walkback page into an html
email seemed the simplest thing that could possibly work.  What do you use?

Ramon Leon
http://onsmalltalk.com

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAComponent and HTML Emails?

Philippe Marschall
2007/8/13, Ramon Leon <[hidden email]>:

>
> > Can you have a look at Seaside2.8a1-pmm.434. It introduces
> > the somewhat unfortunately named WAHtmlBuilder (I'm open for
> > better suggestions). This already helped to reduce
> > duplication in tests and could further reduce duplication in
> > Comet and RSRSS2.
>
> Looks great, glad to see it was immediately useful.
>
> > htmlString would look something like this:
> >
> > htmlString
> >     ^WAHtmlCanvas builder
> >         fullDocument: true;
> >         rootBlock: [ :root | self updateRoot: root ];
> >         render: self
>
> Any reason you wouldn't want that method in WAComponent?

One step at a time ;)

> > Wouldn't you want something more customized that includes the
> > full stack and not html?
> >
> > Cheers
> > Philippe
>
> Sure, there's lots of things I'd want, but there's the matter of how much
> time I have available, tossing in the existing walkback page into an html
> email seemed the simplest thing that could possibly work.  What do you use?

Debugger >> #mailOutBugReport

Cheers
Philippe
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: WAComponent and HTML Emails?

Ramon Leon-5
> One step at a time ;)

:)

> Debugger >> #mailOutBugReport
>
> Cheers
> Philippe

Damn, that's exactly what I needed, thanks.

Ramon Leon
http://onsmalltalk.com

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside