Hands on Pier

43
www.tudorgirba.com hands on

description

Hands on Pier. Tudor Girba, ESUG 2008, Amsterdam

Transcript of Hands on Pier

Page 1: Hands on Pier

www.tudorgirba.com

hands on

Page 2: Hands on Pier

ESUG 2008© Tudor Gîrba

Roadmap

•About Pier

•Pier is not just a wiki, it is a content management system (CMS) based on Magritte and Seaside

•Pier is open source under the MIT license

•Pier from the outside

•Demos

•Pier from the inside

•Architecture

•Extensions

2

Page 3: Hands on Pier

CMS, easy, cool, free

Page 4: Hands on Pier

?Who builds

Page 5: Hands on Pier

Lukas RenggliMichel BanyMatthias BerthDamien CassouTudor GîrbaDale HenrichsKeith HodgesRamon LeonNik LutzPhilippe MarshallDamien PolletNiall Ross

Page 6: Hands on Pier

Lukas RenggliMichel BanyMatthias BerthDamien CassouTudor GîrbaDale HenrichsKeith HodgesRamon LeonNik LutzPhilippe MarshallDamien PolletNiall Ross

Page 7: Hands on Pier

Why do I present it?

Page 8: Hands on Pier

CMS, easy, cool, free

Page 9: Hands on Pier

1from the outside

Page 10: Hands on Pier

= CMS

Page 11: Hands on Pier

?How mature is

Page 18: Hands on Pier

?How extensible is

Page 19: Hands on Pier

Citezen

LightBox

Poll

Post ticker

Randomizer

Search

StehlDichEin

Top Feeder

Twitter

Page 20: Hands on Pier

?How to customizethe look of

Page 21: Hands on Pier
Page 22: Hands on Pier

2from the inside

Page 23: Hands on Pier

Structure

Page 24: Hands on Pier

Structure*

children

Page 25: Hands on Pier

Structure

Page File

*

children

Page 26: Hands on Pier

Structure

Page File

Blog

*

children

Page 27: Hands on Pier

Structure

Page File

Blog

Context*

children

*

Page 28: Hands on Pier

Structure

Page File

Blog

Context Command

Edit Login

*

children

*

Page 29: Hands on Pier

Kernel

Structure

Page File

Blog

Context Command

Edit Login

*

children

*

Page 30: Hands on Pier

Kernel

Structure

Page File

Blog

Context Command

Edit Login

Persistency

*

children

**

Page 31: Hands on Pier

Kernel

Structure

Page File

Blog

Context Command

Edit Login

Persistency

*

children

**

environment

Page 32: Hands on Pier

Kernel

Structure

Page File

Blog

Context Command

Edit Login

Persistency

*

childrenroot

**

environment

View

Browse Changes

Page 33: Hands on Pier

Kernel

Structure

Page File

Blog

Context Command

Edit Login

Persistency

*

childrenroot

**

Component

environment

View

Browse Changes

PostTicker

Page 34: Hands on Pier

is based on

Magritte

describe once, get everywhere

Page 35: Hands on Pier

Any Seaside application can be a widget

Page 36: Hands on Pier

Persistency: Gemstone, image

Page 37: Hands on Pier

CMS, easy, cool, free

Page 38: Hands on Pier

3from the ...

Page 39: Hands on Pier
Page 40: Hands on Pier

'From Squeak3.9.1 of 2 March 2008 [latest update: #7075] on 27 August 2008 at 10:18:30 am'!

ISComponent subclass: #ISPier

instanceVariableNames: 'context'

classVariableNames: ''

poolDictionaries: ''

category: 'ISea-Tests'!

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 07:30'!

renderCommand: aString on: html

self

renderHeading: [ self renderCommandHeadingOn: html ]

contents: [ self renderCommandBodyOn: html ]

animation: aString

on: html! !

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 07:32'!

renderCommandBodyOn: html

context command isView

ifTrue: [ ^ self renderViewOn: html ].

html form: [

ISMagritte new

start: context command description

object: context command

on: html ]! !

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 09:36'!

renderCommandHeadingOn: html

html isea button

beBack; beLeft; beCancel;

callback: [ context := context structure: context structure ];

response: [ :renderer | self renderChildren: 'push_left_to_right' on: renderer ];

with: (context command isView

ifTrue: [ 'Up' ]

ifFalse: [ context command cancelButton value ]).

html heading: context command label.

