From 576a408fb5d73cdcb6b4a88fbbec9ff2c407d7b9 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 31 Jan 2022 22:12:33 -0500 Subject: [PATCH] Moving methods to better owners for functionality encapsulation. --- .../Grafoscopio-Utils/GrafoscopioUtils.class.st | 6 ++++++ .../GrafoscopioUtils.extension.st | 7 +++++++ .../Grafoscopio-Utils/LeDatabase.extension.st | 11 +++++++++++ repository/Grafoscopio-Utils/LePage.extension.st | 16 ---------------- 4 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 repository/Grafoscopio-Utils/GrafoscopioUtils.extension.st create mode 100644 repository/Grafoscopio-Utils/LeDatabase.extension.st diff --git a/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st b/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st index b5b30f8..9d651a8 100644 --- a/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st +++ b/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st @@ -160,3 +160,9 @@ GrafoscopioUtils class >> update [ package: 'Grafoscopio-Utils'; load. ] + +{ #category : #'*Grafoscopio-Utils-Core' } +GrafoscopioUtils class >> xmlFromUrl: aString [ + + ^ (XMLHTMLParser on: aString asUrl retrieveContents) parseDocument +] diff --git a/repository/Grafoscopio-Utils/GrafoscopioUtils.extension.st b/repository/Grafoscopio-Utils/GrafoscopioUtils.extension.st new file mode 100644 index 0000000..2b76af2 --- /dev/null +++ b/repository/Grafoscopio-Utils/GrafoscopioUtils.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #GrafoscopioUtils } + +{ #category : #'*Grafoscopio-Utils-Core' } +GrafoscopioUtils class >> xmlFromUrl: aString [ + + ^ (XMLHTMLParser on: aString asUrl retrieveContents) parseDocument +] diff --git a/repository/Grafoscopio-Utils/LeDatabase.extension.st b/repository/Grafoscopio-Utils/LeDatabase.extension.st new file mode 100644 index 0000000..a4be762 --- /dev/null +++ b/repository/Grafoscopio-Utils/LeDatabase.extension.st @@ -0,0 +1,11 @@ +Extension { #name : #LeDatabase } + +{ #category : #'*Grafoscopio-Utils-Core' } +LeDatabase >> detectLocalPageForRemote: markdeepDocUrl [ + | markdeepHelper id remoteMetadata docTree | + markdeepHelper := Markdeep new. + docTree := (XMLHTMLParser on: markdeepDocUrl asUrl retrieveContents) parseDocument. + remoteMetadata := markdeepHelper metadataFromXML: docTree. + id := remoteMetadata at: 'id' ifAbsent: [ ^ false ]. + ^ self pageWithID: id ifAbsent: [ nil ]. +] diff --git a/repository/Grafoscopio-Utils/LePage.extension.st b/repository/Grafoscopio-Utils/LePage.extension.st index fbc4652..baf3319 100644 --- a/repository/Grafoscopio-Utils/LePage.extension.st +++ b/repository/Grafoscopio-Utils/LePage.extension.st @@ -48,16 +48,6 @@ LePage >> fromMarkdeepUrl: aString [ ] -{ #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' } LePage >> markdeepFileName [ | sanitized | @@ -102,9 +92,3 @@ 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 -]