Compare commits

..

21 Commits

Author SHA1 Message Date
2875964efc Replacing temporal downloded folders for new themes. 2024-10-20 19:59:36 -05:00
7b86b2cfeb Replacing in memory process from GtSubProcess instead of TaskIt futures. 2024-08-02 14:19:00 -05:00
af81f92399 Using GtSubProcess to work on memory and avoid external files creation. 2024-08-02 13:29:56 -05:00
b500a65c00 Renaming. 2024-04-03 10:15:32 -05:00
83ea8d4310 Renaming. 2024-04-01 13:16:55 -05:00
2d811e9f38 Default server shared with the one serving MiniDocs. 2024-03-30 18:06:16 -05:00
a8d12ec46f Implementing components. #defaultView needs to be debugged. 2024-03-30 13:40:50 -05:00
c609595272 Starting implementation of default app view body. 2024-03-30 10:41:25 -05:00
81298aefba Starting implementation of default app view body. 2024-03-30 10:24:17 -05:00
72e0c775e5 Default view as a code block. 2024-03-29 22:25:37 -05:00
f3a1927615 Starting default views. 2024-03-29 21:46:34 -05:00
a96dd95359 Default shared server with MiniDocs to create App views/(sub)routes. 2024-03-29 20:27:48 -05:00
8833341eee Starting BreaApps. 2024-03-29 20:11:27 -05:00
bbda57b908 Replacing GrafoscopioUtils for MiniDocs as a dependency. 2024-03-29 19:13:57 -05:00
f0dfea31b5 Testing future collections. 2023-12-10 13:44:11 -05:00
ef3218a343 Renabling themes downloading. 2023-12-09 18:20:38 -05:00
f29ea2d014 Reenabling themes download. 2023-12-09 18:19:18 -05:00
b0498bfcc5 Disabling Noha's Fork to make Brea installable. 2021-05-08 17:41:33 -05:00
5b04df81b7 Merge 6055fd04f4 2020-12-19 11:24:36 -05:00
9f28bccc1e Support for BreaOperators 2020-12-19 11:24:21 -05:00
6055fd04f4 Merge pull request 'Improving Windows support.' (#2) from Windows into master 2020-12-18 13:54:40 -05:00
17 changed files with 1188 additions and 1140 deletions

View File

@ -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 ]
]

View File

@ -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 ].

View File

@ -113,6 +113,7 @@ BreaPageTest >> setUp [
super setUp.
self createMarkdownFile.
self createHTMLTemplateFile.
self createJSONFile
]
{ #category : #tests }

View File

@ -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 ]
]

View 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 ]]
]

View File

@ -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
]

View File

@ -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 }

View File

@ -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. ]

View File

@ -0,0 +1,6 @@
Extension { #name : #String }
{ #category : #'*Brea' }
String >> webView [
^ (Pandoc htmlStringToMarkdown: self) accentedCharactersCorrection
]

View File

@ -0,0 +1,6 @@
Extension { #name : #Teapot }
{ #category : #'*Brea' }
Teapot >> dynamicRoutes [
^ dynamicRouter routes
]