[Seaside] Should WAFileLibrary convert files in #deployFiles?

jtuchel at objektfabrik.de jtuchel at objektfabrik.de
Sat Nov 17 05:33:43 UTC 2018


I am not sure whether this topic is of interest to anybody not on VA 
Smalltalk. Let me just explain my problem:

VA Smalltalk is not (yet) natively UTF-8. So when you edit code in the 
Smalltalk Browser, it is encoded in the local codepage. In my case this 
is iso-8859-15. Seaside code and file library contents are served using 
a server adaptor. In VAST, this adaptor converts between UTF-8 for 
everything going to or coming from the Browser and the native code page. 
Not sure if this is the case on Pharo, Squeak or VW as well, but I guess so.

So as long as you server the files from the Smalltalk image, special 
characters in, say javascript files, will be converted to UTF.8 when 
delivered to the Browser.

The trouble starts when you use #deployFiles to have the files served by 
a web server (apache, nginx etc.). WAFileLibrary doesn't convert the 
files before writing them to the filesystem.

I hacked GRVASTPlatform to handle this:

write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString
     "Writes @aStringOrByteArray to a file named @aFilenameString in
      the folder @aFolderString."
     |  fullFilePath streamstr|
     fullFilePath := CfsPath fromParts: (Array with: aFolderString with: aFileNameString).
     stream := fullFilePath newReadWriteStreamBinary: aStringOrByteArray isString not.
      str := aStringOrByteArray isString ifTrue: [aStringOrByteArray 
convertToCodePage: 'UTF-8'] ifFalse: [aStringOrByteArray].    [ stream nextPutAll:str  ]
         ensure: [ stream close ]

The idea is that if teh contents of a method is not binary (like .png or 
.gif etc.), it most likely wants to be in UTF-8 on the file system.

I am not sure, however, if the Grease layer is the right place for this. 
What if other users do not want the files converted to UTF-8. I am also 
not sure if it is okay to convert everything non-binary to UTF-8. Maybe 
there should be a way to tell a Library which codepage to convert to, or 
maybe it is desired to be able to decide for every file individually, or 
maybe even something else.

And, I am not even sure if this is even necessary on other platforms. 
That's why I post here first and ask for comments/discussion.

More on this topic: 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20181117/85bf12b3/attachment.html>

More information about the seaside mailing list