Adding default example.

This commit is contained in:
Offray Luna 2017-09-05 14:58:28 +00:00
parent 7bae9c9980
commit 7799be7865

View File

@ -12,6 +12,42 @@ Class {
#category : #Brea #category : #Brea
} }
{ #category : #utility }
BreaWebsite class >> downloadDemoFiles [
| remoteUrl demoFolder templatesFile |
demoFolder := FileLocator temp asFileReference / 'BreaDemo'.
demoFolder ensureDeleteAll.
demoFolder ensureCreateDirectory.
remoteUrl := 'https://code.getmdl.io/1.3.0/mdl-template-portfolio.zip'.
GrafoscopioUtils
downloadingFrom: remoteUrl
withMessage: 'Downloading templates'
into: FileLocator temp asFileReference.
templatesFile := FileLocator temp asFileReference / (remoteUrl splitOn: '/') last.
ZipArchive new
readFrom: templatesFile;
extractAllTo: demoFolder
]
{ #category : #example }
BreaWebsite class >> example [
"I run an example mockup of a website using Brea.
After runing me, go to http://localhost:8080/demo .
Notice that one part of the template in the website has been replaced by dynamic content
produce by Brea."
self downloadDemoFiles.
self new
local: FileLocator temp asFileReference / 'BreaDemo';
start
]
{ #category : #'server handling' }
BreaWebsite class >> stopAll [
"I stop the server"
self server class stopAll
]
{ #category : #accessing } { #category : #accessing }
BreaWebsite >> fossilRepo [ BreaWebsite >> fossilRepo [
^ fossilRepo ifNil: [ fossilRepo := FossilRepo new ] ^ fossilRepo ifNil: [ fossilRepo := FossilRepo new ]
@ -78,7 +114,7 @@ BreaWebsite >> remote: anUrl [
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: 'demo' from: '/opt/gig/'; serveStatic: 'demo' from: (self local);
GET: 'members/test' -> [ :req | BreaMember new renderTestUserAsHtml ]; GET: 'members/test' -> [ :req | BreaMember new renderTestUserAsHtml ];
GET: 'members/add' -> [ :req | BreaMember new htmlInput ]; GET: 'members/add' -> [ :req | BreaMember new htmlInput ];
POST: 'members/summit' -> [ :req | self processNewMember: req ] POST: 'members/summit' -> [ :req | self processNewMember: req ]
@ -101,12 +137,6 @@ BreaWebsite >> start [
self server start self server start
] ]
{ #category : #'server handling' }
BreaWebsite >> stop [
"I define the routes and start the server"
self server class stopAll
]
{ #category : #'server handling' } { #category : #'server handling' }
BreaWebsite >> storageFor: anObject [ BreaWebsite >> storageFor: anObject [
"I define the places where local storage is done for several types of objects" "I define the places where local storage is done for several types of objects"