Serving pictures from the image

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

Serving pictures from the image

Jens Pall
Hi

How would I go about serving a picture from within the image (not using
static content) and making it a link?

And then (not Seaside related), how can I read the picture into the
image in the first place?

Probably some basic stuff, but I'm new at this :)

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

Re: Serving pictures from the image

Michel Bany

On 24 Jan 2007, at 19:53 , Jens Pall wrote:

> Hi
>
> How would I go about serving a picture from within the image (not  
> using static content) and making it a link?
>
> And then (not Seaside related), how can I read the picture into the  
> image in the first place?
>
> Probably some basic stuff, but I'm new at this :)

Hi Jens,

Please have a look to the SeasideFAQ package in squeaksource/Seaside
There are some info on how to serve files.
HTH

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

Re: Serving pictures from the image

Göran Krampe
Hi!

> On 24 Jan 2007, at 19:53 , Jens Pall wrote:
>> Hi
>>
>> How would I go about serving a picture from within the image (not
>> using static content) and making it a link?
>>
>> And then (not Seaside related), how can I read the picture into the
>> image in the first place?
>>
>> Probably some basic stuff, but I'm new at this :)
>
> Hi Jens,
>
> Please have a look to the SeasideFAQ package in squeaksource/Seaside
> There are some info on how to serve files.
> HTH

I haven't had time to look at the absolutely latest Seaside versions (so
perhaps it has been changed) but what about WACachedDocument (check class
comment)? IIRC I described it pretty good.

regards, Göran

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

Re: Serving pictures from the image

Alan Capewell-3
Göran Krampe <goran <at> krampe.se> writes:

>
> Hi!
>
> > On 24 Jan 2007, at 19:53 , Jens Pall wrote:
> >> Hi
> >>
> >> How would I go about serving a picture from within the image (not
> >> using static content) and making it a link?
> >>
> >> And then (not Seaside related), how can I read the picture into the
> >> image in the first place?
> >>
> >> Probably some basic stuff, but I'm new at this :)
> >
> > Hi Jens,
> >
> > Please have a look to the SeasideFAQ package in squeaksource/Seaside
> > There are some info on how to serve files.
> > HTH
>
> I haven't had time to look at the absolutely latest Seaside versions (so
> perhaps it has been changed) but what about WACachedDocument (check class
> comment)? IIRC I described it pretty good.
>
> regards, Göran
>
Hi Jens

I'm currently writing a blog based tutorial at http://objeccentric.wordpress.com
  and session session (to be posted on Friday) covers loading with a multipart
form, resizing it, and displaying the image inside a scriptaculous div.
Hopefully it will be of use to you.

Regards Alan




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

Re: Serving pictures from the image

Jens Pall
In reply to this post by Michel Bany
Michel Bany wrote:

>
> On 24 Jan 2007, at 19:53 , Jens Pall wrote:
>
>> Hi
>>
>> How would I go about serving a picture from within the image (not
>> using static content) and making it a link?
>>
>> And then (not Seaside related), how can I read the picture into the
>> image in the first place?
>>
>> Probably some basic stuff, but I'm new at this :)
>
> Hi Jens,
>
> Please have a look to the SeasideFAQ package in squeaksource/Seaside
> There are some info on how to serve files.
> HTH
>
> Michel.

This is a really helpful tiny FAQ - I wish I had known about it earlier.
Thanks Michel.

Shouldn't this FAQ be advertised on the seaside web page (along with
instructions on how to view it)? It clears out many of the problems
beginners run into when starting Seaside and try to follow the tutorials
found online. Nearly all the tutorials use the old WAHtmlRenderer which
is not used by default in a new Seaside installation - this FAQ explains
the difference and reasons behind the switch.

Regarding the files, I am looking for a way to serve binary data from
directly within the image itself, not using files on the external
filesystem. I'm planning on using Magma as the persistent repository for
everything and don't want to rely on stuff out on the filesystem, hence
I need a way to load and serve my images completely from within squeak.

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

Re: Serving pictures from the image

Jens Pall
In reply to this post by Göran Krampe
Göran Krampe wrote:

> Hi!
>
>> On 24 Jan 2007, at 19:53 , Jens Pall wrote:
>>> Hi
>>>
>>> How would I go about serving a picture from within the image (not
>>> using static content) and making it a link?
>>>
>>> And then (not Seaside related), how can I read the picture into the
>>> image in the first place?
>>>
>>> Probably some basic stuff, but I'm new at this :)
>> Hi Jens,
>>
>> Please have a look to the SeasideFAQ package in squeaksource/Seaside
>> There are some info on how to serve files.
>> HTH
>
> I haven't had time to look at the absolutely latest Seaside versions (so
> perhaps it has been changed) but what about WACachedDocument (check class
> comment)? IIRC I described it pretty good.
>
> regards, Göran
>

Maybe I can use something similar to what you do in preloadCache? I'll
have to examine it more closely.

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

RE: Serving pictures from the image

