'From Squeak3.1alpha [latest update: #''Squeak3.1alpha'' of 5 February 2001 update 3945] on 23 April 2001 at 4:55:59 pm'! "Change Set: swikiPassword Date: 23 April 2001 Author: Bob Arning Add password protection to projects published on a SuperSwiki. There is a new preference #passwordsOnPublish which controls whether you will be prompted for a password when you publish. If this preference is off, your projects will be published without a password, allowing others to publish updated versions. If you attempt to publish a new version of a protected project, it will fail. If this preference is on, you will be prompted for a password with which to protect the project. If the project already exists and the passwords do not match, the publish will fail." Preferences addPreference: #passwordsOnPublish categories: #(publishing) default: false balloonHelp: 'Turn this on if you want to be prompted for a password when publishing a project.'. ! Notification subclass: #ProjectPasswordNotification instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'System-Exceptions Kernel'! !Morph methodsFor: 'submorphs-add/remove' stamp: 'RAA 4/23/2001 16:55'! delete "Remove the receiver as a submorph of its owner and make its new owner be nil." | aWorld | aWorld _ self world ifNil: [World]. "or some proper of getting the World" "Terminate genie recognition focus" "I encountered a case where the hand was nil, so I put in a little protection - raa" aWorld ifNotNil: [ aWorld currentHand ifNotNilDo: [ :h | h disableGenieFocus: self]. ]. owner ifNotNil: [(extension == nil or: [self player == nil]) ifTrue: [owner privateRemoveMorph: self. owner _ nil] ifFalse: ["Player must be notified" owner privateRemoveMorph: self. owner _ nil. self player noteDeletionOf: self fromWorld: aWorld] ].! ! !Project methodsFor: 'file in/out' stamp: 'RAA 4/23/2001 16:48'! storeOnServerInnards "Save to disk as an Export Segment. Then put that file on the server I came from, as a new version. Version is literal piece of file name. Mime encoded and http encoded." | servers resp newName primaryServerDirectory serverVersionPair localDirectory localVersionPair myVersionNumber warning maxNumber suppliedPassword | self assureIntegerVersion. "Find out what version" (servers _ self serverList) ifNil: [ (primaryServerDirectory _ self findAFolderToStoreProjectIn) ifNotNil: [ servers _ Array with: primaryServerDirectory. self storeNewPrimaryURL: primaryServerDirectory realUrl, '/'. ]. ] ifNotNil: [ primaryServerDirectory _ servers first. ]. localDirectory _ self squeakletDirectory. serverVersionPair _ self class mostRecent: self name onServer: primaryServerDirectory. localVersionPair _ self class mostRecent: self name onServer: localDirectory. maxNumber _ myVersionNumber _ self currentVersionNumber. ProgressNotification signal: '2:versionsDetected'. warning _ ''. myVersionNumber < serverVersionPair second ifTrue: [ warning _ warning,'\There are newer version(s) on the server'. maxNumber _ maxNumber max: serverVersionPair second. ]. myVersionNumber < localVersionPair second ifTrue: [ warning _ warning,'\There are newer version(s) in the local directory'. maxNumber _ maxNumber max: localVersionPair second. ]. "8 Nov 2000 - only check on the first attempt to publish" myVersionNumber = 0 ifTrue: [ warning isEmpty ifFalse: [ myVersionNumber = 0 ifTrue: [ warning _ warning,'\THIS PROJECT HAS NEVER BEEN SAVED' ]. warning _ 'WARNING', '\Project: ',self name,warning. resp _ (PopUpMenu labels: 'Store anyway\Cancel' withCRs) startUpWithCaption: (warning, '\Please cancel, rename this project, and see what is there.') withCRs. resp ~= 1 ifTrue: [^ nil] ]. ]. version _ self bumpVersion: maxNumber. "write locally - now zipped automatically" newName _ self versionedFileName. lastSavedAtSeconds _ Time totalSeconds. self exportSegmentFileName: newName directory: localDirectory. ProgressNotification signal: '4:localSaveComplete'. "3 is deep in export logic" primaryServerDirectory ifNotNil: [ suppliedPassword _ ''. Preferences passwordsOnPublish ifTrue: [ suppliedPassword _ FillInTheBlank requestPassword: 'Project password' ]. [ self writeFileNamed: newName fromDirectory: localDirectory toServer: primaryServerDirectory. ] on: ProjectPasswordNotification do: [ :ex | ex resume: (suppliedPassword ifNil: ['']) ]. ]. ProgressNotification signal: '9999 save complete'. "Later, store with same name on secondary servers. Still can be race conditions. All machines will go through the server list in the same order." "2 to: servers size do: [:aServer | aServer putFile: local named: newName]." ! ! !ProjectPasswordNotification methodsFor: 'as yet unclassified' stamp: 'RAA 4/23/2001 16:47'! defaultAction self resume: ''! ! !SuperSwikiServer methodsFor: 'for real' stamp: 'RAA 4/23/2001 16:48'! putFile: fileStream named: fileNameOnServer ^( self sendToSwikiProjectServer: { 'uploadproject: ',fileNameOnServer. 'password: ',ProjectPasswordNotification signal. fileStream contentsOfEntireFile. } ) beginsWith: 'OK' ! ! !SuperSwikiServer methodsFor: 'for real' stamp: 'RAA 4/23/2001 16:49'! updateProjectInfoFor: aProject | data details projectLinks linkString uploader | data _ OrderedCollection new. data add: 'action: updatepage'. data add: 'password: ',ProjectPasswordNotification signal. data add: 'projectimage: ',aProject name,'.gif'. uploader _ Utilities authorNamePerSe. uploader isEmptyOrNil ifTrue: [uploader _ Utilities authorInitialsPerSe]. uploader isEmptyOrNil ifFalse: [ data add: 'submittedBy: ',uploader. ]. projectLinks _ Set new. aProject world allMorphsDo: [ :each | (each isKindOf: ProjectViewMorph) ifTrue: [ projectLinks add: each safeProjectName. ]. ]. details _ aProject world valueOfProperty: #ProjectDetails ifAbsent: [Dictionary new]. details at: 'projectname' ifAbsentPut: [aProject name]. projectLinks isEmpty ifTrue: [ details removeKey: 'projectlinks' ifAbsent: [] ] ifFalse: [ linkString _ String streamContents: [ :strm | projectLinks asSortedCollection do: [ :each | strm nextPutAll: each ] separatedBy: [ strm nextPut: $. ]. ]. details at: 'projectlinks' put: linkString ]. details keysAndValuesDo: [ :k :v | data add: k , ': ' , v ]. ^self sendToSwikiProjectServer: data. ! ! !SuperSwikiServer methodsFor: 'squeaklets' stamp: 'RAA 4/23/2001 16:48'! upLoadProject: projectName members: archiveMembers retry: aBool | answer | archiveMembers do:[:entry| ProgressNotification signal: '4:uploadingFile' extra:'(uploading ', entry fileName,'...)'. answer _ self sendToSwikiProjectServer: { 'uploadproject2: ', entry fileName. 'password: ',ProjectPasswordNotification signal. entry contents. }. answer = 'OK' ifFalse:[ self inform:'Server responded ', answer. ^false]. ]. ProgressNotification signal: '4:uploadingFile' extra:''. ^true! ! SuperSwikiServer removeSelector: #testPost3! SuperSwikiServer removeSelector: #updateBioPythagoras! SuperSwikiServer removeSelector: #updateProject3! SuperSwikiServer removeSelector: #updateSunday1! "Postscript: Leave the line above, and replace the rest of this comment by a useful one. Executable statements should follow this comment, and should be separated by periods, with no exclamation points (!!). Be sure to put any further comments in double-quotes, like this one." !