all: intial code import

This commit is contained in:
2018-05-12 15:25:36 +02:00
parent 1f20ee2574
commit 9f47b858c3
59 changed files with 375 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }

View File

@@ -0,0 +1,17 @@
I represent a contact.
I know about my name and email.
Collaborators:
- Veit Heller <veit@veitheller.de
Public API and Key Messages
- there are accessors for both fullname and email.
- you can create new instances using the newNamed:email: message.
Internal Representation and Key Implementation Points.
Instance Variables
email: a String
fullname: a String

View File

@@ -0,0 +1,6 @@
instance creation
newNamed: aNameString email: anEmailString
^ self new
fullname: aNameString;
email: anEmailString;
yourself

View File

@@ -0,0 +1,3 @@
accessing
email: aString
email := aString

View File

@@ -0,0 +1,3 @@
accessing
email
^ email

View File

@@ -0,0 +1,3 @@
accessing
fullname: aString
fullname := aString trimBoth

View File

@@ -0,0 +1,3 @@
accessing
fullname
^ fullname

View File

@@ -0,0 +1,3 @@
accessing
gravatarUrl
^ 'http://www.gravatar.com/avatar/', (MD5 hashMessage: email trimBoth asLowercase) hex, '.jpg'

View File

@@ -0,0 +1,7 @@
printing
printOn: aStream
aStream
nextPutAll: self fullname;
nextPutAll: ' <';
nextPutAll: self email;
nextPutAll: '>'

View File

@@ -0,0 +1,15 @@
{
"category" : "ContactBook",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "VeitHeller 5/12/2018 14:05",
"instvars" : [
"fullname",
"email" ],
"name" : "Contact",
"pools" : [
],
"super" : "Object",
"type" : "normal" }

View File

@@ -0,0 +1,9 @@
I represent a contact book.
I have contacts.
Collaborators:
- Veit Heller <veit@veitheller.de>
Instance Variables
contacts: a List of Contacts

View File

@@ -0,0 +1,16 @@
instance creation
createDefault
^ self new
addContact: (Contact
newNamed: 'Damien Cassou'
email: 'damien@cassou.me');
addContact: (Contact
newNamed: 'Marcus Denker'
email: 'marcus.denker@inria.fr');
addContact: (Contact
newNamed: 'Tudor Girba'
email: 'tudor@tudorgirba.com');
addContact: (Contact
newNamed: 'Clara Allende'
email: 'clari.allende@gmail.com');
yourself

View File

@@ -0,0 +1,3 @@
accessing
addContact: aContact
contacts add: aContact

View File

@@ -0,0 +1,3 @@
accessing
contacts
^ contacts

View File

@@ -0,0 +1,3 @@
initialization
initialize
contacts := OrderedCollection new.

View File

@@ -0,0 +1,3 @@
accessing
removeContact: aContact
contacts remove: aContact

View File

@@ -0,0 +1,14 @@
{
"category" : "ContactBook",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "VeitHeller 5/12/2018 14:19",
"instvars" : [
"contacts" ],
"name" : "ContactBook",
"pools" : [
],
"super" : "Object",
"type" : "normal" }

View File

@@ -0,0 +1,10 @@
testing
testContactManagement
| book contact |
book := ContactBook new.
contact := Contact newNamed: 'Veit Heller' email: 'veit@veitheller.de'.
book addContact: contact.
self assert: book contacts size equals: 1.
book removeContact: contact.
self assert: book contacts size equals: 0.

View File

@@ -0,0 +1,5 @@
testing
testCreation
| book |
book := ContactBook new.
self assert: book contacts size equals: 0.

View File

@@ -0,0 +1,14 @@
{
"category" : "ContactBook",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "ContactBookTest",
"pools" : [
],
"super" : "TestCase",
"type" : "normal" }

View File

@@ -0,0 +1,6 @@
testing
testInstanceCreation
| contact |
contact := Contact newNamed: 'Marcus Denker' email: 'marcus.denker@inria.fr'.
self assert: contact fullname equals: 'Marcus Denker'.
self assert: contact email equals: 'marcus.denker@inria.fr'.

View File

@@ -0,0 +1,5 @@
testing
testNameTrimmed
| contact |
contact := Contact newNamed: ' Veit Heller ' email: 'veit@veitheller.de'.
self assert: contact fullname equals: 'Veit Heller'.

View File

@@ -0,0 +1,5 @@
testing
testString
| contact |
contact := Contact newNamed: ' Veit Heller ' email: 'veit@veitheller.de'.
self assert: contact asString equals: 'Veit Heller <veit@veitheller.de>'.

View File

@@ -0,0 +1,14 @@
{
"category" : "ContactBook",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "ContactTest",
"pools" : [
],
"super" : "TestCase",
"type" : "normal" }

View File

@@ -0,0 +1,5 @@
operations
editContact: aContact
^ self new
setContact: aContact;
yourself

View File

@@ -0,0 +1,3 @@
accessing
contact
^ contact

View File

@@ -0,0 +1,4 @@
initialize
initialize
super initialize.
contact := Contact new.

View File

@@ -0,0 +1,9 @@
rendering
renderButtonsOn: html
html tbsFormGroup: [
html tbsButtonGroup: [
self
renderSubmitButtonOn: html;
renderCancelButtonOn: html
]
]

View File

