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 12:53'! addToSource: aSource | package | package := PBPackage new name: self name; comment: self description; addToSource: aSource. dependencies do: [ :each | package addDependency: (aSource addPackage: each) ]. ^ package 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: #PBInstallerBuilder instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBInstallerBuilder methodsFor: 'building' stamp: 'lr 10/18/2008 19:22'! 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 | 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 10/18/2008 14:45'! comment ^ 'Creates a small scripts that loads the sources from Monticello.'! ! !PBInstallerBuilder methodsFor: 'accessing' stamp: 'lr 10/19/2008 09:00'! title ^ 'Monticello Load Script'! ! PBBuilder subclass: #PBMapBuilder instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBMapBuilder methodsFor: 'building' stamp: 'lr 10/18/2008 19:10'! 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 10/4/2008 21:35'! comment ^ 'Creates a Monticello Map that loads the requested packages from public repositories.'! ! !PBMapBuilder methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:33'! title ^ 'Monticello Map'! ! Object subclass: #PBPackage instanceVariableNames: 'title comment name uuid location dependencies' 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 10/18/2008 14:37'! addDependenciesTo: aCollection (aCollection includes: self) ifFalse: [ self dependencies do: [ :each | each addDependenciesTo: aCollection ]. aCollection addLast: self ]. ^ aCollection! ! !PBPackage methodsFor: 'adding' stamp: 'lr 10/4/2008 21:09'! addDependency: aPackage (aPackage isNil or: [ aPackage = self or: [ dependencies includes: aPackage ] ]) ifFalse: [ dependencies := dependencies copyWith: aPackage ]. ^ aPackage ! ! !PBPackage methodsFor: 'adding' stamp: 'lr 11/29/2008 12:52'! 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 location isEmptyOrNil ifFalse: [ self location: repository locationWithTrailingSlash ]. "self name isEmptyOrNil ifFalse: [ self name: working currentVersionInfo name ]. self uuid isEmptyOrNil ifFalse: [ self uuid: working currentVersionInfo id asString ]." aSource packages add: self ]! ! !PBPackage methodsFor: 'querying' stamp: 'lr 10/18/2008 11:05'! 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: 'querying' stamp: 'lr 10/4/2008 21:07'! dependencies "Answer the direct dependencies." ^ dependencies! ! !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 10/4/2008 21:10'! initialize dependencies := #()! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:46'! location ^ location! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 11/29/2008 12:05'! location: aString location := aString. (location last = $/) ifFalse: [ location := location copyWith: $/ ]. (location beginsWith: 'http://') ifFalse: [ location := 'http://' , location ]! ! !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: 'printing' stamp: 'lr 10/4/2008 21:52'! printOn: aStream super printOn: aStream. aStream nextPutAll: ' ('; print: self title; nextPutAll: ')'! ! !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/4/2008 21:01'! url ^ url! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:01'! url: aString url := 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! ! Object subclass: #PBSource instanceVariableNames: 'title version packages groups configs' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBSource class methodsFor: 'accessing' stamp: 'lr 11/29/2008 12:36'! seaside "self seaside" | model | model := self new. model title: 'Seaside'; version: '2.9.0-alpha2'. model addPackage: 'DynamicBindings'. model addPackage: 'KomServices'. model addPackage: 'KomHttpServer'. model addPackages: WAPackage packages. " initialize: (PDPackageAnalyzer onPackages: WADevelopment packages , (Array with: (PackageInfo named: 'DynamicBindings') with: (PackageInfo named: 'KomHttpServer') with: (PackageInfo named: 'KomServices'))) using: [ :package | ((package name includesSubString: 'Scriptaculous') or: [ (package name includesSubString: 'JQuery') or: [ (package name includesSubString: 'Comet') or: [ (package name includesSubString: 'RSS') or: [ (package name includesSubString: 'HTML5') ] ] ] ]) ifTrue: [ package group: 'Web 2.0' ]. ((package name includesSubString: 'Kom') or: [ (package name includesSubString: 'DynamicBindings') or: [ (package name includesSubString: 'Swazoo') ] ]) ifTrue: [ package group: 'Server' ]. (package name includesSubString: 'Development') ifTrue: [ package group: 'Development' ]. (package name includesSubString: 'Examples') ifTrue: [ package group: 'Examples' ]. (package name includesSubString: 'Tests') ifTrue: [ package group: 'Tests' ]. (package group isNil) ifTrue: [ package group: 'Core' ]. ((package name includesSubString: 'Squeak') and: [ (package name includesSubString: 'Kom') not ]) ifTrue: [ package group: nil ]. (package name includesSubString: 'Swazoo') ifFalse: [ package ] ]. model packages do: [ :package | (package name includesSubString: 'Squeak-') ifTrue: [ other := model findPackage: (package name copyReplaceAll: 'Squeak-' with: ''). other isNil ifFalse: [ package addDependency: other ] ] ]. model addConfiguration: 'Framework' rejecting: [ :each | each name includesSubString: 'Examples-' ]. model addConfiguration: 'Development' rejecting: [ :each | each name includesSubString: 'Tests-' ]. model addConfiguration: 'Deployment' rejecting: [ :each | (each name includesSubString: 'Examples-') or: [ (each name includesSubString: 'Tests-') or: [ each name includesSubString: 'Development-' ] ] ]." ^ model! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 12:32'! addConfig: aString select: aBlock "Adds a configuration named aString containing those packages for which aBlock evaluates to true." configs add: aString -> (self visiblePackages select: aBlock)! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 12:33'! addGroup: aString select: aBlock "Adds a group named aString containing those packages for which aBlock evaluates to true." groups add: aString -> (self visiblePackages select: aBlock)! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 12:12'! addPackage: aPackage ^ aPackage addToSource: self! ! !PBSource methodsFor: 'adding' stamp: 'lr 11/29/2008 10:41'! addPackages: aCollection ^ aCollection do: [ :each | self addPackage: each ]! ! !PBSource methodsFor: 'enumerating' stamp: 'lr 10/22/2008 21:33'! configurationsDo: aBlock aBlock value: 'All Packages' value: self visiblePackages. configurations do: [ :assoc | aBlock value: assoc key value: assoc value ]. aBlock value: 'No Packages' value: Set new! ! !PBSource methodsFor: 'enumerating' stamp: 'lr 10/4/2008 22:03'! groupsAndPackagesDo: aBlock groups do: [ :group | aBlock value: group value: (groupsAndPackages at: group) ]! ! !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/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: '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! ! !PBSource methodsFor: 'querying' stamp: 'lr 10/22/2008 21:26'! visiblePackages ^ groupsAndPackages inject: Set new into: [ :result :items | result addAll: items; yourself ]! ! !PackageInfo methodsFor: '*package-builder' stamp: 'lr 11/29/2008 12:53'! addToSource: aSource ^ WAPackage new name: self name; addToSource: aSource! ! WAComponent subclass: #PBBuilderView instanceVariableNames: 'model selected dependent url' classVariableNames: 'Builders SourceModel' poolDictionaries: '' category: 'Package-Builder-View'! PBBuilderView class instanceVariableNames: 'builderClasses'! PBBuilderView class instanceVariableNames: 'builderClasses'! !PBBuilderView class methodsFor: 'accessing' stamp: 'lr 10/18/2008 12:58'! builders ^ Builders ifNil: [ 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 10/4/2008 21:37'! model ^ SourceModel ifNil: [ SourceModel := PBSource seaside ]! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 10/18/2008 15:06'! add: aCollection selected addAll: aCollection. self refresh! ! !PBBuilderView methodsFor: 'accessing-dynamic' stamp: 'lr 10/18/2008 15:08'! dependent ^ dependent! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 10/19/2008 00:31'! download: aBuilder self requestContext respond: (WAResponse document: (aBuilder build: self model selected: self dependent url: self url))! ! !PBBuilderView methodsFor: 'initialization' stamp: 'lr 10/22/2008 21:47'! initialRequest: aRequest | package | super initialRequest: aRequest. aRequest fields at: 'packages' ifPresent: [ :value | (value findTokens: $,) do: [ :name | package := self model findPackage: name. package isNil ifFalse: [ self selected add: package ] ]. self refresh ]! ! !PBBuilderView methodsFor: 'initialization' stamp: 'lr 10/22/2008 21:51'! initialize super initialize. dependent := OrderedCollection new. 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 10/4/2008 21:58'! model ^ model ifNil: [ self class model ]! ! !PBBuilderView methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:54'! model: aSource model := aSource! ! !PBBuilderView methodsFor: 'actions' stamp: 'lr 10/18/2008 13:08'! refresh dependent := OrderedCollection 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 10/22/2008 21:49'! renderContentOn: html 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 10/18/2008 15:06'! renderGroupsOn: html html table: [ self model groupsAndPackagesDo: [ :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 10/18/2008 18:54'! updateUrl: aUrl super updateUrl: aUrl. self selected isEmpty ifTrue: [ ^ self ]. aUrl addParameter: 'packages' value: (String streamContents: [ :stream | self selected do: [ :each | stream nextPutAll: each packageName ] separatedBy: [ stream nextPut: $, ] ])! ! !PBBuilderView methodsFor: 'accessing-dynamic' stamp: 'lr 10/18/2008 19:07'! url self updateUrl: url. ^ url! ! PBBuilderView initialize!