Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
2875964efc | |||
7b86b2cfeb | |||
af81f92399 | |||
b500a65c00 | |||
83ea8d4310 | |||
2d811e9f38 | |||
a8d12ec46f | |||
c609595272 | |||
81298aefba | |||
72e0c775e5 | |||
f3a1927615 | |||
a96dd95359 | |||
8833341eee | |||
bbda57b908 | |||
f0dfea31b5 | |||
ef3218a343 | |||
f29ea2d014 | |||
b0498bfcc5 | |||
5b04df81b7 | |||
9f28bccc1e | |||
6055fd04f4 |
@ -16,42 +16,27 @@ BaselineOfBrea >> baseline: spec [
|
||||
for: #common
|
||||
do: [
|
||||
"Dependencies"
|
||||
self grafoscopioUtils: spec.
|
||||
self miniDocs: spec.
|
||||
spec
|
||||
baseline: 'NeoJSON' with: [ spec repository: 'github://svenvc/NeoJSON/repository' ];
|
||||
baseline: 'Mustache' with: [ spec repository: 'github://noha/mustache/repository' ];
|
||||
baseline: 'TaskIt' with: [ spec repository: 'github://noha/taskit:add-all-future' ].
|
||||
baseline: 'TaskIt' with: [ spec repository: 'github://pharo-contributions/taskit:v1.0' ]
|
||||
"[ spec repository: 'github://noha/taskit:add-all-future' ]"
|
||||
"Disabling Noha's Fork to make Brea installable.".
|
||||
|
||||
"Packages"
|
||||
spec package: 'Brea' with: [ spec requires: #('NeoJSON' 'Mustache' 'TaskIt' 'Grafoscopio-Utils') ].
|
||||
spec package: 'Brea' with: [ spec requires: #('MiniDocs' 'TaskIt') ].
|
||||
]
|
||||
]
|
||||
|
||||
{ #category : #baselines }
|
||||
BaselineOfBrea >> grafoscopioUtils: spec [
|
||||
"I load the configuration of this package using a external Gitea repository."
|
||||
"While more Git independient providers are implemented in Monticello, I will use Iceberg
|
||||
to download the repository and load it from a local directory"
|
||||
|
||||
| location localRepo |
|
||||
"Dependencies"
|
||||
|
||||
"Local and remote repo definition"
|
||||
location := FileLocator localDirectory / 'iceberg' / 'Offray' / 'GrafoscopioUtils'.
|
||||
location exists ifFalse: [
|
||||
(IceRepositoryCreator new
|
||||
location: location;
|
||||
remote: (IceGitRemote url: 'https://code.tupale.co/Offray/GrafoscopioUtils.git');
|
||||
createRepository)
|
||||
register
|
||||
].
|
||||
"Package loading"
|
||||
localRepo := 'gitlocal://', location fullName.
|
||||
Metacello new
|
||||
repository: localRepo;
|
||||
baseline: 'GrafoscopioUtils';
|
||||
BaselineOfBrea >> miniDocs: spec [
|
||||
| repo |
|
||||
repo := ExoRepo new
|
||||
repository: 'https://code.tupale.co/Offray/MiniDocs'.
|
||||
repo
|
||||
onConflict: [ :ex | ex useLoaded ];
|
||||
onUpgrade: [ :ex | ex useLoaded ];
|
||||
onDowngrade: [ :ex | ex useLoaded ];
|
||||
onWarningLog;
|
||||
load.
|
||||
spec baseline: 'GrafoscopioUtils' with: [ spec repository: localRepo ].
|
||||
spec package: 'Grafoscopio-Utils' with: [ spec repository: localRepo ].
|
||||
|
||||
spec baseline: 'MiniDocs' with: [ spec repository: 'gitlocal://', repo local fullName ]
|
||||
]
|
||||
|
@ -2,16 +2,16 @@
|
||||
A BreaQueryTest is a test class for testing the behavior of BreaQuery
|
||||
"
|
||||
Class {
|
||||
#name : #BreaQueryTest,
|
||||
#name : #BreaOperatorTest,
|
||||
#superclass : #TestCase,
|
||||
#category : #'Brea-Tests'
|
||||
}
|
||||
|
||||
{ #category : #tests }
|
||||
BreaQueryTest >> testSTONSerialization [
|
||||
BreaOperatorTest >> testSTONSerialization [
|
||||
|
||||
| original store deserialized |
|
||||
original := BreaQuery new
|
||||
original := BreaOperator new
|
||||
name: 'plus';
|
||||
inputs: {'a' -> 3. 'b' -> 4} asDictionary;
|
||||
codeBlock: [ :x :y | x + y ].
|
@ -113,6 +113,7 @@ BreaPageTest >> setUp [
|
||||
super setUp.
|
||||
self createMarkdownFile.
|
||||
self createHTMLTemplateFile.
|
||||
self createJSONFile
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
|
@ -1,51 +0,0 @@
|
||||
"
|
||||
I model an Airtable (https://airtable.com/) database (or Base as they call it).
|
||||
"
|
||||
Class {
|
||||
#name : #Airtable,
|
||||
#superclass : #Object,
|
||||
#instVars : [
|
||||
'id',
|
||||
'apiKey'
|
||||
],
|
||||
#category : #Brea
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
Airtable >> apiKey [
|
||||
^ apiKey
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Airtable >> apiKey: aString [
|
||||
apiKey := aString
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Airtable >> id [
|
||||
^ id
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Airtable >> id: aString [
|
||||
id := aString
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
Airtable >> rawRecords [
|
||||
|
||||
(self id isNil or: [ self apiKey isNil ]) ifTrue: [ ^ self ].
|
||||
^ ZnClient new
|
||||
url: (self id);
|
||||
headerAt: 'Authorization' put: 'Bearer ', (self apiKey);
|
||||
get.
|
||||
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
Airtable >> records [
|
||||
|
||||
^ ((NeoJSONReader fromString: (self rawRecords)) at: 'records')
|
||||
select: [ :each | (each at: 'fields') isNotEmpty ]
|
||||
|
||||
]
|
104
repository/Brea/BreaApp.class.st
Normal file
104
repository/Brea/BreaApp.class.st
Normal file
@ -0,0 +1,104 @@
|
||||
Class {
|
||||
#name : #BreaApp,
|
||||
#superclass : #Object,
|
||||
#instVars : [
|
||||
'name',
|
||||
'folder',
|
||||
'host',
|
||||
'componets'
|
||||
],
|
||||
#category : #Brea
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> add: anObject [
|
||||
anObject class = String ifFalse: [ ].
|
||||
self body
|
||||
nextPutAll: (Pandoc htmlStringToMarkdown: anObject); cr.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> appName [
|
||||
^ self name asCamelCase
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> at: key put: anObject [
|
||||
self components at: key put: anObject.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> components [
|
||||
^ componets ifNil: [ componets := OrderedDictionary new]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> componentsWebView [
|
||||
| response |
|
||||
response := '' writeStream.
|
||||
self components ifEmpty: [ ^ response contents ].
|
||||
self components valuesDo: [ :component |
|
||||
response
|
||||
nextPutAll: component webView; cr
|
||||
].
|
||||
^ response contents
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> defaultView [
|
||||
^ '<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
<link rel="stylesheet" href="css/pico.min.css">
|
||||
<title>', self name, '</title>
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
', self componentsWebView,'
|
||||
</main>
|
||||
</body>
|
||||
</html>'
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> folder [
|
||||
^ folder
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> folder: aFileDirectory [
|
||||
folder := aFileDirectory
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> name [
|
||||
^ name
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> name: aString [
|
||||
name := aString
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> parentFolder: anObject [
|
||||
self folder: anObject / self name asCamelCase
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> preview [
|
||||
| defaultRoute |
|
||||
defaultRoute := 'http://localhost:',self webHost server port asString, '/', self appName.
|
||||
self webHost
|
||||
GET: self appName -> [ self defaultView ].
|
||||
GoogleChrome openWindowOn: defaultRoute
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaApp >> webHost [
|
||||
^ host ifNil: [ host := Teapot allInstances detect: [ :each | each server isRunning ] ifNone: [ host := Teapot on. host server start ]]
|
||||
]
|
@ -20,7 +20,7 @@ Internal Representation and Key Implementation Points.
|
||||
Implementation Points
|
||||
"
|
||||
Class {
|
||||
#name : #BreaQuery,
|
||||
#name : #BreaOperator,
|
||||
#superclass : #Object,
|
||||
#instVars : [
|
||||
'name',
|
||||
@ -32,12 +32,12 @@ Class {
|
||||
}
|
||||
|
||||
{ #category : #converting }
|
||||
BreaQuery >> asSton [
|
||||
BreaOperator >> asSton [
|
||||
^ STON toStringPretty: self
|
||||
]
|
||||
|
||||
{ #category : #converting }
|
||||
BreaQuery >> cleanInputs [
|
||||
BreaOperator >> cleanInputs [
|
||||
self cleanedInputs ifNil: [ ^ self ].
|
||||
self cleanedInputs ifTrue: [
|
||||
self inputs keysAndValuesDo: [ :k :v | | currentValue |
|
||||
@ -48,48 +48,48 @@ BreaQuery >> cleanInputs [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> cleanedInputs [
|
||||
BreaOperator >> cleanedInputs [
|
||||
^ cleanedInputs
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> cleanedInputs: aBoolean [
|
||||
BreaOperator >> cleanedInputs: aBoolean [
|
||||
"I tell if the inputs should be cleaned when the query is serialized as STON, for
|
||||
example when they contain sensible information, like API keys or passwords"
|
||||
cleanedInputs := aBoolean
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> codeBlock [
|
||||
BreaOperator >> codeBlock [
|
||||
^ codeBlock
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> codeBlock: anObject [
|
||||
BreaOperator >> codeBlock: anObject [
|
||||
codeBlock := anObject
|
||||
]
|
||||
|
||||
{ #category : #execution }
|
||||
BreaQuery >> execute [
|
||||
BreaOperator >> execute [
|
||||
^ self codeBlock valueWithArguments: self inputs values.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> inputs [
|
||||
BreaOperator >> inputs [
|
||||
^ inputs
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> inputs: anOrderedDictionary [
|
||||
BreaOperator >> inputs: anOrderedDictionary [
|
||||
inputs := anOrderedDictionary
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> name [
|
||||
BreaOperator >> name [
|
||||
^ name
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaQuery >> name: anObject [
|
||||
BreaOperator >> name: anObject [
|
||||
name := anObject
|
||||
]
|
@ -24,14 +24,17 @@ Class {
|
||||
|
||||
{ #category : #operation }
|
||||
BreaPage >> bodyContentsAsHTML [
|
||||
| sourcePage |
|
||||
| sourcePage commandParameters |
|
||||
self contentsFile ifNil: [ ^ self ].
|
||||
sourcePage := self file file.
|
||||
Smalltalk os isWindows ifTrue: [
|
||||
^ Pandoc markdownToHtml: self file file
|
||||
].
|
||||
sourcePage := FileLocator temp / 'wikiPage.md'.
|
||||
MarkupFile exportAsFileOn: sourcePage containing: self contents.
|
||||
^ Pandoc markdownToHtml: sourcePage
|
||||
].
|
||||
commandParameters := ' -f markdown+startnum+task_lists -t html '.
|
||||
^ GtSubprocessWithInMemoryOutput new
|
||||
shellCommand: 'pandoc', commandParameters, sourcePage fullName;
|
||||
runAndWait;
|
||||
stdout.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -63,7 +66,7 @@ BreaPage >> contents [
|
||||
result nextPutAll: (Markdown fromFile: markdownTempFile) contents.
|
||||
]
|
||||
].
|
||||
^ result contents.
|
||||
^ result contents withInternetLineEndings.
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
@ -83,7 +86,7 @@ BreaPage >> exportAsHTML [
|
||||
self splitters ifNotEmpty: [ actionsArray := actionsArray copyWith: [ self split ] future ].
|
||||
self bodyTag ifNotNil: [
|
||||
actionsArray := actionsArray copyWith: [ self populateBodyAs: self bodyTag ] future ].
|
||||
allActions := TKTFuture all: actionsArray.
|
||||
allActions := TKTFuture fromCollectionOfFutures: actionsArray.
|
||||
semaphore := Semaphore new.
|
||||
allActions onSuccessDo: [ :values |
|
||||
result := values last.
|
||||
@ -136,17 +139,7 @@ BreaPage >> metadata: aDictionary [
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
BreaPage >> populateBodyAs: key [
|
||||
| allActions result semaphore |
|
||||
|
||||
allActions := TKTFuture all: {
|
||||
[ self bodyContentsAsHTML ] future.
|
||||
}.
|
||||
semaphore := Semaphore new.
|
||||
allActions onSuccessDo: [ :values |
|
||||
result := values last.
|
||||
semaphore signal ].
|
||||
semaphore wait.
|
||||
self templateData at: key put: result contents.
|
||||
self templateData at: key put: self bodyContentsAsHTML.
|
||||
^ self.
|
||||
]
|
||||
|
||||
@ -164,7 +157,7 @@ BreaPage >> populateMetadata [
|
||||
ifNil: [ metadataTemp := self contentsFile metadata].
|
||||
metadataTemp keysAndValuesDo: [ :key :value |
|
||||
self templateData at: key put: value ].
|
||||
^ templateData
|
||||
^ self templateData
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
|
@ -32,8 +32,7 @@ Class {
|
||||
'url',
|
||||
'preview',
|
||||
'license',
|
||||
'queries',
|
||||
'customizations'
|
||||
'operators'
|
||||
],
|
||||
#category : #Brea
|
||||
}
|
||||
@ -103,8 +102,8 @@ BreaTheme class >> downloadLinks [
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
BreaTheme >> addQuery: aBreaQuery [
|
||||
self queries add: aBreaQuery cleanInputs
|
||||
BreaTheme >> addOperator: aBreaQuery [
|
||||
self operators add: aBreaQuery cleanInputs
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
@ -144,8 +143,13 @@ BreaTheme >> folder: anObject [
|
||||
BreaTheme >> installInto: aFolder [
|
||||
| zippedFile |
|
||||
self url ifNil: [ ^ self ].
|
||||
zippedFile := self downloadInto: FileLocator temp.
|
||||
zippedFile := FileLocator temp / 'download'.
|
||||
zippedFile ensureDelete.
|
||||
ZnClient new
|
||||
url: self url;
|
||||
downloadTo: FileLocator temp.
|
||||
(ZipArchive new readFrom: zippedFile) extractAllTo: aFolder.
|
||||
self folder: aFolder.
|
||||
^ aFolder
|
||||
]
|
||||
|
||||
@ -184,6 +188,16 @@ BreaTheme >> name: anObject [
|
||||
name := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaTheme >> operators [
|
||||
^ operators ifNil: [ operators := OrderedCollection new ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaTheme >> operators: cleanedBreaQueriesCollection [
|
||||
operators := cleanedBreaQueriesCollection
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaTheme >> preview [
|
||||
^ preview
|
||||
@ -204,16 +218,6 @@ BreaTheme >> provider: anObject [
|
||||
provider := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaTheme >> queries [
|
||||
^ queries ifNil: [ queries := OrderedCollection new ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaTheme >> queries: cleanedBreaQueriesCollection [
|
||||
queries := cleanedBreaQueriesCollection
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaTheme >> url [
|
||||
^ url ifNil: [ url := self class downloadLinks at: self name. ]
|
||||
|
6
repository/Brea/String.extension.st
Normal file
6
repository/Brea/String.extension.st
Normal file
@ -0,0 +1,6 @@
|
||||
Extension { #name : #String }
|
||||
|
||||
{ #category : #'*Brea' }
|
||||
String >> webView [
|
||||
^ (Pandoc htmlStringToMarkdown: self) accentedCharactersCorrection
|
||||
]
|
6
repository/Brea/Teapot.extension.st
Normal file
6
repository/Brea/Teapot.extension.st
Normal file
@ -0,0 +1,6 @@
|
||||
Extension { #name : #Teapot }
|
||||
|
||||
{ #category : #'*Brea' }
|
||||
Teapot >> dynamicRoutes [
|
||||
^ dynamicRouter routes
|
||||
]
|
Loading…
Reference in New Issue
Block a user