context command isView ifFalse: [

html isea button

beBlue; beRight;

callback: [ self execute ];

response: [ :renderer |

context command isView

ifTrue: [ self renderChildren: 'push_left_to_right' on: renderer ]

ifFalse: [ self renderCommand: 'push_right_to_left' on: renderer ] ];

with: context command saveButton value ]! !

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 09:41'!

renderViewOn: html

PRCurrentContext use: self during: [

html div style: 'padding: 10px; background: #fff; height: 100%'; with: [

ISRenderer new

start: context structure

in: self on: html ] ]! !

!ISPier methodsFor: 'initialization' stamp: 'tg 8/14/2008 14:54'!

initialize

super initialize.

context := PRContext kernel: PRKernel instances anyOne! !

!ISPier methodsFor: 'rendering' stamp: 'lr 8/27/2008 07:31'!

renderContentOn: html

self renderChildren: nil on: html! !

!ISPier methodsFor: 'rendering-children' stamp: 'lr 8/27/2008 00:23'!

renderChildren: aString on: html

self

renderHeading: [ self renderChildrenHeadingOn: html ]

contents: [ self renderChildrenBodyOn: html ]

animation: aString

on: html! !

!ISPier methodsFor: 'rendering-children' stamp: 'lr 8/27/2008 09:08'!

renderChildrenBodyOn: html

html isea list

list: context enumerator contents;

labels: [ :each | each title ];

callback: [ :value | context := context structure: value ];

response: [ :renderer | self renderChildren: 'push_right_to_left' on: renderer ].

context commands do: [ :each |

html isea action

class: 'tallButton black right';

callback: [ context := context command: each new ];

response: [ :renderer |

context command isQuick

ifTrue: [

self execute.

self renderChildren: 'push_left_to_right' on: renderer ]

ifFalse: [ self renderCommand: 'push_right_to_left' on: renderer ] ];

with: each label ]! !

!ISPier methodsFor: 'rendering-children' stamp: 'lr 8/27/2008 07:32'!

renderChildrenHeadingOn: html

context structure parent notNil ifTrue: [

html isea button

beBack; beLeft; beCancel;

callback: [ context := context structure: context structure parent ];

response: [ :renderer | self renderChildren: 'push_left_to_right' on: renderer ];

with: 'Up' ].

html heading: context structure title.

(PREditCommand isValidIn: self context)

ifTrue: [

html isea button

beRight; beCancel;

callback: [ context := context command: PREditCommand new ];

response: [ :renderer | self renderCommand: 'push_right_to_left' on: renderer ];

with: 'Edit' ]

ifFalse: [

html isea button

beRight; beCancel;

callback: [ context := context command: PULogin new ];

response: [ :renderer | self renderCommand: 'push_right_to_left' on: renderer ];

with: 'Login' ]! !

!ISPier methodsFor: 'accessing' stamp: 'lr 8/27/2008 07:33'!

context

^ context! !

!ISPier methodsFor: 'accessing' stamp: 'lr 8/27/2008 09:18'!

context: aContext

context := aContext! !

!ISPier methodsFor: 'actions' stamp: 'lr 8/27/2008 09:12'!

execute

PRCurrentContext use: self during: [

[ context command execute ]

on: Error

do: [ :err |

Transcript show: err description; cr.

^ context := context structure: context structure ].

context := context command answer ]! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

ISPier class

instanceVariableNames: ''!

!ISPier class methodsFor: 'initialization' stamp: 'lr 8/27/2008 00:12'!

initialize

| application |

application := self registerAsApplication: 'isea/pier'.

application libraries do: [ :each | application removeLibrary: each ].

application preferenceAt: #deploymentMode put: true.

application addLibrary: ISLibrary! !

ISPier initialize!

Page 41: Hands on Pier

'From Squeak3.9.1 of 2 March 2008 [latest update: #7075] on 27 August 2008 at 10:18:30 am'!

ISComponent subclass: #ISPier

instanceVariableNames: 'context'

classVariableNames: ''

poolDictionaries: ''

category: 'ISea-Tests'!

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 07:30'!

renderCommand: aString on: html

self

renderHeading: [ self renderCommandHeadingOn: html ]

contents: [ self renderCommandBodyOn: html ]

animation: aString

on: html! !

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 07:32'!

renderCommandBodyOn: html

context command isView

ifTrue: [ ^ self renderViewOn: html ].

