From 17d32b32ba14109fc85a687df5354ac0d345c342 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 1 Jun 2017 00:38:13 +0000 Subject: [PATCH] Basic adding of information tested. --- repository/Brea/BreaMember.class.st | 29 +++++++++++++++++----------- repository/Brea/BreaWebsite.class.st | 29 +++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/repository/Brea/BreaMember.class.st b/repository/Brea/BreaMember.class.st index 636ce26..5dcd379 100644 --- a/repository/Brea/BreaMember.class.st +++ b/repository/Brea/BreaMember.class.st @@ -18,6 +18,13 @@ Class { #category : #Brea } +{ #category : #converting } +BreaMember >> asStonModified [ + "asSton is generated a core dumped now. This renaming is trying to solve that. Maybe + in the offical release it will be solved" + ^ STON toStringPretty: self +] + { #category : #accessing } BreaMember >> country [ ^ country @@ -191,51 +198,51 @@ BreaMember >> htmlInput [ Fill out the form. The fields preceded by [*] are obligatory.

-
+
- + Letters and spaces only
- + Letters and spaces only

- +
- + Letters and spaces only

- + Letters and spaces only

- +

- +
- +

- +

diff --git a/repository/Brea/BreaWebsite.class.st b/repository/Brea/BreaWebsite.class.st index 97f4ac0..6dfdd19 100644 --- a/repository/Brea/BreaWebsite.class.st +++ b/repository/Brea/BreaWebsite.class.st @@ -22,18 +22,37 @@ BreaWebsite >> fossilRepo: anObject [ fossilRepo := anObject ] +{ #category : #'input processing' } +BreaWebsite >> processNewMember: request [ + | member badRequest | + badRequest := [ ^ ZnResponse badRequest: request ]. + (request hasEntity + and: [ request contentType matches: ZnMimeType applicationFormUrlEncoded ]) + ifFalse: [ badRequest ]. + member := BreaMember new + givenName: (request at: #givenName); + familyName: (request at: #familyName); + email: (request at: #email); + country: (request at: #country); + twitter: (request at: #twitter); + facebook: (request at: #facebook); + tags: (request at: #tags). + ^ member asStonModified +] + { #category : #'server handling' } BreaWebsite >> routes [ - "Maybe the first part should be in a separate method." + "I define how the website behaves accordingly to particular routes." self server serveStatic: '/gig/demo' from: '/opt/gig/'; GET: '/gig/members/test' -> [ :req | BreaMember new renderTestUserAsHtml ]; - GET: '/gig/members/add' -> [ :req | BreaMember new htmlInput ] + GET: '/gig/members/add' -> [ :req | BreaMember new htmlInput ]; + POST: '/gig/members/summit' -> [ :req | self processNewMember: req ] ] { #category : #accessing } BreaWebsite >> server [ - ^ server ifNil: [ server := Teapot configure: { #port ->8080 } ] + ^ server ifNil: [ server := Teapot configure: { #port ->8080 . #debugMode -> true } ] ] { #category : #accessing } @@ -43,8 +62,8 @@ BreaWebsite >> server: anObject [ { #category : #'server handling' } BreaWebsite >> start [ - "I define the routes and start the server" - self routes. + "I define the config and start the server" + self routes. self server start ]