Grafoscopio/repository/Grafoscopio/GrafoscopioCodeModel.class.st

69 lines
1.6 KiB
Smalltalk

"
I represent a Pharo code node inside a Grafoscopio notebook as a
embedded interactive Playground.
"
Class {
#name : #GrafoscopioCodeModel,
#superclass : #ComposableModel,
#instVars : [
'body'
],
#category : #'Grafoscopio-UI'
}
{ #category : #specs }
GrafoscopioCodeModel class >> defaultSpec [
^ SpecLayout composed add: #body
]
{ #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.
]