70 lines
1.6 KiB
Smalltalk
70 lines
1.6 KiB
Smalltalk
"
|
|
I represent a Pharo code node inside a Grafoscopio notebook as a
|
|
embedded interactive Playground.
|
|
"
|
|
Class {
|
|
#name : #GrafoscopioCodeModel,
|
|
#superclass : #SpPresenter,
|
|
#instVars : [
|
|
'body'
|
|
],
|
|
#category : #'Grafoscopio-UI'
|
|
}
|
|
|
|
{ #category : #specs }
|
|
GrafoscopioCodeModel class >> defaultSpec [
|
|
^ SpBoxLayout newVertical
|
|
add: #body;
|
|
yourself
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioCodeModel >> body [
|
|
^ body
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioCodeModel >> body: anObject [
|
|
body := anObject
|
|
]
|
|
|
|
{ #category : #API }
|
|
GrafoscopioCodeModel >> content: aGrafoscopioNodeContent [
|
|
|
|
body
|
|
presentationClass: GTPlayground
|
|
startOn: (GTPlayPage new saveContent: aGrafoscopioNodeContent)
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioCodeModel >> extractHtmlImages [
|
|
"comment stating purpose of message"
|
|
|imgSoup imgHost imgList src|
|
|
|
|
imgList := Set new.
|
|
imgSoup := Soup fromString: self body.
|
|
(imgSoup findAllTags: 'img') do: [ :each|
|
|
src := (each attributeAt: 'src') asUrl.
|
|
(src host) ifNil: [src host: self links last asUrl removeLastPathSegment].
|
|
imgList add: src.
|
|
"imgList add: (each attributeAt: 'src') asUrl."
|
|
|
|
"OSProcess waitForCommand: 'wget ', (each attributeAt: 'src')."
|
|
"imgHost := self links last removeLastPathSegment."
|
|
|
|
"imgPath:= ((each attributeAt: 'src') asUrl). "
|
|
"ZnEasy getJpeg: (imgHost , imgPath) asUrl."
|
|
|
|
"OSProcess waitForCommand: ('mkdir ', imgPath)."
|
|
|
|
"Transcript show: ' wget ', imgPath , '/',(each attributeAt: 'src'). "
|
|
].
|
|
^imgList .
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioCodeModel >> initializeWidgets [
|
|
|
|
body := GlamourPresentationModel new.
|
|
]
|