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
parent 14f2c67d94
commit fdf7deb931
2 changed files with 39 additions and 9 deletions

View File

@ -7,6 +7,15 @@ Class {
#category : #'Grafoscopio-Model' #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 } { #category : #tests }
GrafoscopioNodeTest >> testAddingChildren [ GrafoscopioNodeTest >> testAddingChildren [
| tree nnode orig | | tree nnode orig |
@ -51,19 +60,14 @@ GrafoscopioNodeTest >> testDownloadImagesInto [
{ #category : #tests } { #category : #tests }
GrafoscopioNodeTest >> testExtractHtmlImages [ GrafoscopioNodeTest >> testExtractHtmlImages [
"comment stating purpose of message" "comment stating purpose of message"
| txt txtNode | | txt txtNode |
txt := self dummyHtml.
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 := GrafoscopioNode new body: txt.
txtNode links: 'http://pharo.org/files/'. txtNode links: 'http://pharo.org/files/'.
txtNode extractHtmlImages. txtNode extractHtmlImages.
txtNode downloadImagesInto: FileLocator temp. txtNode downloadImagesInto: FileLocator temp.
self assert: (FileLocator temp / 'web' ) allChildren size equals: 4. self assert: (FileLocator temp / 'web') allChildren size equals: 4
] ]
{ #category : #tests } { #category : #tests }

View File

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