[Seaside] IAFileTemplate
Kamil Kukura
kamk@volny.cz
Sun, 17 Mar 2002 16:20:00 +0100
This is a multi-part message in MIME format.
--------------070703030300010400040602
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
I'm developing my first application. Because I want layouts to be also
done by people I call 'layoutists' I use IAFileTemplate. However I
needed to change it little bit. It was chrashing in #parseTemplate,
actually in ReadWriteStream>>contents (wanted to use readLimit which is
nil). So I put there # contentsOfEntireFile instead. I also adopted it
to use files specified with relative path.
I am very new smalltalker so this may be very imperfect :)
--
Kamil
--------------070703030300010400040602
Content-Type: text/plain;
name="IAFileTemplate.st"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="IAFileTemplate.st"
'From Squeak3.0 of 4 February 2001 [latest update: #3545] on 17 March 2002 at 4:16:22 pm'!
IATemplate subclass: #IAFileTemplate
instanceVariableNames: 'filePath dirPath fileName loadTime '
classVariableNames: ''
poolDictionaries: ''
category: 'Seaside-Kernel'!
!IAFileTemplate commentStamp: '<historical>' prior: 0!
I maintain a file-based HTML template. I am usually created in the #template method of an IAPage. I reload my file whenever it changes - note that on some systems checking for modification can be quite slow, so I am probably better for development use than for deployment.!
!IAFileTemplate methodsFor: 'as yet unclassified' stamp: 'KamK 3/17/2002 16:08'!
file: aPath
filePath _ aPath.
FileDirectory splitName: aPath to: [ :dir :file |
dirPath _ (FileDirectory default) directoryNamed: dir.
fileName _ file]
! !
!IAFileTemplate methodsFor: 'as yet unclassified' stamp: 'AB 2/4/2002 11:54'!
initialize
super initialize.
loadTime _ 0.! !
!IAFileTemplate methodsFor: 'as yet unclassified' stamp: 'KamK 3/17/2002 16:09'!
isModified
|now|
now _ Time totalSeconds.
now - loadTime > 2 ifTrue: [
(dirPath entryAt: fileName) modificationTime > loadTime
ifTrue: [loadTime _ now. ^ true]].
^ false
! !
!IAFileTemplate methodsFor: 'as yet unclassified' stamp: 'KamK 3/17/2002 09:51'!
parseTemplate
Transcript cr; show: 'loading ', fileName.
^ IAHtmlParser parse: (FileStream fileNamed: filePath) contentsOfEntireFile! !
!IAFileTemplate methodsFor: 'as yet unclassified' stamp: 'AB 2/4/2002 11:50'!
printHtmlTo: context
self isModified ifTrue: [root _ nil].
super printHtmlTo: context! !
--------------070703030300010400040602--