Bany, Michel
In reply to this post by Jens Pall
> This is a really helpful tiny FAQ - I wish I had known about
> it earlier.
> Thanks Michel.
>
> Shouldn't this FAQ be advertised on the seaside web page
> (along with instructions on how to view it)? It clears out
> many of the problems beginners run into when starting Seaside
> and try to follow the tutorials found online. Nearly all the
> tutorials use the old WAHtmlRenderer which is not used by
> default in a new Seaside installation - this FAQ explains the
> difference and reasons behind the switch.

You may also commit your knowledge to this package :)

> Regarding the files, I am looking for a way to serve binary
> data from directly within the image itself, not using files
> on the external filesystem. I'm planning on using Magma as
> the persistent repository for everything and don't want to
> rely on stuff out on the filesystem, hence I need a way to
> load and serve my images completely from within squeak.

You may want something like this

        (html anchor)
                document: aByteArray
                mimeType: 'application/msword'
                fileName: 'report.doc'

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

Re: Re: Serving pictures from the image

Jens Pall
In reply to this post by Alan Capewell-3
Alan Capewell wrote:

> Göran Krampe <goran <at> krampe.se> writes:
>
>> Hi!
>>
>>> On 24 Jan 2007, at 19:53 , Jens Pall wrote:
>>>> Hi
>>>>
>>>> How would I go about serving a picture from within the image (not
>>>> using static content) and making it a link?
>>>>
>>>> And then (not Seaside related), how can I read the picture into the
>>>> image in the first place?
>>>>
>>>> Probably some basic stuff, but I'm new at this :)
>>> Hi Jens,
>>>
>>> Please have a look to the SeasideFAQ package in squeaksource/Seaside
>>> There are some info on how to serve files.
>>> HTH
>> I haven't had time to look at the absolutely latest Seaside versions (so
>> perhaps it has been changed) but what about WACachedDocument (check class
>> comment)? IIRC I described it pretty good.
>>
>> regards, Göran
>>
> Hi Jens
>
> I'm currently writing a blog based tutorial at http://objeccentric.wordpress.com
>   and session session (to be posted on Friday) covers loading with a multipart
> form, resizing it, and displaying the image inside a scriptaculous div.
> Hopefully it will be of use to you.
>

I'm sure it will, Alan. I'm trying to learn as much as I can about
Seaside and I think tutorials are the best way to do that.

Looking forward to it.

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

Re: Serving pictures from the image

Jens Pall
In reply to this post by Bany, Michel
Bany, Michel wrote:

>
>> Regarding the files, I am looking for a way to serve binary
>> data from directly within the image itself, not using files
>> on the external filesystem. I'm planning on using Magma as
>> the persistent repository for everything and don't want to
>> rely on stuff out on the filesystem, hence I need a way to
>> load and serve my images completely from within squeak.
>
> You may want something like this
>
> (html anchor)
> document: aByteArray
> mimeType: 'application/msword'
> fileName: 'report.doc'
>

Yes, this looks promising.

But how do I load the document from disk into aByteArray? I think I can
do this using a web form, but I want to be able to load it directly from
the filesystem (used in a batch load later).

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

Re: Serving pictures from the image

Brian Brown-2

On Jan 25, 2007, at 11:04 AM, Jens Pall wrote:

> Bany, Michel wrote:
>>> Regarding the files, I am looking for a way to serve binary data  
>>> from directly within the image itself, not using files on the  
>>> external filesystem. I'm planning on using Magma as the  
>>> persistent repository for everything and don't want to rely on  
>>> stuff out on the filesystem, hence I need a way to load and serve  
>>> my images completely from within squeak.
>> You may want something like this
>> (html anchor)
>> document: aByteArray mimeType: 'application/msword'
>> fileName: 'report.doc'
>
> Yes, this looks promising.
>
> But how do I load the document from disk into aByteArray? I think I  
> can do this using a web form, but I want to be able to load it  
> directly from the filesystem (used in a batch load later).

Here was a method I used quite some time ago for a Seaside app that  
had to have the pictures in the image ;) Basically, I loaded the jpeg  
files from the hard drive and put them into a class side Dictionary.  
I had a singleton JPEGImages class through which I would reference  
the dictionary. When I wanted to transfer things between images, I  
would save the dictionary as a reference stream and could load that  
in with a different message on my JPEGImages class.

Here is the import method from the JPEGimages class:

importFromPath: pathString
        | jpegFiles thisDir |
        thisDir _ FileDirectory on: pathString.
        jpegFiles _ thisDir fileNamesMatching: '*jpg'.
        jpegFiles do: [:ea  ||fileStream |
                fileStream _ thisDir readOnlyFileNamed: ea.
                DictionaryOfImages at: ea put: ((JPEGImage fromStream:fileStream)  
name: ea)]


And the JPEGImage class:

Object subclass: #JPEGImage
        instanceVariableNames: 'height width contents name'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'AbleLink-Utility-Images'!

asMIMEDocument
        ^ MIMEDocument contentType: 'image/jpeg' content: self contents! !

contents
        ^ contents! !