@@ -0,0 +1,6 @@
rendering
renderCancelButtonOn: html
html tbsButton
beDanger;
cancelCallback: [ self answer: nil ];
with: 'Cancel'

View File

@@ -0,0 +1,9 @@
rendering
renderContentOn: html
html tbsContainer: [
html heading with: 'Contact Editing'.
html tbsForm with: [
self renderFieldsOn: html.
self renderButtonsOn: html
]
]

View File

@@ -0,0 +1,10 @@
rendering
renderEmailFieldOn: html
html tbsFormGroup: [
html label: 'Email'.
html emailInput
tbsFormControl;
placeholder: 'your@email.eu';
callback: [ :email | self contact email: email address ];
value: (self contact email ifNil: '')
]

View File

@@ -0,0 +1,4 @@
rendering
renderFieldsOn: html
self renderFullnameFieldOn: html.
self renderEmailFieldOn: html

View File

@@ -0,0 +1,10 @@
rendering
renderFullnameFieldOn: html
html tbsFormGroup: [
html label: 'Fullname'.
html textInput
tbsFormControl;
placeholder: 'fullname';
callback: [ :value | self contact fullname: value ];
value: (self contact fullname ifNil: '')
]

View File

@@ -0,0 +1,7 @@
rendering
renderSubmitButtonOn: html
html tbsSubmitButton
beSuccess;
bePrimary;
callback: [ self answer: self contact ];
with: 'Save'

View File

@@ -0,0 +1,3 @@
accessing
setContact: aContact
contact := aContact

View File

@@ -0,0 +1,14 @@
{
"category" : "ContactBook",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"contact" ],
"name" : "WAContact",
"pools" : [
],
"super" : "WAComponent",
"type" : "normal" }

View File

@@ -0,0 +1,14 @@
I represent a contact book web application.
I render a contact book to HTML using Seaside.
Collaborators:
Veit Heller <veit@veitheller.de>
Internal Representation and Key Implementation Points.
Instance Variables
contactBook: a Contactbook
Implementation Points

View File

@@ -0,0 +1,5 @@
initialization
initialize
(WAAdmin register: self asApplicationAt: 'contacts')
addLibrary: JQDeploymentLibrary;
addLibrary: TBSDeploymentLibrary

View File

@@ -0,0 +1,4 @@
rendering
addContact
(self call: WAContact new)
ifNotNil: [ :contact | contactBook addContact: contact ]

View File

@@ -0,0 +1,3 @@
accessing
contacts
^ contactBook contacts

View File

@@ -0,0 +1,3 @@
operations
contactsDo: aBlock
self contacts do: aBlock

View File

@@ -0,0 +1,4 @@
initialization
initialize
super initialize.
contactBook := ContactBook createDefault

View File

@@ -0,0 +1,7 @@
rendering
renderButtonsForContact: aContact on: html
html tbsButtonGroup: [
self
renderEditButtonForContact: aContact on: html;
renderRemoveButtonForContact: aContact on: html
]

View File

@@ -0,0 +1,9 @@
rendering
renderContact: aContact on: html
html tableRow: [
html
tableData: [ self renderPhotoOf: aContact on: html ];
tableData: aContact fullname;
tableData: aContact email;
tableData: [ self renderButtonsForContact: aContact on: html ]
]

View File

@@ -0,0 +1,12 @@
rendering
renderContactsOn: html
html tbsTable: [
html tableHead: [
html
tableHeading: 'Photo';
tableHeading: 'Name';
tableHeading: 'Email';
tableHeading: 'Actions'
].
self contactsDo: [ :contact | self renderContact: contact on: html ]
]

View File

@@ -0,0 +1,11 @@
rendering
renderContentOn: html
html tbsContainer: [
html heading
level: 1;
with: 'My Contact Book'.
html tbsForm: [
self renderContactsOn: html.
self renderGlobalButtonsOn: html
]
]

View File

@@ -0,0 +1,6 @@
updating
renderEditButtonForContact: aContact on: html
html tbsButton
beSuccess;
callback: [ self call: (WAContact editContact: aContact) ];
with: 'Edit'

View File

@@ -0,0 +1,8 @@
rendering
renderGlobalButtonsOn: html
html tbsButtonGroup: [
html tbsButton
beSuccess;
callback: [ self addContact ];
with: 'New contact'
]

View File

@@ -0,0 +1,3 @@
rendering
renderPhotoOf: aContact on: html
html image url: aContact gravatarUrl

View File

@@ -0,0 +1,6 @@
rendering
renderRemoveButtonForContact: aContact on: html
html tbsButton
beDanger;
callback: [ self contactBook removeContact: aContact ];
with: 'Remove'

View File

@@ -0,0 +1,4 @@
updating
updateRoot: anHtmlRoot
super updateRoot: anHtmlRoot.
anHtmlRoot title: 'Contact Book'

View File

@@ -0,0 +1,14 @@
{
"category" : "ContactBook",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "VeitHeller 5/12/2018 14:29",
"instvars" : [
"contactBook" ],
"name" : "WAContactBook",
"pools" : [
],
"super" : "WAComponent",
"type" : "normal" }

View File

@@ -0,0 +1 @@
SystemOrganization addCategory: #ContactBook!

View File

@@ -0,0 +1 @@
(name 'ContactBook')

View File

@@ -0,0 +1,2 @@
{
}