SystemOrganization addCategory: #'Package-Builder-Model'! SystemOrganization addCategory: #'Package-Builder-View'! 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/18/2008 14:44'! title ^ 'Monticello'! ! 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 group 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: '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: '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: 'accessing' stamp: 'lr 10/4/2008 21:01'! group ^ group! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:01'! 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 10/4/2008 21:10'! initialize dependencies := #()! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:46'! location ^ location! ! !PBPackage methodsFor: 'accessing' stamp: 'lr 10/4/2008 21:45'! location: aString location := 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: '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 groupsAndPackages' classVariableNames: '' poolDictionaries: '' category: 'Package-Builder-Model'! !PBSource class methodsFor: 'accessing' stamp: 'lr 10/18/2008 19:56'! seaside | model other | model := self new. model title: 'Seaside'; version: '2.9.0-alpha1'. model 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! ! !PBSource methodsFor: 'adding' stamp: 'lr 10/4/2008 21:49'! addPackage: aPackage (aPackage isNil or: [ packages includes: aPackage ]) ifTrue: [ ^ aPackage ]. aPackage group notNil ifTrue: [ (groupsAndPackages at: aPackage group ifAbsentPut: [ OrderedCollection new ]) addLast: aPackage. (groups includes: aPackage group) ifFalse: [ groups add: aPackage group ] ]. ^ packages add: aPackage! ! !PBSource methodsFor: 'querying' stamp: 'lr 10/18/2008 18:12'! findPackage: aString ^ self packages detect: [ :each | each name beginsWith: aString ] ifNone: [ nil ]! ! !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 10/4/2008 20:55'! initialize packages := Set new. groups := OrderedCollection new. groupsAndPackages := Dictionary new! ! !PBSource methodsFor: 'initialization' stamp: 'lr 10/18/2008 18:44'! initialize: anAnalizer using: aValuable | imported working repository dependency | imported := anAnalizer relation packages collect: [ :package | working := MCWorkingCopy allManagers detect: [ :each | each packageInfo = package info ] ifNone: [ self error: 'Working copy for ' , package packageName , ' not found.' ]. repository := working repositoryGroup repositories detect: [ :each | each isKindOf: MCHttpRepository ] ifNone: [ self error: 'HTTP repository for ' , package packageName , ' not found.' ]. package -> (PBPackage new title: working packageName; name: working currentVersionInfo name; uuid: working currentVersionInfo id asString; location: ((repository locationWithTrailingSlash beginsWith: 'http://') ifTrue: [ repository locationWithTrailingSlash ] ifFalse: [ 'http://' , repository locationWithTrailingSlash ]); yourself) ]. imported do: [ :assoc | assoc key dependentPackages do: [ :dependent | dependency := imported detect: [ :each | each key info = dependent info ] ifNone: [ nil ]. dependency isNil ifFalse: [ assoc value addDependency: dependency value ] ]. self addPackage: (aValuable value: assoc value) ]! ! !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! ! WAComponent subclass: #PBBuilderView instanceVariableNames: 'model selected dependent url' classVariableNames: 'SourceModel Builders' 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/4/2008 22:00'! initialize | application | application := self registerAsApplication: 'builder'. application addLibrary: SULibrary. 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/18/2008 19:03'! download: aBuilder self requestContext returnResponse: (WAResponse document: (aBuilder build: self model selected: self dependent url: self url))! ! !PBBuilderView methodsFor: 'initialization' stamp: 'lr 10/18/2008 18:52'! 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/18/2008 14:35'! initialize super initialize. selected := Set new. dependent := OrderedCollection new! ! !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/18/2008 19:07'! renderContentOn: html url := html context actionUrl withoutParameters. self renderIntroOn: 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/4/2008 21:55'! 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: '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/18/2008 18:50'! 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!