Re: Serve static files with WAKom (was: Bespin integration)

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

Re: Serve static files with WAKom (was: Bespin integration)

laurent laffont
Hi,

finally I've managed to serve static files without using an external web server. Indeed I want to have a standalone application that's why I don't want to use an external web server.

Here's how I did, It looks hacky so I'm looking for better code. It was taken from http://www.shaffer-consulting.com/david/Seaside/GettingSoftware/index.html with little modifications to make it works.

Object subclass: #SeaslidesServer
   ....

SeaslidesServer class
instanceVariableNames: 'adaptor'



SeaslidesServer class>>startSeaslides
  | ma seaside |

  "Kill all existing Kom HTTP servers"
  HttpService allInstancesDo: [:each | each stop. each unregister].

  adaptor := (WAKom startOn: 8080).

  ma := ModuleAssembly core.
  ma serverRoot: (FileDirectory default directoryNamed: 'Bespin') fullName.
  ma alias: '/seaslides' to: [ma addPlug: [:request | self processHttpRequest: request]].
  ma alias: '/files' to: [ma addPlug: [:request | self processHttpRequest: request]].
  ma documentRoot: (FileDirectory default directoryNamed: 'Bespin') fullName.
  ma directoryIndex: 'index.html index.htm'.
  ma serveFiles.

  adaptor service plug: ma rootModule.



SeaslidesServer class>>processHttpRequest: aRequest
^ self adaptor process: aRequest


The directory Bespin is at the same level at the Seaside image. So I can access http://localhost:8080/BespinEmbedded.js and all other ressources.

http://localhost:8080/seaslides is my application. http://localhost:8080/files is needed for Seaside libraires.

Cheers,

Laurent Laffont

http://pharocasts.blogspot.com/
http://magaloma.blogspot.com/


On Sat, Sep 11, 2010 at 9:47 AM, Philippe Marschall <[hidden email]> wrote:
2010/9/11 laurent laffont <[hidden email]>:
> Hi,
> I'm trying to create a WAFileLibrary subclass and import Bespin
> Embedded. https://bespin.mozillalabs.com/docs/embedding/index.html
> However, Bespin expects this file hierarchy to work:
> ressources/
>     -- screen_theme/
>            -- theme.less
>            -- images
>                 lines.png
>                 ....
> With WAFileLibrary the path to files is built using the class name.
>
> Is there a way to choose the directory name for a WAFileLibrary ? So I can
> access theme.less like this:
> http://localhost:8080/BespinLibrary/ressources/screen_theme/theme.less
> I know I can serve static filesusing an external Web server but I really
> want to put this in the image. (Or, if possible, serve static files
> via KomHttpServer or another Web server running on another port).
> Laurent Laffont

The easiest is probably to create a file handler named 'resources' and
override #name in your file library to answer 'screen_theme'.

Cheers
Philippe
_______________________________________________
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