contents: aFileStream
        | tform |
        contents _ aFileStream contentsOfEntireFile.
        tform _ ImageReadWriter formFromStream: aFileStream binary.
        width _ tform width.
        height _ tform height.
        ^ self.! !

height
        ^ height! !

name
        ^ name! !

name: aString
        name _ aString! !

width
        ^ width! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

JPEGImage class
        instanceVariableNames: ''!

!JPEGImage class methodsFor: 'creation' stamp: 'rbb 7/7/2003 13:59'!
fromStream: aFileStream
        ^ (self new) contents: aFileStream! !


>
> JP
> _______________________________________________
> 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: Serving pictures from the image

Jens Pall
Brian Brown wrote:

>
> On Jan 25, 2007, at 11:04 AM, Jens Pall wrote:
>
>> Bany, Michel wrote:
>>>> Regarding the files, I am looking for a way to serve binary data
>>>> from directly within the image itself, not using files on the
>>>> external filesystem. I'm planning on using Magma as the persistent
>>>> repository for everything and don't want to rely on stuff out on the
>>>> filesystem, hence I need a way to load and serve my images
>>>> completely from within squeak.
>>> You may want something like this
>>>     (html anchor)
>>>         document: aByteArray         mimeType:
>>> 'application/msword'         fileName: 'report.doc'
>>
>> Yes, this looks promising.
>>
>> But how do I load the document from disk into aByteArray? I think I
>> can do this using a web form, but I want to be able to load it
>> directly from the filesystem (used in a batch load later).
>
> Here was a method I used quite some time ago for a Seaside app that had
> to have the pictures in the image ;) Basically, I loaded the jpeg files
> from the hard drive and put them into a class side Dictionary. I had a
> singleton JPEGImages class through which I would reference the
> dictionary. When I wanted to transfer things between images, I would
> save the dictionary as a reference stream and could load that in with a
> different message on my JPEGImages class.
>
> Here is the import method from the JPEGimages class:
>
> importFromPath: pathString
>     | jpegFiles thisDir |
>     thisDir _ FileDirectory on: pathString.
>     jpegFiles _ thisDir fileNamesMatching: '*jpg'.
>     jpegFiles do: [:ea  ||fileStream |
>         fileStream _ thisDir readOnlyFileNamed: ea.
>         DictionaryOfImages at: ea put: ((JPEGImage
> fromStream:fileStream) name: ea)]
>

<snip>

>
> JPEGImage class
>     instanceVariableNames: ''!
>
> !JPEGImage class methodsFor: 'creation' stamp: 'rbb 7/7/2003 13:59'!
> fromStream: aFileStream
>     ^ (self new) contents: aFileStream! !
>

Wow! This is great!

Thanks Brian

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

Re: Serving pictures from the image

saza solutions
In reply to this post by Jens Pall
I did the following.
 
Firstly I initialized the gifs. I could do this because my gifs are fixed, I don´t need dynamic files:
 
SomeClass>>intializeGifs
 |gifs imagekey newGif|
 gifs:= (FileDirectory on: 'C:\SES\product\squeak 3.8\working\img') fileNamesMatching: '*.gif'.
 gifs do: [:gif |
  imagekey:= ('DES-',(gif copyUpTo: $.)) asSymbol.
  newGif:= (FileStream readOnlyFileNamed: 'C:\SES\product\squeak 3.8\working\img\' , gif) reset; binary; contents.
  ScriptingSystem formDictionary at: imagekey put: (newGif)].
   
where 'C:\SES\product\squeak 3.8\working\img' is a path in the server context.
 
Then to use them:
 
MyWAHtmlRenderer>>getImage: anImageName withPath: aPath
 |imagekey newForm|
 imagekey:= ('DES-',(anImageName copyUpTo: $.)) asSymbol.
 (ScriptingSystem formAtKey: imagekey) isNil
  ifTrue: [newForm:= (FileStream readOnlyFileNamed: ((FileDirectory default pathName),'\', aPath,'\',anImageName)) reset; binary; contents.
    ScriptingSystem formDictionary at: imagekey put: (newForm).
    ].
 
 ^self imageWithForm: (ScriptingSystem formAtKey: imagekey).

 
and also override...
 
MyWAHtmlRenderer>>imageWithForm: aForm
 self image: (self context urlForDocument: aForm)
 
and defined:
 
ByteArray>>asMIMEDocument 
 ^MIMEDocument contentType: 'image/gif' content: self

Felipe

Jens Pall <[hidden email]> escribió:
Bany, Michel wrote:

>
>> Regarding the files, I am looking for a way to serve binary
>> data from directly within the image itself, not using files
>> on the external filesystem. I'm planning on using Magma as
>> the persistent repository for everything and don't want to
>> rely on stuff out on the filesystem, hence I need a way to
>> load and serve my images completely from within squeak.
>
> You may want something like this
>
> (html anchor)
> document: aByteArray
> mimeType: 'application/msword'
> fileName: 'report.doc'
>

Yes, this looks promising.

But how do I load the document from disk into aByteArray? I think I can
do this using a web form, but I want to be able to load it directly from
the filesystem (used in a batch load later).

JP
_______________________________________________
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