SystemOrganization addCategory: #'Package-Builder-Model'! SystemOrganization addCategory: #'Package-Builder-View'! !String methodsFor: '*package-builder' stamp: 'lr 11/29/2008 12:42'! addToSource: aSource ^ (PackageOrganizer default packageNamed: self ifAbsent: [ self error: 'Unknown package named ' , self printString ]) addToSource: aSource! ! !WAPackage methodsFor: '*package-builder' stamp: 'lr 11/29/2008 16:44'! addToSource: aSource | package | package := PBPackage new title: self name; name: self name; comment: self description; addToSource: aSource. dependencies do: [ :each | package addDependency: (aSource addPackage: each) ]. ^ package addToSource: aSource! ! WAComponent subclass: #PBBuilderView instanceVariableNames: 'model selected dependent url' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-View'! !PBBuilderView class methodsFor: 'accessing' stamp: 'lr 11/29/2008 17:09'! builders ^ PBBuilder allSubclasses collect: [ :each | each new ]! ! !PBBuilderView class methodsFor: 'initialization' stamp: 'lr 10/25/2008 11:21'! initialize | application | application := self registerAsApplication: 'builder'. application addLibrary: JQDeploymentLibrary. application configuration addParent: WADevelopmentConfiguration instance! ! !PBBuilderView class methodsFor: 'accessing' stamp: 'lr 11/29/2008 17:09'! model ^ PBSource seaside! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 10/18/2008 15:06'! add: aCollection selected addAll: aCollection. self refresh! ! !PBBuilderView methodsFor: 'accessing' stamp: 'lr 10/18/2008 15:08'! dependent ^ dependent! ! !PBBuilderView methodsFor: 'accessing' stamp: 'lr 11/30/2008 12:32'! dependent: aCollection dependent := aCollection asSet! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 11/30/2008 13:36'! download: aBuilder self requestContext respond: (WAResponse document: (aBuilder build: self model selected: self ordered url: self url))! ! !PBBuilderView methodsFor: 'initialization' stamp: 'lr 11/29/2008 17:18'! initialRequest: aRequest | package | super initialRequest: aRequest. aRequest fields at: 'packages' ifPresent: [ :value | (value findTokens: $,) do: [ :name | package := self model packageNamed: name ifAbsent: [ nil ]. package isNil ifFalse: [ self selected add: package ] ]. self refresh ]! ! !PBBuilderView methodsFor: 'initialization' stamp: 'lr 11/30/2008 12:32'! initialize super initialize. self dependent: #(). self selected: #() ! ! !PBBuilderView methodsFor: 'testing' stamp: 'lr 10/4/2008 22:38'! isChecked: aPackage ^ dependent includes: aPackage! ! !PBBuilderView methodsFor: 'testing' stamp: 'lr 10/4/2008 22:56'! isDisabled: aPackage (selected includes: aPackage) ifTrue: [ ^ false ]. (dependent includes: aPackage) ifTrue: [ ^ true ]. ^ false ! ! !PBBuilderView methodsFor: 'accessing' stamp: 'lr 11/29/2008 17:26'! model ^ model ifNil: [ model := self class model ]! ! !PBBuilderView methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:54'! model: aSource model := aSource! ! !PBBuilderView methodsFor: 'accessing-dynamic' stamp: 'lr 11/30/2008 12:43'! ordered "Answer all the packages in the order they should be loaded." | result | result := SortedCollection new: self dependent size. result sortBlock: [ :a :b | b allDependencies includes: a ]. result addAll: self dependent. ^ result asArray! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 11/30/2008 13:31'! refresh dependent := Set new. selected do: [ :package | package addDependenciesTo: dependent ]! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 10/22/2008 21:50'! renderConfigsOn: html html unorderedList: [ self model configurationsDo: [ :label :packages | html listItem: [ html anchor callback: [ self selected: packages ]; with: label ] ] ]! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 11/30/2008 12:36'! renderContentOn: html Transcript show: self ordered; cr; cr. url := html context actionUrl withoutParameters. self renderIntroOn: html. self renderConfigsOn: html. self renderGroupsOn: html. self renderDownloadOn: html! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 10/18/2008 19:05'! renderDownloadOn: html html heading level: 2; with: 'Download'. html unorderedList: [ self class builders do: [ :each | html listItem: [ html anchor title: each comment; callback: [ self download: each ]; with: each title ] ] ]! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 11/29/2008 17:06'! renderGroupsOn: html html table: [ self model groupsDo: [ :group :packages | html tableRow: [ html tableHeading colSpan: 3; with: [ html anchor callback: [ self add: packages ]; with: group ] ]. packages do: [ :package | html tableRow: [ self renderPackage: package on: html ] ] ] ]! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 10/22/2008 21:07'! renderIntroOn: html html paragraph: [ html text: 'You are downloading '; text: self model title; text: ' '; text: self model version; text: '.' ]! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 10/18/2008 15:06'! renderPackage: aPackage on: html html tableData class: 'checkbox'; with: [ html anchor id: aPackage id; callback: [ self toggle: aPackage ]; class: 'checked' if: (self isChecked: aPackage); class: 'disabled' if: (self isDisabled: aPackage) ]. html tableData class: 'title'; with: [ html label for: aPackage id; with: aPackage name ]. html tableData class: 'description'; with: aPackage comment! ! !PBBuilderView methodsFor: 'accessing-dynamic' stamp: 'lr 10/18/2008 15:08'! selected ^ selected! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 10/22/2008 21:51'! selected: aCollection selected := Set withAll: aCollection. self refresh! ! !PBBuilderView methodsFor: 'rendering' stamp: 'lr 10/18/2008 12:37'! style ^ '.checkbox a { width: 10px; height: 10px; display: block; border: 2px black solid; } .checkbox a.checked { background-color: black; } .checkbox a.disabled { border-color: gray; background-color: gray; }'! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 10/18/2008 15:06'! toggle: aPackage (self isChecked: aPackage) ifTrue: [ selected remove: aPackage ifAbsent: [ ] ] ifFalse: [ selected add: aPackage ]. self refresh! ! !PBBuilderView methodsFor: 'updating' stamp: 'lr 10/22/2008 21:16'! updateRoot: aHtmlRoot super updateRoot: aHtmlRoot. aHtmlRoot title: self model title , ' ' , self model version , ' Builder'! ! !PBBuilderView methodsFor: 'updating' stamp: 'lr 11/29/2008 17:19'! updateUrl: aUrl super updateUrl: aUrl. self selected isEmpty ifTrue: [ ^ self ]. aUrl addParameter: 'packages' value: (String streamContents: [ :stream | self selected do: [ :each | stream nextPutAll: each name ] separatedBy: [ stream nextPut: $, ] ])! ! !PBBuilderView methodsFor: 'accessing-dynamic' stamp: 'lr 10/18/2008 19:07'! url self updateUrl: url. ^ url! ! !PackageInfo methodsFor: '*package-builder' stamp: 'lr 11/29/2008 16:42'! addToSource: aSource ^ WAPackage new name: self packageName; addToSource: aSource! ! Object subclass: #PBBuilder instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBBuilder methodsFor: 'building' stamp: 'lr 10/18/2008 19:03'! build: aModel selected: aCollection url: aUrl self subclassResponsibility! ! !PBBuilder methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:34'! comment self subclassResponsibility! ! !PBBuilder methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:34'! title self subclassResponsibility! ! PBBuilder subclass: #PBFileOutBuilder instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBFileOutBuilder methodsFor: 'building' stamp: 'lr 11/29/2008 17:53'! build: aModel selected: aCollection url: anUrl ^ WAMimeDocument on: (String streamContents: [ :stream | aCollection do: [ :each | each comment isEmptyOrNil ifTrue: [ stream nextPut: $"; nextPutAll: each name; nextPut: $"; cr ] ifFalse: [ stream nextPut: $"; nextPutAll: each comment; nextPut: $"; cr ]. (MCStWriter on: stream) writeDefinitions: each version snapshot definitions. stream cr; cr ] ]) mimeType: 'application/smalltalk-fine-in' fileName: aModel title asLowercase , '-' , aModel version , '.st'! ! !PBFileOutBuilder methodsFor: 'accessing' stamp: 'lr 11/29/2008 17:51'! comment ^ 'Creates a compled file-out of all the selected sources.'! ! !PBFileOutBuilder methodsFor: 'accessing' stamp: 'lr 11/29/2008 17:51'! title ^ 'File-Out'! ! PBBuilder subclass: #PBInstallerBuilder instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBInstallerBuilder methodsFor: 'building' stamp: 'lr 11/29/2008 17:28'! build: aModel selected: aCollection url: anUrl ^ WAMimeDocument on: (String streamContents: [ :stream | stream nextPut: $"; nextPutAll: aModel title; nextPut: $ ; nextPutAll: aModel version; nextPut: $"; cr. stream nextPut: $"; nextPutAll: anUrl printString; nextPut: $"; cr. stream nextPut: $!!; cr. stream nextPutAll: '(HTTPSocket httpGet: ''http://installer.pbwiki.com/f/Installer.st'') fileIn.'; cr. stream nextPutAll: '!!'; cr. aCollection do: [ :each | each comment isEmptyOrNil ifFalse: [ stream nextPut: $"; nextPutAll: each comment; nextPut: $"; cr ]. stream nextPutAll: '(Installer repository: '; print: each locationHost; nextPut: $); cr. stream nextPutAll: ' project: '; print: each locationProject; nextPut: $;; cr. stream nextPutAll: ' install: '; print: each name; cr. stream nextPutAll: '!!'; cr ] ]) mimeType: 'application/smalltalk-changeset' fileName: aModel title asLowercase , '-' , aModel version , '.cs'! ! !PBInstallerBuilder methodsFor: 'accessing' stamp: 'lr 11/29/2008 16:51'! comment ^ 'Creates an Installer script that loads the sources from Monticello.'! ! !PBInstallerBuilder methodsFor: 'accessing' stamp: 'lr 11/29/2008 16:51'! title ^ 'Installer Script'! ! PBBuilder subclass: #PBMapBuilder instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBMapBuilder methodsFor: 'building' stamp: 'lr 11/29/2008 17:35'! build: aModel selected: aCollection url: anUrl ^ WAMimeDocument on: (String streamContents: [ :stream | stream nextPut: $"; nextPutAll: aModel title; nextPut: $ ; nextPutAll: aModel version; nextPut: $"; cr. stream nextPut: $"; nextPutAll: anUrl printString; nextPut: $"; cr; cr. stream nextPut: $(; cr. (aCollection collect: [ :each | each location ]) asSet asSortedCollection do: [ :each | stream tab; nextPutAll: 'repository ('; print: each; nextPut: $); cr ]. aCollection do: [ :each | stream tab; nextPutAll: 'dependency ('; print: each packageName; nextPut: $ ; print: each name; nextPut: $ ; print: each uuid; nextPut: $); cr. ]. stream nextPut: $) ]) mimeType: 'application/monticello-map' fileName: aModel title asLowercase , '-' , aModel version , '.mcm'! ! !PBMapBuilder methodsFor: 'accessing' stamp: 'lr 11/29/2008 16:51'! comment ^ 'Creates a Monticello Map that loads the sources from public repositories.'! ! !PBMapBuilder methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:33'! title ^ 'Monticello Map'! ! Object subclass: #PBPackage instanceVariableNames: 'source title comment name uuid location group dependencies postloads' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBPackage methodsFor: 'comparing' stamp: 'lr 10/4/2008 21:00'! = aPackage ^ self class = aPackage class and: [ self name = aPackage name ]! ! !PBPackage methodsFor: 'querying' stamp: 'lr 11/30/2008 13:32'! addDependenciesTo: aCollection (aCollection includes: self) ifFalse: [ self dependencies do: [ :each | each addDependenciesTo: aCollection ]. aCollection add: self. self postloads do: [ :each | each addDependenciesTo: aCollection ] ]. ^ aCollection! ! !PBPackage methodsFor: 'adding' stamp: 'lr 11/30/2008 13:05'! addDependency: aPackage | package | package := self source addPackage: aPackage. (package isNil or: [ dependencies includes: package ]) ifFalse: [ dependencies := dependencies copyWith: package ]. ^ package! ! !PBPackage methodsFor: 'adding' stamp: 'lr 11/30/2008 13:24'! addPostload: aPackage | package | package := self source addPackage: aPackage. (package isNil or: [ postloads includes: package ]) ifFalse: [ postloads := postloads copyWith: package. package addDependency: self ]. ^ package! ! !PBPackage methodsFor: 'adding' stamp: 'lr 11/30/2008 13:08'! addToSource: aSource ^ aSource packageNamed: self name ifAbsent: [ | working repository package | working := MCWorkingCopy allManagers detect: [ :each | self name = each packageName ] ifNone: [ self error: 'Working copy for ' , self name , ' not found.' ]. working modified ifTrue: [ self error: 'Working copy for ' , self name , ' is modified.' ]. repository := working repositoryGroup repositories detect: [ :each | each isKindOf: MCHttpRepository ] ifNone: [ self error: 'HTTP repository for ' , self name , ' not found.' ]. self name: working currentVersionInfo name. self location: repository locationWithTrailingSlash. self uuid: working currentVersionInfo id asString. aSource packages add: (self setSource: aSource) ]! ! !PBPackage methodsFor: 'querying' stamp: 'lr 11/30/2008 13:06'! allDependencies "Answer an ordered collection of dependencies for the receiving package." ^ self addDependenciesTo: OrderedCollection new! ! !PBPackage methodsFor: 'converting' stamp: 'lr 11/29/2008 10:44'! asBuilderPackage ^ self! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 22:06'! comment ^ comment! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 22:06'! comment: aString comment := aString! ! !PBPackage methodsFor: 'accessing-readonly' stamp: 'lr 10/4/2008 21:07'! dependencies "Answer the direct dependencies." ^ dependencies! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 11/29/2008 16:57'! group ^ group! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 11/29/2008 16:57'! group: aString group := aString! ! !PBPackage methodsFor: 'comparing' stamp: 'lr 10/4/2008 21:00'! hash ^ name hash! ! !PBPackage methodsFor: 'querying' stamp: 'lr 10/18/2008 12:44'! id ^ name copyUpToLast: $-! ! !PBPackage methodsFor: 'initialization' stamp: 'lr 11/30/2008 13:24'! initialize dependencies := #(). postloads := #()! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:46'! location ^ location! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 11/29/2008 16:46'! location: aString location := (aString beginsWith: 'http://') ifFalse: [ 'http://' , aString ] ifTrue: [ aString ]! ! !PBPackage methodsFor: 'querying' stamp: 'lr 10/18/2008 18:10'! locationHost ^ (WAUrl absolute: self location) hostname! ! !PBPackage methodsFor: 'querying' stamp: 'lr 10/18/2008 18:11'! locationProject ^ (WAUrl absolute: self location) path first! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:11'! name ^ name! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:11'! name: aString name := aString! ! !PBPackage methodsFor: 'querying' stamp: 'lr 10/18/2008 18:54'! packageName ^ self name copyUpToLast: $-! ! !PBPackage methodsFor: 'accessing-readonly' stamp: 'lr 11/30/2008 13:23'! postloads "Answer the postload packages." ^ postloads! ! !PBPackage methodsFor: 'printing' stamp: 'lr 11/30/2008 12:43'! printOn: aStream super printOn: aStream. aStream nextPut: $(; print: self title; nextPut: $)! ! !PBPackage methodsFor: 'initialization' stamp: 'lr 11/30/2008 13:04'! setSource: aSource source := aSource! ! !PBPackage methodsFor: 'querying' stamp: 'lr 11/30/2008 13:04'! source ^ source! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:45'! title ^ title! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:45'! title: aString title := aString! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/18/2008 18:36'! uuid ^ uuid! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/18/2008 18:36'! uuid: aString uuid := aString! ! !PBPackage methodsFor: 'querying' stamp: 'lr 11/29/2008 17:50'! version | repository | repository := MCHttpRepository location: self location user: '' password: ''. ^ repository versionFromFileNamed: self name , '.mcz'! ! Object subclass: #PBSource instanceVariableNames: 'title version packages groups configs' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBSource class methodsFor: 'accessing' stamp: 'lr 11/30/2008 13:33'! seaside "self seaside" | model | model := self new. model title: 'Seaside'; version: '2.9.0-alpha2'. " packages " model addPackages: WAPackage packages. " groups " model addGroup: 'Core Library' select: [ :each | (each name beginsWith: 'Seaside-') ]. model addGroup: 'Server Adaptors' select: [ :each | (each name includesSubString: 'Adaptors') ]. model addGroup: 'Web 2.0' select: [ :each | (each name beginsWith: 'Javascript') or: [ (each name beginsWith: 'Scriptaculous') or: [ (each name beginsWith: 'JQuery') or: [ (each name beginsWith: 'Comet') or: [ (each name beginsWith: 'RSS') or: [ (each name beginsWith: 'HTML5') ] ] ] ] ] ]. model addGroup: 'Development' select: [ :each | (each name includesSubString: 'Development') ]. model addGroup: 'Examples' select: [ :each | (each name includesSubString: 'Examples') ]. model addGroup: 'Tests' select: [ :each | (each name includesSubString: 'Tests') ]. " special dependencies " (((model packageNamed: 'Seaside-Adaptors-Comanche') addDependency: 'KomHttpServer') addDependency: 'KomServices') addDependency: 'DynamicBindings'. (model packageNamed: 'Seaside-Slime') group: 'Development'; addDependency: 'Refactoring-Core'. " special post load " model packages do: [ :each | (each name includesSubString: '-Squeak') ifTrue: [ (model packageNamed: (each packageName copyReplaceAll: '-Squeak' with: '') ifAbsent: [ model packageNamed: 'Seaside-Platform' ]) addPostload: each packageName. each group: nil ] ]. " configurations " model addConfig: 'Development' reject: [ :each | (each name includesSubString: 'Tests') ]. model addConfig: 'Integration' reject: [ :each | (each name includesSubString: 'Examples') ]. model addConfig: 'Deployment' reject: [ :each | (each name includesSubString: 'Examples') or: [ (each name includesSubString: 'Tests') or: [ (each name includesSubString: 'Slime') or: [ (each name includesSubString: 'Development') ] ] ] ]. ^ model! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 17:25'! addConfig: aString reject: aBlock "Adds a configuration named aString containing those packages for which aBlock evaluates to false." self addConfig: aString select: [ :each | (aBlock value: each) not ]! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 17:20'! addConfig: aString select: aBlock "Adds a configuration named aString containing those packages for which aBlock evaluates to true." configs add: aString -> (self packagesSorted: (self packages select: aBlock))! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 16:59'! addGroup: aString "Adds a group named aString." (groups includes: aString) ifFalse: [ groups add: aString ]! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 16:59'! addGroup: aString reject: aBlock "Adds a group named aString containing those packages for which aBlock evaluates to false." self addGroup: aString reject: [ :each | (aBlock value: each) not ]! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 16:59'! addGroup: aString select: aBlock "Adds a group named aString containing those packages for which aBlock evaluates to true." self addGroup: aString. self packages do: [ :each | (aBlock value: each) ifTrue: [ each group: aString ] ]! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 16:54'! addPackage: aPackage "Add a single package to the receiver. The package can be represented as a String, a PackageInfo, a WAPackage, or as a PBPackage. Answer an existing or newly added package." ^ aPackage addToSource: self! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 16:55'! addPackages: aCollection "Add a collection of packages to the receiver." ^ aCollection do: [ :each | self addPackage: each ]! ! !PBSource methodsFor: 'enumerating' stamp: 'lr 11/29/2008 16:49'! configurationsDo: aBlock aBlock value: 'All Packages' value: self packages. configs do: [ :assoc | aBlock value: assoc key value: assoc value ]. aBlock value: 'No Packages' value: Set new! ! !PBSource methodsFor: 'enumerating' stamp: 'lr 11/29/2008 17:21'! groupsDo: aBlock groups do: [ :name | aBlock value: name value: (self packagesSorted: (self packages select: [ :package | package group = name ])) ]! ! !PBSource methodsFor: 'initialization' stamp: 'lr 11/29/2008 12:31'! initialize packages := Set new. groups := OrderedCollection new. configs := OrderedCollection new! ! !PBSource methodsFor: 'querying' stamp: 'lr 11/30/2008 12:52'! packageNamed: aString ^ self packageNamed: aString ifAbsent: [ nil ]! ! !PBSource methodsFor: 'querying' stamp: 'lr 11/29/2008 12:18'! packageNamed: aString ifAbsent: aBlock ^ self packages detect: [ :each | each name beginsWith: aString ] ifNone: aBlock! ! !PBSource methodsFor: 'querying' stamp: 'lr 10/4/2008 22:19'! packages ^ packages! ! !PBSource methodsFor: 'querying' stamp: 'lr 11/29/2008 17:20'! packagesSorted ^ self packagesSorted: self packages! ! !PBSource methodsFor: 'querying' stamp: 'lr 11/29/2008 17:20'! packagesSorted: aCollection ^ aCollection asArray sort: [ :a :b | a title < b title ]! ! !PBSource methodsFor: 'printing' stamp: 'lr 10/4/2008 21:52'! printOn: aStream super printOn: aStream. aStream nextPutAll: ' ('; print: self title; nextPutAll: ')'! ! !PBSource methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:52'! title ^ title! ! !PBSource methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:52'! title: aString title := aString! ! !PBSource methodsFor: 'accessing' stamp: 'lr 10/4/2008 20:35'! version ^ version! ! !PBSource methodsFor: 'accessing' stamp: 'lr 10/4/2008 20:35'! version: aString version := aString! ! PBBuilderView initialize!