Starting detection of remote Markdeep pages in current database.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-01-30 21:54:16 -05:00
parent 7f1e2b24e2
commit ce3b6a96a0
2 changed files with 33 additions and 2 deletions

View File

@ -39,8 +39,23 @@ LePage >> fileName [
]
{ #category : #'*Grafoscopio-Utils-Core' }
LePage >> fromMarkdeepUrl: aString [
^ aString asUrl retrieveContents.
LePage >> fromMarkdeepUrl: aString [
| markdeepHelper id remoteMetadata |
markdeepHelper := Markdeep new.
remoteMetadata := markdeepHelper metadataFromXML: (self xmlFromUrl: aString).
id := remoteMetadata at: 'id' ifAbsent: [ ^ false ].
]
{ #category : #'*Grafoscopio-Utils-Core' }
LePage >> isInDocumentsDatabase: markdeepDocUrl [
| markdeepHelper id remoteMetadata |
markdeepHelper := Markdeep new.
remoteMetadata := markdeepHelper metadataFromXML: (self xmlFromUrl: markdeepDocUrl).
id := remoteMetadata at: 'id' ifAbsent: [ ^ false ].
self database pagesByDateToShow
detect: [ :page | page uidString = id ] ifFound: [ ^ true ] ifNone: [ ^ false ].
]
{ #category : #'*Grafoscopio-Utils-Core' }
@ -87,3 +102,9 @@ LePage >> preorderTraversal [
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
^ output.
]
{ #category : #'*Grafoscopio-Utils-Core' }
LePage >> xmlFromUrl: aString [
^ (XMLHTMLParser on: aString asUrl retrieveContents) parseDocument
]

View File

@ -210,6 +210,16 @@ Markdeep >> metadata [
^ metadata ifNil: [ metadata := OrderedDictionary new ]
]
{ #category : #utilities }
Markdeep >> metadataFromXML: aXMLDocument [
| metaDict |
metaDict := OrderedDictionary new.
(aXMLDocument xpath: '//meta') do: [ :each |
metaDict at: (each @ 'name') stringValue put: (each @ 'content') stringValue ].
^ metaDict
]
{ #category : #printing }
Markdeep >> printOn: aStream [