From fdf7deb931cbc3a27634cf64c7b4607d5f0dc9b2 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sat, 2 Dec 2017 21:16:51 +0000 Subject: [PATCH] Preliminary support in the notebook for extracting and showing images in the notebook. --- .../Grafoscopio/GrafoscopioNodeTest.class.st | 20 +++++++------ .../Grafoscopio/GrafoscopioNotebook.class.st | 28 ++++++++++++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioNodeTest.class.st b/repository/Grafoscopio/GrafoscopioNodeTest.class.st index 7a01360..904ac23 100644 --- a/repository/Grafoscopio/GrafoscopioNodeTest.class.st +++ b/repository/Grafoscopio/GrafoscopioNodeTest.class.st @@ -7,6 +7,15 @@ Class { #category : #'Grafoscopio-Model' } +{ #category : #tests } +GrafoscopioNodeTest >> dummyHtml [ + | txt | + txt := ' + + '. + ^ 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:= ' - - '. + | 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 } diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index 4ea8a34..1a5aa3b 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -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...';