How to combine Pharo Desktop and Seaside?

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

How to combine Pharo Desktop and Seaside?

Torsten Bergmann
Hi,

If you want to write your collection to a static HTML page you can

    |aCollection|
    aCollection := #('Smalltalk' 'Object').
       
    FileSystem workingDirectory / 'test.html' writeStreamDo: [:stream |
                stream nextPutAll: '<html><head></head><body><ol>'.
                aCollection do: [:each | stream
                                                                nextPutAll: '<li>';
                                                                nextPutAll: each asString ].
                stream nextPutAll: '</ol></body><html>'].

and then serve it from an external webserver (like Apache or Nginx).
But this is static html file generation.


I'm sure you want something more dynamic. So you can serve the contents right from the
image using one of the Smalltalk webframeworks like Seaside or Aida. Here is a short
Seaside HOWTO for this:


Prepare an image with Seaside
=============================
- download Pharo 2.0 from www.pharo.org
- start it, then select "Tools" -> "ConfigurationBrowser" from the world menu to
  open a list of additional loadable packages
- search for "Seaside3" and click on "Install", this will install the seaside web framework
  into your image
- When loading is finished just open a workspace ("Workspace" from world menu) and evaluate
           
                   ZnZincServerAdaptor startOn: 8080
   
  This will start a local webserver right from your Pharo image on the given port.  

  - check with a web browser (Firefox, Chrome, IE, ...) that Seaside is running by
    opening http://localhost:8080  There you can browse first Seaside examples.

As an alternative to the above steps you can also download a premade Seaside distribution
from http://seaside.st

Implement your own webapp
=========================
- open the Nautlius System browser ("SystemBrowser" from the world menu)
- implement an own Seaside component class

          WAComponent subclass: #MyHome
                 instanceVariableNames: ''
                 classVariableNames: ''
                 poolDictionaries: ''
                 category: 'KillerApp-Web-UI'

- now register this class for Seaside by evaluating the following expression in a workspace

         WAAdmin register: MyHome asApplicationAt: 'killerapp'
                 
  This registers your component as an own custom seaside application under /killerapp.  

- so if you point your browser now to http://localhost:8080/killerapp you will see an empty
  page - but it means you application is there but has not yet some content

- now implement an instance side method called #renderContentOn: on the MyHome class

         renderContentOn: html
                        "Render a collection as html list"
       
                        |coll|
                        coll := #('Seaside' 'is' 'really' 'cool').
                        html orderedList list: coll.
                       
- refresh your browser on http://localhost:8080/killerapp you will now see the contents of
  the collection
 
How to continue
===============
Read books, try to implement something and if in doubt just ask on the mailinglist. There is also
a seaside mailinglist http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

Learn about Pharo by getting on of these books:
 http://pharobyexample.org/
 http://rmod.lille.inria.fr/pbe2/ 

learn about Seaside
  http://book.seaside.st/book                         
 
learn about Smalltalk in general with these free books:
  http://stephane.ducasse.free.fr/FreeBooks.html 
 
 

Reply | Threaded
Open this post in threaded view
|

Re: How to combine Pharo Desktop and Seaside?

Stéphane Ducasse
this is a cool two pages getting started.
We should really put it on the Collabactive book.

On Nov 22, 2013, at 12:08 PM, Torsten Bergmann <[hidden email]> wrote:

> Hi,
>
> If you want to write your collection to a static HTML page you can
>
>    |aCollection|
>    aCollection := #('Smalltalk' 'Object').
>
>    FileSystem workingDirectory / 'test.html' writeStreamDo: [:stream |
> stream nextPutAll: '<html><head></head><body><ol>'.
> aCollection do: [:each | stream
> nextPutAll: '<li>';
> nextPutAll: each asString ].
> stream nextPutAll: '</ol></body><html>'].
>
> and then serve it from an external webserver (like Apache or Nginx).
> But this is static html file generation.
>
>
> I'm sure you want something more dynamic. So you can serve the contents right from the
> image using one of the Smalltalk webframeworks like Seaside or Aida. Here is a short
> Seaside HOWTO for this:
>
>
> Prepare an image with Seaside
> =============================
> - download Pharo 2.0 from www.pharo.org
> - start it, then select "Tools" -> "ConfigurationBrowser" from the world menu to
>  open a list of additional loadable packages
> - search for "Seaside3" and click on "Install", this will install the seaside web framework
>  into your image
> - When loading is finished just open a workspace ("Workspace" from world menu) and evaluate
>
>   ZnZincServerAdaptor startOn: 8080
>
>  This will start a local webserver right from your Pharo image on the given port.  
>
>  - check with a web browser (Firefox, Chrome, IE, ...) that Seaside is running by
>    opening http://localhost:8080  There you can browse first Seaside examples.
>
> As an alternative to the above steps you can also download a premade Seaside distribution
> from http://seaside.st
>
> Implement your own webapp
> =========================
> - open the Nautlius System browser ("SystemBrowser" from the world menu)
> - implement an own Seaside component class
>
>          WAComponent subclass: #MyHome
>         instanceVariableNames: ''
>         classVariableNames: ''
>         poolDictionaries: ''
>         category: 'KillerApp-Web-UI'
>
> - now register this class for Seaside by evaluating the following expression in a workspace
>
>         WAAdmin register: MyHome asApplicationAt: 'killerapp'
>
>  This registers your component as an own custom seaside application under /killerapp.  
>
> - so if you point your browser now to http://localhost:8080/killerapp you will see an empty
>  page - but it means you application is there but has not yet some content
>
> - now implement an instance side method called #renderContentOn: on the MyHome class
>
>         renderContentOn: html
> "Render a collection as html list"
>
> |coll|
> coll := #('Seaside' 'is' 'really' 'cool').
> html orderedList list: coll.
>
> - refresh your browser on http://localhost:8080/killerapp you will now see the contents of
>  the collection
>
> How to continue
> ===============
> Read books, try to implement something and if in doubt just ask on the mailinglist. There is also
> a seaside mailinglist http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> Learn about Pharo by getting on of these books:
> http://pharobyexample.org/
> http://rmod.lille.inria.fr/pbe2/ 
>
> learn about Seaside
>  http://book.seaside.st/book                         
>
> learn about Smalltalk in general with these free books:
>  http://stephane.ducasse.free.fr/FreeBooks.html 
>
>
>