Preliminar support for downloading images done. Still it needs some debugging because is creating an extra directory to put the images.
This commit is contained in:
parent
222f164827
commit
4cc7fa0a43
@ -329,22 +329,6 @@ GrafoscopioNode >> demote [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
|
||||||
GrafoscopioNode >> downloadImagesInto: folder [
|
|
||||||
"comment stating purpose of message"
|
|
||||||
|
|
||||||
self extractHtmlImages do: [ :each | |localFolder path|
|
|
||||||
path:=''.
|
|
||||||
(each directory substrings: '/') do: [ :eachDirectory |
|
|
||||||
path:= path , '/' , eachDirectory .
|
|
||||||
(folder / path) ensureCreateDirectory ].
|
|
||||||
localFolder := (folder / each directory).
|
|
||||||
(localFolder / each lastPathSegment) exists ifFalse: [
|
|
||||||
ZnClient new
|
|
||||||
url: each ;
|
|
||||||
downloadTo: localFolder . ]]
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #'custom markup' }
|
{ #category : #'custom markup' }
|
||||||
GrafoscopioNode >> embedAll [
|
GrafoscopioNode >> embedAll [
|
||||||
"This is just a previous part of the messy markDownContent. The %embed-all keyword should be revaluated.
|
"This is just a previous part of the messy markDownContent. The %embed-all keyword should be revaluated.
|
||||||
@ -437,27 +421,17 @@ GrafoscopioNode >> exportPreambleTo: aStream [
|
|||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'as yet unclassified' }
|
||||||
GrafoscopioNode >> extractHtmlImages [
|
GrafoscopioNode >> extractHtmlImages [
|
||||||
"comment stating purpose of message"
|
"comment stating purpose of message"
|
||||||
|imgSoup imgHost imgList src folders|
|
|imgSoup imgHost imgList folders|
|
||||||
|
|
||||||
imgList := Set new.
|
imgList := Set new.
|
||||||
imgSoup := Soup fromString: self body.
|
imgSoup := Soup fromString: self body.
|
||||||
imgHost:= self links last asUrl removeLastPathSegment.
|
imgHost:= self links last asUrl removeLastPathSegment.
|
||||||
folders:= Set new.
|
folders:= Set new.
|
||||||
(imgSoup findAllTags: 'img') do: [ :each|
|
(imgSoup findAllTags: 'img') do: [ :each|| src |
|
||||||
src := (each attributeAt: 'src') asUrl.
|
src := (each attributeAt: 'src') asUrl.
|
||||||
(src host) ifNil: [ src := imgHost addPathSegments: src pathSegments ].
|
(src host) ifNil: [ src := imgHost addPathSegments: src pathSegments ].
|
||||||
imgList add: src.
|
imgList add: src.
|
||||||
"folders add: src directory."
|
].
|
||||||
"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 .
|
^imgList .
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -296,7 +296,6 @@ 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
|
||||||
]
|
]
|
||||||
@ -318,6 +317,12 @@ GrafoscopioNotebook >> imagesList: anObject [
|
|||||||
imagesList := anObject
|
imagesList := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'as yet unclassified' }
|
||||||
|
GrafoscopioNotebook >> importImages [
|
||||||
|
self imagesList: (Pandoc listImagesFrom: self markdownFile).
|
||||||
|
self inform: 'All notebook images has been imported.', String cr, 'Now you can list and download them.'
|
||||||
|
]
|
||||||
|
|
||||||
{ #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
|
||||||
@ -522,18 +527,18 @@ GrafoscopioNotebook >> notebookSubMenu [
|
|||||||
name: 'Save as...';
|
name: 'Save as...';
|
||||||
icon: (Smalltalk ui icons iconNamed: #smallSaveAs);
|
icon: (Smalltalk ui icons iconNamed: #smallSaveAs);
|
||||||
action: [ self saveToFileUI ] ].
|
action: [ self saveToFileUI ] ].
|
||||||
group
|
|
||||||
addItem: [ :item |
|
|
||||||
item
|
|
||||||
name: 'Extract images';
|
|
||||||
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
|
||||||
action: [ self extractImages ] ].
|
|
||||||
group
|
group
|
||||||
addItem: [ :item |
|
addItem: [ :item |
|
||||||
item
|
item
|
||||||
name: 'Import images';
|
name: 'Import images';
|
||||||
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
||||||
action: [ self importImages ] ].
|
action: [ self importImages ] ].
|
||||||
|
group
|
||||||
|
addItem: [ :item |
|
||||||
|
item
|
||||||
|
name: 'Download images';
|
||||||
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
||||||
|
action: [ self downloadImages ] ].
|
||||||
group
|
group
|
||||||
addItem: [ :item |
|
addItem: [ :item |
|
||||||
item
|
item
|
||||||
@ -1003,7 +1008,7 @@ GrafoscopioNotebook >> updateBodyFor: aNodeContainer [
|
|||||||
self buildWithSpecLayout: self class defaultSpec
|
self buildWithSpecLayout: self class defaultSpec
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'editing nodes' }
|
{ #category : #operation }
|
||||||
GrafoscopioNotebook >> visitNodeLink [
|
GrafoscopioNotebook >> visitNodeLink [
|
||||||
|
|
||||||
tree highlightedItem content visitLastLink.
|
tree highlightedItem content visitLastLink.
|
||||||
|
@ -10,6 +10,17 @@ Class {
|
|||||||
#category : #'Grafoscopio-Model'
|
#category : #'Grafoscopio-Model'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #'as yet unclassified' }
|
||||||
|
Pandoc class >> downloadLuaFilters [
|
||||||
|
self luaFilters do: [ :filter | | filterUrl |
|
||||||
|
filterUrl := filter asUrl.
|
||||||
|
(FileLocator temp asFileReference / (filterUrl segments last)) exists
|
||||||
|
ifFalse: [
|
||||||
|
ZnClient new
|
||||||
|
url: filterUrl;
|
||||||
|
downloadTo: FileLocator temp ] ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Pandoc class >> executable [
|
Pandoc class >> executable [
|
||||||
^ executable ifNil: [ self executableLocation ]
|
^ executable ifNil: [ self executableLocation ]
|
||||||
@ -29,6 +40,20 @@ Pandoc class >> executableLocation [
|
|||||||
ifFalse: [ self definePandocExecutable ]
|
ifFalse: [ self definePandocExecutable ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'as yet unclassified' }
|
||||||
|
Pandoc class >> listImagesFrom: aFileReference [
|
||||||
|
"I provide a list of all images contained in aFile."
|
||||||
|
| filter commandString outputString |
|
||||||
|
filter := FileLocator temp asFileReference / 'image-links.lua'.
|
||||||
|
filter exists ifFalse: [ self downloadLuaFilters ].
|
||||||
|
commandString := 'pandoc ', aFileReference fullName, ' --lua-filter=',filter fullName.
|
||||||
|
Smalltalk platformName = 'unix'
|
||||||
|
ifTrue: [ outputString := (PipeableOSProcess waitForCommand: commandString ) output ].
|
||||||
|
Smalltalk platformName = 'Win32'
|
||||||
|
ifTrue: [ WindowsProcess ].
|
||||||
|
^ ((Soup fromString: outputString) findAllTags: 'td') collect: [ :each | each next ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #utility }
|
{ #category : #utility }
|
||||||
Pandoc class >> luaFilters [
|
Pandoc class >> luaFilters [
|
||||||
"I define the location of set of scripts, that allows to change the default behaviour of Pandoc
|
"I define the location of set of scripts, that allows to change the default behaviour of Pandoc
|
||||||
@ -42,5 +67,6 @@ Pandoc class >> luaFilters [
|
|||||||
| filters |
|
| filters |
|
||||||
filters := OrderedCollection new.
|
filters := OrderedCollection new.
|
||||||
filters
|
filters
|
||||||
add: 'http://mutabit.com/repos.fossil/dataweek/doc/tip/Artefactos/Scripts/links.lua'
|
add: 'http://mutabit.com/repos.fossil/dataweek/doc/tip/Artefactos/Scripts/image-links.lua'.
|
||||||
|
^ filters
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user