Notebook support for downloading linked images.
This commit is contained in:
parent
b5a6163596
commit
ffa5ce7782
|
@ -418,23 +418,6 @@ GrafoscopioNode >> exportPreambleTo: aStream [
|
|||
aStream nextPutAll: 'abstract: ', '|'; lf; nextPutAll: (configDict at: 'abstract'); lf]
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioNode >> extractHtmlImages [
|
||||
"comment stating purpose of message"
|
||||
|imgSoup imgHost imgList folders|
|
||||
|
||||
imgList := Set new.
|
||||
imgSoup := Soup fromString: self body.
|
||||
imgHost:= self links last asUrl removeLastPathSegment.
|
||||
folders:= Set new.
|
||||
(imgSoup findAllTags: 'img') do: [ :each|| src |
|
||||
src := (each attributeAt: 'src') asUrl.
|
||||
(src host) ifNil: [ src := imgHost addPathSegments: src pathSegments ].
|
||||
imgList add: src.
|
||||
].
|
||||
^imgList .
|
||||
]
|
||||
|
||||
{ #category : #utility }
|
||||
GrafoscopioNode >> find: aString andReplaceWith: anotherString [
|
||||
anotherString ifNil: [ ^ self ].
|
||||
|
|
|
@ -42,34 +42,6 @@ GrafoscopioNodeTest >> testDemoteNode [
|
|||
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
GrafoscopioNodeTest >> testDownloadImagesInto [
|
||||
"comment stating purpose of message"
|
||||
|
||||
|txt txtNode|
|
||||
txt:= '<html> <body> <img src="web/files/pharo-logo-small.png">
|
||||
<img src="https://pharo.org/web/files/pharo.png">
|
||||
</body></html>'.
|
||||
|
||||
txtNode := GrafoscopioNode new body: txt.
|
||||
txtNode links: 'http://pharo.org'.
|
||||
txtNode downloadImagesInto: FileLocator temp.
|
||||
self assert: (FileLocator temp / 'web') allChildren size equals: 4.
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
GrafoscopioNodeTest >> testExtractHtmlImages [
|
||||
"comment stating purpose of message"
|
||||
|
||||
| txt txtNode |
|
||||
txt := self dummyHtml.
|
||||
txtNode := GrafoscopioNode new body: txt.
|
||||
txtNode links: 'http://pharo.org/files/'.
|
||||
txtNode extractHtmlImages.
|
||||
txtNode downloadImagesInto: FileLocator temp.
|
||||
self assert: (FileLocator temp / 'web') allChildren size equals: 4
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
GrafoscopioNodeTest >> testFindAndReplace [
|
||||
| tree |
|
||||
|
|
Loading…
Reference in New Issue