WAVersionUploader


Seaside-Components-Tools-Squeak

Comment:



Hierarchy:

ProtoObject
Object
WAPresenter
WAComponent
WAVersionUploader

Summary:

instance variables:

file url

methods:

instance class
as yet unclassified as yet unclassified

Detail:

instance variables:

file
url

instance methods:

as yet unclassified
loadFile

	| reader version |
	reader _ MCVersionReader readerClassForFileNamed: file fileName.
	reader ifNil: [self inform: file fileName, ' is not in a known format'].
	version _ reader versionFromStream: file contents asByteArray readStream.
	version load.
loadURL

	| stream version |
	stream _ url asUrl retrieveContents content asByteArray readStream .
	version _ (MCVersionReader readerClassForFileNamed: url) versionFromStream: stream.
	version load.
newVersion: aWorkingCopy

	| version s |
	version _ [aWorkingCopy newVersion]
				on: MCVersionNameAndMessageRequest 
				do: [:n | n resume: (Array with: n suggestedName with: '')].
	s _ RWBinaryOrTextStream on: String new.
	version fileOutOn: s.
	self session respond:
		[:u |
		u addToPath: version fileName.
		WAResponse redirectTo: u asString].
	self session returnResponse: (WAResponse new
									contentType: 'application/octet-stream';
									nextPutAll: s contents;
									yourself)
renderContentOn: html

	html bold: 'Loaded versions:'.
	html list: MCWorkingCopy allManagers do:
		[:ea |
		html anchorWithAction: [self newVersion: ea] text: 'Save'.
		html space.
		html text: ea description].
	
	html attributeAt: 'enctype' put: 'multipart/form-data'.
	html form: [
		html bold: 'Load version from file: '; break.
		html fileUploadWithCallback: [:f | file _ f].
		html space.
		html submitButtonWithAction: [self loadFile] text: 'Load'.
	].
	html form: [
		html bold: 'Load version from URL: '; break.
		html attributes size: 60.
		html textInputWithValue: 'http://' callback: [:u | url _ u].
		html space.
		html submitButtonWithAction: [self loadURL] text: 'Load'.
	].
	html anchorWithAction: [self saveImage] text: 'Save Image'. 
saveImage

	Smalltalk snapshot: true andQuit: false

class methods:

as yet unclassified
canBeRoot

	^ true

^top


- made by Dandelion -