Preliminary support in the notebook for extracting and showing images in the notebook.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-12-02 21:16:51 +00:00 committed by SantiagoBragagnolo
parent 7eee23f5f1
commit 3d4b74699b
2 changed files with 39 additions and 9 deletions

View File

@ -7,6 +7,15 @@ Class {
#category : #'Grafoscopio-Model'
}
{ #category : #tests }
GrafoscopioNodeTest >> dummyHtml [
| txt |
txt := '<html> <body> <img src="/web/files/pharo-logo-small.png">
<img src="https://pharo.org/web/files/pharo.png">
</body></html>'.
^ txt
]
{ #category : #tests }
GrafoscopioNodeTest >> testAddingChildren [
| tree nnode orig |
@ -51,19 +60,14 @@ GrafoscopioNodeTest >> testDownloadImagesInto [
{ #category : #tests }
GrafoscopioNodeTest >> testExtractHtmlImages [
"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>'.
| 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.
self assert: (FileLocator temp / 'web') allChildren size equals: 4
]
{ #category : #tests }

View File

@ -19,7 +19,8 @@ Class {
'windowMainMenu',
'workingFile',
'notebook',
'debugMessage'
'debugMessage',
'imagesList'
],
#category : #'Grafoscopio-UI'
}
@ -297,6 +298,7 @@ GrafoscopioNotebook >> header: anObject [
{ #category : #operation }
GrafoscopioNotebook >> htmlToMarkdown [
self imagesList: self currentNodeContent extractHtmlImages.
self currentNodeContent htmlToMarkdown.
self updateBodyFor: self currentNode
]
@ -307,6 +309,17 @@ GrafoscopioNotebook >> htmlToMarkdownSubtree [
self updateBodyFor: self currentNode
]
{ #category : #accessing }
GrafoscopioNotebook >> imagesList [
imagesList ifNil: [ ^ #('No images list for this notebook') ].
^ imagesList
]
{ #category : #accessing }
GrafoscopioNotebook >> imagesList: anObject [
imagesList := anObject
]
{ #category : #operation }
GrafoscopioNotebook >> importLinkContent [
"I see if a node header is an url located at 'http://ws.stfx.eu', wich means that is a shared
@ -384,6 +397,14 @@ GrafoscopioNotebook >> links: anObject [
links := anObject
]
{ #category : #'as yet unclassified' }
GrafoscopioNotebook >> listImagesUI [
ListModel new
title: 'Images files list';
items: self imagesList ;
openWithSpec
]
{ #category : #persistence }
GrafoscopioNotebook >> loadFromFile: aFileReference [
"I load the contents of aFileReference into a GrafoscopioNotebook, without opening it."
@ -532,6 +553,11 @@ GrafoscopioNotebook >> notebookSubMenu [
name: 'See pdf';
icon: (Smalltalk ui icons iconNamed: #smallInspectIt);
action: [ self inform: 'To be implemented...' ]].
group addItem: [ :item |
item
name: 'See images list';
icon: (Smalltalk ui icons iconNamed: #glamorousTable);
action: [ self listImagesUI ]].
group addItem: [ :item |
item
name: 'Define debug message...';