html form: [

ISMagritte new

start: context command description

object: context command

on: html ]! !

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 09:36'!

renderCommandHeadingOn: html

html isea button

beBack; beLeft; beCancel;

callback: [ context := context structure: context structure ];

response: [ :renderer | self renderChildren: 'push_left_to_right' on: renderer ];

with: (context command isView

ifTrue: [ 'Up' ]

ifFalse: [ context command cancelButton value ]).

html heading: context command label.

context command isView ifFalse: [

html isea button

beBlue; beRight;

callback: [ self execute ];

response: [ :renderer |

context command isView

ifTrue: [ self renderChildren: 'push_left_to_right' on: renderer ]

ifFalse: [ self renderCommand: 'push_right_to_left' on: renderer ] ];

with: context command saveButton value ]! !

!ISPier methodsFor: 'rendering-command' stamp: 'lr 8/27/2008 09:41'!

renderViewOn: html

PRCurrentContext use: self during: [

html div style: 'padding: 10px; background: #fff; height: 100%'; with: [

ISRenderer new

start: context structure

in: self on: html ] ]! !

!ISPier methodsFor: 'initialization' stamp: 'tg 8/14/2008 14:54'!

initialize

super initialize.

context := PRContext kernel: PRKernel instances anyOne! !

!ISPier methodsFor: 'rendering' stamp: 'lr 8/27/2008 07:31'!

renderContentOn: html

self renderChildren: nil on: html! !

!ISPier methodsFor: 'rendering-children' stamp: 'lr 8/27/2008 00:23'!

renderChildren: aString on: html

self

renderHeading: [ self renderChildrenHeadingOn: html ]

contents: [ self renderChildrenBodyOn: html ]

animation: aString

on: html! !

!ISPier methodsFor: 'rendering-children' stamp: 'lr 8/27/2008 09:08'!

renderChildrenBodyOn: html

html isea list

list: context enumerator contents;

labels: [ :each | each title ];

callback: [ :value | context := context structure: value ];

response: [ :renderer | self renderChildren: 'push_right_to_left' on: renderer ].

context commands do: [ :each |

html isea action

class: 'tallButton black right';

callback: [ context := context command: each new ];

response: [ :renderer |

context command isQuick

ifTrue: [

self execute.

self renderChildren: 'push_left_to_right' on: renderer ]

ifFalse: [ self renderCommand: 'push_right_to_left' on: renderer ] ];

with: each label ]! !

!ISPier methodsFor: 'rendering-children' stamp: 'lr 8/27/2008 07:32'!

renderChildrenHeadingOn: html

context structure parent notNil ifTrue: [

html isea button

beBack; beLeft; beCancel;

callback: [ context := context structure: context structure parent ];

response: [ :renderer | self renderChildren: 'push_left_to_right' on: renderer ];

with: 'Up' ].

html heading: context structure title.

(PREditCommand isValidIn: self context)

ifTrue: [

html isea button

beRight; beCancel;

callback: [ context := context command: PREditCommand new ];

response: [ :renderer | self renderCommand: 'push_right_to_left' on: renderer ];

with: 'Edit' ]

ifFalse: [

html isea button

beRight; beCancel;

callback: [ context := context command: PULogin new ];

response: [ :renderer | self renderCommand: 'push_right_to_left' on: renderer ];

with: 'Login' ]! !

!ISPier methodsFor: 'accessing' stamp: 'lr 8/27/2008 07:33'!

context

^ context! !

!ISPier methodsFor: 'accessing' stamp: 'lr 8/27/2008 09:18'!

context: aContext

context := aContext! !

!ISPier methodsFor: 'actions' stamp: 'lr 8/27/2008 09:12'!

execute

PRCurrentContext use: self during: [

[ context command execute ]

on: Error

do: [ :err |

Transcript show: err description; cr.

^ context := context structure: context structure ].

context := context command answer ]! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

ISPier class

instanceVariableNames: ''!

!ISPier class methodsFor: 'initialization' stamp: 'lr 8/27/2008 00:12'!

initialize

| application |

application := self registerAsApplication: 'isea/pier'.

application libraries do: [ :each | application removeLibrary: each ].

application preferenceAt: #deploymentMode put: true.

application addLibrary: ISLibrary! !

ISPier initialize!

~100 lines o

f code

Page 42: Hands on Pier

CMS, easy, cool, free

www.lukas-renggli.ch/smalltalk/pier