Members persistance in local storage done. Next steps: Repo sincronization, info update and queries.

This commit is contained in:
Offray Luna 2017-06-01 16:18:21 +00:00
parent 45c22a857c
commit 2ce59c6097
2 changed files with 72 additions and 8 deletions

View File

@ -104,6 +104,11 @@ BreaMember >> familyName: anObject [
familyName := anObject familyName := anObject
] ]
{ #category : #helpers }
BreaMember >> fullName [
^ self givenName asLowercase, '-', self familyName asLowercase
]
{ #category : #accessing } { #category : #accessing }
BreaMember >> getGenericProfilePicture [ BreaMember >> getGenericProfilePicture [
"Other considered avatars where: "Other considered avatars where:
@ -393,6 +398,18 @@ BreaMember >> renderTestUserAsHtml [
^ self class new createTestUser html ^ self class new createTestUser html
] ]
{ #category : #'server handling' }
BreaMember >> storeInto: aFileDirectory [
| folder file |
folder := (aFileDirectory asFileReference / self fullName) ensureCreateDirectory.
file := (folder / 'info.ston') ensureCreateFile.
file writeStreamDo: [:stream |
(STON writer on: stream)
newLine: String crlf;
prettyPrint: true;
nextPut: self]
]
{ #category : #accessing } { #category : #accessing }
BreaMember >> tags [ BreaMember >> tags [
^ tags ^ tags

View File

@ -14,12 +14,36 @@ Class {
{ #category : #accessing } { #category : #accessing }
BreaWebsite >> fossilRepo [ BreaWebsite >> fossilRepo [
^ fossilRepo ^ fossilRepo ifNil: [ fossilRepo := FossilRepo new ]
] ]
{ #category : #accessing } { #category : #accessing }
BreaWebsite >> fossilRepo: anObject [ BreaWebsite >> fossilRepo: aFossilRepo [
fossilRepo := anObject fossilRepo := aFossilRepo
]
{ #category : #utility }
BreaWebsite >> local [
^ self fossilRepo local
]
{ #category : #'server handling' }
BreaWebsite >> local: aFilePath [
"I define the local storage of the Fossil repository.
For the moment aFilePath must be an absolute "
| localSite |
aFilePath asFileReference exists
ifFalse: [
localSite := (FileLocator temp / 'breaSite') ensureCreateDirectory.
self fossilRepo local: localSite fullName ]
ifTrue: [ self fossilRepo local: aFilePath ].
]
{ #category : #'server handling' }
BreaWebsite >> local: aFilePath remote: anUrl [
"I define the local and remote storages of the Fossil repository"
self remote: anUrl.
self local: aFilePath
] ]
{ #category : #'input processing' } { #category : #'input processing' }
@ -40,17 +64,24 @@ BreaWebsite >> processNewMember: request [
twitter: (request at: #twitter); twitter: (request at: #twitter);
facebook: (request at: #facebook); facebook: (request at: #facebook);
tags: (request at: #tags). tags: (request at: #tags).
^ member asStonModified self store: member.
^ 'New member stored!'
]
{ #category : #'server handling' }
BreaWebsite >> remote: anUrl [
"I define the remote storage of the Fossil repository"
self remote: anUrl.
] ]
{ #category : #'server handling' } { #category : #'server handling' }
BreaWebsite >> routes [ BreaWebsite >> routes [
"I define how the website behaves accordingly to particular routes." "I define how the website behaves accordingly to particular routes."
self server self server
serveStatic: '/gig/demo' from: '/opt/gig/'; serveStatic: 'demo' from: '/opt/gig/';
GET: '/gig/members/test' -> [ :req | BreaMember new renderTestUserAsHtml ]; GET: 'members/test' -> [ :req | BreaMember new renderTestUserAsHtml ];
GET: '/gig/members/add' -> [ :req | BreaMember new htmlInput ]; GET: 'members/add' -> [ :req | BreaMember new htmlInput ];
POST: '/gig/members/summit' -> [ :req | self processNewMember: req ] POST: 'members/summit' -> [ :req | self processNewMember: req ]
] ]
{ #category : #accessing } { #category : #accessing }
@ -75,3 +106,19 @@ BreaWebsite >> stop [
"I define the routes and start the server" "I define the routes and start the server"
self server class stopAll self server class stopAll
] ]
{ #category : #'server handling' }
BreaWebsite >> storageFor: anObject [
"I define the places where local storage is done for several types of objects"
anObject class = BreaMember
ifTrue: [ ^ self local asFileReference / 'members' ].
^ self
]
{ #category : #'server handling' }
BreaWebsite >> store: anObject [
"I store different kind of objects in the website repository.
For the moment I will only store BreaMembers, but as long as new
objects will emerge, I will specialize other ways of storage."
anObject storeInto: (self storageFor: anObject)
]